forked from matter-labs/zksync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
288 lines (198 loc) · 7.02 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
export IMAGE_TAG = $(shell git rev-parse --short HEAD)
export SERVER_DOCKER_IMAGE ?=matterlabs/server:$(IMAGE_TAG)
export SERVER_DOCKER_IMAGE_LATEST ?=matterlabs/server:latest
export PROVER_DOCKER_IMAGE ?=matterlabs/prover:$(IMAGE_TAG)
export PROVER_DOCKER_IMAGE_LATEST ?=matterlabs/prover:latest
export NGINX_DOCKER_IMAGE ?= matterlabs/nginx:$(IMAGE_TAG)
export NGINX_DOCKER_IMAGE_LATEST ?= matterlabs/nginx:latest
export GETH_DOCKER_IMAGE ?= matterlabs/geth:latest
export DEV_TICKER_DOCKER_IMAGE ?= matterlabs/dev-ticker:latest
export KEYBASE_DOCKER_IMAGE ?= matterlabs/keybase-secret:latest
export CI_DOCKER_IMAGE ?= matterlabs/ci
# Getting started
# Check and change environment (listed here for autocomplete and documentation only)
# next two target are hack that allows to pass arguments to makefile
env:
@bin/zkenv $(filter-out $@,$(MAKECMDGOALS))
%:
@:
# Get everything up and running for the first time
init:
@bin/init
yarn:
@cd sdk/zksync-crypto
@cd sdk/zksync.js && yarn && yarn build
@cd infrastructure/explorer && yarn
@cd contracts && yarn
@cd core/tests/ts-tests && yarn
# Helpers
# This will prompt user to confirm an action on production environment
confirm_action:
@bin/.confirm_action
rust-checks:
cargo fmt -- --check
@find core/ -type f -name "*.rs" -exec touch {} +
cargo clippy --tests --benches -- -D warnings
# Database tools
sql = psql "$(DATABASE_URL)" -c
db-test:
@bin/db-test.sh reset
db-test-no-reset:
@bin/db-test.sh no-reset
db-setup:
@bin/db-setup
db-insert-contract:
@bin/db-insert-contract.sh
db-insert-eth-data:
@bin/db-insert-eth-data.sh
db-reset: confirm_action db-wait db-drop db-setup db-insert-contract db-insert-eth-data
@echo database is ready
db-migrate: confirm_action
@cd core/storage && diesel migration run
db-drop: confirm_action
@# this is used to clear the produciton db; cannot do `diesel database reset` because we don't own the db
@echo DATABASE_URL=$(DATABASE_URL)
@$(sql) 'DROP OWNED BY CURRENT_USER CASCADE' || \
{ $(sql) 'DROP SCHEMA IF EXISTS public CASCADE' && $(sql)'CREATE SCHEMA public'; }
db-wait:
@bin/db-wait
genesis: confirm_action db-reset
@bin/genesis.sh
# Frontend clients
client:
@cd js/client && yarn serve
explorer:
@cd js/explorer && yarn serve
dist-client: yarn build-contracts
@cd js/client && yarn build
dist-explorer: yarn build-contracts
@cd js/explorer && yarn build
image-nginx: dist-client dist-explorer
@docker build -t "${NGINX_DOCKER_IMAGE}" -t "${NGINX_DOCKER_IMAGE_LATEST}" -f ./docker/nginx/Dockerfile .
push-image-nginx: image-nginx
docker push "${NGINX_DOCKER_IMAGE}"
docker push "${NGINX_DOCKER_IMAGE_LATEST}"
image-ci:
@docker build -t "${CI_DOCKER_IMAGE}" -f ./docker/ci/Dockerfile .
push-image-ci: image-ci
docker push "${CI_DOCKER_IMAGE}"
image-keybase:
@docker build -t "${KEYBASE_DOCKER_IMAGE}" -f ./docker/keybase-secrets/Dockerfile .
push-image-keybase: image-keybase
docker push "${KEYBASE_DOCKER_IMAGE}"
# Rust: main stuff
server:
@cargo run --bin server --release
sandbox:
@cargo run --bin sandbox
image-server: build-contracts build-dev-contracts
@DOCKER_BUILDKIT=1 docker build -t "${SERVER_DOCKER_IMAGE}" -t "${SERVER_DOCKER_IMAGE_LATEST}" -f ./docker/server/Dockerfile .
image-prover: build-contracts build-dev-contracts
@DOCKER_BUILDKIT=1 docker build -t "${PROVER_DOCKER_IMAGE}" -t "${PROVER_DOCKER_IMAGE_LATEST}" -f ./docker/prover/Dockerfile .
image-rust: image-server image-prover
push-image-server:
docker push "${SERVER_DOCKER_IMAGE}"
docker push "${SERVER_DOCKER_IMAGE_LATEST}"
push-image-prover:
docker push "${PROVER_DOCKER_IMAGE}"
docker push "${PROVER_DOCKER_IMAGE_LATEST}"
push-image-rust: image-rust push-image-server push-image-prover
# Contracts
deploy-contracts: confirm_action build-contracts
@bin/deploy-contracts.sh
publish-contracts:
@bin/publish-contracts.sh
test-contracts: confirm_action build-contracts
@bin/contracts-test.sh
build-dev-contracts: confirm_action prepare-verify-contracts
@bin/prepare-test-contracts.sh
@cd contracts && yarn build-dev
prepare-verify-contracts:
@cp ${KEY_DIR}/account-${ACCOUNT_TREE_DEPTH}_balance-${BALANCE_TREE_DEPTH}/KeysWithPlonkVerifier.sol contracts/contracts/ || (echo "please download keys" && exit 1)
build-contracts: confirm_action prepare-verify-contracts
@cargo run --release --bin gen_token_add_contract
@cd contracts && yarn build
# testing
ci-check:
@ci-check.sh
integration-testkit:
@bin/integration-testkit.sh
integration-simple:
@cd core/tests/ts-tests && yarn && yarn simple $(filter-out $@,$(MAKECMDGOALS))
integration-full-exit:
@cd core/tests/ts-tests && yarn && yarn full-exit
price:
@node contracts/scripts/check-price.js
prover-tests:
f cargo test -p prover --release -- --ignored
# Devops: main
# Promote build
promote-to-stage:
@bin/promote-to.sh stage $(ci-build)
promote-to-rinkeby:
# TODO: change testnet to rinkeby with #447 issue.
@bin/promote-to.sh testnet $(ci-build)
promote-to-ropsten:
@bin/promote-to.sh ropsten $(ci-build)
# (Re)deploy contracts and database
redeploy: confirm_action stop init-deploy
init-deploy: confirm_action deploy-contracts db-insert-contract publish-contracts
update-images: push-image-rust push-image-nginx
update-kubeconfig:
@bin/k8s-gen-resource-definitions
@bin/k8s-apply
ifeq (dev,$(ZKSYNC_ENV))
start:
else
start: start-provers start-server start-nginx
endif
ifeq (dev,$(ZKSYNC_ENV))
stop:
else ifeq (ci,$(ZKSYNC_ENV))
stop:
else
stop: confirm_action stop-provers stop-server stop-nginx
endif
restart: stop start
start-provers:
@bin/kube scale deployments/prover --namespace $(ZKSYNC_ENV) --replicas=1
start-nginx:
@bin/kube scale deployments/nginx --namespace $(ZKSYNC_ENV) --replicas=1
start-server:
@bin/kube scale deployments/server --namespace $(ZKSYNC_ENV) --replicas=1
stop-provers:
@bin/kube scale deployments/prover --namespace $(ZKSYNC_ENV) --replicas=0
stop-server:
@bin/kube scale deployments/server --namespace $(ZKSYNC_ENV) --replicas=0
stop-nginx:
@bin/kube scale deployments/nginx --namespace $(ZKSYNC_ENV) --replicas=0
# Monitoring
log-server:
kubectl logs -f deployments/server --namespace $(ZKSYNC_ENV)
log-prover:
kubectl logs --tail 300 -f deployments/prover --namespace $(ZKSYNC_ENV)
# Kubernetes: monitoring shortcuts
pods:
kubectl get pods -o wide --namespace $(ZKSYNC_ENV) | grep -v Pending
nodes:
kubectl get nodes -o wide
# Dev environment
dev-up:
@docker-compose up -d postgres geth dev-ticker
@docker-compose up -d tesseracts
dev-down:
@docker-compose stop tesseracts
@docker-compose stop postgres geth dev-ticker
geth-up: geth
@docker-compose up geth
# Auxillary docker containers for dev environment (usually no need to build, just use images from dockerhub)
dev-build-geth:
@docker build -t "${GETH_DOCKER_IMAGE}" ./docker/geth
dev-push-geth:
@docker push "${GETH_DOCKER_IMAGE}"
image-dev-ticker:
@docker build -t "${DEV_TICKER_DOCKER_IMAGE}" -f ./docker/dev-ticker/Dockerfile .
push-image-dev-ticker: image-dev-ticker
@docker push "${DEV_TICKER_DOCKER_IMAGE}"
api-type-validate:
@cd core/tests/ts-tests && yarn && yarn api-type-validate --test