reth
reth copied to clipboard
Proof Calc Rewrite: Leaf-only Implementation
Describe the feature
Implementation of base scaffolding and types which will be iterated upon in subsequent tasks. To start with we will only use leaf data (HashedAccounts/Storages) to generate proofs, leaving room to later introduce cached branch nodes from Accounts/StoragesTrie tables.
Requirements:
-
Given one or more B256 proof targets, sorted lexicographically, the new proof calculator should return the proof nodes for all proof targets as a Vec, sorted lexicographically by proof node paths.
-
Given zero proof targets, the proof calculator should return just the root.
-
Once a proof is calculated, the calculator should automatically "reset" itself, such that it is ready for another calculation with new proof targets.
-
The calculator should re-use cursors from one calculation to the next.
-
The value type should be a generic. The generic should have a method which returns an FnOnce. The FnOnce should synchronously return the RlpNode for the value.
- For storage proofs this will simply return the RlpNode of the slot value.
- For account proofs the default implementation will synchronously call a storage proof for the account with empty targets.
- This will leave room for injecting parallelization and caching of storage roots in later iterations.
- Calling of the FnOnce should be done as lazily as possible in the algorithm, to maximize the time that storage proof workers have to calculate the root.
-
Implement a proptest which generates random sets of accounts, storage slots, and proof targets. The proptest should compare the results of a proof calculated against a mock cursor factory using the legacy proof implementation vs a proof calculated against that same factory with the new implementation.
Additional context
No response