forked from anoma/namada
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
316 lines (255 loc) · 9.17 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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
package = namada
# Some env vars defaults if not specified
NAMADA_E2E_USE_PREBUILT_BINARIES ?= true
NAMADA_E2E_DEBUG ?= true
RUST_BACKTRACE ?= 1
NAMADA_MASP_TEST_SEED ?= 0
PROPTEST_CASES ?= 100
# Disable shrinking in `make test-pos-sm` for CI runs. If the test fail in CI,
# we only want to get the seed.
PROPTEST_MAX_SHRINK_ITERS ?= 0
cargo := $(env) cargo
rustup := $(env) rustup
debug-env := RUST_BACKTRACE=$(RUST_BACKTRACE) RUST_LOG=$(package)=debug
debug-cargo := $(env) $(debug-env) cargo
# Nightly build is currently used for rustfmt and clippy.
nightly := $(shell cat rust-nightly-version)
# Path to the wasm source for the provided txs and VPs
wasms := wasm/wasm_source
wasms_for_tests := wasm_for_tests/wasm_source
# Paths for all the wasm templates
wasm_templates := wasm/tx_template wasm/vp_template
ifdef JOBS
jobs := -j $(JOBS)
else
jobs :=
endif
# TODO upgrade libp2p
audit-ignores += RUSTSEC-2021-0076
# Workspace crates
crates := namada_core
crates += namada
crates += namada_apps
crates += namada_benchmarks
crates += namada_encoding_spec
crates += namada_ethereum_bridge
crates += namada_macros
crates += namada_proof_of_stake
crates += namada_sdk
crates += namada_test_utils
crates += namada_tests
crates += namada_tx_prelude
crates += namada_vm_env
crates += namada_vp_prelude
build:
$(cargo) build $(jobs) --workspace --exclude namada_benchmarks
build-test:
$(cargo) +$(nightly) build --tests $(jobs)
build-release:
$(cargo) build $(jobs) --release --timings --package namada_apps --manifest-path Cargo.toml
build-debug:
$(cargo) build --package namada_apps --manifest-path Cargo.toml
install-release:
$(cargo) install --path ./apps --locked
check-release:
$(cargo) check --release --package namada_apps
package: build-release
scripts/make-package.sh
check-wasm = $(cargo) check --target wasm32-unknown-unknown --manifest-path $(wasm)/Cargo.toml
check:
$(cargo) check --workspace && \
make -C $(wasms) check && \
make -C $(wasms_for_tests) check && \
$(foreach wasm,$(wasm_templates),$(check-wasm) && ) true
check-mainnet:
$(cargo) check --workspace --features "mainnet"
# Check that every crate can be built with default features and that shared crate
# can be built for wasm
check-crates:
$(foreach p,$(crates), echo "Checking $(p)" && cargo +$(nightly) check -Z unstable-options --tests -p $(p) && ) \
make -C $(wasms_for_tests) check && \
cargo check --package namada --target wasm32-unknown-unknown --no-default-features --features "namada-sdk" && \
cargo check --package namada_sdk --all-features
clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets -- -D warnings
clippy:
$(cargo) +$(nightly) clippy $(jobs) --all-targets -- -D warnings && \
make -C $(wasms) clippy && \
make -C $(wasms_for_tests) clippy && \
$(foreach wasm,$(wasm_templates),$(clippy-wasm) && ) true
clippy-mainnet:
$(cargo) +$(nightly) clippy --all-targets --features "mainnet" -- -D warnings
clippy-fix:
$(cargo) +$(nightly) clippy --fix -Z unstable-options --all-targets --allow-dirty --allow-staged
tendermint:
./scripts/get_tendermint.sh
install: cometbft
$(cargo) install --path ./apps --locked
cometbft:
./scripts/get_cometbft.sh
run-ledger:
# runs the node
$(cargo) run --bin namadan -- ledger run
run-gossip:
# runs the node gossip node
$(cargo) run --bin namadan -- gossip run
reset-ledger:
# runs the node
$(cargo) run --bin namadan -- ledger reset
audit:
$(cargo) audit $(foreach ignore,$(audit-ignores), --ignore $(ignore))
test: test-unit test-e2e test-wasm test-benches
test-coverage:
# Run integration tests separately because they require `integration`
# feature (and without coverage) and run them with pre-built MASP proofs
$(cargo) +$(nightly) llvm-cov --output-dir target \
--features namada/testing \
--html \
-- --skip e2e --skip pos_state_machine_test --skip integration \
-Z unstable-options --report-time && \
NAMADA_MASP_TEST_SEED=$(NAMADA_MASP_TEST_SEED) \
NAMADA_MASP_TEST_PROOFS=load \
$(cargo) +$(nightly) test integration:: \
--features integration \
-- -Z unstable-options --report-time
# NOTE: `TEST_FILTER` is prepended with `e2e::`. Since filters in `cargo test`
# work with a substring search, TEST_FILTER only works if it contains a string
# that directly follows `e2e::`, e.g. `TEST_FILTER=multitoken_tests` would run
# all tests that start with `e2e::multitoken_tests`.
test-e2e:
NAMADA_E2E_USE_PREBUILT_BINARIES=$(NAMADA_E2E_USE_PREBUILT_BINARIES) \
NAMADA_E2E_DEBUG=$(NAMADA_E2E_DEBUG) \
RUST_BACKTRACE=$(RUST_BACKTRACE) \
$(cargo) +$(nightly) test e2e::$(TEST_FILTER) \
-Z unstable-options \
-- \
--test-threads=1 \
-Z unstable-options --report-time
# Run integration tests with pre-built MASP proofs
test-integration:
NAMADA_MASP_TEST_SEED=$(NAMADA_MASP_TEST_SEED) \
NAMADA_MASP_TEST_PROOFS=load \
make test-integration-slow
# Clear pre-built proofs, run integration tests and save the new proofs
test-integration-save-proofs:
# Clear old proofs first
rm -f test_fixtures/masp_proofs/*.bin || true
NAMADA_MASP_TEST_SEED=$(NAMADA_MASP_TEST_SEED) \
NAMADA_MASP_TEST_PROOFS=save \
TEST_FILTER=masp \
make test-integration-slow
# Run integration tests without specifying any pre-built MASP proofs option
test-integration-slow:
RUST_BACKTRACE=$(RUST_BACKTRACE) \
$(cargo) +$(nightly) test integration::$(TEST_FILTER) --features integration \
-Z unstable-options \
-- \
--test-threads=1 \
-Z unstable-options --report-time
test-unit:
$(cargo) +$(nightly) test \
$(TEST_FILTER) \
$(jobs) \
-- --skip e2e --skip integration --skip pos_state_machine_test \
-Z unstable-options --report-time
test-unit-with-coverage:
$(cargo) +$(nightly) llvm-cov --output-dir target \
--features namada/testing \
--html \
-- --skip e2e --skip pos_state_machine_test --skip integration \
-Z unstable-options --report-time
test-unit-mainnet:
$(cargo) +$(nightly) test \
--features "mainnet" \
$(TEST_FILTER) \
$(jobs) \
-- --skip e2e --skip integration \
-Z unstable-options --report-time
test-unit-debug:
$(debug-cargo) +$(nightly) test \
$(jobs) \
$(TEST_FILTER) \
-- --skip e2e --skip integration --skip pos_state_machine_test \
--nocapture \
-Z unstable-options --report-time
test-wasm:
make -C $(wasms) test
test-wasm-template = $(cargo) +$(nightly) test \
--manifest-path $(wasm)/Cargo.toml \
-- \
-Z unstable-options --report-time
test-wasm-templates:
$(foreach wasm,$(wasm_templates),$(test-wasm-template) && ) true
test-debug:
$(debug-cargo) +$(nightly) test \
-- \
--nocapture \
-Z unstable-options --report-time
# Test that the benchmarks run successfully without performing measurement
test-benches:
$(cargo) +$(nightly) test --package namada_benchmarks --benches
# Run PoS state machine tests with shrinking disabled by default (can be
# overridden with `PROPTEST_MAX_SHRINK_ITERS`)
test-pos-sm:
cd proof_of_stake && \
RUST_BACKTRACE=1 \
PROPTEST_CASES=$(PROPTEST_CASES) \
PROPTEST_MAX_SHRINK_ITERS=$(PROPTEST_MAX_SHRINK_ITERS) \
RUSTFLAGS='-C debuginfo=2 -C debug-assertions=true -C overflow-checks=true' \
cargo test pos_state_machine_test --release
fmt-wasm = $(cargo) +$(nightly) fmt --manifest-path $(wasm)/Cargo.toml
fmt:
$(cargo) +$(nightly) fmt --all && \
make -C $(wasms) fmt && \
$(foreach wasm,$(wasm_templates),$(fmt-wasm) && ) true
fmt-check-wasm = $(cargo) +$(nightly) fmt --manifest-path $(wasm)/Cargo.toml -- --check
fmt-check:
$(cargo) +$(nightly) fmt --all -- --check && \
make -C $(wasms) fmt-check && \
$(foreach wasm,$(wasm_templates),$(fmt-check-wasm) && ) true
watch:
$(cargo) watch
clean:
$(cargo) clean
bench:
$(cargo) bench --package namada_benchmarks
build-doc:
$(cargo) doc --no-deps
doc:
# build and opens the docs in browser
$(cargo) doc --open
build-wasm-image-docker:
docker build -t namada-wasm - < docker/namada-wasm/Dockerfile
build-wasm-scripts-docker: build-wasm-image-docker
docker run --rm -v ${PWD}:/__w/namada/namada namada-wasm make build-wasm-scripts
debug-wasm-scripts-docker: build-wasm-image-docker
docker run --rm -v ${PWD}:/usr/local/rust/wasm namada-wasm make debug-wasm-scripts
# Build the validity predicate and transactions wasm
build-wasm-scripts:
rm wasm/*.wasm || true
make -C $(wasms)
make opt-wasm
make checksum-wasm
# Debug build the validity predicate and transactions wasm
debug-wasm-scripts:
rm wasm/*.wasm || true
make -C $(wasms) debug
make opt-wasm
make checksum-wasm
# need python
checksum-wasm:
python3 wasm/checksums.py
# this command needs wasm-opt installed
opt-wasm:
@for file in $(shell ls wasm/*.wasm); do wasm-opt -Oz -o $${file} $${file}; done
clean-wasm-scripts:
make -C $(wasms) clean
dev-deps:
$(rustup) toolchain install $(nightly)
$(rustup) target add wasm32-unknown-unknown
$(rustup) component add rustfmt clippy miri --toolchain $(nightly)
$(cargo) install cargo-watch unclog wasm-opt
test-miri:
$(cargo) +$(nightly) miri setup
$(cargo) +$(nightly) clean
MIRIFLAGS="-Zmiri-disable-isolation" $(cargo) +$(nightly) miri test
.PHONY : build check build-release clippy install run-ledger run-gossip reset-ledger test test-debug fmt watch clean build-doc doc build-wasm-scripts-docker debug-wasm-scripts-docker build-wasm-scripts debug-wasm-scripts clean-wasm-scripts dev-deps test-miri test-unit bench