28 major breaking releases

31.0.0 Apr 8, 2024
30.0.0 Mar 18, 2024
29.0.0 Feb 26, 2024
28.0.0 Feb 13, 2024
3.0.0 Feb 10, 2021

#963 in Magic Beans

Download history 45/week @ 2023-12-22 543/week @ 2023-12-29 679/week @ 2024-01-05 369/week @ 2024-01-12 362/week @ 2024-01-19 383/week @ 2024-01-26 348/week @ 2024-02-02 681/week @ 2024-02-09 1106/week @ 2024-02-16 1164/week @ 2024-02-23 631/week @ 2024-03-01 360/week @ 2024-03-08 745/week @ 2024-03-15 804/week @ 2024-03-22 890/week @ 2024-03-29 606/week @ 2024-04-05

3,105 downloads per month
Used in 12 crates (4 directly)

Apache-2.0

2.5MB
44K SLoC

Merkle Mountain Range

Overview

Details on Merkle Mountain Ranges (MMRs) can be found here: https://github.com/mimblewimble/grin/blob/master/doc/mmr.md

The MMR pallet constructs an MMR from leaf data obtained on every block from LeafDataProvider. MMR nodes are stored both in:

  • on-chain storage - hashes only; not full leaf content;
  • off-chain storage - via Indexing API we push full leaf content (and all internal nodes as well) to the Off-chain DB, so that the data is available for Off-chain workers. Hashing used for MMR is configurable independently from the rest of the runtime (i.e. not using frame_system::Hashing) so something compatible with external chains can be used (like Keccak256 for Ethereum compatibility).

Depending on the usage context (off-chain vs on-chain) the pallet is able to:

  • verify MMR leaf proofs (on-chain)
  • generate leaf proofs (off-chain)

See primitives::Compact documentation for how you can optimize proof size for leafs that are composed from multiple elements.

What for?

Primary use case for this pallet is to generate MMR root hashes, that can latter on be used by BEEFY protocol (see https://github.com/paritytech/grandpa-bridge-gadget). MMR root hashes along with BEEFY will make it possible to build Super Light Clients (SLC) of Substrate-based chains. The SLC will be able to follow finality and can be shown proofs of more details that happened on the source chain. In that case the chain which contains the pallet generates the Root Hashes and Proofs, which are then presented to another chain acting as a light client which can verify them.

Secondary use case is to archive historical data, but still be able to retrieve them on-demand if needed. For instance if parent block hashes are stored in the MMR it's possible at any point in time to provide an MMR proof about some past block hash, while this data can be safely pruned from on-chain storage.

NOTE This pallet is experimental and not proven to work in production.

Dependencies

~17–31MB
~512K SLoC