Skip to content

Commit

Permalink
chore(levm): rename EF tests from levm to state. (#1888)
Browse files Browse the repository at this point in the history
**Motivation**
To be more aligned with the nomenclature used by the EF.


**Description**
We have "blockchain tests" and "state tests". These ones are state
tests, see:
https://ethereum.github.io/execution-spec-tests/main/consuming_tests/state_test/

Adding `levm` is confusing since we could also run them with revm. But
instead of calling them evm tests, let's stick with state so it is
aligned with how Ethereum calls them.
  • Loading branch information
mpaulucci authored Feb 10, 2025
1 parent 3f0f124 commit 824f659
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 45 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
**/*.rs.bk

cmd/ef_tests/blockchain/vectors
cmd/ef_tests/levm/vectors
cmd/ef_tests/state/vectors

**/.DS_Store
**/.vscode
Expand All @@ -24,4 +24,4 @@ crates/levm_mlir/ethtests
crates/levm_mlir/*.tar.gz

# used by Flamegraph and Samply
cmd/ef_tests/levm/levm_perfgraphs
cmd/ef_tests/state/levm_perfgraphs
2 changes: 1 addition & 1 deletion .github/scripts/publish_levm_ef_tests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
curl -X POST $1 \
-H 'Content-Type: application/json; charset=utf-8' \
--data "$(cat cmd/ef_tests/levm/levm_ef_tests_summary_slack.txt)"
--data "$(cat cmd/ef_tests/state/levm_ef_tests_summary_slack.txt)"
12 changes: 6 additions & 6 deletions .github/workflows/flamegraph_reporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
${{ env.HOME }}/.cargo/bin/addr2line
${{ env.HOME }}/.cargo/bin/flamegraph
${{ env.HOME }}/.cargo/bin/inferno-*
${{ env.HOME }}/ethrex/ethrex/cmd/ef_tests/levm/vectors
${{ env.HOME }}/ethrex/ethrex/cmd/ef_tests/state/vectors
key: ${{ runner.os }}-${{ env.RUST_VERSION }}-extra-binaries

- name: Change perf settings
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
- name: Download EF Tests
run: |
if [ ! -f "$HOME/ethrex/ethrex/cmd/ef_tests/levm/vectors" ]; then
if [ ! -f "$HOME/ethrex/ethrex/cmd/ef_tests/state/vectors" ]; then
cd crates/vm/levm
make download-evm-ef-tests
fi
Expand All @@ -101,13 +101,13 @@ jobs:
start_time=$(date +%s)
if [ "${{ matrix.name }}" == "levm" ]; then
rm -rf target/debug/ef_tests_levm
rm -rf target/debug/ef_tests_state
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -c "record -o perf.data -F997 --call-graph dwarf,16384 -g" \
-p ef_tests-levm -- --tests stSolidityTest,stCallCodes
-p ef_tests-state --test all -- --tests stSolidityTest,stCallCodes
elif [ "${{ matrix.name }}" == "revm" ]; then
rm -rf target/debug/ef_tests_levm
rm -rf target/debug/ef_tests_state
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -c "record -o perf.data -F997 --call-graph dwarf,16384 -g" \
-p ef_tests-levm -- --revm --tests stSolidityTest,stCallCodes
-p ef_tests-state --test all -- --revm --tests stSolidityTest,stCallCodes
fi
end_time=$(date +%s)
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ debug/

cmd/ef_tests/blockchain/vectors

cmd/ef_tests/levm/vectors
cmd/ef_tests/state/vectors

# Repos checked out by make target
hive/
Expand Down Expand Up @@ -59,7 +59,7 @@ loc_report.json
ethrex.redb

# used by Flamegraph and Samply
cmd/ef_tests/levm/levm_perfgraphs
cmd/ef_tests/state/levm_perfgraphs
*.svg
prof_*.json
prof.json
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ members = [
"crates/common/rlp",
"cmd/ethrex",
"cmd/ef_tests/blockchain",
"cmd/ef_tests/levm",
"cmd/ef_tests/state",
"cmd/ethrex_l2",
"cmd/hive_report",
"crates/vm/levm",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lint: ## 🧹 Linter check

CRATE ?= *
test: ## 🧪 Run each crate's tests
cargo test -p '$(CRATE)' --workspace --exclude ethrex-prover --exclude ethrex-levm --exclude ef_tests-blockchain --exclude ef_tests-levm --exclude ethrex-l2 -- --skip test_contract_compilation
cargo test -p '$(CRATE)' --workspace --exclude ethrex-prover --exclude ethrex-levm --exclude ef_tests-blockchain --exclude ef_tests-state --exclude ethrex-l2 -- --skip test_contract_compilation
$(MAKE) -C cmd/ef_tests/blockchain test

clean: clean-vectors ## 🧹 Remove build artifacts
Expand Down
10 changes: 3 additions & 7 deletions cmd/ef_tests/levm/Cargo.toml → cmd/ef_tests/state/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ef_tests-levm"
name = "ef_tests-state"
version.workspace = true
edition.workspace = true

Expand Down Expand Up @@ -33,12 +33,8 @@ revm = { version = "18.0.0", features = [
hex = "0.4.3"

[lib]
path = "./ef_tests.rs"

[[bin]]
name = "ef_tests_levm"
path = "tests/ef_tests_levm.rs"
path = "./lib.rs"

[[test]]
name = "ef_tests_levm"
name = "all"
harness = false
File renamed without changes.
9 changes: 9 additions & 0 deletions cmd/ef_tests/state/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# State Tests

https://ethereum.github.io/execution-spec-tests/main/consuming_tests/state_test/

## Running the tests

```bash
make run-evm-ef-tests
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use ef_tests_levm::{
use ef_tests_state::{
parser,
runner::{self, EFTestRunnerOptions},
};
Expand Down
File renamed without changes.
File renamed without changes.
34 changes: 17 additions & 17 deletions crates/vm/levm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fmt: ## 📄 Runs rustfmt
cargo fmt --all

###### EF Tests ######
EFTEST_DIR := ../../../cmd/ef_tests/levm
EFTEST_DIR := ../../../cmd/ef_tests/state
VECTORS_DIR := $(EFTEST_DIR)/vectors
TMP_DIR := tmp
TESTS_REPO := $(TMP_DIR)/ethereum-tests
Expand Down Expand Up @@ -59,22 +59,22 @@ clean-evm-ef-tests: ## 🗑️ Clean test vectors and temporary files
run-evm-ef-tests: ## 🏃‍♂️ Run EF Tests
if [ "$(QUIET)" = "true" ]; then \
cd ../../../ && \
time cargo test --quiet -p ef_tests-levm --test ef_tests_levm --release -- $(flags) --summary;\
time cargo test --quiet -p ef_tests-state --test all --release -- $(flags) --summary;\
elif [ "$(DEBUG)" = "true" ]; then \
cd ../../../ && \
time cargo test -p ef_tests-levm --test ef_tests_levm -- $(flags);\
time cargo test -p ef_tests-state --test all -- $(flags);\
else \
cd ../../../ && \
time cargo test -p ef_tests-levm --test ef_tests_levm --release -- $(flags);\
time cargo test -p ef_tests-state --test all --release -- $(flags);\
fi

run-evm-ef-tests-ci: ## 🏃‍♂️ Run EF Tests only with LEVM and without spinner, for CI.
cd ../../../ && \
time cargo test -p ef_tests-levm --test ef_tests_levm --release -- --summary
time cargo test -p ef_tests-state --test all --release -- --summary

generate-evm-ef-tests-report: ## 📊 Generate EF Tests Report
cd ../../../ && \
cargo test -p ef_tests-levm --test ef_tests_levm --release -- --summary
cargo test -p ef_tests-state --test all --release -- --summary

###### Benchmarks ######
REPETITIONS := 10000
Expand Down Expand Up @@ -169,7 +169,7 @@ SUBDIRS := $(shell find $(VECTORS_DIR)/GeneralStateTests -maxdepth 1 -type d ! -

flamegraph-run-ef-tests: ## 🔥 Run EF tests and create a flamegraph per test folder
cd $(EFTEST_DIR) &&\
mkdir -p levm_perfgraphs/flamegraph/ef_tests/levm ||: && \
mkdir -p levm_perfgraphs/flamegraph/ef_tests/state ||: && \
mkdir -p levm_perfgraphs/flamegraph/ef_tests/revm ||:
$(MAKE) flamegraph-run-ef-tests-revm
$(MAKE) flamegraph-run-ef-tests-levm
Expand All @@ -178,18 +178,18 @@ flamegraph-run-ef-tests-revm:
@for dir in $(SUBDIRS); do\
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --root \
--output $(EFTEST_DIR)/levm_perfgraphs/flamegraph/ef_tests/revm/$$dir.svg\
-p ef_tests-levm --test ef_tests_levm -- --summary --revm --tests $$dir;\
-p ef_tests-state --test all -- --summary --revm --tests $$dir;\
done
flamegraph-run-ef-tests-levm:
@for dir in $(SUBDIRS); do\
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --root \
--output $(EFTEST_DIR)/levm_perfgraphs/flamegraph/ef_tests/levm/$$dir.svg\
-p ef_tests-levm --test ef_tests_levm -- --summary --tests $$dir;\
--output $(EFTEST_DIR)/levm_perfgraphs/flamegraph/ef_tests/state/$$dir.svg\
-p ef_tests-state --test all -- --summary --tests $$dir;\
done

samply-run-ef-tests: ## ⚡️ Run EF tests and create a samply profiling file per test folder
cd $(EFTEST_DIR) && \
mkdir -p levm_perfgraphs/samply/ef_tests/levm ||: && \
mkdir -p levm_perfgraphs/samply/ef_tests/state ||: && \
mkdir -p levm_perfgraphs/samply/ef_tests/revm ||:
$(MAKE) samply-run-ef-tests-revm
$(MAKE) samply-run-ef-tests-levm
Expand All @@ -198,14 +198,14 @@ samply-run-ef-tests-revm:
@for dir in $(SUBDIRS); do\
CARGO_PROFILE_RELEASE_DEBUG=true samply record --save-only \
-o $(EFTEST_DIR)/levm_perfgraphs/samply/ef_tests/revm/prof_$$dir.json \
cargo test --release -p ef_tests-levm --test ef_tests_levm -- --summary --revm --tests $$dir;\
cargo test --release -p ef_tests-state --test all -- --summary --revm --tests $$dir;\
done

samply-run-ef-tests-levm:
@for dir in $(SUBDIRS); do\
CARGO_PROFILE_RELEASE_DEBUG=true samply record --save-only \
-o $(EFTEST_DIR)/levm_perfgraphs/samply/ef_tests/levm/prof_$$dir.json \
cargo test --release -p ef_tests-levm --test ef_tests_levm -- --summary --tests $$dir;\
-o $(EFTEST_DIR)/levm_perfgraphs/samply/ef_tests/state/prof_$$dir.json \
cargo test --release -p ef_tests-state --test all -- --summary --tests $$dir;\
done

################
Expand Down Expand Up @@ -235,7 +235,7 @@ endef

FLAMEGRAPH_DIR := $(EFTEST_DIR)/levm_perfgraphs/flamegraph/bench
flamegraph-benchmarks: ## 🔥 Run benchmarks and create flamegraph
cd ../../../cmd/ef_tests/levm &&\
cd ../../../cmd/ef_tests/state &&\
mkdir -p levm_perfgraphs/flamegraph/bench ||:
$(call run_flamegraph,Fibonacci,REPETITIONS,BENCH_FIB_ITERATIONS)
$(call run_flamegraph,Factorial,REPETITIONS,BENCH_FACT_ITERATIONS)
Expand All @@ -246,9 +246,9 @@ flamegraph-benchmarks: ## 🔥 Run benchmarks and create flamegraph
$(call run_flamegraph,ERC20Transfer,REPETITIONS_SLOW,BENCH_TRANSFER_ITERATIONS)
$(call run_flamegraph,ERC20Mint,REPETITIONS_SLOW,BENCH_MINT_ITERATIONS)

SAMPLY_DIR := ../../../cmd/ef_tests/levm/levm_perfgraphs/samply/bench
SAMPLY_DIR := ../../../cmd/ef_tests/state/levm_perfgraphs/samply/bench
samply-benchmarks: ## ⚡️ Run benchmarks and create samply profiling file
cd ../../../cmd/ef_tests/levm &&\
cd ../../../cmd/ef_tests/state &&\
mkdir -p levm_perfgraphs/samply/bench ||:
$(call run_samply,Fibonacci,REPETITIONS,BENCH_FIB_ITERATIONS)
$(call run_samply,Factorial,REPETITIONS,BENCH_FACT_ITERATIONS)
Expand Down
12 changes: 6 additions & 6 deletions crates/vm/levm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ make run-hive-debug-levm

## Useful Links

[Ethereum Yellowpaper](https://ethereum.github.io/yellowpaper/paper.pdf) - Formal definition of Ethereum protocol.
[The EVM Handbook](https://noxx3xxon.notion.site/The-EVM-Handbook-bb38e175cc404111a391907c4975426d) - General EVM Resources
[EVM Codes](https://www.evm.codes/) - Reference for opcode implementation
[EVM Playground](https://www.evm.codes/playground) - Useful for seeing opcodes in action
[Ethereum Yellowpaper](https://ethereum.github.io/yellowpaper/paper.pdf) - Formal definition of Ethereum protocol.
[The EVM Handbook](https://noxx3xxon.notion.site/The-EVM-Handbook-bb38e175cc404111a391907c4975426d) - General EVM Resources
[EVM Codes](https://www.evm.codes/) - Reference for opcode implementation
[EVM Playground](https://www.evm.codes/playground) - Useful for seeing opcodes in action
[EVM Deep Dives](https://noxx.substack.com/p/evm-deep-dives-the-path-to-shadowy) - Deep Dive into different aspects of the EVM

## Performance metrics
Expand All @@ -241,7 +241,7 @@ Run the tests
make flamegraph-run-ef-tests
```

This will create a folder inside `cmd/ef_tests/levm/` named `levm_ef_test_perfgraphs` you can find the flamegraphs inside the folder `levm_ef_test_perfgraphs/flamegraph` open them with your preferred browser.
This will create a folder inside `cmd/ef_tests/state/` named `levm_ef_test_perfgraphs` you can find the flamegraphs inside the folder `levm_ef_test_perfgraphs/flamegraph` open them with your preferred browser.

### To run Samply on the Ethereum Foundation tests

Expand All @@ -257,7 +257,7 @@ Run the tests
make samply-run-ef-tests
```

This will create a folder inside `cmd/ef_tests/levm/` named `levm_ef_test_perfgraphs` you can find the flamegraphs inside the folder `levm_ef_test_perfgraphs/samply` run
This will create a folder inside `cmd/ef_tests/state/` named `levm_ef_test_perfgraphs` you can find the flamegraphs inside the folder `levm_ef_test_perfgraphs/samply` run

```Shell
samply load <path-to-perf-file.json>
Expand Down

0 comments on commit 824f659

Please sign in to comment.