Documentation
¶
Index ¶
- Constants
- Variables
- func NewLightClientModule(cdc codec.BinaryCodec, storeProvider clienttypes.StoreProvider, ...) (LightClientModule, TrustedClientUpdateFunc)
- func RegisterInterfaces(registry codectypes.InterfaceRegistry)
- type AppModule
- type AppModuleBasic
- func (AppModuleBasic) IsAppModule()
- func (AppModuleBasic) IsOnePerModuleType()
- func (a AppModuleBasic) Name() string
- func (a AppModuleBasic) RegisterGRPCGatewayRoutes(context client.Context, mux *runtime.ServeMux)
- func (a AppModuleBasic) RegisterInterfaces(registry types.InterfaceRegistry)
- func (a AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino)
- type AttestationClaim
- func (m *AttestationClaim) ClientType() string
- func (*AttestationClaim) Descriptor() ([]byte, []int)
- func (m *AttestationClaim) GetAttestations() []types.Attestation
- func (m *AttestationClaim) Marshal() (dAtA []byte, err error)
- func (m *AttestationClaim) MarshalTo(dAtA []byte) (int, error)
- func (m *AttestationClaim) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*AttestationClaim) ProtoMessage()
- func (m *AttestationClaim) Reset()
- func (m *AttestationClaim) Size() (n int)
- func (m *AttestationClaim) String() string
- func (m *AttestationClaim) Unmarshal(dAtA []byte) error
- func (m *AttestationClaim) ValidateBasic() error
- func (m *AttestationClaim) XXX_DiscardUnknown()
- func (m *AttestationClaim) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *AttestationClaim) XXX_Merge(src proto.Message)
- func (m *AttestationClaim) XXX_Size() int
- func (m *AttestationClaim) XXX_Unmarshal(b []byte) error
- type AttestatorsController
- type ClientState
- func (cs *ClientState) ClientType() string
- func (*ClientState) Descriptor() ([]byte, []int)
- func (cs ClientState) Initialize(cdc codec.BinaryCodec, clientStore storetypes.KVStore, ...) error
- func (m *ClientState) Marshal() (dAtA []byte, err error)
- func (m *ClientState) MarshalTo(dAtA []byte) (int, error)
- func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*ClientState) ProtoMessage()
- func (m *ClientState) Reset()
- func (m *ClientState) Size() (n int)
- func (m *ClientState) String() string
- func (m *ClientState) Unmarshal(dAtA []byte) error
- func (cs *ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, ...) []exported.Height
- func (cs *ClientState) Validate() error
- func (cs *ClientState) VerifyClientMessage(ctx sdk.Context, cdc codec.BinaryCodec, ...) error
- func (cs ClientState) VerifyMembership(clientStore storetypes.KVStore, packetCommitment []byte) error
- func (m *ClientState) XXX_DiscardUnknown()
- func (m *ClientState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ClientState) XXX_Merge(src proto.Message)
- func (m *ClientState) XXX_Size() int
- func (m *ClientState) XXX_Unmarshal(b []byte) error
- type ConsensusState
- func (m *ConsensusState) ClientType() string
- func (*ConsensusState) Descriptor() ([]byte, []int)
- func (m *ConsensusState) GetTimestamp() uint64
- func (m *ConsensusState) Marshal() (dAtA []byte, err error)
- func (m *ConsensusState) MarshalTo(dAtA []byte) (int, error)
- func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*ConsensusState) ProtoMessage()
- func (m *ConsensusState) Reset()
- func (m *ConsensusState) Size() (n int)
- func (m *ConsensusState) String() string
- func (m *ConsensusState) Unmarshal(dAtA []byte) error
- func (m *ConsensusState) ValidateBasic() error
- func (m *ConsensusState) XXX_DiscardUnknown()
- func (m *ConsensusState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ConsensusState) XXX_Merge(src proto.Message)
- func (m *ConsensusState) XXX_Size() int
- func (m *ConsensusState) XXX_Unmarshal(b []byte) error
- type LightClientModule
- func (l *LightClientModule) CheckForMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) bool
- func (l *LightClientModule) Initialize(ctx sdk.Context, clientID string, clientStateBz, consensusStateBz []byte) error
- func (l *LightClientModule) LatestHeight(ctx sdk.Context, clientID string) exported.Height
- func (l *LightClientModule) RecoverClient(ctx sdk.Context, clientID, substituteClientID string) error
- func (l *LightClientModule) Status(ctx sdk.Context, clientID string) exported.Status
- func (l *LightClientModule) TimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error)
- func (l *LightClientModule) UpdateState(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) []exported.Height
- func (l *LightClientModule) UpdateStateOnMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage)
- func (l *LightClientModule) VerifyClientMessage(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) error
- func (l *LightClientModule) VerifyMembership(ctx sdk.Context, clientID string, height exported.Height, ...) error
- func (l *LightClientModule) VerifyNonMembership(ctx sdk.Context, clientID string, height exported.Height, ...) error
- func (l *LightClientModule) VerifyUpgradeAndUpdateState(ctx sdk.Context, clientID string, newClient []byte, newConsState []byte, ...) error
- type TrustedClientUpdateFunc
Constants ¶
const ( ModuleName = "10-attestation" PacketCommitmentStoreKey = "packetCommitment" )
ModuleName is the name of the module and the ClientType of the light client
Variables ¶
var ( ErrInvalidLengthClientmsg = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowClientmsg = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupClientmsg = fmt.Errorf("proto: unexpected end of group") )
var ( ErrInvalidChainID = errorsmod.Register(ModuleName, 2, "invalid chain-id") ErrInvalidRequiredTokenPower = errorsmod.Register(ModuleName, 3, "invalid required token power") ErrInvalidHeaderHeight = errorsmod.Register(ModuleName, 4, "invalid header height") ErrInvalidClientMsg = errorsmod.Register(ModuleName, 5, "invalid client message") ErrPacketCommitmentNotFound = errorsmod.Register(ModuleName, 6, "packet commitment not found") ErrInvalidUpdateMethod = errorsmod.Register(ModuleName, 7, "invalid update method, can only be done through code") )
Attestation Light Client sentinel errors
Functions ¶
func NewLightClientModule ¶
func NewLightClientModule(cdc codec.BinaryCodec, storeProvider clienttypes.StoreProvider, attestatorsHandler AttestatorsController) (LightClientModule, TrustedClientUpdateFunc)
NewLightClientModule creates and returns a new attestation LightClientModule.
func RegisterInterfaces ¶
func RegisterInterfaces(registry codectypes.InterfaceRegistry)
RegisterInterfaces register the ibc channel submodule interfaces to protobuf Any.
Types ¶
type AppModule ¶
type AppModule struct { AppModuleBasic // contains filtered or unexported fields }
AppModule is the application module for the attestation client module
func NewAppModule ¶
func NewAppModule(lightClientModule LightClientModule) AppModule
NewAppModule creates a new attestation client AppModule
type AppModuleBasic ¶
type AppModuleBasic struct{}
func (AppModuleBasic) IsAppModule ¶
func (AppModuleBasic) IsAppModule()
IsAppModule implements the appmodule.AppModule interface.
func (AppModuleBasic) IsOnePerModuleType ¶
func (AppModuleBasic) IsOnePerModuleType()
IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (AppModuleBasic) Name ¶
func (a AppModuleBasic) Name() string
func (AppModuleBasic) RegisterGRPCGatewayRoutes ¶
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(context client.Context, mux *runtime.ServeMux)
RegisterGRPCGatewayRoutes performs a no-op.
func (AppModuleBasic) RegisterInterfaces ¶
func (a AppModuleBasic) RegisterInterfaces(registry types.InterfaceRegistry)
RegisterInterfaces registers module concrete types into protobuf Any. This allows core IBC to unmarshal the attestation light client types.
func (AppModuleBasic) RegisterLegacyAminoCodec ¶
func (a AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino)
RegisterLegacyAminoCodec performs a no-op. The attestation client does not support amino.
type AttestationClaim ¶
type AttestationClaim struct {
Attestations []types.Attestation `protobuf:"bytes,1,rep,name=attestations,proto3" json:"attestations"`
}
AttestationClaim is the clientMsg that is sent to the light client to update the consensus state All the claims need to be for the same height and have the same packet_commitments
func NewAttestationClaim ¶
func NewAttestationClaim(attestation []types.Attestation) *AttestationClaim
func (*AttestationClaim) ClientType ¶
func (m *AttestationClaim) ClientType() string
func (*AttestationClaim) Descriptor ¶
func (*AttestationClaim) Descriptor() ([]byte, []int)
func (*AttestationClaim) GetAttestations ¶
func (m *AttestationClaim) GetAttestations() []types.Attestation
func (*AttestationClaim) Marshal ¶
func (m *AttestationClaim) Marshal() (dAtA []byte, err error)
func (*AttestationClaim) MarshalToSizedBuffer ¶
func (m *AttestationClaim) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*AttestationClaim) ProtoMessage ¶
func (*AttestationClaim) ProtoMessage()
func (*AttestationClaim) Reset ¶
func (m *AttestationClaim) Reset()
func (*AttestationClaim) Size ¶
func (m *AttestationClaim) Size() (n int)
func (*AttestationClaim) String ¶
func (m *AttestationClaim) String() string
func (*AttestationClaim) Unmarshal ¶
func (m *AttestationClaim) Unmarshal(dAtA []byte) error
func (*AttestationClaim) ValidateBasic ¶
func (m *AttestationClaim) ValidateBasic() error
func (*AttestationClaim) XXX_DiscardUnknown ¶
func (m *AttestationClaim) XXX_DiscardUnknown()
func (*AttestationClaim) XXX_Marshal ¶
func (m *AttestationClaim) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*AttestationClaim) XXX_Merge ¶
func (m *AttestationClaim) XXX_Merge(src proto.Message)
func (*AttestationClaim) XXX_Size ¶
func (m *AttestationClaim) XXX_Size() int
func (*AttestationClaim) XXX_Unmarshal ¶
func (m *AttestationClaim) XXX_Unmarshal(b []byte) error
type AttestatorsController ¶
type AttestatorsController interface {
SufficientAttestations(ctx context.Context, attestatorIds [][]byte) (bool, error)
}
TODO: Document the interface and its methods
type ClientState ¶
type ClientState struct { // chain_id is the chain-id of the chain this light client is tracking ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // TODO: Do we actually need this, or should it come from the controller? RequiredTokenPower cosmossdk_io_math.Int `` /* 140-byte string literal not displayed */ // Block height when the client was frozen due to a misbehaviour FrozenHeight types.Height `protobuf:"bytes,3,opt,name=frozen_height,json=frozenHeight,proto3" json:"frozen_height"` // Latest height the client was updated to LatestHeight types.Height `protobuf:"bytes,4,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height"` }
ClientState tracks the validation setup required for a light client
func NewClientState ¶
func NewClientState( chainID string, requiredTokenPower sdkmath.Int, frozenHeight clienttypes.Height, latestHeight clienttypes.Height, ) *ClientState
func (*ClientState) ClientType ¶
func (cs *ClientState) ClientType() string
func (*ClientState) Descriptor ¶
func (*ClientState) Descriptor() ([]byte, []int)
func (ClientState) Initialize ¶
func (cs ClientState) Initialize(cdc codec.BinaryCodec, clientStore storetypes.KVStore, consState exported.ConsensusState) error
Initialize checks that the initial consensus state is an 07-tendermint consensus state and sets the client state, consensus state and associated metadata in the provided client store.
func (*ClientState) Marshal ¶
func (m *ClientState) Marshal() (dAtA []byte, err error)
func (*ClientState) MarshalToSizedBuffer ¶
func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*ClientState) ProtoMessage ¶
func (*ClientState) ProtoMessage()
func (*ClientState) Reset ¶
func (m *ClientState) Reset()
func (*ClientState) Size ¶
func (m *ClientState) Size() (n int)
func (*ClientState) String ¶
func (m *ClientState) String() string
func (*ClientState) Unmarshal ¶
func (m *ClientState) Unmarshal(dAtA []byte) error
func (*ClientState) UpdateState ¶
func (cs *ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) []exported.Height
func (*ClientState) Validate ¶
func (cs *ClientState) Validate() error
func (*ClientState) VerifyClientMessage ¶
func (cs *ClientState) VerifyClientMessage( ctx sdk.Context, cdc codec.BinaryCodec, attestatorsHandler AttestatorsController, clientMsg exported.ClientMessage, ) error
VerifyClientMessage checks if the clientMessage is the correct type and verifies the message
func (ClientState) VerifyMembership ¶
func (cs ClientState) VerifyMembership(clientStore storetypes.KVStore, packetCommitment []byte) error
func (*ClientState) XXX_DiscardUnknown ¶
func (m *ClientState) XXX_DiscardUnknown()
func (*ClientState) XXX_Marshal ¶
func (m *ClientState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ClientState) XXX_Merge ¶
func (m *ClientState) XXX_Merge(src proto.Message)
func (*ClientState) XXX_Size ¶
func (m *ClientState) XXX_Size() int
func (*ClientState) XXX_Unmarshal ¶
func (m *ClientState) XXX_Unmarshal(b []byte) error
type ConsensusState ¶
type ConsensusState struct { // timestamp that corresponds to the block height in which the ConsensusState // was stored Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,proto3,stdtime" json:"timestamp"` }
ConsensusState tracks the state of the counterparty chain
func NewConsensusState ¶
func NewConsensusState( timestamp time.Time, ) *ConsensusState
func (*ConsensusState) ClientType ¶
func (m *ConsensusState) ClientType() string
func (*ConsensusState) Descriptor ¶
func (*ConsensusState) Descriptor() ([]byte, []int)
func (*ConsensusState) GetTimestamp ¶
func (m *ConsensusState) GetTimestamp() uint64
GetTimestamp returns the timestamp (in nanoseconds) of the consensus state
func (*ConsensusState) Marshal ¶
func (m *ConsensusState) Marshal() (dAtA []byte, err error)
func (*ConsensusState) MarshalToSizedBuffer ¶
func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*ConsensusState) ProtoMessage ¶
func (*ConsensusState) ProtoMessage()
func (*ConsensusState) Reset ¶
func (m *ConsensusState) Reset()
func (*ConsensusState) Size ¶
func (m *ConsensusState) Size() (n int)
func (*ConsensusState) String ¶
func (m *ConsensusState) String() string
func (*ConsensusState) Unmarshal ¶
func (m *ConsensusState) Unmarshal(dAtA []byte) error
func (*ConsensusState) ValidateBasic ¶
func (m *ConsensusState) ValidateBasic() error
func (*ConsensusState) XXX_DiscardUnknown ¶
func (m *ConsensusState) XXX_DiscardUnknown()
func (*ConsensusState) XXX_Marshal ¶
func (m *ConsensusState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ConsensusState) XXX_Merge ¶
func (m *ConsensusState) XXX_Merge(src proto.Message)
func (*ConsensusState) XXX_Size ¶
func (m *ConsensusState) XXX_Size() int
func (*ConsensusState) XXX_Unmarshal ¶
func (m *ConsensusState) XXX_Unmarshal(b []byte) error
type LightClientModule ¶
type LightClientModule struct {
// contains filtered or unexported fields
}
LightClientModule implements the core IBC api.LightClientModule interface.
func (*LightClientModule) CheckForMisbehaviour ¶
func (l *LightClientModule) CheckForMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) bool
TODO: implement this TODO: test this TODO: godoc
func (*LightClientModule) Initialize ¶
func (l *LightClientModule) Initialize(ctx sdk.Context, clientID string, clientStateBz, consensusStateBz []byte) error
Initialize unmarshals the provided client and consensus states and performs basic validation. It then initializes the client state with the provided consensus state (and stores it in the client store).A
CONTRACT: clientID is validated in 02-client router, thus clientID is assumed here to have the correct format.
func (*LightClientModule) LatestHeight ¶
LatestHeight returns the latest height of the light client with the given clientID.
func (*LightClientModule) RecoverClient ¶
func (l *LightClientModule) RecoverClient(ctx sdk.Context, clientID, substituteClientID string) error
TODO: implement this TODO: test this TODO: godoc
func (*LightClientModule) Status ¶
Status returns the status of the light client with the given clientID. TODO: Implement frozen client
func (*LightClientModule) TimestampAtHeight ¶
func (l *LightClientModule) TimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error)
TimestampAtHeight returns the timestamp associated with the given height.
func (*LightClientModule) UpdateState ¶
func (l *LightClientModule) UpdateState(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) []exported.Height
UpdateState will always return an error, because it is only supposed to be called by validators in the trustedUpdateState call
func (*LightClientModule) UpdateStateOnMisbehaviour ¶
func (l *LightClientModule) UpdateStateOnMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage)
TODO: implement this TODO: test this TODO: godoc
func (*LightClientModule) VerifyClientMessage ¶
func (l *LightClientModule) VerifyClientMessage(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) error
VerifyClientMessage obtains the client state associated with the client identifier and calls into the clientState.VerifyClientMessage method.
CONTRACT: clientID is validated in 02-client router, thus clientID is assumed here to have the format 07-tendermint-{n}.
func (*LightClientModule) VerifyMembership ¶
func (l *LightClientModule) VerifyMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error
VerifyMembership uses the packet commitment bytes (value) to verify the membership proof. The client module has all the packet commitments stored and will just look for their existence.
func (*LightClientModule) VerifyNonMembership ¶
func (l *LightClientModule) VerifyNonMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path) error
VerifyNonMembership is currently not possible as we need a packet commitment to check if it exists in the store
func (*LightClientModule) VerifyUpgradeAndUpdateState ¶
func (l *LightClientModule) VerifyUpgradeAndUpdateState(ctx sdk.Context, clientID string, newClient []byte, newConsState []byte, upgradeClientProof, upgradeConsensusStateProof []byte) error
TODO: implement this TODO: test this TODO: godoc