forked from anoma/namada
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
257 lines (202 loc) · 6.9 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
package = namada
# Some env vars defaults if not specified
NAMADA_E2E_USE_PREBUILT_BINARIES ?= true
NAMADA_E2E_DEBUG ?= true
RUST_BACKTRACE ?= 1
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_encoding_spec
crates += namada_macros
crates += namada_proof_of_stake
crates += namada_test_utils
crates += namada_tests
crates += namada_tx_prelude
crates += namada_vm_env
crates += namada_vp_prelude
build:
$(cargo) build $(jobs)
build-test:
$(cargo) +$(nightly) build --tests $(jobs)
build-release:
NAMADA_DEV=false $(cargo) build $(jobs) --release --package namada_apps --manifest-path Cargo.toml
build-debug:
NAMADA_DEV=false $(cargo) build --package namada_apps --manifest-path Cargo.toml
install-release:
NAMADA_DEV=false $(cargo) install --path ./apps --locked
check-release:
NAMADA_DEV=false $(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 && \
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
check-crates:
$(foreach p,$(crates), echo "Checking $(p)" && cargo +$(nightly) check -Z unstable-options --tests -p $(p) && ) \
make -C $(wasms_for_tests) check
clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets -- -D warnings
clippy:
NAMADA_DEV=false $(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
NAMADA_DEV=false $(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
# Unit tests with coverage report
test-coverage:
$(cargo) +$(nightly) llvm-cov --output-dir target \
--features namada/testing \
--html \
-- --skip e2e --skip 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
test-integration:
RUST_BACKTRACE=$(RUST_BACKTRACE) \
$(cargo) +$(nightly) test integration::$(TEST_FILTER) \
-Z unstable-options \
-- \
-Z unstable-options --report-time
test-unit:
$(cargo) +$(nightly) test \
$(TEST_FILTER) \
$(jobs) \
-- --skip e2e --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 \
--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
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
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
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