github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/ibc-go/modules/core/exported/client.go (about) 1 package exported 2 3 import ( 4 ics23 "github.com/confio/ics23/go" 5 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 6 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 7 proto "github.com/gogo/protobuf/proto" 8 ) 9 10 // Status represents the status of a client 11 type Status string 12 13 const ( 14 // TypeClientMisbehaviour is the shared evidence misbehaviour type 15 TypeClientMisbehaviour string = "client_misbehaviour" 16 17 // Solomachine is used to indicate that the light client is a solo machine. 18 Solomachine string = "06-solomachine" 19 20 // Tendermint is used to indicate that the client uses the Tendermint Consensus Algorithm. 21 Tendermint string = "07-tendermint" 22 23 // Localhost is the client type for a localhost client. It is also used as the clientID 24 // for the localhost client. 25 Localhost string = "09-localhost" 26 27 // Active is a status type of a client. An active client is allowed to be used. 28 Active Status = "Active" 29 30 // Frozen is a status type of a client. A frozen client is not allowed to be used. 31 Frozen Status = "Frozen" 32 33 // Expired is a status type of a client. An expired client is not allowed to be used. 34 Expired Status = "Expired" 35 36 // Unknown indicates there was an error in determining the status of a client. 37 Unknown Status = "Unknown" 38 ) 39 40 // Height is a wrapper interface over clienttypes.Height 41 // all clients must use the concrete implementation in types 42 type Height interface { 43 IsZero() bool 44 LT(Height) bool 45 LTE(Height) bool 46 EQ(Height) bool 47 GT(Height) bool 48 GTE(Height) bool 49 GetRevisionNumber() uint64 50 GetRevisionHeight() uint64 51 Increment() Height 52 Decrement() (Height, bool) 53 String() string 54 } 55 56 // ClientState defines the required common functions for light clients. 57 type ClientState interface { 58 proto.Message 59 60 ClientType() string 61 GetLatestHeight() Height 62 Validate() error 63 GetProofSpecs() []*ics23.ProofSpec 64 65 // Initialization function 66 // Clients must validate the initial consensus state, and may store any client-specific metadata 67 // necessary for correct light client operation 68 Initialize(sdk.Context, *codec.CodecProxy, sdk.KVStore, ConsensusState) error 69 70 // Status function 71 // Clients must return their status. Only Active clients are allowed to process packets. 72 // Ywmet todo 73 Status(ctx sdk.Context, clientStore sdk.KVStore, cdc *codec.CodecProxy) Status 74 75 // Genesis function 76 ExportMetadata(sdk.KVStore) []GenesisMetadata 77 78 // Update and Misbehaviour functions 79 80 CheckHeaderAndUpdateState(sdk.Context, *codec.CodecProxy, sdk.KVStore, Header) (ClientState, ConsensusState, error) 81 CheckMisbehaviourAndUpdateState(sdk.Context, *codec.CodecProxy, sdk.KVStore, Misbehaviour) (ClientState, error) 82 CheckSubstituteAndUpdateState(ctx sdk.Context, cdc *codec.CodecProxy, subjectClientStore, substituteClientStore sdk.KVStore, substituteClient ClientState) (ClientState, error) 83 84 // Upgrade functions 85 // NOTE: proof heights are not included as upgrade to a new revision is expected to pass only on the last 86 // height committed by the current revision. Clients are responsible for ensuring that the planned last 87 // height of the current revision is somehow encoded in the proof verification process. 88 // This is to ensure that no premature upgrades occur, since upgrade plans committed to by the counterparty 89 // may be cancelled or modified before the last planned height. 90 VerifyUpgradeAndUpdateState( 91 ctx sdk.Context, 92 cdc *codec.CodecProxy, 93 store sdk.KVStore, 94 newClient ClientState, 95 newConsState ConsensusState, 96 proofUpgradeClient, 97 proofUpgradeConsState []byte, 98 ) (ClientState, ConsensusState, error) 99 // Utility function that zeroes out any client customizable fields in client state 100 // Ledger enforced fields are maintained while all custom fields are zero values 101 // Used to verify upgrades 102 ZeroCustomFields() ClientState 103 104 // State verification functions 105 106 VerifyClientState( 107 store sdk.KVStore, 108 cdc *codec.CodecProxy, 109 height Height, 110 prefix Prefix, 111 counterpartyClientIdentifier string, 112 proof []byte, 113 clientState ClientState, 114 ) error 115 VerifyClientConsensusState( 116 store sdk.KVStore, 117 cdc *codec.CodecProxy, 118 height Height, 119 counterpartyClientIdentifier string, 120 consensusHeight Height, 121 prefix Prefix, 122 proof []byte, 123 consensusState ConsensusState, 124 ) error 125 VerifyConnectionState( 126 store sdk.KVStore, 127 cdc *codec.CodecProxy, 128 height Height, 129 prefix Prefix, 130 proof []byte, 131 connectionID string, 132 connectionEnd ConnectionI, 133 ) error 134 VerifyChannelState( 135 store sdk.KVStore, 136 cdc *codec.CodecProxy, 137 height Height, 138 prefix Prefix, 139 proof []byte, 140 portID, 141 channelID string, 142 channel ChannelI, 143 ) error 144 VerifyPacketCommitment( 145 ctx sdk.Context, 146 store sdk.KVStore, 147 cdc *codec.CodecProxy, 148 height Height, 149 delayTimePeriod uint64, 150 delayBlockPeriod uint64, 151 prefix Prefix, 152 proof []byte, 153 portID, 154 channelID string, 155 sequence uint64, 156 commitmentBytes []byte, 157 ) error 158 VerifyPacketAcknowledgement( 159 ctx sdk.Context, 160 store sdk.KVStore, 161 cdc *codec.CodecProxy, 162 height Height, 163 delayTimePeriod uint64, 164 delayBlockPeriod uint64, 165 prefix Prefix, 166 proof []byte, 167 portID, 168 channelID string, 169 sequence uint64, 170 acknowledgement []byte, 171 ) error 172 VerifyPacketReceiptAbsence( 173 ctx sdk.Context, 174 store sdk.KVStore, 175 cdc *codec.CodecProxy, 176 height Height, 177 delayTimePeriod uint64, 178 delayBlockPeriod uint64, 179 prefix Prefix, 180 proof []byte, 181 portID, 182 channelID string, 183 sequence uint64, 184 ) error 185 VerifyNextSequenceRecv( 186 ctx sdk.Context, 187 store sdk.KVStore, 188 cdc *codec.CodecProxy, 189 height Height, 190 delayTimePeriod uint64, 191 delayBlockPeriod uint64, 192 prefix Prefix, 193 proof []byte, 194 portID, 195 channelID string, 196 nextSequenceRecv uint64, 197 ) error 198 } 199 200 // ConsensusState is the state of the consensus process 201 type ConsensusState interface { 202 proto.Message 203 204 ClientType() string // Consensus kind 205 206 // GetRoot returns the commitment root of the consensus state, 207 // which is used for key-value pair verification. 208 GetRoot() Root 209 210 // GetTimestamp returns the timestamp (in nanoseconds) of the consensus state 211 GetTimestamp() uint64 212 213 ValidateBasic() error 214 } 215 216 // Misbehaviour defines counterparty misbehaviour for a specific consensus type 217 type Misbehaviour interface { 218 proto.Message 219 220 ClientType() string 221 GetClientID() string 222 ValidateBasic() error 223 } 224 225 // Header is the consensus state update information 226 type Header interface { 227 proto.Message 228 229 ClientType() string 230 GetHeight() Height 231 ValidateBasic() error 232 } 233 234 // GenesisMetadata is a wrapper interface over clienttypes.GenesisMetadata 235 // all clients must use the concrete implementation in types 236 type GenesisMetadata interface { 237 // return store key that contains metadata without clientID-prefix 238 GetKey() []byte 239 // returns metadata value 240 GetValue() []byte 241 }