Crate mmr_gadget
source ·Expand description
MMR offchain gadget
The MMR offchain gadget is run alongside pallet-mmr
to assist it with offchain
canonicalization of finalized MMR leaves and nodes.
The gadget should only be run on nodes that have Indexing API enabled (otherwise
pallet-mmr
cannot write to offchain and this gadget has nothing to do).
The runtime pallet-mmr
creates one new MMR leaf per block and all inner MMR parent nodes
generated by the MMR when adding said leaf. MMR nodes are stored both in:
- on-chain storage - hashes only; not full leaf content;
- off-chain storage - via Indexing API, full leaf content (and all internal nodes as well) is
saved to the Off-chain DB using a key derived from
parent_hash
and node index in MMR. Theparent_hash
is also used within the key to avoid conflicts and overwrites on forks (leaf data is only allowed to reference data coming from parent block).
This gadget is driven by block finality and in responsible for pruning stale forks from
offchain db, and moving finalized forks under a “canonical” key based solely on node pos
in the MMR.
Structs
- A MMR Gadget.
Constants
- Logging target for the mmr gadget.
Traits
- A convenience MMR client trait that defines all the type bounds a MMR client has to satisfy and defines some helper methods.