types

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2023 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RelayPackagesChannelId is not a communication channel actually, we just use it to record sequence.
	RelayPackagesChannelName               = "relayPackages"
	RelayPackagesChannelId   sdk.ChannelID = 0x00
)
View Source
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
)
View Source
const (
	EventTypeClaim = "claim"

	ClaimResultCode      = "ClaimResultCode"
	ClaimResultMsg       = "ClaimResultMsg"
	ClaimChannel         = "ClaimChannel"
	ClaimReceiveSequence = "ClaimReceiveSequence"
	ClaimSendSequence    = "ClaimSendSequence"
	ClaimCrash           = "ClaimCrash"
	ClaimPackageType     = "ClaimPackageType"
)
View Source
const (
	RouteOracle = "oracle"

	ClaimMsgType = "oracleClaim"
)
View Source
const (
	Topic = pubsub.Topic("oracle-event")
)

Variables

View Source
var (
	// DefaultConsensusNeeded defines the default consensus value required for a
	// prophecy to be finalized
	DefaultConsensusNeeded      sdk.Dec = sdk.NewDecWithPrec(7, 1)
	ParamStoreKeyProphecyParams         = []byte("prophecyParams")
)
View Source
var StatusTextToString = [...]string{"pending", "success", "failed"}
View Source
var StringToStatusText = map[string]StatusText{
	"pending": PendingStatusText,
	"success": SuccessStatusText,
	"failed":  FailedStatusText,
}

Functions

func ErrChannelNotRegistered

func ErrChannelNotRegistered(msg string) sdk.Error

func ErrDuplicateMessage

func ErrDuplicateMessage() sdk.Error

func ErrFeeOverflow

func ErrFeeOverflow(msg string) sdk.Error

func ErrInternalDB

func ErrInternalDB() sdk.Error

func ErrInvalidClaim

func ErrInvalidClaim() sdk.Error

func ErrInvalidIdentifier

func ErrInvalidIdentifier() sdk.Error

func ErrInvalidPackageType

func ErrInvalidPackageType() sdk.Error

func ErrInvalidPayload

func ErrInvalidPayload(msg string) sdk.Error

func ErrInvalidPayloadHeader

func ErrInvalidPayloadHeader(msg string) sdk.Error

func ErrInvalidSequence

func ErrInvalidSequence(msg string) sdk.Error

func ErrInvalidValidator

func ErrInvalidValidator() sdk.Error

func ErrMinimumConsensusNeededInvalid

func ErrMinimumConsensusNeededInvalid() sdk.Error

func ErrNoClaims

func ErrNoClaims() sdk.Error

func ErrProphecyFinalized

func ErrProphecyFinalized() sdk.Error

func ErrProphecyNotFound

func ErrProphecyNotFound() sdk.Error

func GetClaimId

func GetClaimId(chainId sdk.ChainID, channelId sdk.ChannelID, sequence uint64) string

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

func NewClaim

func NewClaim(id string, validatorAddress sdk.ValAddress, payload string) Claim

NewClaim returns a new Claim

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 NewClaimMsg(ChainId sdk.ChainID, sequence uint64, payload []byte, validatorAddr sdk.AccAddress) ClaimMsg

func (ClaimMsg) GetInvolvedAddresses

func (msg ClaimMsg) GetInvolvedAddresses() []sdk.AccAddress

func (ClaimMsg) GetSignBytes

func (msg ClaimMsg) GetSignBytes() []byte

GetSignBytes - Get the bytes for the message signer to sign on

func (ClaimMsg) GetSigners

func (msg ClaimMsg) GetSigners() []sdk.AccAddress

func (ClaimMsg) Route

func (msg ClaimMsg) Route() string

nolint

func (ClaimMsg) String

func (msg ClaimMsg) String() string

func (ClaimMsg) Type

func (msg ClaimMsg) Type() string

func (ClaimMsg) ValidateBasic

func (msg ClaimMsg) ValidateBasic() sdk.Error

ValidateBasic is used to quickly disqualify obviously invalid messages quickly

type CrossAppFailEvent

type CrossAppFailEvent struct {
	TxHash     string
	ChainId    string
	RelayerFee int64
	From       string
}

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 Package

type Package struct {
	ChannelId sdk.ChannelID
	Sequence  uint64
	Payload   []byte
}

type Packages

type Packages []Package

type Params

type Params struct {
	ConsensusNeeded sdk.Dec `json:"ConsensusNeeded"` //  Minimum deposit for a proposal to enter voting period.
}

func (*Params) GetParamAttribute

func (p *Params) GetParamAttribute() (string, bool)

func (*Params) KeyValuePairs

func (p *Params) KeyValuePairs() params.KeyValuePairs

func (*Params) UpdateCheck

func (p *Params) UpdateCheck() error

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

func NewProphecy(id string) Prophecy

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL