36 major breaking releases

40.0.0 Sep 26, 2024
39.0.0 Jul 18, 2024
37.0.0 Jul 12, 2024
36.0.0 Jun 24, 2024
0.0.0 Nov 29, 2022

#4 in #mmr

Download history 609/week @ 2024-07-01 434/week @ 2024-07-08 496/week @ 2024-07-15 427/week @ 2024-07-22 379/week @ 2024-07-29 453/week @ 2024-08-05 574/week @ 2024-08-12 696/week @ 2024-08-19 427/week @ 2024-08-26 428/week @ 2024-09-02 651/week @ 2024-09-09 585/week @ 2024-09-16 1012/week @ 2024-09-23 975/week @ 2024-09-30 695/week @ 2024-10-07 731/week @ 2024-10-14

3,457 downloads per month
Used in 12 crates (2 directly)

GPL-3.0-or-later…

1MB
20K SLoC

Release

Polkadot SDK stable2409


lib.rs:

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. The parent_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.

Dependencies

~76–115MB
~2M SLoC