forked from parallel-finance/parallel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
195 lines (160 loc) · 8.66 KB
/
Copy pathMakefile
File metadata and controls
195 lines (160 loc) · 8.66 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
PARA_ID := 2085
CHAIN := vanilla-dev
RELAY_CHAIN := kusama-local
RUNTIME := vanilla-runtime
BLOCK_AT := 0x0000000000000000000000000000000000000000000000000000000000000000
URL := ws://localhost:9948
RELAY_URL := ws://localhost:9944
KEYSTORE_PATH := keystore
SURI := //Alice
LAUNCH_CONFIG_YAML := config.yml
LAUNCH_CONFIG_JSON := config.json
DOCKER_TAG := latest
RELAY_DOCKER_TAG := v0.9.16
.PHONY: init
init: submodules
git config advice.ignoredHook false
git config core.hooksPath .githooks
rustup target add wasm32-unknown-unknown
cd scripts/helper && yarn
cd scripts/polkadot-launch && yarn
.PHONY: submodules
submodules:
git submodule update --init --recursive
git submodule foreach git pull origin master
.PHONY: build
build:
cargo build --bin parallel
.PHONY: ci
ci: check lint check-helper check-wasm test
.PHONY: check
check:
SKIP_WASM_BUILD= cargo check --all-targets --features runtime-benchmarks --features try-runtime
.PHONY: check-wasm
check-wasm:
cargo check -p vanilla-runtime -p kerria-runtime -p parallel-runtime -p heiko-runtime --features runtime-benchmarks
.PHONY: check-helper
check-helper:
cd scripts/helper && yarn && yarn build
.PHONY: test
test:
SKIP_WASM_BUILD= cargo test --workspace --features runtime-benchmarks --exclude parallel --exclude parallel-runtime --exclude vanilla-runtime --exclude kerria-runtime --exclude heiko-runtime --exclude pallet-loans-rpc --exclude pallet-loans-rpc-runtime-api --exclude parallel-primitives -- --nocapture
.PHONY: bench
bench: bench-loans bench-liquid-staking bench-amm bench-amm-router bench-crowdloans bench-bridge bench-xcm-helper bench-farming
./scripts/benchmark.sh
.PHONY: bench-farming
bench-farming:
cargo run --release --features runtime-benchmarks -- benchmark --chain=$(CHAIN) --execution=wasm --wasm-execution=compiled --pallet=pallet-farming --extrinsic='*' --steps=50 --repeat=20 --heap-pages=4096 --template=./.maintain/frame-weight-template.hbs --output=./pallets/farming/src/weights.rs
.PHONY: bench-loans
bench-loans:
cargo run --release --features runtime-benchmarks -- benchmark --chain=$(CHAIN) --execution=wasm --wasm-execution=compiled --pallet=pallet-loans --extrinsic='*' --steps=50 --repeat=20 --heap-pages=4096 --template=./.maintain/frame-weight-template.hbs --output=./pallets/loans/src/weights.rs
.PHONY: bench-crowdloans
bench-crowdloans:
cargo run --release --features runtime-benchmarks -- benchmark --chain=$(CHAIN) --execution=wasm --wasm-execution=compiled --pallet=pallet-crowdloans --extrinsic='*' --steps=50 --repeat=20 --heap-pages=4096 --template=./.maintain/frame-weight-template.hbs --output=./pallets/crowdloans/src/weights.rs
.PHONY: bench-bridge
bench-bridge:
cargo run --release --features runtime-benchmarks -- benchmark --chain=$(CHAIN) --execution=wasm --wasm-execution=compiled --pallet=pallet-bridge --extrinsic='*' --steps=50 --repeat=20 --heap-pages=4096 --template=./.maintain/frame-weight-template.hbs --output=./pallets/bridge/src/weights.rs
.PHONY: bench-xcm-helper
bench-xcm-helper:
cargo run --release --features runtime-benchmarks -- benchmark --chain=$(CHAIN) --execution=wasm --wasm-execution=compiled --pallet=pallet-xcm-helper --extrinsic='*' --steps=50 --repeat=20 --heap-pages=4096 --template=./.maintain/frame-weight-template.hbs --output=./pallets/xcm-helper/src/weights.rs
.PHONY: bench-amm
bench-amm:
cargo run --release --features runtime-benchmarks -- benchmark --chain=$(CHAIN) --execution=wasm --wasm-execution=compiled --pallet=pallet-amm --extrinsic='*' --steps=50 --repeat=20 --heap-pages=4096 --template=./.maintain/frame-weight-template.hbs --output=./pallets/amm/src/weights.rs
.PHONY: bench-liquid-staking
bench-liquid-staking:
cargo run --release --features runtime-benchmarks -- benchmark --chain=$(CHAIN) --execution=wasm --wasm-execution=compiled --pallet=pallet-liquid-staking --extrinsic='*' --steps=50 --repeat=20 --heap-pages=4096 --template=./.maintain/frame-weight-template.hbs --output=./pallets/liquid-staking/src/weights.rs
.PHONY: bench-amm-router
bench-amm-router:
cargo run --release --features runtime-benchmarks -- benchmark --chain=$(CHAIN) --execution=wasm --wasm-execution=compiled --pallet=pallet-router --extrinsic='*' --steps=50 --repeat=20 --heap-pages=4096 --template=./.maintain/frame-weight-template.hbs --output=./pallets/router/src/weights.rs
.PHONY: lint
lint:
SKIP_WASM_BUILD= cargo fmt --all -- --check
SKIP_WASM_BUILD= cargo clippy --workspace --features runtime-benchmarks --exclude parallel -- -D dead_code -A clippy::derivable_impls -A clippy::explicit_counter_loop -A clippy::unnecessary_cast -A clippy::unnecessary_mut_passed -A clippy::too_many_arguments -A clippy::type_complexity -A clippy::identity_op -D warnings
cd scripts/helper && yarn format -c && yarn lint
.PHONY: fix
fix:
SKIP_WASM_BUILD= cargo fix --all-targets --allow-dirty --allow-staged
.PHONY: fmt
fmt:
SKIP_WASM_BUILD= cargo fmt --all
cd scripts/helper && yarn format
.PHONY: resources
resources:
docker run --rm parallelfinance/parallel:$(DOCKER_TAG) export-genesis-state --chain $(CHAIN) > ./resources/para-$(PARA_ID)-genesis
docker run --rm parallelfinance/parallel:$(DOCKER_TAG) export-genesis-wasm --chain $(CHAIN) > ./resources/para-$(PARA_ID).wasm
.PHONY: shutdown
shutdown:
pkill parallel || true
pkill polkadot || true
docker-compose \
-f output/docker-compose.yml \
-f output/docker-compose.override.yml \
down \
--remove-orphans > /dev/null 2>&1 || true
rm -fr output || true
rm -fr data || true
docker volume prune -f
.PHONY: launch
launch: shutdown
yq -i eval '.relaychain.image = "parallelfinance/polkadot:$(RELAY_DOCKER_TAG)"' $(LAUNCH_CONFIG_YAML)
yq -i eval '.relaychain.chain = "$(RELAY_CHAIN)"' $(LAUNCH_CONFIG_YAML)
yq -i eval '.parachains[0].image = "parallelfinance/parallel:$(DOCKER_TAG)"' $(LAUNCH_CONFIG_YAML)
yq -i eval '.parachains[0].id = $(PARA_ID)' $(LAUNCH_CONFIG_YAML)
yq -i eval '.parachains[0].chain.base = "$(CHAIN)"' $(LAUNCH_CONFIG_YAML)
docker image pull parallelfinance/polkadot:$(RELAY_DOCKER_TAG)
docker image pull parallelfinance/parallel:$(DOCKER_TAG)
docker image pull parallelfinance/stake-client:latest
docker image pull parallelfinance/liquidation-client:latest
docker image pull parallelfinance/nominate-client:latest
docker image pull parallelfinance/oracle-client:latest
docker image pull parallelfinance/parallel-dapp:latest
parachain-launch generate $(LAUNCH_CONFIG_YAML) \
&& (cp -r keystore* output || true) \
&& cp docker-compose.override.yml output \
&& cd output \
&& DOCKER_CLIENT_TIMEOUT=180 COMPOSE_HTTP_TIMEOUT=180 docker-compose up -d --build
cd scripts/helper && yarn start launch --network $(CHAIN)
.PHONY: launch-kerria
launch-kerria:
make PARA_ID=2012 CHAIN=kerria-dev RELAY_CHAIN=polkadot-local launch
.PHONY: dev-launch
dev-launch: shutdown
yq -i eval '.relaychain.chain = "$(RELAY_CHAIN)"' $(LAUNCH_CONFIG_JSON) -j
yq -i eval '.parachains[0].id = $(PARA_ID)' $(LAUNCH_CONFIG_JSON) -j
yq -i eval '.parachains[0].chain = "$(CHAIN)"' $(LAUNCH_CONFIG_JSON) -j
ts-node scripts/polkadot-launch/src/cli.ts config.json
.PHONY: dev-launch-kerria
dev-launch-kerria:
make PARA_ID=2012 CHAIN=kerria-dev RELAY_CHAIN=polkadot-local dev-launch
.PHONY: logs
logs:
docker-compose -f output/docker-compose.yml logs -f
.PHONY: wasm
wasm:
PACKAGE=$(RUNTIME) ./scripts/srtool-build.sh
.PHONY: spec
spec:
docker run --rm parallelfinance/parallel:$(DOCKER_TAG) build-spec --chain $(CHAIN) --disable-default-bootnode --raw > ./resources/$(CHAIN)-raw.json
.PHONY: image
image:
docker build --build-arg BIN=parallel \
-c 512 \
-t parallelfinance/parallel:$(DOCKER_TAG) \
-f Dockerfile.release \
. --network=host
.PHONY: key
key:
docker run --rm parallelfinance/parallel:$(DOCKER_TAG) key generate-node-key
.PHONY: keystore
keystore:
cargo run --bin parallel key insert -d . --keystore-path $(KEYSTORE_PATH) --suri "$(SURI)" --key-type aura
cargo run --bin parallel key insert -d . --keystore-path $(KEYSTORE_PATH) --suri "$(SURI)" --key-type gran
cargo run --bin parallel key insert -d . --keystore-path $(KEYSTORE_PATH) --suri "$(SURI)" --key-type babe
.PHONY: snapshot
snapshot:
cargo run --bin parallel --features try-runtime -- try-runtime --chain $(CHAIN) --wasm-execution=compiled on-runtime-upgrade live -a=$(BLOCK_AT) -u=$(URL) -s=snapshot.bin
.PHONY: try-runtime-upgrade
try-runtime-upgrade:
RUST_LOG=debug cargo run --bin parallel --features try-runtime -- try-runtime --chain $(CHAIN) --wasm-execution=compiled on-runtime-upgrade snap -s snapshot.bin
help:
@grep -E '^[a-zA-Z_-]+:.*?' Makefile | cut -d: -f1 | sort