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

MMR: scope storing full subtrees in offchain db #13000

Open
serban300 opened this issue Dec 22, 2022 · 1 comment
Open

MMR: scope storing full subtrees in offchain db #13000

serban300 opened this issue Dec 22, 2022 · 1 comment
Labels
I9-optimisation An enhancement to provide better overall performance in terms of time-to-completion for a task.

Comments

@serban300
Copy link
Contributor

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

@serban300 serban300 added the I9-optimisation An enhancement to provide better overall performance in terms of time-to-completion for a task. label Dec 22, 2022
@serban300 serban300 self-assigned this Dec 22, 2022
@serban300 serban300 added this to BEEFY Dec 22, 2022
@serban300 serban300 moved this to Some Day Maybe in BEEFY Dec 22, 2022
@serban300 serban300 removed their assignment Dec 22, 2022
@serban300 serban300 changed the title MMR: scope storing full subtrees MMR: scope storing full subtrees in offchain db Dec 22, 2022
@EmmanuellNorbertTulbure

Is this still relevant? @serban300 @acatangiu ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I9-optimisation An enhancement to provide better overall performance in terms of time-to-completion for a task.
Projects
No open projects
Status: Some Day Maybe
Development

No branches or pull requests

2 participants