Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve history and note commitment trees forking #2378

Closed
conradoplg opened this issue Jun 23, 2021 · 1 comment
Closed

Improve history and note commitment trees forking #2378

conradoplg opened this issue Jun 23, 2021 · 1 comment
Labels
A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement I-slow Problems with performance or responsiveness NU-3 Heartwood Network Upgrade: Heartwood specific tasks

Comments

@conradoplg
Copy link
Collaborator

conradoplg commented Jun 23, 2021

Motivation

ZIP-221 specifies a history tree (a Merkle Mountain Range) that is committed to in the block header. This history tree must be kept in memory/state and, when a fork happens in the non-finalized state, it must be reversed to the state it had at the tip of the fork.

The history tree was included in #2301 and it handles forks by rebuilding the history tree from the finalized state history tree. However, that can be improved since librustzcash (which we use for the tree) can handle removing nodes from the tree (though it's a bit tricky and that's why we went with the simpler option). That way we can simply remove nodes from the tree until we reach the state at the fork tip.

The same issue applies to note commitment trees.

Specifications

N/A

Designs

N/A

Solution

Use the librustzcash node removal in order to compute the history tree of the fork.

To remove a node from the tree, librustzcash requires "extra" nodes (each node corresponds to a block) which are required in order to carry out the removal. We will need to come up with an approach to load these extra nodes when required.

For note commitment trees, check if the incrementalmerkletree crate supports node removal (it probably does).

Alternatives

Leave it as is, which will decrease performance when forks happen.

Related Work

Must be done after #2301

@conradoplg conradoplg added C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage labels Jun 23, 2021
@teor2345 teor2345 added A-rust Area: Updates to Rust code NU-3 Heartwood Network Upgrade: Heartwood specific tasks P-Medium labels Jun 23, 2021
@conradoplg conradoplg mentioned this issue Jun 25, 2021
3 tasks
@teor2345 teor2345 added P-Low and removed P-Medium labels Jun 28, 2021
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Jun 28, 2021
@conradoplg conradoplg changed the title Improve history tree forking Improve history and note commitment trees forking Jul 22, 2021
@conradoplg
Copy link
Collaborator Author

Performance on forks doesn't seem to be an issue so I'll close this for now.

@conradoplg conradoplg added S-incomplete I-slow Problems with performance or responsiveness labels Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement I-slow Problems with performance or responsiveness NU-3 Heartwood Network Upgrade: Heartwood specific tasks
Projects
None yet
Development

No branches or pull requests

3 participants