forked from FindoraNetwork/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
299 lines (241 loc) · 8.4 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
#
#
#
all: build_release_goleveldb
export CARGO_NET_GIT_FETCH_WITH_CLI = true
export PROTOC = $(shell which protoc)
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
export STAKING_INITIAL_VALIDATOR_CONFIG_ABCI_MOCK = $(shell pwd)/src/ledger/src/staking/init/staking_config_abci_mock.json
export DEBUG_DIR=/tmp/findora
export ENABLE_QUERY_SERVICE = true
ifndef CARGO_TARGET_DIR
export CARGO_TARGET_DIR=target
endif
$(info ====== Build root is "$(CARGO_TARGET_DIR)" ======)
ifdef DBG
target_dir = debug
else
target_dir = release
endif
bin_dir = bin
lib_dir = lib
pick = ${CARGO_TARGET_DIR}/$(target_dir)
subdirs = $(bin_dir) $(lib_dir)
bin_files = \
./$(pick)/findorad \
./$(pick)/abcid \
$(shell go env GOPATH)/bin/tendermint \
./$(pick)/fn \
./$(pick)/stt \
./$(pick)/staking_cfg_generator
WASM_PKG = wasm.tar.gz
lib_files = ./$(WASM_PKG)
define pack
- rm -rf $(target_dir)
mkdir $(target_dir)
cd $(target_dir); for i in $(subdirs); do mkdir $$i; done
cp $(bin_files) $(target_dir)/$(bin_dir)
cp $(target_dir)/$(bin_dir)/* ~/.cargo/bin/
cd $(target_dir)/$(bin_dir)/ && findorad pack
cp -f /tmp/findorad $(target_dir)/$(bin_dir)/
cp -f /tmp/findorad ~/.cargo/bin/
endef
# Build for cleveldb
build: tendermint_cleveldb
ifdef DBG
cargo build --bins -p abciapp -p finutils
$(call pack,$(target_dir))
else
echo -e "\x1b[31;01m\$$(DBG) must be defined !\x1b[00m"
exit 1
endif
# Build for cleveldb
build_release: tendermint_cleveldb
ifdef DBG
echo -e "\x1b[31;01m\$$(DBG) must NOT be defined !\x1b[00m"
exit 1
else
cargo build --release --bins -p abciapp -p finutils
$(call pack,$(target_dir))
endif
# Build for goleveldb
build_goleveldb: tendermint_goleveldb
ifdef DBG
cargo build --bins -p abciapp -p finutils
$(call pack,$(target_dir))
else
echo -e "\x1b[31;01m\$$(DBG) must be defined !\x1b[00m"
exit 1
endif
# Build for goleveldb
build_release_goleveldb: tendermint_goleveldb
ifdef DBG
echo -e "\x1b[31;01m\$$(DBG) must NOT be defined !\x1b[00m"
exit 1
else
cargo build --release --bins -p abciapp -p finutils
$(call pack,$(target_dir))
endif
build_release_debug: tendermint_goleveldb
ifdef DBG
echo -e "\x1b[31;01m\$$(DBG) must NOT be defined !\x1b[00m"
exit 1
else
cargo build --features="debug_env" --release --bins -p abciapp -p finutils
$(call pack,$(target_dir))
endif
tendermint_cleveldb:
- rm $(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 $(shell which tendermint)
bash tools/download_tendermint.sh 'tools/tendermint'
cd tools/tendermint && $(MAKE) install
test:
# cargo test --workspace -- --test-threads=1 # --nocapture
cargo test --release --features="abci_mock" -- --test-threads=1 # --nocapture
coverage:
cargo tarpaulin --timeout=900 --branch --workspace --release --features="abci_mock" \
|| cargo install cargo-tarpaulin \
&& cargo tarpaulin --timeout=900 --branch --workspace --release --features="abci_mock"
staking_cfg:
cargo run --bin staking_cfg_generator
bench:
cargo bench --workspace
lint:
cargo clippy --workspace
cargo clippy --workspace --no-default-features
cargo clippy --features="abci_mock" --workspace --tests
update:
cargo update
fmt:
cargo fmt
fmtall:
bash ./tools/fmt.sh
clean:
cargo clean
rm -rf tools/tendermint .git/modules/tools/tendermint
rm -rf debug release Cargo.lock
cleanall: clean
git clean -fdx
wasm:
cd src/components/wasm && wasm-pack build
tar -zcpf $(WASM_PKG) src/components/wasm/pkg
single:
./tools/devnet/stopnodes.sh
./tools/devnet/resetsingle.sh
./tools/devnet/startsingle.sh
devnet:
./tools/devnet/stopnodes.sh
./tools/devnet/resetnodes.sh 20 1
./tools/devnet/startnodes.sh
debug_env: stop_debug_env build_release_debug
- rm -rf $(DEBUG_DIR)
mkdir $(DEBUG_DIR)
cp tools/debug_env.tar.gz $(DEBUG_DIR)/
cd $(DEBUG_DIR) && tar -xpf debug_env.tar.gz && mv debug_env devnet
./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_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_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 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_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:
@ 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-cleveldb .
ifeq ($(ENV),release)
docker tag $(PUBLIC_ECR_URL)/$(ENV)/findorad:$(IMAGE_TAG) $(PUBLIC_ECR_URL)/$(ENV)/findorad:latest
endif
ci_push_image:
docker push $(PUBLIC_ECR_URL)/$(ENV)/findorad:$(IMAGE_TAG)
ifeq ($(ENV),release)
docker push $(PUBLIC_ECR_URL)/$(ENV)/findorad:latest
endif
clean_image:
docker rmi $(PUBLIC_ECR_URL)/$(ENV)/findorad:$(IMAGE_TAG)
ifeq ($(ENV),release)
docker rmi $(PUBLIC_ECR_URL)/$(ENV)/findorad:latest
endif
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 build -t $(DOCKERHUB_URL)/findorad:$(IMAGE_TAG) -f container/Dockerfile-goleveldb .
ifeq ($(ENV),release)
docker tag $(DOCKERHUB_URL)/findorad:$(IMAGE_TAG) $(DOCKERHUB_URL)/findorad:latest
endif
ci_push_image_dockerhub:
docker push $(DOCKERHUB_URL)/findorad:$(IMAGE_TAG)
ifeq ($(ENV),release)
docker push $(DOCKERHUB_URL)/findorad:latest
endif
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)
ifeq ($(ENV),release)
docker rmi $(DOCKERHUB_URL)/findorad:latest
endif
clean_binary_dockerhub:
docker rmi findorad-binary-image:$(IMAGE_TAG)
####@./tools/devnet/snapshot.sh <user_nick> <password> <token_name> <max_units> <genesis_issuance> <memo> <memo_updatable>
snapshot:
@./tools/devnet/snapshot.sh Findora my_pass FRA 21210000000000000 21000000000000000 my_memo N
network:
@./tools/devnet/startnetwork.sh Findora my_pass FRA 21210000000000000 21000000000000000 my_memo N
####@./tools/devnet/resetnodes.sh <num_of_validator_nodes> <num_of_normal_nodes>
mainnet:
@./tools/devnet/stopnodes.sh
@./tools/devnet/resetnodes.sh 4 4