Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

ics23_mpt source pure

Constants 1

Variables 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)
source

Sentinel errors for the object-form client. Proof-shape errors reuse the errors declared in consensus.gno (ErrConsensusStateTooShort, ErrInvalidCommitmentKey).

Functions 8

func VerifyCommitmentKey

1func VerifyCommitmentKey(path []byte, proofKey []byte) error
source

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 NewStateLensIcs23MptLightClient

1func NewStateLensIcs23MptLightClient(clientState *ClientState, consensusState *ConsensusState, getL1ClientFn func(types.ClientId) (lightclient.Interface, bool)) (*StateLensIcs23MptLightClient, error)
source

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.

Types 4

type ClientState

struct
1type ClientState struct {
2	L2ChainID         string
3	L1ClientID        uint32
4	L2ClientID        uint32
5	L2LatestHeight    uint64
6	TimestampOffset   uint16
7	StateRootOffset   uint16
8	StorageRootOffset uint16
9}
source

ClientState 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 ClientState
1func (cs ClientState) ExtractConsensusState(data []byte) (ConsensusState, error)
source

ExtractConsensusState 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

struct
1type ConsensusState struct {
2	Timestamp   uint64 // nanoseconds since Unix epoch
3	StateRoot   []byte // bytes32
4	StorageRoot []byte // bytes32
5}
source

ConsensusState mirrors state-lens-ics23-mpt ConsensusState.

type Header

struct
1type Header struct {
2	L1Height              uint64
3	L2Height              uint64
4	L2ConsensusStateProof []byte
5	L2ConsensusState      []byte
6}
source

Header is the state-lens ClientMessage used to update the client.

type StateLensIcs23MptLightClient

struct
1type 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}
source

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 StateLensIcs23MptLightClient
1func (c *StateLensIcs23MptLightClient) GetCounterpartyChainID() string
source

func GetLatestHeight

method on StateLensIcs23MptLightClient
1func (c *StateLensIcs23MptLightClient) GetLatestHeight() uint64
source

func GetTimestamp

method on StateLensIcs23MptLightClient
1func (c *StateLensIcs23MptLightClient) GetTimestamp() types.Timestamp
source

GetTimestamp returns the timestamp of the consensus state at the latest height, or zero when none exists.

func GetTimestampAtHeight

method on StateLensIcs23MptLightClient
1func (c *StateLensIcs23MptLightClient) GetTimestampAtHeight(height uint64) (types.Timestamp, error)
source

func Misbehaviour

method on StateLensIcs23MptLightClient
1func (c *StateLensIcs23MptLightClient) Misbehaviour(caller address, misbehaviour []byte, relayer address) ([]byte, error)
source

Misbehaviour is unsupported for state-lens clients, mirroring Union's `unimplemented!()` for this client type.

func Status

method on StateLensIcs23MptLightClient
1func (c *StateLensIcs23MptLightClient) Status() lightclient.Status
source

Status 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 StateLensIcs23MptLightClient
1func (c *StateLensIcs23MptLightClient) VerifyCreation(caller address, relayer address) (types.ClientCreationResult, error)
source

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 StateLensIcs23MptLightClient
1func (c *StateLensIcs23MptLightClient) VerifyHeader(caller address, headerBytes []byte, relayer address) (types.StateUpdate, error)
source

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 StateLensIcs23MptLightClient
1func (c *StateLensIcs23MptLightClient) VerifyMembership(height uint64, key []byte, proof []byte, value []byte) error
source

VerifyMembership 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 StateLensIcs23MptLightClient
1func (c *StateLensIcs23MptLightClient) VerifyNonMembership(height uint64, key []byte, proof []byte) error
source

Imports 12

Source Files 5