Skip to content

Tracking PR for projects/binary-trie (PBT)#3207

Draft
kevaundray wants to merge 24 commits into
forks/amsterdamfrom
projects/binary-trie
Draft

Tracking PR for projects/binary-trie (PBT)#3207
kevaundray wants to merge 24 commits into
forks/amsterdamfrom
projects/binary-trie

Conversation

@kevaundray

Copy link
Copy Markdown
Contributor

Description

Related Issues or PRs

N/A.

Checklist

  • Ran fast static checks to avoid CI fails, see Code Standards & Verifying Changes: just static
  • PR title has the form <type>(<area>): <title>, where <type> and <area> come from an appropriate C-<type>, respectively A-<area>, label. The title should match the target squash commit message.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.18750% with 185 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.94%. Comparing base (a2e59a6) to head (fdaf890).

Files with missing lines Patch % Lines
src/ethereum/binary_trie/embedding.py 0.00% 97 Missing ⚠️
src/ethereum/binary_trie/trie.py 0.00% 82 Missing ⚠️
src/ethereum/state_mpt.py 95.29% 2 Missing and 2 partials ⚠️
src/ethereum/forks/spurious_dragon/fork.py 75.00% 1 Missing ⚠️
src/ethereum/forks/tangerine_whistle/fork.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           forks/amsterdam    #3207      +/-   ##
===================================================
- Coverage            93.39%   92.94%   -0.45%     
===================================================
  Files                  624      627       +3     
  Lines                37014    37215     +201     
  Branches              3386     3398      +12     
===================================================
+ Hits                 34568    34590      +22     
- Misses                1672     1851     +179     
  Partials               774      774              
Flag Coverage Δ
unittests 92.94% <42.18%> (-0.45%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

feat(8297): Add key derivation layer
The State class and its helpers moved to ethereum.state_mpt, but two
test files import the module itself rather than names from it, which
the import rewrite missed: test_optimized_state.py aliases it for
state_root calls (caught by mypy in CI) and load_vm_tests.py returns
it as the fallback fork state module (hidden behind an Any return).
@kevaundray

Copy link
Copy Markdown
Contributor Author

Before adding pbt to a fork, seems we need #3218 to be able to use the interface, see #3216 for what it would look like

…rface

Squash-merge of kevaundray:kw/state-interface (PR #3218) so the
binary tree work can build on the new interface without waiting for
the upstream merge into forks/amsterdam:

- PreState.compute_state_root_and_trie_changes becomes
  compute_state_root and returns only the root: the trie-changes
  list was produced empty by the only implementation and discarded
  by every caller.
- The MPT-backed State and its helpers move from ethereum/state.py
  to the new ethereum/state_mpt.py; state.py keeps the
  commitment-agnostic model and protocol.
- compute_state_root gains a code_changes parameter so commitments
  over code contents (not just code hashes) are implementable
  behind the protocol.
@kevaundray

Copy link
Copy Markdown
Contributor Author

4796acc squash merges #3218 into this branch, we can rebase if that gets merged into forks/smaterdam

The evm tools hardcoded the MPT-backed provider: alloc loading built
ethereum.state_mpt.State directly, and t8n applied diffs, serialized
allocs, and backed up state by reaching into MPT trie internals.

Resolve the provider through the fork instead: every fork's fork
module imports its State class, so ForkLoad.state_provider derives
the provider module from it. Alloc loading, diff application,
serialization, and backup/restore all go through that module. The
provider gains the uniform helpers this needs: copy_state,
restore_state, all_accounts, and account_storage.

With this, a fork whose commitment is not the Merkle Patricia Trie
works with the tooling by supplying a provider with the same module
surface as ethereum.state_mpt.
The evm tools hardcoded the MPT-backed provider: alloc loading built
ethereum.state_mpt.State directly, and t8n applied diffs, serialized
allocs, and backed up state by reaching into MPT trie internals.

Resolve the provider through the fork instead: every fork's fork
module imports its State class, so ForkLoad.state_provider derives
the provider module from it. Alloc loading, diff application,
serialization, and backup/restore all go through that module. The
provider gains the uniform helpers this needs: copy_state,
restore_state, all_accounts, and account_storage.

With this, a fork whose commitment is not the Merkle Patricia Trie
works with the tooling by supplying a provider with the same module
surface as ethereum.state_mpt.
…-interface

# Conflicts:
#	src/ethereum_spec_tools/evm_tools/loaders/fork_loader.py
#	src/ethereum_spec_tools/evm_tools/t8n/__init__.py
#	src/ethereum_spec_tools/evm_tools/t8n/t8n_types.py
# Conflicts:
#	src/ethereum/forks/amsterdam/fork.py
#	src/ethereum/forks/arrow_glacier/fork.py
#	src/ethereum/forks/berlin/fork.py
#	src/ethereum/forks/bpo1/fork.py
#	src/ethereum/forks/bpo2/fork.py
#	src/ethereum/forks/bpo3/fork.py
#	src/ethereum/forks/bpo4/fork.py
#	src/ethereum/forks/bpo5/fork.py
#	src/ethereum/forks/byzantium/fork.py
#	src/ethereum/forks/cancun/fork.py
#	src/ethereum/forks/constantinople/fork.py
#	src/ethereum/forks/dao_fork/fork.py
#	src/ethereum/forks/frontier/fork.py
#	src/ethereum/forks/gray_glacier/fork.py
#	src/ethereum/forks/homestead/fork.py
#	src/ethereum/forks/istanbul/fork.py
#	src/ethereum/forks/london/fork.py
#	src/ethereum/forks/muir_glacier/fork.py
#	src/ethereum/forks/osaka/fork.py
#	src/ethereum/forks/paris/fork.py
#	src/ethereum/forks/prague/fork.py
#	src/ethereum/forks/shanghai/fork.py
#	src/ethereum/forks/spurious_dragon/fork.py
#	src/ethereum/forks/tangerine_whistle/fork.py
#	src/ethereum/state.py
#	src/ethereum/state_mpt.py
#	src/ethereum_spec_tools/evm_tools/t8n/__init__.py
#	src/ethereum_spec_tools/evm_tools/t8n/t8n_types.py
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.

1 participant