reth icon indicating copy to clipboard operation
reth copied to clipboard

feat(trie): Implement skeleton of proof_v2

Open mediocregopher opened this issue 1 week ago • 0 comments
trafficstars

Towards #19512

This implements the skeleton of the new proof calculator rewrite. No actual logic is implemented yet, this only sets up most of the new types which will be involved.

  • RevealedSparseNode is renamed to SparseTrieNode and moved to reth-trie-common. This is the type which will be returned from the calculator for proofs (letting avoid a translation step during sparse trie revealing). The rename helps to denote that this type is no longer just for revealing.

  • ValueEncoder is defined. This is the primary mechanism by which we deal with the differences between storage and account tries, and which allows us to inject behavior in the future like dispatching storage root calculation to other threads for account proofs.

    • ValueEncoder::Value - Either Account or U256 for account and storage tries, respectively. This is the value returned from the DB.

    • ValueEncoder::Fut - A future-like type which will be called-upon later to encode the Value into its RLP form. For storage tries (U256) this is trivial. For account tries we need some mechanism to obtain the storage root of the account. A default SyncAccountValueEncoder is provided which synchronously computes the storage root when the future is invoked, but in later PRs we can to proof workers, add in caching, etc...

  • ProofCalculator is where the actual logic of calculating proofs is going to live. For the moment it is un-implemented.

mediocregopher avatar Nov 12 '25 17:11 mediocregopher