Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

MMR: scope storing full subtrees in offchain db #13000

Open
@serban300

Description

@serban300

Derived from: #12864

Now we are saving each MMR node by their position in the MMR. Another option would be to save each subtree by the block that introduced it (this would save multiple nodes at once). For example

For the tree:

  2  
 / \    
1   3

we are now saving the data for each node at the following keys:

1_[genesis_hash]
2_[block_1_hash]
3_[block_1_hash]

The other option would be to save:

1_[genesis_hash] -> the subtree containing node 1 (the subtree added by block 1)
2_[block_1_hash] -> the subtree containing nodes 2 and 3 (the subtree added by block 2)

This could have a couple of advantages:

  • less writes to the DB => more efficient on-chain processing
  • faster time for generating proofs (because of hot cache hits)
  • the mmr client gadget code would get more sipler because:
    • we wouldn't need to handle node indexes and leaf indexes
    • we wouldn't need to handle pallet resets

However, I'm not sure this would be compatible with MMBs. It might sense to look at this optimization after switching to MMBs.

PoC: https://github.com/serban300/substrate/tree/mmr_subtree

Metadata

Metadata

Assignees

No one assigned

    Labels

    I9-optimisationAn enhancement to provide better overall performance in terms of time-to-completion for a task.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions