ics23_mpt source pure
1
2
var ErrNoL1Client, ErrInvalidHeight, ErrConsensusStateNotFound, ErrInvalidCommitmentValue, ErrStoredValueMismatch, ErrMisbehaviourUnsupported
1var (
2 ErrNoL1Client = errors.New("ics23mpt: l1 client not configured")
3 ErrInvalidHeight = errors.New("ics23mpt: proof height above latest height")
4 ErrConsensusStateNotFound = errors.New("ics23mpt: consensus state not found at height")
5 ErrInvalidCommitmentValue = errors.New("ics23mpt: commitment value must be 32 bytes")
6 ErrStoredValueMismatch = errors.New("ics23mpt: stored value mismatch")
7 ErrMisbehaviourUnsupported = errors.New("ics23mpt: misbehaviour is not supported for state-lens clients")
8)Sentinel errors for the object-form client. Proof-shape errors reuse the errors declared in consensus.gno (ErrConsensusStateTooShort, ErrInvalidCommitmentKey).
var ErrConsensusStateTooShort, ErrInvalidCommitmentKey
8
func EncodeClientState
func EncodeConsensusState
func EncodeHeader
func VerifyCommitmentKey
VerifyCommitmentKey checks that proofKey matches the IBC commitment key derived from path. It rejects proofs whose key does not bind to the expected commitment path.
func DecodeClientState
func DecodeConsensusState
func DecodeHeader
func NewStateLensIcs23MptLightClient
1func NewStateLensIcs23MptLightClient(clientState *ClientState, consensusState *ConsensusState, getL1ClientFn func(types.ClientId) (lightclient.Interface, bool)) (*StateLensIcs23MptLightClient, error)NewStateLensIcs23MptLightClient builds the Gno object-form light client from decoded client and consensus state. getL1ClientFn is a live store getter called on every L1 lookup, matching Union's ctx-based approach where the light client resolves the L1 dependency lazily from the host store.
4
type ClientState
structClientState mirrors Union's state-lens ClientState<ics23-mpt Extra>.
The generic Rust form is flattened here:
Example
1(string,uint32,uint32,uint64,uint16,uint16,uint16)
L1ClientID is the client on this chain tracking the settlement chain. L2ClientID is the client on the settlement chain tracking the chain whose state this state-lens client exposes.
Methods on ClientState
func ExtractConsensusState
method on ClientStateExtractConsensusState parses the L2 consensus state bytes into a ConsensusState using the byte offsets recorded in this client state. The state-lens client trusts the counterparty's opaque L2 consensus blob and reads timestamp / state root / storage root from fixed offsets.
type ConsensusState
structConsensusState mirrors state-lens-ics23-mpt ConsensusState.
type Header
structHeader is the state-lens ClientMessage used to update the client.
type StateLensIcs23MptLightClient
struct1type StateLensIcs23MptLightClient struct {
2 clientState *ClientState
3 consensusStateByHeight *bptree.BPTree // height:*ConsensusState
4 // getL1ClientFn resolves the settlement-chain light client from the host store
5 // on every call, so the state-lens always sees the current L1 state without
6 // needing an explicit refresh step.
7 getL1ClientFn func(types.ClientId) (lightclient.Interface, bool)
8}StateLensIcs23MptLightClient is the stateful object implementing lightclient.Interface for the state-lens/ics23/mpt client.
It holds the client state and the L2 consensus states keyed by height. The L1 client dependency is resolved lazily on every use via getL1Client, mirroring Union's ctx-based approach where the light client struct is stateless and the host provides L1 access through the execution context.
A state-lens client does not track its own chain directly. It trusts the counterparty's opaque L2 consensus blob, proven to exist in the L1 chain's state via the L1 light client. Membership of application state is then verified against the L2 storage root with EVM MPT storage proofs.
This mirrors Union's StateLensIcs23MptLightClient (cosmwasm/lightclient/state-lens-ics23-mpt).
Methods on StateLensIcs23MptLightClient
func GetCounterpartyChainID
method on StateLensIcs23MptLightClientfunc GetLatestHeight
method on StateLensIcs23MptLightClientfunc GetTimestamp
method on StateLensIcs23MptLightClientGetTimestamp returns the timestamp of the consensus state at the latest height, or zero when none exists.
func GetTimestampAtHeight
method on StateLensIcs23MptLightClientfunc Misbehaviour
method on StateLensIcs23MptLightClient1func (c *StateLensIcs23MptLightClient) Misbehaviour(caller address, misbehaviour []byte, relayer address) ([]byte, error)Misbehaviour is unsupported for state-lens clients, mirroring Union's `unimplemented!()` for this client type.
func Status
method on StateLensIcs23MptLightClientStatus mirrors the L1 client's status. A state-lens client has no liveness of its own: it is only as live as the L1 client it depends on. A missing or unknown L1 status is treated as Frozen, matching Union's unwrap_or(Frozen).
func VerifyCreation
method on StateLensIcs23MptLightClient1func (c *StateLensIcs23MptLightClient) VerifyCreation(caller address, relayer address) (types.ClientCreationResult, error)VerifyCreation performs no creation-time state mutation; the state-lens client trusts its initial consensus state. Mirrors Union's verify_creation, which only emits an event. Union reference: https://github.com/unionlabs/union/blob/1bb07590230e7c4d071f32ad7185be021a1a1789/cosmwasm/lightclient/state-lens-ics23-mpt/src/client.rs#L83-L96
func VerifyHeader
method on StateLensIcs23MptLightClient1func (c *StateLensIcs23MptLightClient) VerifyHeader(caller address, headerBytes []byte, relayer address) (types.StateUpdate, error)VerifyHeader verifies a state-lens header and updates the client. It proves that the submitted L2 consensus state is committed in the L1 state at L1Height (via the L1 client), then extracts and stores the L2 consensus state at L2Height. Mirrors Union's verify_header. Union reference: https://github.com/unionlabs/union/blob/1bb07590230e7c4d071f32ad7185be021a1a1789/cosmwasm/lightclient/state-lens-ics23-mpt/src/client.rs#L98-L134
func VerifyMembership
method on StateLensIcs23MptLightClient1func (c *StateLensIcs23MptLightClient) VerifyMembership(height uint64, key []byte, proof []byte, value []byte) errorVerifyMembership verifies that key stores value under the L2 storage root at the given height using an EVM MPT storage proof. Status gating is the caller's responsibility, mirroring the cometbls object form. Union reference: https://github.com/unionlabs/union/blob/1bb07590230e7c4d071f32ad7185be021a1a1789/cosmwasm/lightclient/state-lens-ics23-mpt/src/client.rs#L39-L50 https://github.com/unionlabs/union/blob/1bb07590230e7c4d071f32ad7185be021a1a1789/cosmwasm/lightclient/state-lens-ics23-mpt/src/client.rs#L189-L218
func VerifyNonMembership
method on StateLensIcs23MptLightClient1func (c *StateLensIcs23MptLightClient) VerifyNonMembership(height uint64, key []byte, proof []byte) errorVerifyNonMembership verifies the absence of key under the L2 storage root at the given height using an EVM MPT absence proof. Union reference: https://github.com/unionlabs/union/blob/1bb07590230e7c4d071f32ad7185be021a1a1789/cosmwasm/lightclient/state-lens-ics23-mpt/src/client.rs#L53-L63 https://github.com/unionlabs/union/blob/1bb07590230e7c4d071f32ad7185be021a1a1789/cosmwasm/lightclient/state-lens-ics23-mpt/src/client.rs#L233-L254
12
- bytes stdlib
- crypto/keccak256 stdlib
- encoding/binary stdlib
- errors stdlib
- gno.land/p/nt/bptree/v0 package
- gno.land/p/nt/ufmt/v0 package
- gno.land/p/onbloc/encoding/abi package
- gno.land/p/onbloc/ibc/union/lightclient package
- gno.land/p/onbloc/ibc/union/types package
- gno.land/p/onbloc/verifier/evm/storage package
- strconv stdlib
- strings stdlib