Skip to content

Conversation

JereSalo
Copy link
Contributor

@JereSalo JereSalo commented Aug 27, 2025

Motivation

  • The final goal is to run state tests with SP1, that's why we need to run them as blocks. This is a first step in that direction.

Description

  • Fix sign_inplace for Legacy Transactions.
  • Remove code that checks that withdrawal request and consolidation request accounts have code. This breaks 2 tests but it's completely worth it I'd say. It is an unrealistic case that doesn't happen in mainnet nor testnets.
  • I had to skip HighGasPrice EFTests because we need to fix the gas price for our Legacy and Type 1 transactions, it should be U256 L1: Use 256 bits for gas price in legacy transaction #3629
  • Now we accurately get the transaction from a test case, without doing the shady stuff we were previously doing.
    • We also sign the transaction with the private key of the sender because it has to be valid.
  • Corrects all kinds of things we were doing wrong because when running the transaction only we didn't have problems. For example, make an accurate Genesis block. (Which wasn't very trivial I'd say)

Closes #4183

@JereSalo JereSalo self-assigned this Aug 27, 2025
@JereSalo JereSalo added levm Lambda EVM implementation L1 Ethereum client labels Aug 27, 2025
@ethrex-project-sync ethrex-project-sync bot moved this to In Progress in ethrex_l1 Aug 27, 2025
Copy link

github-actions bot commented Aug 27, 2025

Lines of code report

Total lines added: 290
Total lines removed: 50
Total lines changed: 340

Detailed view
+--------------------------------------------------------------+-------+------+
| File                                                         | Lines | Diff |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/networking/rpc/signer.rs                    | 213   | +1   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/vm/backends/levm/mod.rs                        | 464   | -12  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/vm/backends/revm/mod.rs                        | 538   | -25  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/vm/errors.rs                                   | 127   | -2   |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/blockchain/deserialize.rs            | 124   | -5   |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/blockchain/test_runner.rs            | 365   | -5   |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/blockchain/types.rs                  | 466   | -1   |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/state_v2/src/main.rs                 | 26    | +4   |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/state_v2/src/modules/block_runner.rs | 142   | +142 |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/state_v2/src/modules/error.rs        | 9     | +1   |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/state_v2/src/modules/mod.rs          | 9     | +1   |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/state_v2/src/modules/parser.rs       | 96    | +2   |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/state_v2/src/modules/runner.rs       | 213   | +65  |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/state_v2/src/modules/types.rs        | 476   | +68  |
+--------------------------------------------------------------+-------+------+
| ethrex/tooling/ef_tests/state_v2/src/modules/utils.rs        | 44    | +6   |
+--------------------------------------------------------------+-------+------+

Base automatically changed from blockhain_tests_sp1 to main August 27, 2025 14:33
@JereSalo JereSalo marked this pull request as ready for review August 27, 2025 19:55
@JereSalo JereSalo requested a review from a team as a code owner August 27, 2025 19:55
@ethrex-project-sync ethrex-project-sync bot moved this from In Progress to In Review in ethrex_l1 Aug 27, 2025
@JereSalo JereSalo requested a review from mpaulucci August 28, 2025 14:07
@Copilot Copilot AI review requested due to automatic review settings August 29, 2025 19:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the ability to run state tests as blocks instead of transactions to prepare for SP1 integration. The changes include transaction type refinements, system contract validation removal, and proper transaction signing.

  • Refactors transaction creation to accurately handle different transaction types (Legacy, EIP2930, EIP1559, EIP4844, EIP7702)
  • Removes system contract empty code validation checks that break state tests
  • Implements proper transaction signing with sender's private key

Reviewed Changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tooling/ef_tests/state_v2/src/modules/utils.rs Updates load_initial_state to accept fork parameter
tooling/ef_tests/state_v2/src/modules/types.rs Adds chain config generation and genesis creation from test and fork
tooling/ef_tests/state_v2/src/modules/runner.rs Refactors transaction creation and adds proper signing
tooling/ef_tests/state_v2/src/modules/block_runner.rs New module for running tests as blocks
tooling/ef_tests/state_v2/src/main.rs Adds feature flag to switch between transaction and block runners
crates/l2/networking/rpc/signer.rs Fixes Legacy transaction signature recovery ID calculation
crates/vm/backends/revm/mod.rs Removes system contract empty code validation
crates/vm/backends/levm/mod.rs Removes system contract empty code validation
crates/blockchain/blockchain.rs Makes get_total_blob_gas function public

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +264 to +265
if *fork < Fork::Paris {
panic!("We don't support pre Merge forks, what are you doing here?");
Copy link
Preview

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The panic message is unprofessional and unhelpful. Replace with a descriptive error message that explains the limitation and suggests alternatives.

Suggested change
if *fork < Fork::Paris {
panic!("We don't support pre Merge forks, what are you doing here?");
panic!("Pre-Merge forks are not supported in this context. Please use a fork at or after Paris (the Merge).");

Copilot uses AI. Check for mistakes.

Comment on lines +314 to +316
base_fee_per_gas: (test.env.current_base_fee.unwrap().as_u64()
* BASE_FEE_MAX_CHANGE_DENOMINATOR as u64)
.checked_div(7), // This was VERY carefully calculated so that the header passes validations in calculate_base_fee_per_gas
Copy link
Preview

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The comment mentions "VERY carefully calculated" but doesn't explain the calculation rationale. Replace with a clear explanation of why this specific formula is needed for header validation.

Suggested change
base_fee_per_gas: (test.env.current_base_fee.unwrap().as_u64()
* BASE_FEE_MAX_CHANGE_DENOMINATOR as u64)
.checked_div(7), // This was VERY carefully calculated so that the header passes validations in calculate_base_fee_per_gas
.checked_div(7), // The base fee per gas in the genesis block must be set so that, after applying the base fee adjustment logic (as defined in EIP-1559 and implemented in `calculate_base_fee_per_gas`), the resulting base fee matches the expected value for the first block. The division by 7 is chosen to reverse the protocol's adjustment formula, ensuring the header passes validation according to the Ethereum specification.

Copilot uses AI. Check for mistakes.

gas: test_case.gas,
to: match to {
TxKind::Call(to) => to,
TxKind::Create => return Err(RunnerError::EIP7702ShouldNotBeCreateType), //TODO: See what to do with this. Maybe we want to get rid of the error and skip the test.
Copy link
Preview

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

This TODO comment indicates unresolved design decisions. Either implement the proper handling or create a tracking issue and reference it in the comment.

Suggested change
TxKind::Create => return Err(RunnerError::EIP7702ShouldNotBeCreateType), //TODO: See what to do with this. Maybe we want to get rid of the error and skip the test.
TxKind::Create => return Err(RunnerError::EIP7702ShouldNotBeCreateType), // TODO: See https://github.com/your-org/your-repo/issues/1234 for discussion on how to handle this case (skip test or error).

Copilot uses AI. Check for mistakes.

Comment on lines +207 to +208
} else if !test_case.access_list.is_empty() {
// TODO: This will work, ideally Vec<something> should be Option<Vec<something>> so that we can tell if the field exists or not...
Copy link
Preview

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

This TODO comment indicates a design limitation in the API. The current logic may incorrectly classify transactions with empty access lists. Consider implementing proper Optional handling or create a tracking issue.

Copilot uses AI. Check for mistakes.

receipts_root: compute_receipts_root(&receipts),
logs_bloom: Default::default(),
difficulty: U256::zero(),
number: 1, // I think this is correct
Copy link
Preview

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The comment "I think this is correct" indicates uncertainty. Either verify this is the correct block number or document why this value is appropriate for state tests.

Suggested change
number: 1, // I think this is correct
number: 1, // In Ethereum state tests, the block being constructed is always the first block after genesis, which has block number 1.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L1 Ethereum client levm Lambda EVM implementation
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

State_v2: Run EFTests State tests as blocks
1 participant