From 6ed183120afbbb08a58503418331812fe0dd3518 Mon Sep 17 00:00:00 2001
From: Mathieu <60658558+enitrat@users.noreply.github.com>
Date: Fri, 22 Mar 2024 15:45:45 +0100
Subject: [PATCH] feat: initial support dencun (#677)
* feat(wip): initial support dencun
* feat: add option to skip an entire directory
* feat: ignore BEACON_ROOT address in post_state
* feat: add fallback mechanism if secretKey is not found
* adapt blockchain-tests-skip.yml
* fix: fmt
* feat: support multi-tx blocks
* refactor: check case name end for fork name
* comment on multi-tx blocks'
* fix: add specific fork-filter case for Pyspec tests
* move secret_key fallback in secret_key()
* feat: base filter on formatted test identifier
* address review
---
Cargo.lock | 1 +
Makefile | 2 +-
blockchain-tests-skip.yml | 104 +++++++++---------
crates/build-utils/Cargo.toml | 1 +
crates/build-utils/src/constants.rs | 33 +++++-
crates/build-utils/src/content_reader.rs | 74 +++++++++++--
crates/build-utils/src/converter.rs | 62 ++++++++---
crates/build-utils/src/filter.rs | 36 +++++-
.../ef-testing/src/evm_sequencer/constants.rs | 10 +-
crates/ef-testing/src/models/case.rs | 52 +++++----
crates/ef-testing/src/models/result.rs | 8 ++
scripts/generate_skip_file.py | 60 +++++-----
12 files changed, 317 insertions(+), 126 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 051a1911..2ac5c176 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -951,6 +951,7 @@ dependencies = [
"lazy_static",
"rayon",
"regex",
+ "reth-primitives",
"serde",
"serde_json",
"serde_yaml",
diff --git a/Makefile b/Makefile
index 8d8a0b76..098f337b 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ ifneq ("$(wildcard .env)","")
endif
# The release tag of https://github.com/ethereum/tests to use for EF tests
-EF_TESTS_TAG := v12.4
+EF_TESTS_TAG := v13.2
EF_TESTS_URL := https://github.com/ethereum/tests/archive/refs/tags/$(EF_TESTS_TAG).tar.gz
EF_TESTS_DIR := ./crates/ef-testing/ethereum-tests
diff --git a/blockchain-tests-skip.yml b/blockchain-tests-skip.yml
index 6832b52d..4cedddf6 100644
--- a/blockchain-tests-skip.yml
+++ b/blockchain-tests-skip.yml
@@ -2,62 +2,66 @@
# The first level corresponds to the directory, the second to the list of file names regex to ignore.
# In the ef-tests repo, we skip all tests but the vmArithmeticTest.
+directories:
+ - Pyspecs
+ - Cancun
+
filename:
None:
- None
testname:
vmArithmeticTest:
- - addmod_d10g0v0_Shanghai
- - addmod_d11g0v0_Shanghai
- - addmod_d8g0v0_Shanghai
- - addmod_d9g0v0_Shanghai
- - divByZero_d63g0v0_Shanghai
- - divByZero_d64g0v0_Shanghai
- - divByZero_d65g0v0_Shanghai
- - divByZero_d66g0v0_Shanghai
- - divByZero_d67g0v0_Shanghai
- - divByZero_d68g0v0_Shanghai
- - divByZero_d69g0v0_Shanghai
- - divByZero_d70g0v0_Shanghai
- - divByZero_d71g0v0_Shanghai
- - divByZero_d72g0v0_Shanghai
- - divByZero_d73g0v0_Shanghai
- - divByZero_d74g0v0_Shanghai
- - divByZero_d75g0v0_Shanghai
- - divByZero_d76g0v0_Shanghai
- - divByZero_d77g0v0_Shanghai
- - divByZero_d78g0v0_Shanghai
- - divByZero_d79g0v0_Shanghai
- - divByZero_d80g0v0_Shanghai
- - divByZero_d81g0v0_Shanghai
- - divByZero_d82g0v0_Shanghai
- - divByZero_d83g0v0_Shanghai
- - divByZero_d84g0v0_Shanghai
- - divByZero_d85g0v0_Shanghai
- - divByZero_d86g0v0_Shanghai
- - divByZero_d87g0v0_Shanghai
- - divByZero_d88g0v0_Shanghai
- - divByZero_d89g0v0_Shanghai
- - divByZero_d90g0v0_Shanghai
- - divByZero_d91g0v0_Shanghai
- - divByZero_d92g0v0_Shanghai
- - divByZero_d93g0v0_Shanghai
- - divByZero_d94g0v0_Shanghai
- - divByZero_d95g0v0_Shanghai
- - divByZero_d96g0v0_Shanghai
- - divByZero_d97g0v0_Shanghai
- - expPower256Of256_d0g0v0_Shanghai
- - exp_d1g0v0_Shanghai
- - exp_d3g0v0_Shanghai
- - exp_d8g0v0_Shanghai
- - exp_d9g0v0_Shanghai
- - expPower256_d0g0v0_Shanghai
- - mulmod_d12g0v0_Shanghai
- - mulmod_d13g0v0_Shanghai
- - mulmod_d14g0v0_Shanghai
- - mulmod_d15g0v0_Shanghai
- - twoOps_d0g0v0_Shanghai
+ - addmod_d10g0v0_Cancun
+ - addmod_d11g0v0_Cancun
+ - addmod_d8g0v0_Cancun
+ - addmod_d9g0v0_Cancun
+ - divByZero_d63g0v0_Cancun
+ - divByZero_d64g0v0_Cancun
+ - divByZero_d65g0v0_Cancun
+ - divByZero_d66g0v0_Cancun
+ - divByZero_d67g0v0_Cancun
+ - divByZero_d68g0v0_Cancun
+ - divByZero_d69g0v0_Cancun
+ - divByZero_d70g0v0_Cancun
+ - divByZero_d71g0v0_Cancun
+ - divByZero_d72g0v0_Cancun
+ - divByZero_d73g0v0_Cancun
+ - divByZero_d74g0v0_Cancun
+ - divByZero_d75g0v0_Cancun
+ - divByZero_d76g0v0_Cancun
+ - divByZero_d77g0v0_Cancun
+ - divByZero_d78g0v0_Cancun
+ - divByZero_d79g0v0_Cancun
+ - divByZero_d80g0v0_Cancun
+ - divByZero_d81g0v0_Cancun
+ - divByZero_d82g0v0_Cancun
+ - divByZero_d83g0v0_Cancun
+ - divByZero_d84g0v0_Cancun
+ - divByZero_d85g0v0_Cancun
+ - divByZero_d86g0v0_Cancun
+ - divByZero_d87g0v0_Cancun
+ - divByZero_d88g0v0_Cancun
+ - divByZero_d89g0v0_Cancun
+ - divByZero_d90g0v0_Cancun
+ - divByZero_d91g0v0_Cancun
+ - divByZero_d92g0v0_Cancun
+ - divByZero_d93g0v0_Cancun
+ - divByZero_d94g0v0_Cancun
+ - divByZero_d95g0v0_Cancun
+ - divByZero_d96g0v0_Cancun
+ - divByZero_d97g0v0_Cancun
+ - expPower256Of256_d0g0v0_Cancun
+ - exp_d1g0v0_Cancun
+ - exp_d3g0v0_Cancun
+ - exp_d8g0v0_Cancun
+ - exp_d9g0v0_Cancun
+ - expPower256_d0g0v0_Cancun
+ - mulmod_d12g0v0_Cancun
+ - mulmod_d13g0v0_Cancun
+ - mulmod_d14g0v0_Cancun
+ - mulmod_d15g0v0_Cancun
+ - twoOps_d0g0v0_Cancun
regex:
stArgsZeroOneBalance:
diff --git a/crates/build-utils/Cargo.toml b/crates/build-utils/Cargo.toml
index f6305f34..4db14262 100644
--- a/crates/build-utils/Cargo.toml
+++ b/crates/build-utils/Cargo.toml
@@ -19,3 +19,4 @@ serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
walkdir = { workspace = true }
+reth-primitives = { workspace = true }
diff --git a/crates/build-utils/src/constants.rs b/crates/build-utils/src/constants.rs
index 8eb961c1..0a664a98 100644
--- a/crates/build-utils/src/constants.rs
+++ b/crates/build-utils/src/constants.rs
@@ -1,2 +1,33 @@
+use lazy_static::lazy_static;
+use reth_primitives::alloy_primitives::{address, Address};
+use std::collections::HashMap;
+
pub const ROOT: &str = "GeneralStateTests";
-pub const FORK: &str = "Shanghai";
+pub const FORK: &str = "Cancun";
+
+lazy_static! {
+ // A registry of the most common addresses and their associated secret keys.
+ // Most secret keys can be read from filler files directly - however, for python-based
+ // tests, the secret keys are not present in the filler files. This registry
+ // is used to fill in the missing secret keys (only two used in pyspec tests).
+ pub static ref ADDRESSES_KEYS: HashMap
= {
+ let mut registry = HashMap::new();
+ registry.insert(
+ address!("a94f5374fce5edbc8e2a8697c15331677e6ebf0b"),
+ "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
+ );
+ registry.insert(
+ address!("8a0a19589531694250d570040a0c4b74576919b8"),
+ "0x9e7645d0cfd9c3a04eb7a9db59a4eb7d359f2e75c9164a9d6b9a7d54e1b6a36f",
+ );
+ registry.insert(
+ address!("d02d72e067e77158444ef2020ff2d325f929b363"),
+ "41f6e321b31e72173f8ff2e292359e1862f24fba42fe6f97efaf641980eff298",
+ );
+ registry.insert(
+ address!("97a7cb1de3cc7d556d0aa32433b035067709e1fc"),
+ "0x0b2986cc45bd8a8d028c3fcf6f7a11a52f1df61f3ea5d63f05ca109dd73a3fa0"
+ );
+ registry
+ };
+}
diff --git a/crates/build-utils/src/content_reader.rs b/crates/build-utils/src/content_reader.rs
index b2dcf08e..d0740b64 100644
--- a/crates/build-utils/src/content_reader.rs
+++ b/crates/build-utils/src/content_reader.rs
@@ -1,8 +1,12 @@
use std::collections::BTreeMap;
+use reth_primitives::{revm_primitives::FixedBytes, Address};
use serde_json::Value;
-use crate::{path::PathWrapper, utils::blockchain_tests_to_general_state_tests_path};
+use crate::{
+ constants::ADDRESSES_KEYS, path::PathWrapper,
+ utils::blockchain_tests_to_general_state_tests_path,
+};
/// The `ContentReader` is used to read the content of the ef-test tests files.
/// The tests files are located in the `BlockchainTests` folder and contain
@@ -22,20 +26,45 @@ impl ContentReader {
///
/// Test location: BlockchainTests/GeneralStateTests/stRandom/randomStatetest0.json
/// Secret key location: GeneralStateTests/stRandom/randomStatetest0.json
- pub fn secret_key(path: PathWrapper) -> Result