Documentation ¶
Index ¶
- Constants
- Variables
- type Claim
- func (*Claim) Descriptor() ([]byte, []int)
- func (m *Claim) GetContent() string
- func (m *Claim) GetId() string
- func (m *Claim) GetValidatorAddress() string
- func (m *Claim) Marshal() (dAtA []byte, err error)
- func (m *Claim) MarshalTo(dAtA []byte) (int, error)
- func (m *Claim) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Claim) ProtoMessage()
- func (m *Claim) Reset()
- func (m *Claim) Size() (n int)
- func (m *Claim) String() string
- func (m *Claim) Unmarshal(dAtA []byte) error
- func (m *Claim) XXX_DiscardUnknown()
- func (m *Claim) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Claim) XXX_Merge(src proto.Message)
- func (m *Claim) XXX_Size() int
- func (m *Claim) XXX_Unmarshal(b []byte) error
- type DBProphecy
- func (*DBProphecy) Descriptor() ([]byte, []int)
- func (dbProphecy DBProphecy) DeserializeFromDB() (Prophecy, error)
- func (m *DBProphecy) GetClaimValidators() []byte
- func (m *DBProphecy) GetId() string
- func (m *DBProphecy) GetStatus() Status
- func (m *DBProphecy) GetValidatorClaims() []byte
- func (m *DBProphecy) Marshal() (dAtA []byte, err error)
- func (m *DBProphecy) MarshalTo(dAtA []byte) (int, error)
- func (m *DBProphecy) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*DBProphecy) ProtoMessage()
- func (m *DBProphecy) Reset()
- func (m *DBProphecy) Size() (n int)
- func (m *DBProphecy) String() string
- func (m *DBProphecy) Unmarshal(dAtA []byte) error
- func (m *DBProphecy) XXX_DiscardUnknown()
- func (m *DBProphecy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *DBProphecy) XXX_Merge(src proto.Message)
- func (m *DBProphecy) XXX_Size() int
- func (m *DBProphecy) XXX_Unmarshal(b []byte) error
- type GenesisState
- func (*GenesisState) Descriptor() ([]byte, []int)
- func (m *GenesisState) GetAddressWhitelist() []string
- func (m *GenesisState) GetAdminAddress() string
- func (m *GenesisState) GetProphecies() []*DBProphecy
- func (m *GenesisState) Marshal() (dAtA []byte, err error)
- func (m *GenesisState) MarshalTo(dAtA []byte) (int, error)
- func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*GenesisState) ProtoMessage()
- func (m *GenesisState) Reset()
- func (m *GenesisState) Size() (n int)
- func (m *GenesisState) String() string
- func (m *GenesisState) Unmarshal(dAtA []byte) error
- func (m *GenesisState) XXX_DiscardUnknown()
- func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *GenesisState) XXX_Merge(src proto.Message)
- func (m *GenesisState) XXX_Size() int
- func (m *GenesisState) XXX_Unmarshal(b []byte) error
- type Prophecy
- type StakingKeeper
- type Status
- func (*Status) Descriptor() ([]byte, []int)
- func (m *Status) GetFinalClaim() string
- func (m *Status) GetText() StatusText
- func (m *Status) Marshal() (dAtA []byte, err error)
- func (m *Status) MarshalTo(dAtA []byte) (int, error)
- func (m *Status) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Status) ProtoMessage()
- func (m *Status) Reset()
- func (m *Status) Size() (n int)
- func (m *Status) String() string
- func (m *Status) Unmarshal(dAtA []byte) error
- func (m *Status) XXX_DiscardUnknown()
- func (m *Status) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Status) XXX_Merge(src proto.Message)
- func (m *Status) XXX_Size() int
- func (m *Status) XXX_Unmarshal(b []byte) error
- type StatusText
Constants ¶
const ( // ModuleName is the name of the oracle module ModuleName = "oracle" // StoreKey is the string store representation StoreKey = ModuleName // QuerierRoute is the querier route for the oracle module QuerierRoute = ModuleName // RouterKey is the msg router key for the oracle module RouterKey = ModuleName )
const DefaultConsensusNeeded float64 = 0.7
DefaultConsensusNeeded defines the default consensus value required for a prophecy to be finalized
Variables ¶
var ( ErrProphecyNotFound = sdkerrors.Register(ModuleName, 1, "prophecy with given id not found") ErrMinimumConsensusNeededInvalid = sdkerrors.Register(ModuleName, 2, "minimum consensus proportion of validator staking power must be > 0 and <= 1") ErrNoClaims = sdkerrors.Register(ModuleName, 3, "cannot create prophecy without initial claim") ErrInvalidIdentifier = sdkerrors.Register(ModuleName, 4, "invalid identifier provided, must be a nonempty string") ErrProphecyFinalized = sdkerrors.Register(ModuleName, 5, "prophecy already finalized") ErrDuplicateMessage = sdkerrors.Register(ModuleName, 6, "already processed message from validator for this id") ErrInvalidClaim = sdkerrors.Register(ModuleName, 7, "claim cannot be empty string") ErrInvalidValidator = sdkerrors.Register(ModuleName, 8, "claim must be made by actively bonded validator") ErrInternalDB = sdkerrors.Register(ModuleName, 9, " failed prophecy serialization/deserialization") ErrValidatorNotInWhiteList = sdkerrors.Register(ModuleName, 10, "validator must be in whitelist") ErrNotAdminAccount = sdkerrors.Register(ModuleName, 11, "Not an admin account") ErrInvalidOperationType = sdkerrors.Register(ModuleName, 12, "invalid operation type for validator whitelist") )
Exported code type numbers
var ( WhiteListValidatorPrefix = []byte{0x00} AdminAccountPrefix = []byte{0x01} ProphecyPrefix = []byte{0x02} )
var ( ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") )
var ModuleCdc *codec.LegacyAmino //nolint
ModuleCdc defines the module codec
var StatusText_name = map[int32]string{
0: "STATUS_TEXT_UNSPECIFIED",
1: "STATUS_TEXT_PENDING",
2: "STATUS_TEXT_SUCCESS",
3: "STATUS_TEXT_FAILED",
}
var StatusText_value = map[string]int32{
"STATUS_TEXT_UNSPECIFIED": 0,
"STATUS_TEXT_PENDING": 1,
"STATUS_TEXT_SUCCESS": 2,
"STATUS_TEXT_FAILED": 3,
}
Functions ¶
This section is empty.
Types ¶
type Claim ¶
type Claim struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` }
Claim contains an arbitrary claim with arbitrary content made by a given validator
func (*Claim) Descriptor ¶
func (*Claim) GetContent ¶
func (*Claim) GetValidatorAddress ¶
func (*Claim) ProtoMessage ¶
func (*Claim) ProtoMessage()
func (*Claim) XXX_DiscardUnknown ¶
func (m *Claim) XXX_DiscardUnknown()
func (*Claim) XXX_Marshal ¶
func (*Claim) XXX_Unmarshal ¶
type DBProphecy ¶
type DBProphecy struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Status Status `protobuf:"bytes,2,opt,name=status,proto3" json:"status"` ClaimValidators []byte `protobuf:"bytes,3,opt,name=claim_validators,json=claimValidators,proto3" json:"claim_validators,omitempty"` ValidatorClaims []byte `protobuf:"bytes,4,opt,name=validator_claims,json=validatorClaims,proto3" json:"validator_claims,omitempty"` }
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) Descriptor ¶
func (*DBProphecy) Descriptor() ([]byte, []int)
func (DBProphecy) DeserializeFromDB ¶
func (dbProphecy DBProphecy) DeserializeFromDB() (Prophecy, error)
DeserializeFromDB deserializes a DBProphecy into a prophecy
func (*DBProphecy) GetClaimValidators ¶
func (m *DBProphecy) GetClaimValidators() []byte
func (*DBProphecy) GetId ¶
func (m *DBProphecy) GetId() string
func (*DBProphecy) GetStatus ¶
func (m *DBProphecy) GetStatus() Status
func (*DBProphecy) GetValidatorClaims ¶
func (m *DBProphecy) GetValidatorClaims() []byte
func (*DBProphecy) Marshal ¶
func (m *DBProphecy) Marshal() (dAtA []byte, err error)
func (*DBProphecy) MarshalToSizedBuffer ¶
func (m *DBProphecy) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*DBProphecy) ProtoMessage ¶
func (*DBProphecy) ProtoMessage()
func (*DBProphecy) Reset ¶
func (m *DBProphecy) Reset()
func (*DBProphecy) Size ¶
func (m *DBProphecy) Size() (n int)
func (*DBProphecy) String ¶
func (m *DBProphecy) String() string
func (*DBProphecy) Unmarshal ¶
func (m *DBProphecy) Unmarshal(dAtA []byte) error
func (*DBProphecy) XXX_DiscardUnknown ¶
func (m *DBProphecy) XXX_DiscardUnknown()
func (*DBProphecy) XXX_Marshal ¶
func (m *DBProphecy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*DBProphecy) XXX_Merge ¶
func (m *DBProphecy) XXX_Merge(src proto.Message)
func (*DBProphecy) XXX_Size ¶
func (m *DBProphecy) XXX_Size() int
func (*DBProphecy) XXX_Unmarshal ¶
func (m *DBProphecy) XXX_Unmarshal(b []byte) error
type GenesisState ¶
type GenesisState struct { AddressWhitelist []string `protobuf:"bytes,1,rep,name=address_whitelist,json=addressWhitelist,proto3" json:"address_whitelist,omitempty"` AdminAddress string `protobuf:"bytes,2,opt,name=admin_address,json=adminAddress,proto3" json:"admin_address,omitempty"` Prophecies []*DBProphecy `protobuf:"bytes,3,rep,name=prophecies,proto3" json:"prophecies,omitempty"` }
func DefaultGenesisState ¶
func DefaultGenesisState() *GenesisState
DefaultGenesisState gets the raw genesis raw message for testing
func GetGenesisStateFromAppState ¶
func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) GenesisState
GetGenesisStateFromAppState gets the GenesisState from raw message
func NewGenesisState ¶
func NewGenesisState() GenesisState
NewGenesisState creates a new GenesisState instance
func (*GenesisState) Descriptor ¶
func (*GenesisState) Descriptor() ([]byte, []int)
func (*GenesisState) GetAddressWhitelist ¶
func (m *GenesisState) GetAddressWhitelist() []string
func (*GenesisState) GetAdminAddress ¶
func (m *GenesisState) GetAdminAddress() string
func (*GenesisState) GetProphecies ¶
func (m *GenesisState) GetProphecies() []*DBProphecy
func (*GenesisState) Marshal ¶
func (m *GenesisState) Marshal() (dAtA []byte, err error)
func (*GenesisState) MarshalToSizedBuffer ¶
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*GenesisState) ProtoMessage ¶
func (*GenesisState) ProtoMessage()
func (*GenesisState) Reset ¶
func (m *GenesisState) Reset()
func (*GenesisState) Size ¶
func (m *GenesisState) Size() (n int)
func (*GenesisState) String ¶
func (m *GenesisState) String() string
func (*GenesisState) Unmarshal ¶
func (m *GenesisState) Unmarshal(dAtA []byte) error
func (*GenesisState) XXX_DiscardUnknown ¶
func (m *GenesisState) XXX_DiscardUnknown()
func (*GenesisState) XXX_Marshal ¶
func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GenesisState) XXX_Merge ¶
func (m *GenesisState) XXX_Merge(src proto.Message)
func (*GenesisState) XXX_Size ¶
func (m *GenesisState) XXX_Size() int
func (*GenesisState) XXX_Unmarshal ¶
func (m *GenesisState) XXX_Unmarshal(b []byte) error
type Prophecy ¶
type Prophecy struct { ID string `json:"id"` Status Status `json:"status"` //WARNING: Mappings are nondeterministic in Amino, // an so iterating over them could result in consensus failure. New code should not iterate over the below 2 mappings. //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, whiteListValidatorAddresses []sdk.ValAddress) (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, total power claimed on the prophecy overall. and the total power of all whitelist validators.
func (Prophecy) SerializeForDB ¶
func (prophecy Prophecy) SerializeForDB() (DBProphecy, error)
SerializeForDB serializes a prophecy into a DBProphecy TODO: Using gob here may mean that different tendermint clients in different languages may serialize/store prophecies in their db in different ways - check with @codereviewer if this is ok or if it introduces a risk of creating forks. Or maybe using a slower json serializer or Amino:JSON would be ok
type StakingKeeper ¶
type StakingKeeper interface { GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator staking.Validator, found bool) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) (power int64) GetLastTotalPower(ctx sdk.Context) (power sdk.Int) GetBondedValidatorsByPower(ctx sdk.Context) []staking.Validator }
StakingKeeper defines the expected staking keeper
type Status ¶
type Status struct { Text StatusText `protobuf:"varint,1,opt,name=text,proto3,enum=sifnode.oracle.v1.StatusText" json:"text,omitempty"` FinalClaim string `protobuf:"bytes,2,opt,name=final_claim,json=finalClaim,proto3" json:"final_claim,omitempty"` }
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
func (*Status) Descriptor ¶
func (*Status) GetFinalClaim ¶
func (*Status) GetText ¶
func (m *Status) GetText() StatusText
func (*Status) MarshalToSizedBuffer ¶
func (*Status) ProtoMessage ¶
func (*Status) ProtoMessage()
func (*Status) XXX_DiscardUnknown ¶
func (m *Status) XXX_DiscardUnknown()
func (*Status) XXX_Marshal ¶
func (*Status) XXX_Unmarshal ¶
type StatusText ¶
type StatusText int32
StatusText is an enum used to represent the status of the prophecy
const ( // Default value StatusText_STATUS_TEXT_UNSPECIFIED StatusText = 0 // Pending status StatusText_STATUS_TEXT_PENDING StatusText = 1 // Success status StatusText_STATUS_TEXT_SUCCESS StatusText = 2 // Failed status StatusText_STATUS_TEXT_FAILED StatusText = 3 )
func (StatusText) EnumDescriptor ¶
func (StatusText) EnumDescriptor() ([]byte, []int)
func (StatusText) String ¶
func (x StatusText) String() string