Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
251 lines (213 loc) · 9.84 KB
/
Copy pathMakefile
File metadata and controls
251 lines (213 loc) · 9.84 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
.PHONY: help
PROVER_DIRS := examples/demo-rollup/provers/risc0/guest-mock \
examples/demo-rollup/provers/risc0/guest-celestia \
examples/demo-rollup/provers/sp1/guest-mock \
examples/demo-rollup/provers/sp1/guest-aggregation-mock \
crates/bench/sp1-microbenches/guest-sha256 \
crates/bench/sp1-microbenches/guest-ed25519
# Absolutely all dirs
ALL_DIRS := $(PROVER_DIRS) \
crates/module-system/module-implementations/extern/hyperlane-solana-register/solana
DATA_DIRS := ./crates/module-system/sov-modules-macros/data \
./crates/module-system/sov-solana-offchain-auth/data \
./crates/module-system/hyperlane/data \
./crates/full-node/sov-stf-runner/data \
./crates/full-node/sov-metrics/data \
./examples/demo-rollup/data
# We run `cargo hack` with the `--partition 1/1` by default, but overrides allow
# CI to parallelize checks.
CARGO_HACK_PARTITION_N ?= 1
CARGO_HACK_PARTITION_M ?= 1
# Default is 256[^1], but `proptest` can be slow[^2] and local testing is not
# the place to run expensive, long-running tests with property checking. That's
# better left to CI.
#
# Ideally, one day we'd be able to increase this number without affecting
# developer productivity.
#
# [^1]: https://proptest-rs.github.io/proptest/proptest/tutorial/config.html
# [^2]: https://github.com/proptest-rs/proptest/issues/286
export PROPTEST_CASES := 50
help: ## Display this help message
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
build: ## Build the project
@cargo build
clean: ## Cleans compiled
@cargo clean
check-provers: ## cargo check in non attached crates
@set -e; for dir in $(PROVER_DIRS); do \
echo "$$(date) Running cargo fmt + check in $$dir"; \
cargo fmt --all --check --quiet --manifest-path "$$dir/Cargo.toml"; \
case "$$dir" in \
*/provers/sp1/*) \
(cd "$$dir" && cargo prove build --features bench) ;; \
*/provers/risc0/*) \
echo "Skipping risc0 prover build in $$dir" ;; \
esac; \
done
total-clean: clean
total-clean:
$(MAKE) -C examples/demo-rollup clean;
$(MAKE) -C examples/demo-rollup clean-wallet;
@for dir in $(ALL_DIRS); do \
echo "Running cargo clean in $$dir"; \
(cargo clean --manifest-path "$$dir/Cargo.toml"); \
done;
rm -rf "soak_data/examples/demo-rollup/sov-soak-testing/soak_data"
rm -rf typescript/node_modules
rm -rf typescript/.turbo
rm -rf typescript/.cache
rm -rf typescript/packages/universal-wallet-wasm/target
cargo clean --manifest-path examples/demo-rollup/tests/prover/sov-aggregated-proof/Cargo.toml
cargo clean --manifest-path python/py_sovereign_web3/rust/Cargo.toml
@for dir in $(DATA_DIRS); do \
rm -rf "$$dir"; \
done;
test: ## Runs test suite using next test
@cargo nextest run --no-fail-fast --status-level skip --all-features
test-all: ## Runs test suite using nextest, across the whole workspace
cargo switcheroo save _backup
cargo switcheroo disable
$(MAKE) test
cargo switcheroo set _backup
test-default-features: ## Runs test suite using default features
@cargo nextest run --no-fail-fast --status-level skip
install-dev-tools: ## Installs all necessary dev tools
install-dev-tools: install-cargo-tools install-risc0-toolchain install-sp1-toolchain
rustup update nightly
## Backup VS Code settings to `.vscode/settings.json.bak`.
cp .vscode/settings.json .vscode/settings.json.bak || true
## Install the default suggested VS Code settings.
cp .vscode/settings.default.json .vscode/settings.json
cargo install cargo-llvm-cov
cargo install cargo-hack
cargo install cargo-machete
cargo install cargo-deny
cargo install flaky-finder
cargo install cargo-insta
cargo install cargo-nextest --locked
cargo install zepter
cargo +stable install cargo-dylint dylint-link
rustup target add wasm32-unknown-unknown
install-cargo-tools: ## Installs all necessary cargo helpers
cargo install cargo-llvm-cov
cargo install cargo-hack
cargo install cargo-machete
cargo install cargo-deny
cargo install flaky-finder
cargo install cargo-insta
cargo install cargo-nextest --locked
cargo install zepter
install-risc0-toolchain: ## install risc0 toolchain
curl -L https://risczero.com/install | bash
~/.risc0/bin/rzup install cargo-risczero 3.0.5
~/.risc0/bin/rzup install r0vm 3.0.5
~/.risc0/bin/rzup install rust 1.91.1
~/.risc0/bin/rzup install cpp 2024.1.5
@echo "Risc0 toolchain version:"
cargo +risc0 --version
install-sp1-toolchain: ## install SP1 toolchain
curl -L https://sp1up.succinct.xyz | bash
~/.sp1/bin/sp1up $${GITHUB_TOKEN:+--token "$$GITHUB_TOKEN"} --version 6.2.2
~/.sp1/bin/cargo-prove prove --version
~/.sp1/bin/cargo-prove prove install-toolchain
@echo "SP1 toolchain version:"
rustc +succinct --version
lint: ## cargo fmt, check and clippy.
## fmt first, because it's the cheapest
cargo fmt --all --check
cargo check --all-targets --all-features
## Invokes Zepter multiple times because fixes sometimes unveal more underlying issues.
zepter
zepter
zepter
cargo machete
if which cargo-dylint > /dev/null; then \
cargo dylint --all; \
else \
echo "cargo-dylint not found, skipping dylint check"; \
fi
$(MAKE) clippy
lint-all: ## cargo fmt, check and clippy, across the whole workspace
cargo switcheroo save _backup
cargo switcheroo disable
$(MAKE) lint
cargo switcheroo set _backup
clippy: ## runs cargo clippy. skips clippy on guest code since it's not supported by risc0
SKIP_GUEST_BUILD=1 cargo clippy --all-targets --all-features -- -A clippy::too_many_arguments
cargo-deny-check-licenses:
cargo deny check licenses
cargo-deny-check: ## Runs a global cargo-deny check, not just the licenses.
cargo deny check --hide-inclusion-graph
lint-fix: ## cargo fmt, fix and clippy. Skip clippy on guest code since it's not supported by risc0
cargo fmt --all
cargo fix --allow-dirty
SKIP_GUEST_BUILD=1 cargo clippy --fix --allow-dirty -- -A clippy::too_many_arguments
# Crates excluded from the feature-powerset check: examples, binaries, benchmarks,
# fuzz/test harnesses, and other non-published leaf crates (absent from
# packages_to_publish.yml). They are already compiled by `check`
# (cargo check --all-targets --all-features) and by the test jobs; no downstream user
# enables partial feature combinations on them, so powerset coverage adds nothing here
# while dominating the run time. Listed explicitly (not derived) to avoid coupling to
# publish-manifest name matching.
HACK_EXCLUDE := \
--exclude demo-simple-stf \
--exclude integration-tests \
--exclude module-template \
--exclude native-gas-microbenches \
--exclude py_sovereign_web3 \
--exclude sov-benchmarks \
--exclude sov-demo-rollup-rest-api-load-testing \
--exclude sov-evm-soak-testing \
--exclude sov-soak-testing \
--exclude sov-soak-testing-lib \
--exclude workspace-hack
check-features: ## Checks that project compiles with all combinations of features.
cargo hack check --feature-powerset --exclude-features default,gas-constant-estimation $(HACK_EXCLUDE) --exclude sov-demo-rollup --partition $(CARGO_HACK_PARTITION_N)/$(CARGO_HACK_PARTITION_M) --all-targets
@# demo-rollup is excluded from the powerset above; its constrained check is partition-independent,
@# so run it only on partition 1 instead of redundantly in every partition.
@if [ "$(CARGO_HACK_PARTITION_N)" = "1" ]; then $(MAKE) check-demo-rollup-features; fi
check-features-default-targets:
cargo hack check --feature-powerset --exclude-features default,gas-constant-estimation $(HACK_EXCLUDE) --exclude sov-demo-rollup --partition $(CARGO_HACK_PARTITION_N)/$(CARGO_HACK_PARTITION_M)
@if [ "$(CARGO_HACK_PARTITION_N)" = "1" ]; then $(MAKE) check-demo-rollup-features; fi
# demo-rollup is split by DA layer (mock_da / celestia_da); its feature-powerset must keep
# at least one DA feature (a no-DA combo hits a compile_error). It is excluded from the
# workspace powerset above and checked here with that constraint. Guest builds are skipped.
check-demo-rollup-features: ## Constrained feature-powerset for demo-rollup (needs a DA feature).
SKIP_GUEST_BUILD=1 cargo hack check -p sov-demo-rollup --feature-powerset --at-least-one-of mock_da,celestia_da --exclude-features default --all-targets
check-constant-overriding-is-disabled-in-release-mode:
# Passes in release mode...
SOV_TEST_CONST_OVERRIDE_CHAIN_ID=1 cargo test -p sov-modules-api --profile release-with-opt-level-0 assert_chain_id_was_not_overridden
# ...but not with standard test profile
if SOV_TEST_CONST_OVERRIDE_CHAIN_ID=1 cargo test -p sov-modules-api assert_chain_id_was_not_overridden; then \
echo "Check succeeded, but was expected to fail!"; \
exit 1; \
fi
@echo "Check succeeded!"
find-flaky-tests: ## Runs tests over and over to find if there's flaky tests
flaky-finder -j16 -r320 --continue "cargo test -- --nocapture"
coverage: ## Coverage in lcov format
SP1_PROVER=mock cargo llvm-cov nextest --cargo-profile coverage --locked --all-features --lcov --output-path lcov.info
coverage-html: ## Coverage in HTML format
SP1_PROVER=mock cargo llvm-cov nextest --locked --all-features --html
dry-run-publish:
yq '.[]' packages_to_publish.yml | xargs -I _ cargo publish --allow-dirty --dry-run -p _
docs: ## Generates documentation locally
cargo doc --open
docs-generate: ## Generate documentation but don't open it, to verify that it would pass CI.
cargo doc --no-deps --all-features
doctest:
cargo test --doc --all-features
mini-ci: ## Runs multiple checks that can most often fail CI as a single command: lint, test, and doctest.
cargo switcheroo save _backup
cargo switcheroo disable
$(MAKE) lint
$(MAKE) test
$(MAKE) doctest
$(MAKE) docs-generate
$(MAKE) check-provers
cargo switcheroo set _backup
start-obs: ## Start docker containers needed for observability stack: influxdb, grafana, etc
./scripts/start_observability.sh
stop-obs: ## Stops observability stack
./scripts/stop_observability.sh