Skip to content

Commit bbbba4f

Browse files
committed
feat(tests): add support of eth spec tests
1 parent 4d1d54e commit bbbba4f

File tree

15 files changed

+2244
-111
lines changed

15 files changed

+2244
-111
lines changed

Cargo.lock

Lines changed: 147 additions & 111 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[workspace]
2+
members = [".", "testing/bsc-ef-tests"]
3+
14
[package]
25
name = "reth_bsc"
36
version = "0.1.0"

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,30 @@ check-features:
3434
--package reth-primitives-traits \
3535
--package reth-primitives \
3636
--feature-powerset
37+
38+
##@ EVM Tests
39+
40+
# Execution spec tests configuration
41+
EEST_VERSION ?= v5.4.0
42+
EEST_URL := https://github.com/ethereum/execution-spec-tests/releases/download/$(EEST_VERSION)/fixtures_stable.tar.gz
43+
EEST_DIR := ./testing/bsc-ef-tests/execution-spec-tests
44+
45+
$(EEST_DIR):
46+
@echo "Downloading execution spec tests $(EEST_VERSION)..."
47+
mkdir -p $(EEST_DIR)
48+
curl -sL $(EEST_URL) | tar -xzf - --strip-components=1 -C $(EEST_DIR)
49+
50+
.PHONY: download-eest
51+
download-eest: $(EEST_DIR) ## Download execution spec test fixtures
52+
53+
.PHONY: ef-tests
54+
ef-tests: $(EEST_DIR) ## Run BSC EVM execution spec tests
55+
cargo test -p bsc-ef-tests --release --features ef-tests,jemalloc,asm-keccak
56+
57+
.PHONY: ef-tests-nextest
58+
ef-tests-nextest: $(EEST_DIR) ## Run BSC EVM execution spec tests with nextest (faster)
59+
cargo nextest run -p bsc-ef-tests --release --features ef-tests,jemalloc,asm-keccak
60+
61+
.PHONY: clean-eest
62+
clean-eest: ## Remove downloaded execution spec test fixtures
63+
rm -rf $(EEST_DIR)

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ make build
4141
make maxperf
4242
```
4343

44+
## Testing
45+
46+
### Ethereum Execution Spec Tests
47+
48+
Run the [Ethereum Execution Spec Tests](https://github.com/ethereum/execution-spec-tests) to validate BSC EVM compatibility:
49+
50+
```bash
51+
# Download test fixtures (v5.4.0)
52+
make download-eest
53+
54+
# Run tests
55+
make ef-tests
56+
57+
# Or use nextest for faster parallel execution (requires cargo-nextest)
58+
# Install with: cargo install cargo-nextest
59+
make ef-tests-nextest
60+
61+
# Clean up test fixtures
62+
make clean-eest
63+
```
64+
4465
## Running
4566

4667
### Full Node (Recommended)

testing/bsc-ef-tests/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Test fixtures (downloaded)
2+
execution-spec-tests/
3+
ethereum-tests/

testing/bsc-ef-tests/Cargo.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[package]
2+
name = "bsc-ef-tests"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "Execution Spec Tests for BSC EVM"
6+
7+
[features]
8+
ef-tests = []
9+
jemalloc = ["dep:tikv-jemallocator"]
10+
asm-keccak = ["alloy-primitives/asm-keccak"]
11+
12+
[dependencies]
13+
# BSC crate
14+
reth_bsc = { path = "../.." }
15+
16+
# reth dependencies from the same reth fork
17+
reth-chainspec = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
18+
reth-consensus = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
19+
reth-ethereum-forks = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
20+
reth-db = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle", features = ["mdbx", "test-utils", "disable-lock"] }
21+
reth-db-api = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
22+
reth-db-common = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
23+
reth-ethereum-consensus = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
24+
reth-ethereum-primitives = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
25+
reth-evm = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
26+
reth-evm-ethereum = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
27+
reth-primitives = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
28+
reth-primitives-traits = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
29+
reth-provider = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle", features = ["test-utils"] }
30+
reth-revm = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle", features = ["std"] }
31+
reth-tracing = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
32+
reth-trie = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
33+
reth-trie-db = { git = "https://github.com/bnb-chain/reth.git", branch = "feat/eip7594-sidecar-toggle" }
34+
35+
# revm
36+
revm = { version = "34.0.0", features = ["secp256k1", "blst", "c-kzg", "memory_limit"] }
37+
38+
# alloy
39+
alloy-consensus = "1.1.3"
40+
alloy-eips = "1.1.3"
41+
alloy-genesis = "1.1.3"
42+
alloy-primitives = "1.4.1"
43+
alloy-rlp = "0.3.12"
44+
45+
# misc
46+
rayon = "1"
47+
serde = { version = "1.0", features = ["derive"] }
48+
serde_json = "1.0"
49+
thiserror = "2.0"
50+
tikv-jemallocator = { version = "0.6", optional = true }
51+
walkdir = "2"

testing/bsc-ef-tests/src/case.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! Test case abstractions
2+
3+
use crate::result::Error;
4+
use std::path::Path;
5+
6+
/// A single test case.
7+
pub trait Case: Sized {
8+
/// Load the test from the given path.
9+
fn load(path: &Path) -> Result<Self, Error>;
10+
11+
/// Run the test.
12+
fn run(&self) -> Result<(), Error>;
13+
}
14+
15+
/// A collection of test cases.
16+
#[derive(Debug)]
17+
pub struct Cases<T> {
18+
/// The test cases.
19+
pub tests: Vec<T>,
20+
}
21+
22+
impl<T: Case> Cases<T> {
23+
/// Run all test cases.
24+
pub fn run(&self) -> Vec<Result<(), Error>> {
25+
self.tests.iter().map(|case| case.run()).collect()
26+
}
27+
}

0 commit comments

Comments
 (0)