-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
382 lines (293 loc) · 11.6 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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
#
#
#
all: fmt lint build_release_goleveldb
export CARGO_NET_GIT_FETCH_WITH_CLI = true
export STATIC_CHAIN_DEV_BASE_DIR_SUFFIX = findora
export STAKING_INITIAL_VALIDATOR_CONFIG := $(shell pwd)/src/ledger/src/staking/init/staking_config.json
export STAKING_INITIAL_VALIDATOR_CONFIG_DEBUG_ENV := $(shell pwd)/src/ledger/src/staking/init/staking_config_debug_env.json
FIN_DEBUG ?= /tmp/findora
export ENABLE_QUERY_SERVICE = true
EXTERNAL_ADDRESS = ""
ifndef CARGO_TARGET_DIR
export CARGO_TARGET_DIR=target
endif
$(info ====== Build root is "$(CARGO_TARGET_DIR)" ======)
bin_dir = bin
lib_dir = lib
subdirs = $(bin_dir) $(lib_dir)
WASM_PKG = wasm.tar.gz
lib_files = ./$(WASM_PKG)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
CP := cp --remove-destination
else
CP := cp -f
endif
define pack
- rm -rf $(1)
mkdir $(1)
cd $(1); for i in $(subdirs); do mkdir $$i; done
$(CP) \
${CARGO_TARGET_DIR}/$(2)/$(1)/findorad \
${CARGO_TARGET_DIR}/$(2)/$(1)/abcid \
${CARGO_TARGET_DIR}/$(2)/$(1)/fn \
${CARGO_TARGET_DIR}/$(2)/$(1)/stt \
${CARGO_TARGET_DIR}/$(2)/$(1)/staking_cfg_generator \
$(shell go env GOPATH)/bin/tendermint \
$(1)/$(bin_dir)/
$(CP) $(1)/$(bin_dir)/* ~/.cargo/bin/
cd $(1)/$(bin_dir)/ && ./findorad pack
$(CP) /tmp/findorad $(1)/$(bin_dir)/
$(CP) /tmp/findorad ~/.cargo/bin/
endef
install: stop_all build_release_goleveldb
$(CP) release/bin/* /usr/local/bin/
bash -x tools/systemd_services/install.sh $(EXTERNAL_ADDRESS)
stop_all:
- pkill -9 abcid
- pkill -9 tendermint
- pkill -9 findorad
# Release binaries for Nightly
rls:
cargo build --release --features debug_env --bins -p abciapp -p finutils
# Build for cleveldb
build: tendermint_cleveldb
cargo build --bins -p abciapp -p finutils
$(call pack,debug)
# Build for cleveldb
build_release: tendermint_cleveldb
cargo build --release --bins -p abciapp -p finutils
$(call pack,release)
# Build for goleveldb
build_goleveldb: tendermint_goleveldb
cargo build --bins -p abciapp -p finutils
$(call pack,debug)
# Build for goleveldb
build_release_goleveldb: tendermint_goleveldb
cargo build --release --bins -p abciapp -p finutils
$(call pack,release)
# Build for goleveldb
build_release_musl_goleveldb: tendermint_goleveldb
cargo build --release --bins -p abciapp -p finutils --target=x86_64-unknown-linux-musl
$(call pack,release,x86_64-unknown-linux-musl)
build_release_debug: tendermint_goleveldb
cargo build --features="debug_env" --release --bins -p abciapp -p finutils
$(call pack,release)
build_bench_release: tendermint_goleveldb
cargo build --features="debug_env benchmark" --release --bins -p abciapp -p finutils
$(call pack,release)
tendermint_cleveldb:
- rm -f $(shell which tendermint)
bash tools/download_tendermint.sh 'tools/tendermint'
mkdir -p $(shell go env GOPATH)/bin
cd tools/tendermint \
&& $(MAKE) build TENDERMINT_BUILD_OPTIONS=cleveldb \
&& cp build/tendermint $(shell go env GOPATH)/bin/
tendermint_goleveldb:
- rm -f $(shell which tendermint)
bash tools/download_tendermint.sh 'tools/tendermint'
cd tools/tendermint && $(MAKE) install
test: checkpoint_cleanup
cargo test --release --workspace -- --test-threads=1 # --nocapture
coverage:
cargo tarpaulin --timeout=900 --branch --workspace --release \
|| cargo install cargo-tarpaulin \
&& cargo tarpaulin --timeout=900 --branch --workspace --release
staking_cfg:
bash tools/update_staking_cfg.sh
staking_cfg_debug:
bash tools/update_staking_cfg_debug.sh
bench:
cargo bench --workspace
bench_50k: stop_all checkpoint_cleanup build_bench_release
bash tools/benchutils/bench.sh 50000
bench_100k: stop_all checkpoint_cleanup build_bench_release
bash tools/benchutils/bench.sh 100000
bench_200k: stop_all checkpoint_cleanup build_bench_release
bash tools/benchutils/bench.sh 200000
dbench_50k: stop_all checkpoint_cleanup build_bench_release
ifeq ($(FN_DDEV_HOSTS),)
@ echo '$$FN_DDEV_HOSTS not set!'
@ exit 1
endif
bash tools/benchutils/bench.sh 50000 y
dbench_100k: stop_all checkpoint_cleanup build_bench_release
ifeq ($(FN_DDEV_HOSTS),)
@ echo '$$FN_DDEV_HOSTS not set!'
@ exit 1
endif
bash tools/benchutils/bench.sh 100000 y
dbench_200k: stop_all checkpoint_cleanup build_bench_release
ifeq ($(FN_DDEV_HOSTS),)
@ echo '$$FN_DDEV_HOSTS not set!'
@ exit 1
endif
bash tools/benchutils/bench.sh 200000 y
checkpoint_cleanup:
- find src -name "checkpoint.toml" | xargs rm -f
- find src -name "checkpoint.json" | xargs rm -f
- find tools -name "checkpoint.toml" | xargs rm -f
- find tools -name "checkpoint.json" | xargs rm -f
lint:
cargo clippy --workspace
cargo clippy --workspace --no-default-features
cargo clippy --workspace --tests
update:
git submodule update --recursive --init
rustup update stable
cargo update
fmt:
cargo fmt
fmtall:
bash ./tools/fmt.sh
clean:
cargo clean
rm -rf debug release
cleanall: clean
rm -rf tools/tendermint .git/modules/tools/tendermint
git clean -fdx
wasm:
cd src/components/wasm && wasm-pack build
tar -zcpf $(WASM_PKG) src/components/wasm/pkg
debug_env: stop_debug_env build_release_debug
- rm -f checkpoint.toml
- rm -rf $(FIN_DEBUG)
mkdir $(FIN_DEBUG)
cp tools/debug_env.tar.gz $(FIN_DEBUG)/
cd $(FIN_DEBUG) && tar -xpf debug_env.tar.gz && mv debug_env devnet
fn setup -S 'http://localhost'
./tools/devnet/startnodes.sh
run_staking_demo: stop_debug_env
bash tools/staking/demo.sh
start_debug_env:
bash ./tools/devnet/startnodes.sh
stop_debug_env:
bash ./tools/devnet/stopnodes.sh
join_debug_env: stop_debug_env build_release_debug
bash tools/node_init.sh debug_env
join_qa01: stop_debug_env build_release_goleveldb
bash tools/node_init.sh qa01
join_qa02: stop_debug_env build_release_goleveldb
bash tools/node_init.sh qa02
join_qa03: stop_debug_env build_release_goleveldb
bash tools/node_init.sh qa03
join_testnet: stop_debug_env build_release_goleveldb
bash tools/node_init.sh testnet
join_mainnet: stop_debug_env build_release_goleveldb
bash tools/node_init.sh mainnet
start_localnode: stop_debug_env
bash -x tools/node_init.sh _ _
# ci_build_image:
# @if [ ! -d "release/bin/" ] && [ -d "debug/bin" ]; then \
# mkdir -p release/bin/; \
# cp debug/bin/findorad release/bin/; \
# fi
# docker build -t $(ECR_URL)/$(ENV)/abci_validator_node:$(IMAGE_TAG) -f container/Dockerfile-CI-abci_validator_node .
# ifeq ($(ENV),release)
# docker tag $(ECR_URL)/$(ENV)/abci_validator_node:$(IMAGE_TAG) $(ECR_URL)/$(ENV)/findorad:latest
# endif
# ci_push_image:
# docker push $(ECR_URL)/$(ENV)/abci_validator_node:$(IMAGE_TAG)
# ifeq ($(ENV),release)
# docker push $(ECR_URL)/$(ENV)/abci_validator_node:latest
# endif
# clean_image:
# docker rmi $(ECR_URL)/$(ENV)/abci_validator_node:$(IMAGE_TAG)
# ifeq ($(ENV),release)
# docker rmi $(ECR_URL)/$(ENV)/abci_validator_node:latest
# endif
ci_build_binary_rust_base:
docker build -t binary-rust-base -f container/Dockerfile-binary-rust-base .
ci_build_dev_binary_image:
sed -i "s/^ENV VERGEN_SHA_EXTERN .*/ENV VERGEN_SHA_EXTERN ${VERGEN_SHA_EXTERN}/g" container/Dockerfile-binary-image-dev
docker build -t findorad-binary-image:$(IMAGE_TAG) -f container/Dockerfile-binary-image-dev .
ci_build_image:
@ if [ -d "./binary" ]; then \
rm -rf ./binary || true; \
fi
@ docker run --rm -d --name findorad-binary findorad-binary-image:$(IMAGE_TAG)
@ docker cp findorad-binary:/binary ./binary
@ docker rm -f findorad-binary
@ docker build -t $(PUBLIC_ECR_URL)/$(ENV)/findorad:$(IMAGE_TAG) -f container/Dockerfile-goleveldb .
# ========================== dev ARM64/v8 ===========================
ci_build_dev_binary_image_arm:
sed -i "s/^ENV VERGEN_SHA_EXTERN .*/ENV VERGEN_SHA_EXTERN ${VERGEN_SHA_EXTERN}/g" container/Dockerfile-binary-image-dev-arm
docker buildx build --platform linux/arm64/v8 --output=type=docker -t findorad-binary-image:$(IMAGE_TAG) -f container/Dockerfile-binary-image-dev-arm .
ci_build_image_arm:
@ if [ -d "./binary" ]; then \
rm -rf ./binary || true; \
fi
@ docker run --rm -d --name findorad-binary findorad-binary-image:$(IMAGE_TAG)
@ docker cp findorad-binary:/binary ./binary
@ docker rm -f findorad-binary
# @ docker build -t $(PUBLIC_ECR_URL)/$(ENV)/findorad:$(IMAGE_TAG) -f container/Dockerfile-goleveldb .
@ docker buildx build --platform linux/arm64/v8 --output=type=docker -t $(PUBLIC_ECR_URL)/$(ENV)/findorad:$(IMAGE_TAG) -f container/Dockerfile-goleveldb-arm .
# ========================== release AMD64 ===========================
ci_build_release_binary_image:
sed -i "s/^ENV VERGEN_SHA_EXTERN .*/ENV VERGEN_SHA_EXTERN ${VERGEN_SHA_EXTERN}/g" container/Dockerfile-binary-image-release
docker build -t findorad-binary-image:$(IMAGE_TAG) -f container/Dockerfile-binary-image-release .
ci_build_image_dockerhub:
@ if [ -d "./binary" ]; then \
rm -rf ./binary || true; \
fi
@ docker run --rm -d --name findorad-binary findorad-binary-image:$(IMAGE_TAG)
@ docker cp findorad-binary:/binary ./binary
@ docker rm -f findorad-binary
@ docker buildx build --platform linux/amd64 -t $(DOCKERHUB_URL)/findorad:$(IMAGE_TAG) -f container/Dockerfile-goleveldb . --push
# ========================== release ARM64/v8 ===========================
ci_build_release_binary_image_arm:
docker run --rm --privileged tonistiigi/binfmt:latest --install all
sed -i "s/^ENV VERGEN_SHA_EXTERN .*/ENV VERGEN_SHA_EXTERN ${VERGEN_SHA_EXTERN}/g" container/Dockerfile-binary-image-release-arm
docker buildx build --platform linux/arm64/v8 --output=type=docker -t findorad-binary-image:$(IMAGE_TAG) -f container/Dockerfile-binary-image-release-arm .
ci_build_image_dockerhub_arm:
@ if [ -d "./binary" ]; then \
rm -rf ./binary || true; \
fi
@ docker run --rm -d --name findorad-binary findorad-binary-image:$(IMAGE_TAG)
@ docker cp findorad-binary:/binary ./binary
@ docker rm -f findorad-binary
@ docker run --rm --privileged tonistiigi/binfmt:latest --install all
@ docker buildx build --platform linux/arm64/v8 -t $(DOCKERHUB_URL)/findorad:$(IMAGE_TAG) -f container/Dockerfile-goleveldb-arm . --push
# ========================== push image and clean up===========================
ci_push_image:
docker push $(PUBLIC_ECR_URL)/$(ENV)/findorad:$(IMAGE_TAG)
clean_image:
docker rmi $(PUBLIC_ECR_URL)/$(ENV)/findorad:$(IMAGE_TAG)
ci_push_image_dockerhub:
docker push $(DOCKERHUB_URL)/findorad:$(IMAGE_TAG)
ci_build_wasm_js_bindings:
docker run --rm -d --name wasm -v /tmp/wasm-js-bindings:/build/wasm-js-bindings -v $(shell pwd)/container/docker-entrypoint-wasm-js-bindings.sh:/entrypoint.sh findorad-binary-image:$(IMAGE_TAG) /entrypoint.sh
docker rm -f wasm findorad-binary || true
clean_image_dockerhub:
docker rmi $(DOCKERHUB_URL)/findorad:$(IMAGE_TAG)
clean_binary_dockerhub:
docker rmi findorad-binary-image:$(IMAGE_TAG)
reset:
- rm -f checkpoint.toml
@./tools/devnet/stopnodes.sh
@./tools/devnet/resetnodes.sh 1 1
snapshot:
@./tools/devnet/snapshot.sh
devnet: reset snapshot
# fn build
build_musl_fn_linux:
docker build -t musl_fn_linux -f container/Dockerfile-fn-musl-linux .
docker run -d --rm --name fn_linux musl_fn_linux
docker cp fn_linux:/volume/target/x86_64-unknown-linux-musl/release/fn fn
tar -czvf fn_linux.tar.gz fn
rm fn
build_musl_fn_macos_base:
docker build -t musl_fn_macos_base -f container/Dockerfile-fn-musl-macos-base .
build_musl_fn_macos:
docker build -t musl_fn_macos -f container/Dockerfile-fn-musl-macos .
docker run -d --rm --name fn_macos musl_fn_macos
docker cp fn_macos:/platform/target/x86_64-apple-darwin/release/fn fn
tar -czvf fn_macos.tar.gz fn
rm fn
build_musl_fn_win:
docker build -t musl_fn_win -f container/Dockerfile-fn-musl-windows .
docker run -d --rm --name fn_windows musl_fn_win
docker cp fn_windows:/volume/target/x86_64-pc-windows-gnu/release/fn.exe fn.exe
tar -czvf fn_windows.tar.gz fn.exe
rm fn.exe