Skip to main content
Version: v8.3.x

Genesis metadata

Synopsis

Learn how to implement the ExportMetadata interface

note

Pre-requisite readings

ClientState instances are provided their own isolated and namespaced client store upon initialisation. ClientState implementations may choose to store any amount of arbitrary metadata in order to verify counterparty consensus state and perform light client updates correctly.

The ExportMetadata method of the ClientState interface provides light client modules with the ability to persist metadata in genesis exports.

ExportMetadata(clientStore sdk.KVStore) []GenesisMetadata

ExportMetadata is provided the client store and returns an array of GenesisMetadata. For maximum flexibility, GenesisMetadata is defined as a simple interface containing two distinct Key and Value accessor methods.

type GenesisMetadata interface {
// return store key that contains metadata without clientID-prefix
GetKey() []byte
// returns metadata value
GetValue() []byte
}

This allows ClientState instances to retrieve and export any number of key-value pairs which are maintained within the store in their raw []byte form.

When a chain is started with a genesis.json file which contains ClientState metadata (for example, when performing manual upgrades using an exported genesis.json) the 02-client submodule of core IBC will handle setting the key-value pairs within their respective client stores. See 02-client InitGenesis.

Please refer to the Tendermint light client implementation for an example.