Documentation ¶
Index ¶
- Constants
- Variables
- func ErrChannelNotRegistered(msg string) sdk.Error
- func ErrDuplicateMessage() sdk.Error
- func ErrFeeOverflow(msg string) sdk.Error
- func ErrInternalDB() sdk.Error
- func ErrInvalidClaim() sdk.Error
- func ErrInvalidIdentifier() sdk.Error
- func ErrInvalidPackageType() sdk.Error
- func ErrInvalidPayload(msg string) sdk.Error
- func ErrInvalidPayloadHeader(msg string) sdk.Error
- func ErrInvalidSequence(msg string) sdk.Error
- func ErrInvalidValidator() sdk.Error
- func ErrMinimumConsensusNeededInvalid() sdk.Error
- func ErrNoClaims() sdk.Error
- func ErrProphecyFinalized() sdk.Error
- func ErrProphecyNotFound() sdk.Error
- func GetClaimId(chainId sdk.ChainID, channelId sdk.ChannelID, sequence uint64) string
- type Claim
- type ClaimMsg
- func (msg ClaimMsg) GetInvolvedAddresses() []sdk.AccAddress
- func (msg ClaimMsg) GetSignBytes() []byte
- func (msg ClaimMsg) GetSigners() []sdk.AccAddress
- func (msg ClaimMsg) Route() string
- func (msg ClaimMsg) String() string
- func (msg ClaimMsg) Type() string
- func (msg ClaimMsg) ValidateBasic() sdk.Error
- type CrossAppFailEvent
- type DBProphecy
- type Package
- type Packages
- type Params
- type Prophecy
- type StakingKeeper
- type Status
- type StatusText
Constants ¶
const ( // RelayPackagesChannelId is not a communication channel actually, we just use it to record sequence. RelayPackagesChannelName = "relayPackages" RelayPackagesChannelId sdk.ChannelID = 0x00 )
const ( DefaultCodespace sdk.CodespaceType = 11 // CodeIncorrectDexOperation module reserves error 1000-1100 CodeProphecyNotFound sdk.CodeType = 1000 CodeMinimumConsensusNeededInvalid sdk.CodeType = 1001 CodeNoClaims sdk.CodeType = 1002 CodeInvalidIdentifier sdk.CodeType = 1003 CodeProphecyFinalized sdk.CodeType = 1004 CodeDuplicateMessage sdk.CodeType = 1005 CodeInvalidClaim sdk.CodeType = 1006 CodeInvalidValidator sdk.CodeType = 1007 CodeInternalDB sdk.CodeType = 1008 CodeInvalidSequence sdk.CodeType = 1009 CodeChannelNotRegistered sdk.CodeType = 1010 CodeInvalidLengthOfPayload sdk.CodeType = 1011 CodeFeeOverflow sdk.CodeType = 1012 CodeInvalidPayload sdk.CodeType = 1013 )
const ( EventTypeClaim = "claim" ClaimResultCode = "ClaimResultCode" ClaimResultMsg = "ClaimResultMsg" ClaimChannel = "ClaimChannel" ClaimReceiveSequence = "ClaimReceiveSequence" ClaimSendSequence = "ClaimSendSequence" ClaimCrash = "ClaimCrash" ClaimPackageType = "ClaimPackageType" )
const ( RouteOracle = "oracle" ClaimMsgType = "oracleClaim" )
const (
Topic = pubsub.Topic("oracle-event")
)
Variables ¶
var ( // DefaultConsensusNeeded defines the default consensus value required for a // prophecy to be finalized DefaultConsensusNeeded sdk.Dec = sdk.NewDecWithPrec(7, 1) ParamStoreKeyProphecyParams = []byte("prophecyParams") )
var StatusTextToString = [...]string{"pending", "success", "failed"}
var StringToStatusText = map[string]StatusText{ "pending": PendingStatusText, "success": SuccessStatusText, "failed": FailedStatusText, }
Functions ¶
func ErrChannelNotRegistered ¶
func ErrDuplicateMessage ¶
func ErrFeeOverflow ¶
func ErrInternalDB ¶
func ErrInvalidClaim ¶
func ErrInvalidIdentifier ¶
func ErrInvalidPackageType ¶
func ErrInvalidPayload ¶
func ErrInvalidPayloadHeader ¶
func ErrInvalidSequence ¶
func ErrInvalidValidator ¶
func ErrNoClaims ¶
func ErrProphecyFinalized ¶
func ErrProphecyNotFound ¶
Types ¶
type Claim ¶
type Claim struct { ID string `json:"id"` ValidatorAddress sdk.ValAddress `json:"validator_address"` Payload string `json:"payload"` }
Claim contains an arbitrary claim with arbitrary content made by a given validator
type ClaimMsg ¶
type ClaimMsg struct { ChainId sdk.ChainID `json:"chain_id"` Sequence uint64 `json:"sequence"` Payload []byte `json:"payload"` ValidatorAddress sdk.AccAddress `json:"validator_address"` }
func NewClaimMsg ¶
func (ClaimMsg) GetInvolvedAddresses ¶
func (msg ClaimMsg) GetInvolvedAddresses() []sdk.AccAddress
func (ClaimMsg) GetSignBytes ¶
GetSignBytes - Get the bytes for the message signer to sign on
func (ClaimMsg) GetSigners ¶
func (msg ClaimMsg) GetSigners() []sdk.AccAddress
func (ClaimMsg) ValidateBasic ¶
ValidateBasic is used to quickly disqualify obviously invalid messages quickly
type CrossAppFailEvent ¶
func (CrossAppFailEvent) GetTopic ¶
func (event CrossAppFailEvent) GetTopic() pubsub.Topic
type DBProphecy ¶
type DBProphecy struct { ID string `json:"id"` Status Status `json:"status"` ValidatorClaims []byte `json:"validator_claims"` }
DBProphecy is what the prophecy becomes when being saved to the database.
Tendermint/Amino does not support maps so we must serialize those variables into bytes.
func (DBProphecy) DeserializeFromDB ¶
func (dbProphecy DBProphecy) DeserializeFromDB() (Prophecy, error)
DeserializeFromDB deserializes a DBProphecy into a prophecy
type Params ¶
type Params struct {
ConsensusNeeded sdk.Dec `json:"ConsensusNeeded"` // Minimum deposit for a proposal to enter voting period.
}
func (*Params) GetParamAttribute ¶
func (*Params) KeyValuePairs ¶
func (p *Params) KeyValuePairs() params.KeyValuePairs
func (*Params) UpdateCheck ¶
type Prophecy ¶
type Prophecy struct { ID string `json:"id"` Status Status `json:"status"` //This is a mapping from a claim to the list of validators that made that claim. ClaimValidators map[string][]sdk.ValAddress `json:"claim_validators"` //This is a mapping from a validator bech32 address to their claim ValidatorClaims map[string]string `json:"validator_claims"` }
Prophecy is a struct that contains all the metadata of an oracle ritual. Claims are indexed by the claim's validator bech32 address and by the claim's json value to allow for constant lookup times for any validation/verifiation checks of duplicate claims Each transaction, pending potential results are also calculated, stored and indexed by their byte result to allow discovery of consensus on any the result in constant time without having to sort or run through the list of claims to find the one with highest consensus
func NewProphecy ¶
NewProphecy returns a new Prophecy, initialized in pending status with an initial claim
func (*Prophecy) AddClaim ¶
func (prophecy *Prophecy) AddClaim(validator sdk.ValAddress, claim string)
AddClaim adds a given claim to this prophecy
func (Prophecy) FindHighestClaim ¶
func (prophecy Prophecy) FindHighestClaim(ctx sdk.Context, stakeKeeper StakingKeeper) (string, int64, int64, int64)
FindHighestClaim looks through all the existing claims on a given prophecy. It adds up the total power across all claims and returns the highest claim, power for that claim, and total power claimed on the prophecy overall.
func (Prophecy) SerializeForDB ¶
func (prophecy Prophecy) SerializeForDB() (DBProphecy, error)
SerializeForDB serializes a prophecy into a DBProphecy
type StakingKeeper ¶
type StakingKeeper interface { GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stake.Validator, found bool) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) (power int64) GetLastTotalPower(ctx sdk.Context) (power int64) GetBondedValidatorsByPower(ctx sdk.Context) []stake.Validator GetOracleRelayersPower(ctx sdk.Context) map[string]int64 CheckIsValidOracleRelayer(ctx sdk.Context, validatorAddress sdk.ValAddress) bool }
StakingKeeper defines the expected staking keeper
type Status ¶
type Status struct { Text StatusText `json:"text"` FinalClaim string `json:"final_claim"` }
Status is a struct that contains the status of a given prophecy
func NewStatus ¶
func NewStatus(text StatusText, finalClaim string) Status
NewStatus returns a new Status with the given data contained
type StatusText ¶
type StatusText int
StatusText is an enum used to represent the status of the prophecy
const ( PendingStatusText StatusText = iota SuccessStatusText FailedStatusText )
func (StatusText) MarshalJSON ¶
func (text StatusText) MarshalJSON() ([]byte, error)
func (StatusText) String ¶
func (text StatusText) String() string
func (*StatusText) UnmarshalJSON ¶
func (text *StatusText) UnmarshalJSON(b []byte) error