Skip to content

Commit

Permalink
Activate EF Cancun tests (#1588)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaziciahmet authored Dec 11, 2024
1 parent 7d6ab43 commit 716f9c4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
22 changes: 18 additions & 4 deletions crates/evm/src/tests/ef_tests/cases/blockchain_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub struct BlockchainTestCase {
}

impl BlockchainTestCase {
#[allow(clippy::too_many_arguments)]
fn execute_transactions(
&self,
evm: &mut Evm<DefaultContext>,
Expand All @@ -61,6 +62,7 @@ impl BlockchainTestCase {
storage: ProverStorage<SnapshotManager>,
root: &[u8; 32],
l2_height: u64,
current_spec: SovSpecId,
) -> (
WorkingSet<ProverStorage<SnapshotManager>>,
ProverStorage<SnapshotManager>,
Expand All @@ -73,7 +75,7 @@ impl BlockchainTestCase {
da_slot_height: 0,
da_slot_txs_commitment: [0u8; 32],
pre_state_root: root.to_vec(),
current_spec: SovSpecId::Genesis,
current_spec,
pub_key: vec![],
deposit_data: vec![],
l1_fee_rate,
Expand Down Expand Up @@ -125,7 +127,7 @@ impl Case for BlockchainTestCase {
// Iterate through test cases, filtering by the network type to exclude specific forks.
self.tests
.values()
.filter(|case| matches!(case.network, ForkSpec::Shanghai))
.filter(|case| case.network <= ForkSpec::Cancun || case.network == ForkSpec::Unknown)
.par_bridge()
.try_for_each(|case| {
let mut evm_config = EvmConfig::default();
Expand Down Expand Up @@ -207,6 +209,11 @@ impl Case for BlockchainTestCase {

let root = case.genesis_block_header.state_root;

let current_spec = if case.network == ForkSpec::Cancun {
SovSpecId::Fork1
} else {
SovSpecId::Genesis
};
// Decode and insert blocks, creating a chain of blocks for the test case.
for block in case.blocks.iter() {
let decoded = SealedBlock::decode(&mut block.rlp.as_ref())?;
Expand All @@ -227,6 +234,7 @@ impl Case for BlockchainTestCase {
storage,
&root,
l2_height,
current_spec,
);

l2_height += 1;
Expand Down Expand Up @@ -314,9 +322,15 @@ pub fn should_skip(path: &Path) -> bool {
| "loopMul.json"
| "CALLBlake2f_MaxRounds.json"
| "shiftCombinations.json"

// In VMTests/vmIOandFlowOperations, returns state root instead of latest state,
// hence we can't test it due to us using different tree than Ethereum
| "jumpToPush.json"
)
// Ignore outdated EOF tests that haven't been updated for Cancun yet.
|| path_contains(path_str, &["EIPTests", "stEOF"])
// We don't support blob transactions
|| path_contains(path_str, &["Cancun", "stEIP4844-blobtransactions"])
|| path_contains(path_str, &["Pyspecs", "cancun", "eip4844_blobs"])
|| path_contains(path_str, &["Pyspecs", "cancun", "eip7516_blobgasfee"])
}

/// `str::contains` but for a path. Takes into account the OS path separator (`/` or `\`).
Expand Down
17 changes: 5 additions & 12 deletions crates/evm/src/tests/ef_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ mod general_state_tests {
general_state_test!(st_sload, stSLoadTest);
general_state_test!(st_zero_calls_revert, stZeroCallsRevert);
general_state_test!(st_zero_calls, stZeroCallsTest);
general_state_test!(stshanghai, Shanghai);
general_state_test!(st_shanghai, Shanghai);
general_state_test!(st_cancun, Cancun);
general_state_test!(st_attack, stAttackTest);
general_state_test!(st_bugs, stBugs);
general_state_test!(st_call_codes, stCallCodes);
Expand Down Expand Up @@ -89,15 +90,7 @@ mod general_state_tests {
general_state_test!(st_wallet, stWalletTest);
general_state_test!(st_zero_knowledge, stZeroKnowledge);
general_state_test!(st_zero_knowledge2, stZeroKnowledge2);

// Failing
// general_state_test!(vm_tests, VMTests);
// general_state_test!(st_bad_opcode, stBadOpcode);
// general_state_test!(st_create2, stCreate2);
// general_state_test!(st_create, stCreateTest);
// general_state_test!(st_quadratic_complexity, stQuadraticComplexityTest);
//general_state_test!(st_recursive_create, stRecursiveCreate);
// general_state_test!(st_stack, stStackTests);
general_state_test!(st_transition, stTransitionTest);
general_state_test!(st_vm, VMTests);
general_state_test!(st_pyspecs, Pyspecs);
}

// TODO: Add ValidBlocks and InvalidBlocks tests

0 comments on commit 716f9c4

Please sign in to comment.