-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
118 lines (89 loc) · 5.05 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
.PHONY: build lint test clean run-image build-image download-test-vectors clean-vectors \
setup-hive test-pattern-default run-hive run-hive-debug clean-hive-logs
help: ## 📚 Show help for each of the Makefile recipes
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
build: ## 🔨 Build the client
cargo build --workspace
lint: ## 🧹 Linter check
cargo clippy --all-targets --all-features --workspace --exclude ethrex-prover -- -D warnings
SPECTEST_VERSION := v3.0.0
SPECTEST_ARTIFACT := tests_$(SPECTEST_VERSION).tar.gz
SPECTEST_VECTORS_DIR := cmd/ef_tests/ethrex/vectors
CRATE ?= *
test: $(SPECTEST_VECTORS_DIR) ## 🧪 Run each crate's tests
cargo test -p '$(CRATE)' --workspace --exclude ethrex-prover --exclude ethrex-levm --exclude ef_tests-levm -- --skip test_contract_compilation --skip testito
clean: clean-vectors ## 🧹 Remove build artifacts
cargo clean
rm -rf hive
STAMP_FILE := .docker_build_stamp
$(STAMP_FILE): $(shell find crates cmd -type f -name '*.rs') Cargo.toml Dockerfile
docker build -t ethrex .
touch $(STAMP_FILE)
build-image: $(STAMP_FILE) ## 🐳 Build the Docker image
run-image: build-image ## 🏃 Run the Docker image
docker run --rm -p 127.0.0.1:8545:8545 ethrex --http.addr 0.0.0.0
$(SPECTEST_ARTIFACT):
rm -f tests_*.tar.gz # Delete older versions
curl -L -o $(SPECTEST_ARTIFACT) "https://github.com/ethereum/execution-spec-tests/releases/download/$(SPECTEST_VERSION)/fixtures_stable.tar.gz"
$(SPECTEST_VECTORS_DIR): $(SPECTEST_ARTIFACT)
mkdir -p $(SPECTEST_VECTORS_DIR) tmp
tar -xzf $(SPECTEST_ARTIFACT) -C tmp
mv tmp/fixtures/blockchain_tests/* $(SPECTEST_VECTORS_DIR)
download-test-vectors: $(SPECTEST_VECTORS_DIR) ## 📥 Download test vectors
clean-vectors: ## 🗑️ Clean test vectors
rm -rf $(SPECTEST_VECTORS_DIR)
ETHEREUM_PACKAGE_REVISION := 5b49d02ee556232a73ea1e28000ec5b3fca1073f
# Shallow clones can't specify a single revision, but at least we avoid working
# the whole history by making it shallow since a given date (one day before our
# target revision).
ethereum-package:
git clone --single-branch --branch ethrex-integration https://github.com/lambdaclass/ethereum-package
checkout-ethereum-package: ethereum-package ## 📦 Checkout specific Ethereum package revision
cd ethereum-package && \
git fetch && \
git checkout $(ETHEREUM_PACKAGE_REVISION)
ENCLAVE ?= lambdanet
localnet: stop-localnet-silent build-image checkout-ethereum-package ## 🌐 Start local network
kurtosis run --enclave $(ENCLAVE) ethereum-package --args-file test_data/network_params.yaml
docker logs -f $$(docker ps -q --filter ancestor=ethrex)
localnet-assertoor-blob: stop-localnet-silent build-image checkout-ethereum-package ## 🌐 Start local network with assertoor test
kurtosis run --enclave $(ENCLAVE) ethereum-package --args-file .github/config/assertoor/network_params_blob.yaml
docker logs -f $$(docker ps -q --filter ancestor=ethrex)
localnet-assertoor-tx: stop-localnet-silent build-image checkout-ethereum-package ## 🌐 Start local network with assertoor test
kurtosis run --enclave $(ENCLAVE) ethereum-package --args-file .github/config/assertoor/network_params_tx.yaml
docker logs -f $$(docker ps -q --filter ancestor=ethrex)
stop-localnet: ## 🛑 Stop local network
kurtosis enclave stop $(ENCLAVE)
kurtosis enclave rm $(ENCLAVE) --force
stop-localnet-silent:
@echo "Double checking local net is not already started..."
@kurtosis enclave stop $(ENCLAVE) >/dev/null 2>&1 || true
@kurtosis enclave rm $(ENCLAVE) --force >/dev/null 2>&1 || true
HIVE_REVISION := df7d5103d4ddc772307f9947be4ad1f20ce03ed0
# Shallow clones can't specify a single revision, but at least we avoid working
# the whole history by making it shallow since a given date (one day before our
# target revision).
HIVE_SHALLOW_SINCE := 2024-09-02
hive:
git clone --single-branch --branch master --shallow-since=$(HIVE_SHALLOW_SINCE) https://github.com/lambdaclass/hive
cd hive && git checkout --detach $(HIVE_REVISION) && go build .
setup-hive: hive ## 🐝 Set up Hive testing framework
if [ "$$(cd hive && git rev-parse HEAD)" != "$(HIVE_REVISION)" ]; then \
cd hive && \
git checkout master && \
git fetch --shallow-since=$(HIVE_SHALLOW_SINCE) && \
git checkout --detach $(HIVE_REVISION) && go build . ;\
fi
TEST_PATTERN ?= /
# Runs a hive testing suite
# The endpoints tested may be limited by supplying a test pattern in the form "/endpoint_1|enpoint_2|..|enpoint_n"
# For example, to run the rpc-compat suites for eth_chainId & eth_blockNumber you should run:
# `make run-hive SIMULATION=ethereum/rpc-compat TEST_PATTERN="/eth_chainId|eth_blockNumber"`
run-hive: build-image setup-hive ## 🧪 Run Hive testing suite
cd hive && ./hive --sim $(SIMULATION) --client ethrex --sim.limit "$(TEST_PATTERN)"
run-hive-debug: build-image setup-hive ## 🐞 Run Hive testing suite in debug mode
cd hive && ./hive --sim $(SIMULATION) --client ethrex --sim.limit "$(TEST_PATTERN)" --docker.output
clean-hive-logs: ## 🧹 Clean Hive logs
rm -rf ./hive/workspace/logs
loc:
cargo run -p loc