forked from provenance-io/provenance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
646 lines (519 loc) · 23.8 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
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
#!/usr/bin/make -f
export GO111MODULE=on
GO ?= go
BINDIR ?= $(GOPATH)/bin
BUILDDIR ?= $(CURDIR)/build
WITH_LEDGER ?= true
WITH_CLEVELDB ?= true
WITH_ROCKSDB ?= false
WITH_BADGERDB ?= true
# We used to use 'yes' on these flags, so at least for now, change 'yes' into 'true'
ifeq ($(WITH_LEDGER),yes)
WITH_LEDGER=true
endif
ifeq ($(WITH_CLEVELDB),yes)
WITH_CLEVELDB=true
endif
ifeq ($(WITH_ROCKSDB),yes)
WITH_ROCKSDB=true
endif
ifeq ($(WITH_BADGERDB),yes)
WITH_BADGERDB=true
endif
BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null)
BRANCH_PRETTY := $(subst /,-,$(BRANCH))
TM_VERSION := $(shell $(GO) list -m github.com/tendermint/tendermint 2> /dev/null | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7"
COMMIT := $(shell git log -1 --format='%h' 2> /dev/null)
# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH_PRETTY)-$(COMMIT)
endif
endif
GOLANGCI_LINT=$(shell which golangci-lint)
ifeq ("$(wildcard $(GOLANGCI_LINT))","")
GOLANGCI_LINT = $(BINDIR)/golangci-lint
endif
HTTPS_GIT := https://github.com/provenance-io/provenance.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
MINIMUM_SUPPORTED_GO_MINOR_VERSION = 17
GO_VERSION_VALIDATION_ERR_MSG = Golang version $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION) is not supported, please update to at least $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION).$(MINIMUM_SUPPORTED_GO_MINOR_VERSION)
# The below include contains the tools target.
include contrib/devtools/Makefile
#Identify the system and if gcc is available.
ifeq ($(OS),Windows_NT)
UNAME_S = 'windows_nt'
UNAME_M = 'unknown'
else
UNAME_S = $(shell uname -s | tr '[A-Z]' '[a-z]')
UNAME_M = $(shell uname -m | tr '[A-Z]' '[a-z]')
endif
ifeq ($(UNAME_S),windows_nt)
ifneq ($(shell where gcc.exe 2> NUL),)
have_gcc = true
endif
else
ifneq ($(shell command -v gcc 2> /dev/null),)
have_gcc = true
endif
endif
##############################
# Build Flags/Tags
##############################
ifeq ($(WITH_CLEVELDB),true)
ifneq ($(have_gcc),true)
$(error gcc not installed for cleveldb support, please install or set WITH_CLEVELDB=false)
else
build_tags += gcc
build_tags += cleveldb
endif
endif
ifeq ($(WITH_ROCKSDB),true)
build_tags += rocksdb
endif
ifeq ($(WITH_BADGERDB),true)
build_tags += badgerdb
endif
ifeq ($(WITH_LEDGER),true)
ifeq ($(UNAME_S),openbsd)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
WITH_LEDGER = false
else ifneq ($(have_gcc),true)
$(error gcc not installed for ledger support, please install or set WITH_LEDGER=false)
else
build_tags += ledger
endif
endif
### CGO Settings
ifeq ($(UNAME_S),darwin)
# osx linker settings
cgo_ldflags += -Wl,-rpath,@loader_path/.
else ifeq ($(UNAME_S),linux)
# linux liner settings
cgo_ldflags += -Wl,-rpath,\$$ORIGIN
endif
# cleveldb linker settings
ifeq ($(WITH_CLEVELDB),true)
ifeq ($(UNAME_S),darwin)
LEVELDB_PATH ?= $(shell brew --prefix leveldb 2> /dev/null)
# Only do stuff if that LEVELDB_PATH exists. Otherwise, leave it up to already installed libraries.
ifneq ($(wildcard $(LEVELDB_PATH)/.),)
cgo_cflags += -I$(LEVELDB_PATH)/include
cgo_ldflags += -L$(LEVELDB_PATH)/lib
endif
else ifeq ($(UNAME_S),linux)
# Intentionally left blank to leave it up to already installed libraries.
endif
endif
cgo_ldflags += $(CGO_LDFLAGS)
cgo_ldflags := $(strip $(cgo_ldflags))
CGO_LDFLAGS := $(cgo_ldflags)
cgo_cflags += $(CGO_CFLAGS)
cgo_cflags := $(strip $(cgo_cflags))
CGO_CFLAGS := $(cgo_cflags)
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
ldflags = -w -s \
-X github.com/cosmos/cosmos-sdk/version.Name=Provenance \
-X github.com/cosmos/cosmos-sdk/version.AppName=provenanced \
-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_comma_sep)" \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION)
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
build_flags = -mod=readonly -tags "$(build_tags)" -ldflags '$(ldflags)' -trimpath
build_flags += $(BUILD_FLAGS)
build_flags := $(strip $(build_flags))
BUILD_FLAGS := $(build_flags)
all: build format lint test
.PHONY: all
##############################
# Build
##############################
# Install puts the binaries in the local environment path.
install: go.sum
CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install $(BUILD_FLAGS) ./cmd/provenanced
build: validate-go-version go.sum
mkdir -p $(BUILDDIR)
CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build -o $(BUILDDIR)/ $(BUILD_FLAGS) ./cmd/provenanced
build-linux: go.sum
WITH_LEDGER=false GOOS=linux GOARCH=amd64 $(MAKE) build
DENOM ?= nhash
MIN_FLOOR_PRICE ?= 1905
CHAIN_ID ?= testing
CHAIN_ID_DOCKER ?= chain-local
# Run an instance of the daemon against a local config (create the config if it does not exit.)
# if required to use something other than nhash, use: make run DENOM=vspn MIN_FLOOR_PRICE=0
run-config: check-built
@if [ ! -d "$(BUILDDIR)/run/provenanced/config" ]; then \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced init --chain-id=$(CHAIN_ID) testing --custom-denom=$(DENOM); \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced keys add validator --keyring-backend test ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-root-name validator pio --keyring-backend test ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-root-name validator pb --restrict=false --keyring-backend test ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-root-name validator io --restrict --keyring-backend test ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-root-name validator provenance --keyring-backend test ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-account validator 100000000000000000000$(DENOM) --keyring-backend test ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced gentx validator 1000000000000000$(DENOM) --keyring-backend test --chain-id=$(CHAIN_ID); \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-marker 100000000000000000000$(DENOM) --manager validator --access mint,burn,admin,withdraw,deposit --activate --keyring-backend test; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-msg-fee /provenance.name.v1.MsgBindNameRequest 10000000000$(DENOM) ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-msg-fee /provenance.marker.v1.MsgAddMarkerRequest 100000000000$(DENOM) ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-msg-fee /provenance.attribute.v1.MsgAddAttributeRequest 10000000000$(DENOM) ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-msg-fee /provenance.metadata.v1.MsgWriteScopeRequest 10000000000$(DENOM) ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-msg-fee /provenance.metadata.v1.MsgP8eMemorializeContractRequest 10000000000$(DENOM) ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced add-genesis-custom-floor $(MIN_FLOOR_PRICE)$(DENOM) ; \
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced collect-gentxs ; \
fi ;
run: check-built run-config ;
ifeq ($(DENOM),nhash)
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced start
else
$(BUILDDIR)/provenanced -t --home $(BUILDDIR)/run/provenanced start --custom-denom $(DENOM)
endif
.PHONY: install build build-linux run
##############################
# Build DB Migration Tools #
##############################
install-dbmigrate: go.sum
CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install $(BUILD_FLAGS) ./cmd/dbmigrate
build-dbmigrate: validate-go-version go.sum
mkdir -p $(BUILDDIR)
CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build -o $(BUILDDIR)/ $(BUILD_FLAGS) ./cmd/dbmigrate
##############################
# Release artifacts and plan #
##############################
LIBWASMVM := libwasmvm
RELEASE_BIN=$(BUILDDIR)/bin
RELEASE_PROTO_NAME=protos-$(VERSION).zip
RELEASE_PROTO=$(BUILDDIR)/$(RELEASE_PROTO_NAME)
RELEASE_PLAN=$(BUILDDIR)/plan-$(VERSION).json
RELEASE_CHECKSUM_NAME=sha256sum.txt
RELEASE_CHECKSUM=$(BUILDDIR)/$(RELEASE_CHECKSUM_NAME)
UNAME_M = $(shell uname -m)
ifeq ($(UNAME_S),darwin)
LIBWASMVM := $(LIBWASMVM).dylib
else ifeq ($(UNAME_S),linux)
ifeq ($(UNAME_M),x86_64)
LIBWASMVM := $(LIBWASMVM).$(UNAME_M).so
else
LIBWASMVM := $(LIBWASMVM).aarch64.so
endif
endif
ARCH=$(UNAME_M)
ifeq ($(ARCH),x86_64)
ARCH=amd64
endif
RELEASE_WASM=$(RELEASE_BIN)/$(LIBWASMVM)
RELEASE_PIO=$(RELEASE_BIN)/provenanced
RELEASE_ZIP_BASE=provenance-$(UNAME_S)-$(ARCH)
RELEASE_ZIP_NAME=$(RELEASE_ZIP_BASE)-$(VERSION).zip
RELEASE_ZIP=$(BUILDDIR)/$(RELEASE_ZIP_NAME)
DBMIGRATE=$(BUILDDIR)/dbmigrate
DBMIGRATE_ZIP_BASE=dbmigrate-$(UNAME_S)-$(ARCH)
DBMIGRATE_ZIP_NAME=$(DBMIGRATE_ZIP_BASE)-$(VERSION).zip
DBMIGRATE_ZIP=$(BUILDDIR)/$(DBMIGRATE_ZIP_NAME)
.PHONY: build-release-clean
build-release-clean:
rm -rf $(RELEASE_BIN) $(RELEASE_PLAN) $(RELEASE_CHECKSUM) $(RELEASE_ZIP) $(DBMIGRATE_ZIP)
.PHONY: build-release-checksum
build-release-checksum: $(RELEASE_CHECKSUM)
$(RELEASE_CHECKSUM):
cd $(BUILDDIR) && \
shasum -a 256 *.zip > $(RELEASE_CHECKSUM) && \
cd ..
.PHONY: build-release-plan
build-release-plan: $(RELEASE_PLAN)
$(RELEASE_PLAN): $(RELEASE_CHECKSUM)
scripts/release-plan $(RELEASE_CHECKSUM) $(VERSION) > $(RELEASE_PLAN)
.PHONY: build-release-libwasm
build-release-libwasm: $(RELEASE_WASM)
$(RELEASE_WASM): $(RELEASE_BIN)
go mod vendor && \
cp vendor/github.com/CosmWasm/wasmvm/internal/api/$(LIBWASMVM) $(RELEASE_BIN)
.PHONY: build-release-bin
build-release-bin: $(RELEASE_PIO)
$(RELEASE_PIO): $(BUILDDIR)/provenanced $(RELEASE_BIN)
cp $(BUILDDIR)/provenanced $(RELEASE_BIN) && \
chmod +x $(RELEASE_PIO)
$(BUILDDIR)/provenanced:
$(MAKE) build
.PHONY: build-release-zip
build-release-zip: $(RELEASE_ZIP)
$(RELEASE_ZIP): $(RELEASE_PIO) $(RELEASE_WASM)
cd $(BUILDDIR) && \
zip -u $(RELEASE_ZIP_NAME) bin/$(LIBWASMVM) bin/provenanced && \
cd ..
$(DBMIGRATE):
$(MAKE) build-dbmigrate
.PHONY: build-dbmigrate-zip
build-dbmigrate-zip: $(DBMIGRATE_ZIP)
$(DBMIGRATE_ZIP): $(DBMIGRATE)
cd $(BUILDDIR) && \
zip -u $(DBMIGRATE_ZIP_NAME) dbmigrate && \
cd ..
# gon packages the zip wrong. need bin/provenanced and bin/libwasmvm
.PHONY: build-release-rezip
build-release-rezip: ZIP_FROM = $(BUILDDIR)/$(RELEASE_ZIP_BASE).zip
build-release-rezip: ZIP_TO = $(BUILDDIR)/$(RELEASE_ZIP_NAME)
build-release-rezip:
scripts/fix-gon-zip $(ZIP_FROM) && \
mv -v $(ZIP_FROM) $(ZIP_TO)
.PHONY: build-release-proto
build-release-proto:
scripts/protoball.sh $(RELEASE_PROTO)
$(RELEASE_BIN):
mkdir -p $(RELEASE_BIN)
##############################
# Tools / Dependencies
##############################
go-mod-cache: go.sum
$(GO) mod download
.PHONY: go-mod-cache
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
$(GO) mod verify
$(GO) mod tidy
# look into .golangci.yml for enabling / disabling linters
lint:
$(GOLANGCI_LINT) run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "./client/*" -not -path "*.git*" -not -path "*.pb.go" | xargs gofmt -d -s
scripts/no-now-lint.sh
$(GO) mod verify
clean:
rm -rf $(BUILDDIR)/*
format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" -not -path "*/statik*" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" -not -path "*/statik*" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" -not -path "*/statik*" | xargs goimports -w -local github.com/provenance-io/provenance
check-built:
@if [ ! -f "$(BUILDDIR)/provenanced" ]; then \
echo "\n fatal: Nothing to run. Try 'make build' first.\n" ; \
exit 1; \
fi
linkify:
python ./scripts/linkify.py CHANGELOG.md
update-tocs:
scripts/update-toc.sh x docs CONTRIBUTING.md
# Download, compile, and install rocksdb so that it can be used when doing a build.
rocksdb:
scripts/rocksdb_build_and_install.sh
# Download, compile, and install cleveldb so that it can be used when doing a build.
cleveldb:
scripts/cleveldb_build_and_install.sh
.PHONY: go-mod-cache go.sum lint clean format check-built linkify update-tocs rocksdb cleveldb
validate-go-version: ## Validates the installed version of go against Provenance's minimum requirement.
@if [ $(GO_MAJOR_VERSION) -gt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
exit 0 ;\
elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
elif [ $(GO_MINOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \
echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\
exit 1; \
fi
download-smart-contracts:
./scripts/download_smart_contracts.sh
##############################
### Test
##############################
include sims.mk
test: test-unit
test-all: test-unit test-ledger-mock test-race test-cover
PACKAGES := $(shell $(GO) list ./... 2>/dev/null || true)
PACKAGES_NOSIMULATION := $(filter-out %/simulation%,$(PACKAGES))
PACKAGES_SIMULATION := $(filter %/simulation%,$(PACKAGES))
TEST_PACKAGES=./...
TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-race test-ledger test-race
ifeq ($(WITH_CLEVELDB),true)
TAGS+= cleveldb
endif
# Test runs-specific rules. To add a new test target, just add
# a new rule, customise TAGS, ARGS and/or TEST_PACKAGES ad libitum, and
# append the new rule to the TEST_TARGETS list.
test-unit: TAGS+=cgo ledger test_ledger_mock norace
test-unit-amino: TAGS+=ledger test_ledger_mock test_amino norace
test-ledger: TAGS+=cgo ledger norace
test-ledger-mock: TAGS+=ledger test_ledger_mock norace
test-race: ARGS+=-race
test-race: TAGS+=cgo ledger test_ledger_mock
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
$(TEST_TARGETS): run-tests
# check-* compiles and collects tests without running them
# note: go test -c doesn't support multiple packages yet (https://github.com/golang/go/issues/15513)
CHECK_TEST_TARGETS := check-test-unit check-test-unit-amino
check-test-unit: TAGS+=cgo ledger test_ledger_mock norace
check-test-unit-amino: TAGS+=ledger test_ledger_mock test_amino norace
$(CHECK_TEST_TARGETS): ARGS+=-run=none
$(CHECK_TEST_TARGETS): run-tests
run-tests: go.sum
ifneq (,$(shell which tparse 2>/dev/null))
$(GO) test -mod=readonly -json $(ARGS) -tags='$(TAGS)'$(TEST_PACKAGES) | tparse
else
$(GO) test -mod=readonly $(ARGS) -tags='$(TAGS)' $(TEST_PACKAGES)
endif
test-cover:
export VERSION=$(VERSION); bash -x contrib/test_cover.sh
benchmark:
$(GO) test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)
.PHONY: test test-all test-unit test-race test-cover benchmark run-tests $(TEST_TARGETS)
##############################
# Test Network Targets
##############################
.PHONY: vendor
vendor:
$(GO) mod vendor -v
# Full build inside a docker container for a clean release build
docker-build: vendor
ifeq ($(UNAME_M),x86_64)
docker build --build-arg VERSION=$(VERSION) --build-arg ARCH=$(UNAME_M) -t provenance-io/blockchain . -f docker/blockchain/Dockerfile
else
docker build --build-arg VERSION=$(VERSION) --build-arg ARCH=aarch64 -t provenance-io/blockchain . -f docker/blockchain/Dockerfile
endif
# Quick build using local environment and go platform target options.
docker-build-local: vendor
docker build --target provenance-$(shell uname -m) --tag provenance-io/blockchain-local -f networks/local/blockchain-local/Dockerfile .
# Generate config files for a 4-node localnet
localnet-generate: localnet-stop docker-build-local
ifeq ($(DENOM),nhash)
@if ! [ -f build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/provenance:Z provenance-io/blockchain-local testnet --v 4 -o . --starting-ip-address 192.168.20.2 --keyring-backend=test --chain-id=$(CHAIN_ID_DOCKER) ; fi
else
@if ! [ -f build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/provenance:Z provenance-io/blockchain-local testnet --v 4 -o . --starting-ip-address 192.168.20.2 --keyring-backend=test --chain-id=$(CHAIN_ID_DOCKER) --custom-denom=$(DENOM) --minimum-gas-prices=$(MIN_FLOOR_PRICE)$(DENOM) --msgfee-floor-price=$(MIN_FLOOR_PRICE) ; fi
endif
# Run a 4-node testnet locally
localnet-up:
docker-compose -f networks/local/docker-compose.yml --project-directory ./ up -d
# Run a 4-node testnet locally (replace docker-build with docker-build local for better speed)
# to run custom denom network, `make clean localnet-start DENOM=vspn MIN_FLOOR_PRICE=0`
localnet-start: localnet-generate localnet-up
# Stop testnet
localnet-stop:
docker-compose -f networks/local/docker-compose.yml --project-directory ./ down
# Quick build using ibc environment and go platform target options.
RELAYER_MNEMONIC ?= "list judge day spike walk easily outer state fashion library review include leisure casino wagon zoo chuckle alien stock bargain stone wait squeeze fade"
RELAYER_KEY ?= tp18uev5722xrwpfd2hnqducmt3qdjsyktmtw558y
RELAYER_VERSION ?= v2.1.2
docker-build-ibc: vendor
docker build --target provenance-$(shell uname -m) --tag provenance-io/blockchain-ibc -f networks/ibc/blockchain-ibc/Dockerfile .
docker build --target relayer --tag provenance-io/blockchain-relayer -f networks/ibc/blockchain-relayer/Dockerfile --build-arg MNEMONIC=$(RELAYER_MNEMONIC) --build-arg VERSION=$(RELAYER_VERSION) .
# Generate config files for a 2-node ibcnet with relayer
ibcnet-generate: ibcnet-stop docker-build-ibc
@if ! [ -f build/ibc0-0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/provenance:Z provenance-io/blockchain-ibc testnet --v 1 -o . --starting-ip-address 192.168.20.2 --node-dir-prefix=ibc0- --keyring-backend=test --chain-id=testing ; fi
mv build/gentxs/ibc0-0.json build/gentxs/tmp
@if ! [ -f build/ibc1-0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/provenance:Z provenance-io/blockchain-ibc testnet --v 1 -o . --starting-ip-address 192.168.20.3 --node-dir-prefix=ibc1- --keyring-backend=test --chain-id=testing2 ; fi
mv build/gentxs/tmp build/gentxs/ibc0-0.json
scripts/ibcnet-add-relayer-key.sh $(RELAYER_KEY)
# Run a 2-node testnet locally with a relayer
ibcnet-up:
docker-compose -f networks/ibc/docker-compose.yml --project-directory ./ up -d
# Run a 2-node testnet locally with a relayer
ibcnet-start: ibcnet-generate ibcnet-up
# Stop ibcnet
ibcnet-stop:
docker-compose -f networks/ibc/docker-compose.yml --project-directory ./ down
# Quick build using devnet environment and go platform target options.
docker-build-dev: vendor
docker build --target provenance-$(shell uname -m) --tag provenance-io/blockchain-dev -f networks/dev/blockchain-dev/Dockerfile .
# Generate config files for a single node devnet
devnet-generate: devnet-stop docker-build-dev
@if ! [ -f build/nodedev/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/provenance:Z provenance-io/blockchain-dev keys list ; fi
# Run a single node devnet locally
devnet-up:
docker-compose -f networks/dev/docker-compose.yml --project-directory ./ up -d
# Run a single node devnet locally (replace docker-build with docker-build local for better speed)
devnet-start: devnet-generate devnet-up
# Stop devnet
devnet-stop:
docker-compose -f networks/dev/docker-compose.yml --project-directory ./ down
# Start postgres indexer instance
indexer-db-up:
docker compose -f docker/postgres-indexer/docker-compose.yaml --project-directory ./ up -d
# Stop postgres indexer instance
indexer-db-down:
docker compose -f docker/postgres-indexer/docker-compose.yaml --project-directory ./ down
.PHONY: docker-build-local localnet-start localnet-stop docker-build-dev devnet-start devnet-stop
##############################
# Proto -> golang compilation
##############################
proto-all: proto-update-deps proto-format proto-lint proto-check-breaking proto-check-breaking-third-party proto-gen proto-swagger-gen
containerProtoVer=v0.2
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
containerProtoGen=prov-proto-gen-$(containerProtoVer)
containerProtoGenSwagger=prov-proto-gen-swagger-$(containerProtoVer)
containerProtoFmt=prov-proto-fmt-$(containerProtoVer)
# The proto gen stuff will update go.mod and go.sum in ways we don't want (due to docker stuff).
# So we need to go mod tidy afterward, but it can't go in the scripts for the same reason that we need it.
proto-gen:
@echo "Generating Protobuf files"
if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then \
docker start -a $(containerProtoGen); \
else \
docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./scripts/protocgen.sh; \
fi
go mod tidy
# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed
proto-gen-any:
@echo "Generating Protobuf Any"
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) sh ./scripts/protocgen-any.sh
go mod tidy
proto-swagger-gen:
@echo "Generating Protobuf Swagger"
if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then \
docker start -a $(containerProtoGenSwagger); \
else \
docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./scripts/protoc-swagger-gen.sh; \
fi
go mod tidy
proto-format:
@echo "Formatting Protobuf files"
if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then \
docker start -a $(containerProtoFmt); \
else \
docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \; ; \
fi
proto-lint:
@echo "Linting Protobuf files"
$(DOCKER_BUF) lint --error-format=json
proto-check-breaking:
@echo "Check breaking Protobuf files"
$(DOCKER_BUF) breaking proto --against $(HTTPS_GIT)#branch=main,subdir=proto --error-format=json
proto-check-breaking-third-party:
@echo "Check breaking Protobuf files"
$(DOCKER_BUF) breaking third_party/proto --against $(HTTPS_GIT)#branch=main,subdir=third_party/proto --error-format=json
proto-update-check:
@echo "Checking for third_party Protobuf updates"
sh ./scripts/proto-update-check.sh
proto-update-deps:
@echo "Updating Protobuf files"
sh ./scripts/proto-update-deps.sh
.PHONY: proto-all proto-gen proto-format proto-gen-any proto-lint proto-check-breaking proto-check-breaking-third-party proto-update-deps proto-update-check
##############################
### Docs
##############################
update-swagger-docs: statik proto-swagger-gen
$(BINDIR)/statik -src=client/docs/swagger-ui -dest=client/docs -f -m
.PHONY: update-swagger-docs
test-rosetta:
docker build -t rosetta-ci:latest -f client/rosetta/rosetta-ci/Dockerfile .
docker-compose -f client/rosetta/docker-compose.yaml --project-directory ./ up --abort-on-container-exit --exit-code-from test_rosetta --build
.PHONY: test-rosetta
##############################
### Relayer
##############################
relayer-install:
scripts/install-relayer.sh
relayer-start: relayer-install
scripts/start-relayer.sh
.PHONY: relayer-install relayer-start