Skip to content

feat(l2): blockchain tests stateless execution #3076

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

Open
wants to merge 55 commits into
base: feat/debug_executionWitness_3
Choose a base branch
from

Conversation

LeanSerra
Copy link
Contributor

@LeanSerra LeanSerra commented Jun 6, 2025

Motivation

We want to run the ef state tests with our prover with stateless execution

Description

  • Add feature flag stateless for cmd/ef_tests/blockchain
  • With stateless enabled
    • after running the tests statefully once, call generate_witness_for_blocks then use this witness for stateless execution
    • in case the test should fail debug_executionWitness returns an error we execute with an empty ExecutionWitness

Fixes:

  • When the trie is empty return Ok(None) for Trie::root_node
  • Add validate_receipts and validate_requests_hash to stateless execution
  • Get accounts in block.body.withdrawals when generating the witness

How to test

cd cmd/ef_tests/blockchain
make test-stateless

LeanSerra added 30 commits June 3, 2025 13:09
@LeanSerra LeanSerra self-assigned this Jun 6, 2025
@LeanSerra LeanSerra added the prover L2 prover label Jun 6, 2025
Copy link

github-actions bot commented Jun 6, 2025

Lines of code report

Total lines added: 63
Total lines removed: 0
Total lines changed: 63

Detailed view
+---------------------------------------------------------+-------+------+
| File                                                    | Lines | Diff |
+---------------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/blockchain/test_runner.rs           | 210   | +43  |
+---------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/blockchain.rs                  | 626   | +7   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/common/trie/trie.rs                       | 884   | +3   |
+---------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/zkvm/interface/src/execution.rs | 204   | +10  |
+---------------------------------------------------------+-------+------+

Copy link

github-actions bot commented Jun 6, 2025

Benchmark for c7431d1

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 36.6±0.98ms 36.0±0.68ms -1.64%
Trie/cita-trie insert 1k 3.7±0.04ms 3.7±0.13ms 0.00%
Trie/ethrex-trie insert 10k 57.8±0.78ms 57.6±0.94ms -0.35%
Trie/ethrex-trie insert 1k 6.7±0.01ms 6.6±0.05ms -1.49%

@LeanSerra LeanSerra changed the title Feat(l2): blockchain tests stateless execution feat(l2): blockchain tests stateless execution Jun 6, 2025
Copy link

github-actions bot commented Jun 6, 2025

Benchmark for 1f369e1

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 37.1±4.97ms 40.1±4.81ms +8.09%
Trie/cita-trie insert 1k 3.7±0.05ms 3.7±0.06ms 0.00%
Trie/ethrex-trie insert 10k 72.3±5.28ms 72.5±4.79ms +0.28%
Trie/ethrex-trie insert 1k 6.6±0.13ms 6.7±0.31ms +1.52%

Copy link

github-actions bot commented Jun 6, 2025

Benchmark for ed360e9

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 36.9±0.55ms 35.9±1.02ms -2.71%
Trie/cita-trie insert 1k 3.7±0.04ms 3.6±0.04ms -2.70%
Trie/ethrex-trie insert 10k 57.5±0.84ms 57.1±0.84ms -0.70%
Trie/ethrex-trie insert 1k 6.6±0.03ms 6.5±0.02ms -1.52%

Base automatically changed from feat/debug_executionWitness_2 to feat/debug_executionWitness_3 June 6, 2025 22:18
Copy link

github-actions bot commented Jun 9, 2025

Benchmark for 086f8cb

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 35.6±0.52ms 35.3±0.54ms -0.84%
Trie/cita-trie insert 1k 3.7±0.04ms 3.7±0.18ms 0.00%
Trie/ethrex-trie insert 10k 56.9±0.53ms 57.2±0.64ms +0.53%
Trie/ethrex-trie insert 1k 6.6±0.05ms 6.6±0.04ms 0.00%

Copy link

github-actions bot commented Jun 9, 2025

Benchmark for 27dbea6

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 35.5±0.47ms 36.1±0.64ms +1.69%
Trie/cita-trie insert 1k 3.8±0.05ms 3.7±0.18ms -2.63%
Trie/ethrex-trie insert 10k 57.7±0.41ms 57.3±0.80ms -0.69%
Trie/ethrex-trie insert 1k 6.6±0.03ms 6.6±0.04ms 0.00%

@LeanSerra LeanSerra marked this pull request as ready for review June 9, 2025 13:47
@LeanSerra LeanSerra requested a review from a team as a code owner June 9, 2025 13:47
Copy link

github-actions bot commented Jun 9, 2025

Benchmark for d11c7e9

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 36.4±1.88ms 36.0±1.32ms -1.10%
Trie/cita-trie insert 1k 3.7±0.05ms 3.9±0.22ms +5.41%
Trie/ethrex-trie insert 10k 63.5±0.79ms 63.0±1.00ms -0.79%
Trie/ethrex-trie insert 1k 6.8±0.09ms 6.7±0.04ms -1.47%

Copy link
Contributor

@ilitteri ilitteri left a comment

Choose a reason for hiding this comment

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

Left 1 nit.

Comment on lines 396 to 402
pub fn root_node(&self) -> Result<Option<Node>, TrieError> {
self.root.get_node(self.db.as_ref())
if self.root.compute_hash().finalize() == *EMPTY_TRIE_HASH {
self.root.get_node(self.db.as_ref())
} else {
Ok(None)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be a !=?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch fixed here

Comment on lines +267 to +269
assert!(test_should_fail, "Expected test to succeed failed with {e}")
} else {
assert!(!test_should_fail, "Expected test to fail succeeded")
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe include the test name in the error message?

Copy link

github-actions bot commented Jun 9, 2025

Benchmark for a499d1f

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 36.4±1.17ms 35.9±0.50ms -1.37%
Trie/cita-trie insert 1k 3.7±0.04ms 3.7±0.04ms 0.00%
Trie/ethrex-trie insert 10k 57.0±1.20ms 57.3±0.61ms +0.53%
Trie/ethrex-trie insert 1k 6.7±0.08ms 6.7±0.22ms 0.00%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prover L2 prover
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants