-
Notifications
You must be signed in to change notification settings - Fork 207
/
Makefile
610 lines (506 loc) Β· 25.7 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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
VERSION ?= $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
# SPID and API_KEY are used for Intel SGX attestation
SPID ?= 00000000000000000000000000000000
API_KEY ?= FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
# Environment variables and build tags setup
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
BUILD_PROFILE ?= release
DEB_BIN_DIR ?= /usr/local/bin
DEB_LIB_DIR ?= /usr/lib
DB_BACKEND ?= goleveldb
SGX_MODE ?= HW
BRANCH ?= develop
DEBUG ?= 0
DOCKER_TAG ?= latest
TM_SGX ?= true
# Paths for contracts and modules
CW_CONTRACTS_V010_PATH = ./cosmwasm/contracts/v010/
CW_CONTRACTS_V1_PATH = ./cosmwasm/contracts/v1/
TEST_CONTRACT_V010_PATH = ./cosmwasm/contracts/v010/compute-tests
TEST_CONTRACT_V1_PATH = ./cosmwasm/contracts/v1/compute-tests
TEST_COMPUTE_MODULE_PATH = ./x/compute/internal/keeper/testdata/
ENCLAVE_PATH = cosmwasm/enclaves/
EXECUTE_ENCLAVE_PATH = $(ENCLAVE_PATH)/execute/
# Determine if Docker Buildx is available for multi-platform builds
DOCKER_BUILD_ARGS ?=
DOCKER_BUILDX_CHECK = $(@shell docker build --load test)
ifeq (Building,$(findstring Building,$(DOCKER_BUILDX_CHECK)))
DOCKER_BUILD_ARGS += "--load"
endif
# Check and set the SGX_MODE to either HW or SW, error if not set
ifeq ($(SGX_MODE), HW)
ext := hw
else ifeq ($(SGX_MODE), SW)
ext := sw
else
$(error SGX_MODE must be either HW or SW)
endif
# Set CGO flags based on the selected database backend (unused - currently only cleveldb is supported)
ifeq ($(DB_BACKEND), rocksdb)
DB_BACKEND = rocksdb
DOCKER_CGO_LDFLAGS = "-L/usr/lib/x86_64-linux-gnu/ -lrocksdb -lstdc++ -llz4 -lm -lz -lbz2 -lsnappy"
DOCKER_CGO_FLAGS = "-I/opt/rocksdb/include"
else ifeq ($(DB_BACKEND), cleveldb)
DB_BACKEND = cleveldb
else ifeq ($(DB_BACKEND), goleveldb)
DB_BACKEND = goleveldb
DOCKER_CGO_LDFLAGS = ""
else
$(error DB_BACKEND must be one of: rocksdb/cleveldb/goleveldb)
endif
CUR_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# Build tags setup for various configurations like ledger, database, etc.
build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error "gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false")
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning "OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)")
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error "gcc not installed for ledger support, please install or set LEDGER_ENABLED=false")
else
build_tags += ledger
endif
endif
endif
endif
IAS_BUILD = sw
ifeq ($(SGX_MODE), HW)
ifneq (,$(findstring production,$(FEATURES)))
IAS_BUILD = production
else
IAS_BUILD = develop
endif
build_tags += hw
build_tags += sgx
else
ifeq ($(TM_SGX), true)
build_tags += sgx
endif
endif
build_tags += $(IAS_BUILD)
ifeq ($(DB_BACKEND),rocksdb)
build_tags += gcc
endif
ifeq ($(DB_BACKEND),cleveldb)
build_tags += gcc
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
# Linker flags to embed version information and other metadata into the binaries
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=SecretNetwork \
-X github.com/cosmos/cosmos-sdk/version.AppName=secretd \
-X github.com/scrtlabs/SecretNetwork/cmd/secretcli/version.ClientName=secretcli \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags)"
ifeq ($(DB_BACKEND),cleveldb)
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ifeq ($(DB_BACKEND),rocksdb)
CGO_ENABLED=1
build_tags += rocksdb
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb
ldflags += -extldflags "-lrocksdb -llz4"
endif
ldflags += -s -w
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
GO_TAGS := $(build_tags)
# -ldflags
LD_FLAGS := $(ldflags)
all: build_all
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify
# Build the CLI tool
build_cli:
go build -o secretcli -mod=readonly -tags "$(filter-out sgx, $(GO_TAGS)) secretcli" -ldflags '$(LD_FLAGS)' ./cmd/secretd
xgo_build_secretcli: go.sum
xgo --targets $(XGO_TARGET) -tags="$(filter-out sgx, $(GO_TAGS)) secretcli" -ldflags '$(LD_FLAGS)' --pkg cmd/secretd .
build_local_no_rust: bin-data-$(IAS_BUILD)
cp go-cosmwasm/target/$(BUILD_PROFILE)/libgo_cosmwasm.so go-cosmwasm/api
go build -mod=readonly -tags "$(GO_TAGS)" -ldflags '$(LD_FLAGS)' ./cmd/secretd
build-secret: build-linux
build-linux: _build-linux build_local_no_rust build_cli
_build-linux:
BUILD_PROFILE=$(BUILD_PROFILE) FEATURES="$(FEATURES)" FEATURES_U="$(FEATURES_U) light-client-validation go-tests" $(MAKE) -C go-cosmwasm build-rust
build-tm-secret-enclave:
git clone https://github.com/scrtlabs/tm-secret-enclave.git /tmp/tm-secret-enclave || true
cd /tmp/tm-secret-enclave && git checkout v1.9.3 && git submodule init && git submodule update --remote
rustup component add rust-src
SGX_MODE=$(SGX_MODE) $(MAKE) -C /tmp/tm-secret-enclave build
# Targets for building the cli on various platforms like Windows, macOS, Linux
build_windows_cli:
$(MAKE) xgo_build_secretcli XGO_TARGET=windows/amd64
sudo mv github.com/scrtlabs/SecretNetwork-windows-* secretcli-windows-amd64.exe
build_macos_cli:
$(MAKE) xgo_build_secretcli XGO_TARGET=darwin/amd64
sudo mv github.com/scrtlabs/SecretNetwork-darwin-amd64 secretcli-macos-amd64
build_macos_arm64_cli:
$(MAKE) xgo_build_secretcli XGO_TARGET=darwin/arm64
sudo mv github.com/scrtlabs/SecretNetwork-darwin-arm64 secretcli-macos-arm64
build_linux_cli:
$(MAKE) xgo_build_secretcli XGO_TARGET=linux/amd64
sudo mv github.com/scrtlabs/SecretNetwork-linux-amd64 secretcli-linux-amd64
build_linux_arm64_cli:
$(MAKE) xgo_build_secretcli XGO_TARGET=linux/arm64
sudo mv github.com/scrtlabs/SecretNetwork-linux-arm64 secretcli-linux-arm64
build_all: build-linux build_windows_cli build_macos_cli build_linux_arm64_cli
# Build Debian package
deb: build-linux deb-no-compile
deb-no-compile:
ifneq ($(UNAME_S),Linux)
exit 1
endif
rm -rf /tmp/SecretNetwork
mkdir -p /tmp/SecretNetwork/deb/$(DEB_BIN_DIR)
cp -f ./secretcli /tmp/SecretNetwork/deb/$(DEB_BIN_DIR)/secretcli
cp -f ./secretd /tmp/SecretNetwork/deb/$(DEB_BIN_DIR)/secretd
chmod +x /tmp/SecretNetwork/deb/$(DEB_BIN_DIR)/secretd /tmp/SecretNetwork/deb/$(DEB_BIN_DIR)/secretcli
mkdir -p /tmp/SecretNetwork/deb/$(DEB_LIB_DIR)
cp -f ./go-cosmwasm/tendermint_enclave.signed.so ./go-cosmwasm/librandom_api.so ./go-cosmwasm/api/libgo_cosmwasm.so ./go-cosmwasm/librust_cosmwasm_enclave.signed.so /tmp/SecretNetwork/deb/$(DEB_LIB_DIR)/
chmod +x /tmp/SecretNetwork/deb/$(DEB_LIB_DIR)/lib*.so
mkdir -p /tmp/SecretNetwork/deb/DEBIAN
cp ./deployment/deb/control /tmp/SecretNetwork/deb/DEBIAN/control
printf "Version: " >> /tmp/SecretNetwork/deb/DEBIAN/control
printf "$(VERSION)" >> /tmp/SecretNetwork/deb/DEBIAN/control
echo "" >> /tmp/SecretNetwork/deb/DEBIAN/control
cp ./deployment/deb/postinst /tmp/SecretNetwork/deb/DEBIAN/postinst
chmod 755 /tmp/SecretNetwork/deb/DEBIAN/postinst
cp ./deployment/deb/postrm /tmp/SecretNetwork/deb/DEBIAN/postrm
chmod 755 /tmp/SecretNetwork/deb/DEBIAN/postrm
cp ./deployment/deb/triggers /tmp/SecretNetwork/deb/DEBIAN/triggers
chmod 755 /tmp/SecretNetwork/deb/DEBIAN/triggers
dpkg-deb --build /tmp/SecretNetwork/deb/ .
-rm -rf /tmp/SecretNetwork
# Clean up generated files and reset the environment
clean:
-rm -rf /tmp/SecretNetwork
-rm -f ./secretcli*
-rm -f ./secretd*
-find -name '*.so' -not -path './third_party/*' -delete
-rm -f ./enigma-blockchain*.deb
-rm -f ./SHA256SUMS*
-rm -rf ./third_party/vendor/
-rm -rf ./.sgx_secrets/*
-rm -rf ./x/compute/internal/keeper/.sgx_secrets/*
-rm -rf ./*.der
-rm -rf ./x/compute/internal/keeper/*.der
-rm -rf ./cmd/secretd/ias_bin*
$(MAKE) -C go-cosmwasm clean-all
$(MAKE) -C cosmwasm/enclaves/test clean
$(MAKE) -C check-hw clean
$(MAKE) -C $(TEST_CONTRACT_V010_PATH)/test-compute-contract clean
$(MAKE) -C $(TEST_CONTRACT_V010_PATH)/test-compute-contract-v2 clean
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/test-compute-contract clean
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/test-compute-contract-v2 clean
###############################################################################
### Dockerized Build Targets ###
###############################################################################
# Build localsecret - dockerized local chain for development and testing. In this version SGX is ran in software/simulation mode
localsecret:
DOCKER_BUILDKIT=1 docker build \
--build-arg FEATURES="${FEATURES},debug-print,random,light-client-validation" \
--build-arg FEATURES_U=${FEATURES_U} \
--secret id=API_KEY,src=.env.local \
--secret id=SPID,src=.env.local \
--build-arg SGX_MODE=SW \
$(DOCKER_BUILD_ARGS) \
--build-arg SECRET_NODE_TYPE=BOOTSTRAP \
--build-arg CHAINID=secretdev-1 \
-f deployment/dockerfiles/Dockerfile \
--target build-localsecret \
-t ghcr.io/scrtlabs/localsecret:${DOCKER_TAG} .
build-ibc-hermes:
docker build -f deployment/dockerfiles/ibc/hermes.Dockerfile -t hermes:v0.0.0 deployment/dockerfiles/ibc
build-testnet-bootstrap:
@mkdir build 2>&3 || true
DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 \
--secret id=API_KEY,src=api_key.txt \
--secret id=SPID,src=spid.txt \
--build-arg BUILD_VERSION=${VERSION} \
--build-arg SGX_MODE=${SGX_MODE} \
$(DOCKER_BUILD_ARGS) \
--build-arg DB_BACKEND=${DB_BACKEND} \
--build-arg SECRET_NODE_TYPE=BOOTSTRAP \
--build-arg CGO_LDFLAGS=${DOCKER_CGO_LDFLAGS} \
-f deployment/dockerfiles/Dockerfile \
-t ghcr.io/scrtlabs/testnet:${DOCKER_TAG} \
--target release-image .
build-testnet:
@mkdir build 2>&3 || true
DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 \
--secret id=API_KEY,src=api_key.txt \
--secret id=SPID,src=spid.txt \
--build-arg BUILD_VERSION=${VERSION} \
--build-arg SGX_MODE=${SGX_MODE} \
--build-arg FEATURES="verify-validator-whitelist,light-client-validation,random,${FEATURES}" \
$(DOCKER_BUILD_ARGS) \
--build-arg DB_BACKEND=${DB_BACKEND} \
--build-arg SECRET_NODE_TYPE=NODE \
--build-arg CGO_LDFLAGS=${DOCKER_CGO_LDFLAGS} \
-f deployment/dockerfiles/Dockerfile \
-t ghcr.io/scrtlabs/secret-network-node-testnet:v$(VERSION) \
--target release-image .
DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 \
--secret id=API_KEY,src=api_key.txt \
--secret id=SPID,src=spid.txt \
--build-arg BUILD_VERSION=${VERSION} \
--build-arg SGX_MODE=${SGX_MODE} \
--build-arg FEATURES="verify-validator-whitelist,light-client-validation,random,${FEATURES}" \
$(DOCKER_BUILD_ARGS) \
--build-arg CGO_LDFLAGS=${DOCKER_CGO_LDFLAGS} \
--build-arg DB_BACKEND=${DB_BACKEND} \
--cache-from ghcr.io/scrtlabs/secret-network-node-testnet:v$(VERSION) \
-f deployment/dockerfiles/Dockerfile \
-t deb_build \
--target build-deb .
docker run -e VERSION=${VERSION} -v $(CUR_DIR)/build:/build deb_build
# special targets for building a deb package that compiles a new secretd but takes the enclaves from the latest package - used for upgrades when we don't want to replace the enclave
build-mainnet-upgrade:
@mkdir build 2>&3 || true
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES="verify-validator-whitelist,light-client-validation,production, ${FEATURES}" \
--build-arg FEATURES_U="production, ${FEATURES_U}" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--secret id=API_KEY,src=api_key.txt \
--secret id=SPID,src=spid.txt \
--build-arg SECRET_NODE_TYPE=NODE \
--build-arg DB_BACKEND=${DB_BACKEND} \
--build-arg BUILD_VERSION=${VERSION} \
--build-arg SGX_MODE=HW \
-f deployment/dockerfiles/Dockerfile \
$(DOCKER_BUILD_ARGS) \
-t ghcr.io/scrtlabs/secret-network-node:v$(VERSION) \
--target mainnet-release .
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES="verify-validator-whitelist,light-client-validation,production, ${FEATURES}" \
--build-arg FEATURES_U="production, ${FEATURES_U}" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--secret id=API_KEY,src=api_key.txt \
--secret id=SPID,src=spid.txt \
--build-arg DB_BACKEND=${DB_BACKEND} \
--build-arg BUILD_VERSION=${VERSION} \
--build-arg SGX_MODE=HW \
-f deployment/dockerfiles/Dockerfile \
-t deb_build \
--target build-deb-mainnet .
docker run -e VERSION=${VERSION} -v $(CUR_DIR)/build:/build deb_build
# full mainnet build - will end up with a .deb package in the ./build folder
build-mainnet:
@mkdir build 2>&3 || true
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES="verify-validator-whitelist,light-client-validation,production,random, ${FEATURES}" \
--build-arg FEATURES_U=${FEATURES_U} \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--secret id=API_KEY,src=api_key.txt \
--secret id=SPID,src=spid.txt \
--build-arg SECRET_NODE_TYPE=NODE \
--build-arg BUILD_VERSION=${VERSION} \
--build-arg SGX_MODE=HW \
--build-arg CGO_LDFLAGS=${DOCKER_CGO_LDFLAGS} \
--build-arg DB_BACKEND=${DB_BACKEND} \
$(DOCKER_BUILD_ARGS) \
-f deployment/dockerfiles/Dockerfile \
-t ghcr.io/scrtlabs/secret-network-node:v$(VERSION) \
--target release-image .
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES="verify-validator-whitelist,light-client-validation,production,random, ${FEATURES}" \
--build-arg FEATURES_U=${FEATURES_U} \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--secret id=API_KEY,src=api_key.txt \
--secret id=SPID,src=spid.txt \
--build-arg BUILD_VERSION=${VERSION} \
--build-arg DB_BACKEND=${DB_BACKEND} \
--build-arg CGO_LDFLAGS=${DOCKER_CGO_LDFLAGS} \
--build-arg SGX_MODE=HW \
-f deployment/dockerfiles/Dockerfile \
-t deb_build \
$(DOCKER_BUILD_ARGS) \
--target build-deb .
docker run -e VERSION=${VERSION} -v $(CUR_DIR)/build:/build deb_build
# Build the hardware compatability checker - this is a binary that just runs attestation and provides details on the result
build-check-hw-tool:
@mkdir build 2>&3 || true
DOCKER_BUILDKIT=1 docker build --build-arg FEATURES="${FEATURES}" \
--build-arg FEATURES_U=${FEATURES_U} \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--secret id=API_KEY,src=ias_keys/develop/api_key.txt \
--secret id=API_KEY_MAINNET,src=ias_keys/production/api_key.txt \
--secret id=SPID,src=spid.txt \
--build-arg SECRET_NODE_TYPE=NODE \
--build-arg BUILD_VERSION=${VERSION} \
--build-arg SGX_MODE=HW \
--build-arg DB_BACKEND=${DB_BACKEND} \
-f deployment/dockerfiles/Dockerfile \
-t compile-check-hw-tool \
--target compile-check-hw-tool .
###############################################################################
### Local Build Targets ###
###############################################################################
build-enclave:
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) enclave
check-enclave:
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) check
clippy-enclave:
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) clippy
clean-enclave:
$(MAKE) -C $(EXECUTE_ENCLAVE_PATH) clean
clippy: clippy-enclave
$(MAKE) -C check-hw clippy
sanity-test:
SGX_MODE=SW $(MAKE) build-linux
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so .
SGX_MODE=SW ./cosmwasm/testing/sanity-test.sh
sanity-test-hw:
$(MAKE) build-linux
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so .
./cosmwasm/testing/sanity-test.sh
callback-sanity-test:
SGX_MODE=SW $(MAKE) build-linux
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so .
SGX_MODE=SW ./cosmwasm/testing/callback-test.sh
build-bench-contract:
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/bench-contract
cp $(TEST_CONTRACT_V1_PATH)/bench-contract/*.wasm $(TEST_COMPUTE_MODULE_PATH)/
build-test-contracts:
# echo "" | sudo add-apt-repository ppa:hnakamur/binaryen
# sudo apt update
# sudo apt install -y binaryen
$(MAKE) -C $(TEST_CONTRACT_V010_PATH)/test-compute-contract
rm -f $(TEST_COMPUTE_MODULE_PATH)/contract.wasm
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract/contract.wasm $(TEST_COMPUTE_MODULE_PATH)/contract.wasm
rm -f $(TEST_COMPUTE_MODULE_PATH)/contract_with_floats.wasm
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract/contract_with_floats.wasm $(TEST_COMPUTE_MODULE_PATH)/contract_with_floats.wasm
rm -f $(TEST_COMPUTE_MODULE_PATH)/static-too-high-initial-memory.wasm
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract/static-too-high-initial-memory.wasm $(TEST_COMPUTE_MODULE_PATH)/static-too-high-initial-memory.wasm
rm -f $(TEST_COMPUTE_MODULE_PATH)/too-high-initial-memory.wasm
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract/too-high-initial-memory.wasm $(TEST_COMPUTE_MODULE_PATH)/too-high-initial-memory.wasm
$(MAKE) -C $(TEST_CONTRACT_V010_PATH)/test-compute-contract-v2
rm -f $(TEST_COMPUTE_MODULE_PATH)/contract-v2.wasm
cp $(TEST_CONTRACT_V010_PATH)/test-compute-contract-v2/contract-v2.wasm $(TEST_COMPUTE_MODULE_PATH)/contract-v2.wasm
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/test-compute-contract
rm -f $(TEST_COMPUTE_MODULE_PATH)/v1-contract.wasm
cp $(TEST_CONTRACT_V1_PATH)/test-compute-contract/v1-contract.wasm $(TEST_COMPUTE_MODULE_PATH)/v1-contract.wasm
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/test-compute-contract-v2
rm -f $(TEST_COMPUTE_MODULE_PATH)/v1-contract-v2.wasm
cp $(TEST_CONTRACT_V1_PATH)/test-compute-contract-v2/v1-contract-v2.wasm $(TEST_COMPUTE_MODULE_PATH)/v1-contract-v2.wasm
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/ibc-test-contract
rm -f $(TEST_COMPUTE_MODULE_PATH)/ibc.wasm
cp $(TEST_CONTRACT_V1_PATH)/ibc-test-contract/ibc.wasm $(TEST_COMPUTE_MODULE_PATH)/ibc.wasm
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/migration/contract-v1
rm -f $(TEST_COMPUTE_MODULE_PATH)/migrate_contract_v1.wasm
cp $(TEST_CONTRACT_V1_PATH)/migration/contract-v1/migrate_contract_v1.wasm $(TEST_COMPUTE_MODULE_PATH)/migrate_contract_v1.wasm
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/migration/contract-v2
rm -f $(TEST_COMPUTE_MODULE_PATH)/migrate_contract_v2.wasm
cp $(TEST_CONTRACT_V1_PATH)/migration/contract-v2/migrate_contract_v2.wasm $(TEST_COMPUTE_MODULE_PATH)/migrate_contract_v2.wasm
$(MAKE) -C $(TEST_CONTRACT_V1_PATH)/random-test
rm -f $(TEST_COMPUTE_MODULE_PATH)/v1_random_test.wasm
cp $(TEST_CONTRACT_V1_PATH)/random-test/v1_random_test.wasm $(TEST_COMPUTE_MODULE_PATH)/v1_random_test.wasm
prep-go-tests: build-test-contracts bin-data-sw
# empty BUILD_PROFILE means debug mode which compiles faster
SGX_MODE=SW $(MAKE) build-linux
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so .
go-tests: build-test-contracts bin-data-sw
# SGX_MODE=SW $(MAKE) build-tm-secret-enclave
# cp /tmp/tm-secret-enclave/tendermint_enclave.signed.so ./x/compute/internal/keeper
SGX_MODE=SW $(MAKE) build-linux
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
GOMAXPROCS=8 SGX_MODE=SW SCRT_SGX_STORAGE='./' SKIP_LIGHT_CLIENT_VALIDATION=TRUE go test -count 1 -failfast -timeout 90m -v ./x/compute/internal/... $(GO_TEST_ARGS)
go-tests-hw: build-test-contracts bin-data
# empty BUILD_PROFILE means debug mode which compiles faster
# SGX_MODE=HW $(MAKE) build-tm-secret-enclave
# cp /tmp/tm-secret-enclave/tendermint_enclave.signed.so ./x/compute/internal/keeper
SGX_MODE=HW $(MAKE) build-linux
cp ./$(EXECUTE_ENCLAVE_PATH)/librust_cosmwasm_enclave.signed.so ./x/compute/internal/keeper
GOMAXPROCS=8 SGX_MODE=HW SCRT_SGX_STORAGE='./' SKIP_LIGHT_CLIENT_VALIDATION=TRUE go test -v ./x/compute/internal/... $(GO_TEST_ARGS)
# When running this more than once, after the first time you'll want to remove the contents of the `ffi-types`
# rule in the Makefile in `enclaves/execute`. This is to speed up the compilation time of tests and speed up the
# test debugging process in general.
.PHONY: enclave-tests
enclave-tests:
$(MAKE) -C cosmwasm/enclaves/test run
build-all-test-contracts: build-test-contracts
cd $(CW_CONTRACTS_V010_PATH)/gov && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os $(CW_CONTRACTS_V010_PATH)/gov/target/wasm32-unknown-unknown/release/gov.wasm -o $(TEST_CONTRACT_PATH)/gov.wasm
cd $(CW_CONTRACTS_V010_PATH)/dist && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os $(CW_CONTRACTS_V010_PATH)/dist/target/wasm32-unknown-unknown/release/dist.wasm -o $(TEST_CONTRACT_PATH)/dist.wasm
cd .$(CW_CONTRACTS_V010_PATH)/mint && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/mint/target/wasm32-unknown-unknown/release/mint.wasm -o $(TEST_CONTRACT_PATH)/mint.wasm
cd .$(CW_CONTRACTS_V010_PATH)/staking && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/staking/target/wasm32-unknown-unknown/release/staking.wasm -o $(TEST_CONTRACT_PATH)/staking.wasm
cd .$(CW_CONTRACTS_V010_PATH)/reflect && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/reflect/target/wasm32-unknown-unknown/release/reflect.wasm -o $(TEST_CONTRACT_PATH)/reflect.wasm
cd .$(CW_CONTRACTS_V010_PATH)/burner && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/burner/target/wasm32-unknown-unknown/release/burner.wasm -o $(TEST_CONTRACT_PATH)/burner.wasm
cd .$(CW_CONTRACTS_V010_PATH)/erc20 && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/erc20/target/wasm32-unknown-unknown/release/cw_erc20.wasm -o $(TEST_CONTRACT_PATH)/erc20.wasm
cd .$(CW_CONTRACTS_V010_PATH)/hackatom && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/hackatom/target/wasm32-unknown-unknown/release/hackatom.wasm -o $(TEST_CONTRACT_PATH)/contract.wasm
cat $(TEST_CONTRACT_PATH)/contract.wasm | gzip > $(TEST_CONTRACT_PATH)/contract.wasm.gzip
build-erc20-contract: build-test-contracts
cd .$(CW_CONTRACTS_V010_PATH)/erc20 && RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
wasm-opt -Os .$(CW_CONTRACTS_V010_PATH)/erc20/target/wasm32-unknown-unknown/release/cw_erc20.wasm -o ./erc20.wasm
bin-data: bin-data-sw bin-data-develop bin-data-production
bin-data-sw:
cd ./x/registration/internal/types && go-bindata -o ias_bin_sw.go -pkg types -prefix "../../../../ias_keys/sw_dummy/" -tags "!hw" ../../../../ias_keys/sw_dummy/...
bin-data-develop:
cd ./x/registration/internal/types && go-bindata -o ias_bin_dev.go -pkg types -prefix "../../../../ias_keys/develop/" -tags "develop,hw" ../../../../ias_keys/develop/...
bin-data-production:
cd ./x/registration/internal/types && go-bindata -o ias_bin_prod.go -pkg types -prefix "../../../../ias_keys/production/" -tags "production,hw" ../../../../ias_keys/production/...
# Before running this you might need to do:
# 1. sudo docker login -u ABC -p XYZ
# 2. sudo docker buildx create --use
secret-contract-optimizer:
sudo docker buildx build --platform=linux/amd64,linux/arm64/v8 -f deployment/dockerfiles/base-images/secret-contract-optimizer.Dockerfile -t enigmampc/secret-contract-optimizer:${TAG} --push .
sudo docker buildx imagetools create -t enigmampc/secret-contract-optimizer:latest enigmampc/secret-contract-optimizer:${TAG}
aesm-image:
docker build -f deployment/dockerfiles/aesm.Dockerfile -t enigmampc/aesm .
###############################################################################
### Swagger & Protobuf ###
###############################################################################
.PHONY: update-swagger-openapi-docs statik statik-install proto-swagger-openapi-gen
statik-install:
@echo "Installing statik..."
@go install github.com/rakyll/[email protected]
statik:
statik -src=client/docs/static/ -dest=client/docs -f -m
proto-swagger-openapi-gen:
cp go.mod /tmp/go.mod.bak
cp go.sum /tmp/go.sum.bak
@./scripts/protoc-swagger-openapi-gen.sh
cp /tmp/go.mod.bak go.mod
cp /tmp/go.sum.bak go.sum
# Example `CHAIN_VERSION=v1.4.0 make update-swagger-openapi-docs`
update-swagger-openapi-docs: statik-install proto-swagger-openapi-gen statik
protoVer=v0.2
proto-all: proto-lint proto-gen proto-swagger-openapi-gen
proto-gen:
cp go.mod /tmp/go.mod.bak
cp go.sum /tmp/go.sum.bak
@echo "Generating Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen:$(protoVer) sh ./scripts/protocgen.sh
cp /tmp/go.mod.bak go.mod
cp /tmp/go.sum.bak go.sum
go mod tidy
proto-lint:
@$(DOCKER_BUF) lint --error-format=json
.PHONY: proto-all proto-gen proto-format proto-lint proto-check-breaking
.PHONY: check-hw
check-hw: build-linux
$(MAKE) -C check-hw