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

Interface and logic to support snap sync for Paprika #349

Merged
merged 68 commits into from
Jan 3, 2025
Merged

Conversation

damian-orzechowski
Copy link
Contributor

@damian-orzechowski damian-orzechowski commented Jun 9, 2024

Implement changes to the IRawState interface required to fully support sync process for Paprika:

  • Add methods to set boundary proof nodes directly as merkle data. Proof nodes to be added together with corresponding RlpMemo which contains hashes of child nodes outside of currently processed data ranges (account or storage). Merkle data created for snap sync is used only to ensure correct root hash calculation and is not persisted on Commit (new EntryType - Proof.
    • CreateMerkleBranch
  • Support hash calculation request for arbitrary path (both for state and storage) for healing (fast sync) purposes
  • Support to create directly merkle data for healing (fast sync)
    • CreateMerkleExtension, CreateMerkleLeaf

- handling of boundary node (only hash stored)
- checking root hash without commit
- encoding keccak hash as NibblePath for merkle Leaf type
- IReadOnlyWorldState implementation for BlockState
- handling of boundary node (only hash stored)
- checking root hash without commit
- encoding keccak hash as NibblePath for merkle Leaf type
- IReadOnlyWorldState implementation for BlockState
@damian-orzechowski damian-orzechowski self-assigned this Jun 9, 2024
@damian-orzechowski damian-orzechowski marked this pull request as ready for review November 28, 2024 10:40
@Scooletz Scooletz self-requested a review December 20, 2024 15:19
Copy link
Contributor

@Scooletz Scooletz left a comment

Choose a reason for hiding this comment

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

Generally, I'd move more parts into Merkle behavior. The usual take with the Blockchain component that I try to apply is make it as Merkle agnostic as possible. If more was moved to the Merkle, it could limit the cast downs as well.

src/Paprika/Chain/Blockchain.cs Outdated Show resolved Hide resolved
src/Paprika/Chain/Blockchain.cs Outdated Show resolved Hide resolved
src/Paprika/Chain/Blockchain.cs Outdated Show resolved Hide resolved
src/Paprika/Chain/Blockchain.cs Outdated Show resolved Hide resolved
src/Paprika/Chain/Blockchain.cs Outdated Show resolved Hide resolved
private class SyncBlockState : BlockState
{
private readonly PooledSpanDictionary _proofKeys;
private readonly HashSet<ulong> _proofHashSet;
Copy link
Contributor

Choose a reason for hiding this comment

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

How big is it? Have you considered BitFilter here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should not be big - max 2 x height of the synced trie.

src/Paprika/Merkle/ComputeMerkleBehavior.cs Outdated Show resolved Hide resolved

public void RecalculateStorageTries(ICommitWithStats commit, CacheBudget budget)
{
using (_storageProcessing.Measure())
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this measurement useful here? It's used for regular node running so that we can attach with dotnet counters I'd remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method was removed, but removed I removed gathering these metrics for RecalculateStorageTrie. This can be useful for measuring sync performance.

src/Paprika/Merkle/ComputeMerkleBehavior.cs Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jan 3, 2025

Code Coverage

Package Line Rate Branch Rate Health
Paprika 80% 76%
Summary 80% (5049 / 6289) 76% (1750 / 2298)

Minimum allowed line rate is 75%

@Scooletz Scooletz merged commit 61c326a into main Jan 3, 2025
5 checks passed
@Scooletz Scooletz deleted the snap-sync branch January 3, 2025 13:50
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