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

Blockchain backend fetch MMR nodes #1918

Merged
merged 1 commit into from
May 28, 2020

Conversation

neonknight64
Copy link
Contributor

Description

Added fetch_mmr_nodes and fetch_mmr_node_count to the blockchain backends to enable downloading of the Kernel, UTXO and Range Proof MMRs when syncing using Pruned mode.

Motivation and Context

The MMR state should be retrievable to allow sharing between nodes that are running in pruned mode.

How Has This Been Tested?

  • Added chain backend tests for testing the lmdb and memory backend implementations of the fetch_mmr_nodes and fetch_mmr_node_count functions for the Kernel, UTXO and Range Proof MMRs.
  • Added a pruned mode test for downloading of blocks when the node is running in pruned mode.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Feature refactor (No new feature or functional changes, but performance or technical debt improvements)
  • New Tests
  • Documentation

Checklist:

  • I'm merging against the development branch.
  • I ran cargo-fmt --all before pushing.
  • I have squashed my commits into a single commit.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

…ckends to enable downloading of the Kernel, UTXO and Range Proof MMRs.

- Added chain backend tests for testing the lmdb and memory backend implementations of the fetch_mmr_nodes and fetch_mmr_node_count functions for the Kernel, UTXO and Range Proof MMRs.
- Added a pruned mode test for downloading of blocks when the node is running in pruned mode.
{
node_count += cp.nodes_added().len() as u32;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remote nodes require the ability to determine the total number of added leaf nodes at a specific chain height, adding of UTXOs requires the same ability but at the tip of the chain. Currently, this calculation is expensive as all the checkpoints need to be traversed. A possible solution is to store the total accumulated added node count with each checkpoint to allow efficient retrieval. It could be implemented as a separate db for each checkpoint set, but then special care needs to be taken to ensure it is kept consistent during reorgs and rewinds. Another possibility is to make use of the existing checkpoint dbs, this will ensure no reorg and rewind logic need to be added but will break backwards compatibility.

Copy link
Member

@sdbondi sdbondi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sdbondi sdbondi merged commit 060ab70 into development May 28, 2020
@sdbondi sdbondi deleted the yuko-pruned_mode_inbound_handlers branch May 28, 2020 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants