Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
85cb3ff
run tests with sp1
JereSalo Aug 21, 2025
28ab1ea
make progress organizing tests
JereSalo Aug 22, 2025
36494f3
make test runner simpler
JereSalo Aug 22, 2025
0875f3e
add test sp1 make target
JereSalo Aug 22, 2025
3f99230
organize tests a little bit more
JereSalo Aug 22, 2025
356228f
Merge branch 'main' into blockhain_tests_sp1
JereSalo Aug 22, 2025
fa178b4
clippy lint
JereSalo Aug 22, 2025
fb3e3a9
fix problems runner
JereSalo Aug 22, 2025
240a216
improve todo comments
JereSalo Aug 22, 2025
6745f04
Update cmd/ef_tests/blockchain/test_runner.rs
JereSalo Aug 25, 2025
d342ee5
tidy a little bit
JereSalo Aug 25, 2025
e9877f0
merge
JereSalo Aug 25, 2025
78915d5
Delete cmd/ef_tests/state_v2/success_report.txt
JereSalo Aug 25, 2025
3c51655
first iteration for running tests (doesnt work)
JereSalo Aug 25, 2025
70d5ca7
make some progress in transaction signing
JereSalo Aug 25, 2025
0614b0e
change gas price for the vm not to fail validation
JereSalo Aug 25, 2025
961167f
comment withdrawals stuff
JereSalo Aug 26, 2025
79c5d04
Merge branch 'main' into blockhain_tests_sp1
JereSalo Aug 26, 2025
9836c16
merge main
JereSalo Aug 26, 2025
beda446
merge main
JereSalo Aug 26, 2025
fbdbc98
differentiate transactions correctly in tests
JereSalo Aug 26, 2025
b3b590d
fix recovery id on legacy txs
JereSalo Aug 26, 2025
e63157b
try use test.env fields instead of LEVM Environment
JereSalo Aug 26, 2025
c4ececd
set headers properly
JereSalo Aug 26, 2025
5209d88
fix problems with headers and gas fees (at least some of them)
JereSalo Aug 26, 2025
5614edd
fix some other tests
JereSalo Aug 26, 2025
76e6007
skip some tests for high gas price
JereSalo Aug 26, 2025
5e7b030
fix blob gas problem on type 3 transactions
JereSalo Aug 26, 2025
f97ffb3
fix for mistake
JereSalo Aug 26, 2025
65d6465
remove system contract empty check
JereSalo Aug 26, 2025
0b337dd
remove dead code and improve comment
JereSalo Aug 26, 2025
2f28404
make revm a feature instead of levm
JereSalo Aug 26, 2025
331d1e9
merge main
JereSalo Aug 26, 2025
bb2e358
Merge branch 'blockhain_tests_sp1' into state_tests_sp1
JereSalo Aug 27, 2025
9e9768e
remove a comment and fix some lints
JereSalo Aug 27, 2025
9a1ff3d
skip system contract deployment tests
JereSalo Aug 27, 2025
6e5bb30
fix lint
JereSalo Aug 27, 2025
801d6eb
tidy more the code
JereSalo Aug 27, 2025
cff62d4
allow clippy all
JereSalo Aug 27, 2025
b57df19
merge main
JereSalo Aug 27, 2025
2611f72
remove comment
JereSalo Aug 27, 2025
147f279
run cargo fmt
JereSalo Aug 27, 2025
ac735a5
rename single_block_run to run_test
JereSalo Aug 27, 2025
3cf7a72
prevrandao from test.env
JereSalo Aug 27, 2025
89a8679
run tests that fail too
JereSalo Aug 27, 2025
3d9501f
improve code
JereSalo Aug 27, 2025
1fe6bec
change some lines
JereSalo Aug 27, 2025
ee312e7
return custom error instead
JereSalo Aug 27, 2025
986fa17
remove print
JereSalo Aug 27, 2025
2af3cfb
skip other tests
JereSalo Aug 27, 2025
772d890
Merge branch 'main' into state_tests_sp1
JereSalo Aug 29, 2025
32c2dd6
Update tooling/ef_tests/state_v2/src/modules/types.rs
JereSalo Aug 29, 2025
3135b11
Update tooling/ef_tests/state_v2/src/modules/types.rs
JereSalo Aug 29, 2025
b835ee2
Update tooling/ef_tests/state_v2/src/modules/block_runner.rs
JereSalo Aug 29, 2025
33be3fd
Revert "Update tooling/ef_tests/state_v2/src/modules/types.rs"
JereSalo Sep 1, 2025
a5ccf82
Revert "Update tooling/ef_tests/state_v2/src/modules/types.rs"
JereSalo Sep 1, 2025
2c39bcb
Merge branch 'main' into state_tests_sp1
JereSalo Sep 1, 2025
0099f0a
add default
JereSalo Sep 1, 2025
2ca16b4
Merge branch 'main' into state_tests_sp1
JereSalo Sep 1, 2025
0a869c3
fix lint
JereSalo Sep 2, 2025
d20269f
Merge branch 'main' into state_tests_sp1
JereSalo Sep 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ fn verify_blob_gas_usage(block: &Block, config: &ChainConfig) -> Result<(), Chai
}

/// Calculates the blob gas required by a transaction
fn get_total_blob_gas(tx: &EIP4844Transaction) -> u32 {
pub fn get_total_blob_gas(tx: &EIP4844Transaction) -> u32 {
GAS_PER_BLOB * tx.blob_versioned_hashes.len() as u32
}

Expand Down
3 changes: 2 additions & 1 deletion crates/l2/networking/rpc/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ impl Signable for LegacyTransaction {
async fn sign_inplace(&mut self, signer: &Signer) -> Result<(), SignerError> {
let signature = signer.sign(self.encode_payload_to_vec().into()).await?;

self.v = U256::from(signature[64]);
let recovery_id = U256::from(signature[64]);
self.v = recovery_id + 27;
(self.r, self.s, _) = parse_signature(signature);

Ok(())
Expand Down
20 changes: 0 additions & 20 deletions crates/vm/backends/levm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,6 @@ impl LEVM {
vm_type,
)?;

// According to EIP-7002 we need to check if the WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because these contracts do not exist in the state tests, so they will always have empty code in these scenarios and therefore block execution will fail because of this. If I added the contracts to the state it would mean that the root hash would be different than the one precalculated in the test fixture and I don't want that.

In mainnet and testnets this check only adds overhead because the contracts do have code. That's why clients like geth don't have this logic either. Not useful in real-world scenarios.

// has any code after being deployed. If not, the whole block becomes invalid.
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7002.md
let account = db.get_account(*WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS)?;
if !account.has_code() {
return Err(EvmError::SystemContractEmpty(
"WITHDRAWAL_REQUEST_PREDEPLOY".to_string(),
));
}

match report.result {
TxResult::Success => Ok(report),
// EIP-7002 specifies that a failed system call invalidates the entire block.
Expand Down Expand Up @@ -294,16 +284,6 @@ impl LEVM {
vm_type,
)?;

// According to EIP-7251 we need to check if the CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS
// has any code after being deployed. If not, the whole block becomes invalid.
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7251.md
let acc = db.get_account(*CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS)?;
if !acc.has_code() {
return Err(EvmError::SystemContractEmpty(
"CONSOLIDATION_REQUEST_PREDEPLOY".to_string(),
));
}

match report.result {
TxResult::Success => Ok(report),
// EIP-7251 specifies that a failed system call invalidates the entire block.
Expand Down
36 changes: 2 additions & 34 deletions crates/vm/backends/revm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ use ethrex_levm::constants::{SYS_CALL_GAS_LIMIT, TX_BASE_COST};
use revm::db::AccountStatus;
use revm::db::states::bundle_state::BundleRetention;

use revm::{Database, DatabaseCommit};
use revm::{
Evm,
DatabaseCommit, Evm,
primitives::{B256, BlobExcessGasAndPrice, BlockEnv, TxEnv},
};
use revm_inspectors::access_list::AccessListInspector;
Expand Down Expand Up @@ -157,16 +156,7 @@ impl REVM {
)?;
Ok(())
}
fn system_contract_account_info(
addr: Address,
state: &mut EvmState,
) -> Result<revm_primitives::AccountInfo, EvmError> {
let revm_addr = RevmAddress::from_slice(addr.as_bytes());
let account_info = state.inner.basic(revm_addr)?.ok_or(EvmError::DB(
"System contract address was not found after deployment".to_string(),
))?;
Ok(account_info)
}

pub(crate) fn read_withdrawal_requests(
block_header: &BlockHeader,
state: &mut EvmState,
Expand All @@ -179,17 +169,6 @@ impl REVM {
*SYSTEM_ADDRESS,
)?;

// According to EIP-7002 we need to check if the WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS
// has any code after being deployed. If not, the whole block becomes invalid.
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7002.md
let account_info =
Self::system_contract_account_info(*WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS, state)?;
if account_info.is_empty_code_hash() {
return Err(EvmError::SystemContractEmpty(
"WITHDRAWAL_REQUEST_PREDEPLOY".to_string(),
));
}

match tx_result {
ExecutionResult::Success {
gas_used: _,
Expand Down Expand Up @@ -224,17 +203,6 @@ impl REVM {
*SYSTEM_ADDRESS,
)?;

// According to EIP-7251 we need to check if the CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS
// has any code after being deployed. If not, the whole block becomes invalid.
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7251.md
let account_info =
Self::system_contract_account_info(*CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS, state)?;
if account_info.is_empty_code_hash() {
return Err(EvmError::SystemContractEmpty(
"CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS".to_string(),
));
}

match tx_result {
ExecutionResult::Success {
gas_used: _,
Expand Down
2 changes: 0 additions & 2 deletions crates/vm/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ pub enum EvmError {
Custom(String),
#[error("Invalid deposit request layout")]
InvalidDepositRequest,
#[error("System contract: {0} has no code after deployment")]
SystemContractEmpty(String),
#[error("System call failed: {0}")]
SystemContractCallFailed(String),
}
Expand Down
5 changes: 0 additions & 5 deletions tooling/ef_tests/blockchain/deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ where
"BlockException.INVALID_REQUESTS" => BlockChainExpectedException::BlockException(
BlockExpectedException::InvalidRequest,
),
"BlockException.SYSTEM_CONTRACT_EMPTY" => {
BlockChainExpectedException::BlockException(
BlockExpectedException::SystemContractEmpty,
)
}
"BlockException.SYSTEM_CONTRACT_CALL_FAILED" => {
BlockChainExpectedException::BlockException(
BlockExpectedException::SystemContractCallFailed,
Expand Down
5 changes: 0 additions & 5 deletions tooling/ef_tests/blockchain/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,6 @@ fn exception_is_expected(
) | (
BlockChainExpectedException::BlockException(BlockExpectedException::InvalidRequest),
ChainError::InvalidBlock(InvalidBlockError::RequestsHashMismatch)
) | (
BlockChainExpectedException::BlockException(
BlockExpectedException::SystemContractEmpty
),
ChainError::EvmError(EvmError::SystemContractEmpty(_))
) | (
BlockChainExpectedException::BlockException(
BlockExpectedException::SystemContractCallFailed
Expand Down
6 changes: 4 additions & 2 deletions tooling/ef_tests/blockchain/tests/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::path::Path;

const TEST_FOLDER: &str = "vectors/";

const SKIPPED_TESTS: &[&str] = &["system_contract_deployment"];

// If neither `sp1` nor `stateless` is enabled: run with whichever engine
// the features imply (LEVM if `levm` is on; otherwise REVM).
#[cfg(not(any(feature = "sp1", feature = "stateless")))]
Expand All @@ -14,7 +16,7 @@ fn blockchain_runner(path: &Path) -> datatest_stable::Result<()> {
EvmEngine::LEVM
};

parse_and_execute(path, engine, None, None)
parse_and_execute(path, engine, Some(SKIPPED_TESTS), None)
}

// If `sp1` or `stateless` is enabled: always use LEVM with the appropriate backend.
Expand All @@ -25,7 +27,7 @@ fn blockchain_runner(path: &Path) -> datatest_stable::Result<()> {
#[cfg(feature = "sp1")]
let backend = Some(ethrex_prover_lib::backends::Backend::SP1);

parse_and_execute(path, EvmEngine::LEVM, None, backend)
parse_and_execute(path, EvmEngine::LEVM, Some(SKIPPED_TESTS), backend)
}

datatest_stable::harness!(blockchain_runner, TEST_FOLDER, r".*");
Expand Down
1 change: 0 additions & 1 deletion tooling/ef_tests/blockchain/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ pub enum BlockExpectedException {
IncorrectExcessBlobGas,
IncorrectBlockFormat,
InvalidRequest,
SystemContractEmpty,
SystemContractCallFailed,
Other, //TODO: Implement exceptions
}
3 changes: 3 additions & 0 deletions tooling/ef_tests/state_v2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ ethrex-storage.workspace = true
ethrex-rlp.workspace = true
ethrex-vm.workspace = true
ethrex-levm.workspace = true
ethrex-l2-rpc.workspace = true

secp256k1.workspace = true
serde.workspace = true
serde_json.workspace = true
bytes.workspace = true
Expand All @@ -30,3 +32,4 @@ hex = "0.4.3"
default = ["c-kzg", "blst"]
c-kzg = ["ethrex-vm/c-kzg", "ethrex-levm/c-kzg", "ethrex-common/c-kzg"]
blst = ["ethrex-vm/blst"]
block = []
10 changes: 8 additions & 2 deletions tooling/ef_tests/state_v2/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#![allow(clippy::all)]

use clap::Parser;
use ef_tests_statev2::modules::{
error::RunnerError,
parser::{RunnerOptions, parse_tests},
runner::run_tests,
};

#[tokio::main]
Expand All @@ -14,7 +15,12 @@ pub async fn main() -> Result<(), RunnerError> {
let tests = parse_tests(&mut runner_options)?;

println!("\nFinished parsing. Executing tests...");
run_tests(tests).await?;

if cfg!(feature = "block") {
ef_tests_statev2::modules::block_runner::run_tests(tests.clone()).await?;
} else {
ef_tests_statev2::modules::runner::run_tests(tests).await?;
}
println!(
"\nTests finished running.
Find successful tests (if any) report at: './success_report.txt'.
Expand Down
Loading
Loading