|
| 1 | +VERSION := 1.0.0 |
| 2 | +COMMIT := $(shell git log -1 --format='%H') |
| 3 | +GOPATH ?= $(shell go env GOPATH) |
| 4 | +BINDIR ?= $(GOPATH)/bin |
| 5 | +CURRENT_DIR = $(shell pwd) |
| 6 | +APP = ./app |
| 7 | + |
| 8 | +ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=mun \ |
| 9 | + -X github.com/cosmos/cosmos-sdk/version.ServerName=mund \ |
| 10 | + -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ |
| 11 | + -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) |
| 12 | + |
| 13 | +BUILD_FLAGS := -ldflags '$(ldflags)' |
| 14 | +DOCKER := $(shell which docker) |
| 15 | +DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf |
| 16 | +PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git) |
| 17 | + |
| 18 | +all: install |
| 19 | + |
| 20 | +install: go.sum |
| 21 | + go install -mod=readonly $(BUILD_FLAGS) ./cmd/mund-manager |
| 22 | + go install -mod=readonly $(BUILD_FLAGS) ./cmd/mund |
| 23 | + |
| 24 | +build: go.sum clean |
| 25 | + go build -mod=mod $(BUILD_FLAGS) -o build/mund-manager ./cmd/mund-manager |
| 26 | + go build -mod=mod $(BUILD_FLAGS) -o build/mund ./cmd/mund |
| 27 | + |
| 28 | +build-linux: |
| 29 | + GOOS=linux GOARCH=amd64 $(MAKE) build |
| 30 | + |
| 31 | +go.sum: go.mod |
| 32 | + @echo "--> Ensure dependencies have not been modified" |
| 33 | + GO111MODULE=on go mod verify |
| 34 | + |
| 35 | +# look into .golangci.yml for enabling / disabling linters |
| 36 | +lint: |
| 37 | + @echo "--> Running linter" |
| 38 | + @golangci-lint run |
| 39 | + @go mod verify |
| 40 | + |
| 41 | +# devnet |
| 42 | + |
| 43 | +devnet: clean install devnet-prepare devnet-start |
| 44 | + |
| 45 | +devnet-prepare: |
| 46 | + ./scripts/prepare-devnet.sh |
| 47 | + |
| 48 | +devnet-start: |
| 49 | + DAEMON_NAME=diversifid DAEMON_HOME=~/.diversifid DAEMON_ALLOW_DOWNLOAD_BINARIES=true DAEMON_RESTART_AFTER_UPGRADE=true \ |
| 50 | + diversifid start --pruning="nothing" --inv-check-period 5 |
| 51 | + |
| 52 | +# Clean up the build directory |
| 53 | +clean: |
| 54 | + rm -rf build/ |
| 55 | + rm -rf vue/ |
| 56 | + rm -rf ts-client/ |
| 57 | + |
| 58 | + |
| 59 | +# Localnet |
| 60 | + |
| 61 | +# Build nodes using Docker |
| 62 | +build-docker: |
| 63 | + $(MAKE) -C networks/local |
| 64 | + |
| 65 | +# Run a 4-node testnet locally |
| 66 | +localnet-start: build-linux localnet-stop |
| 67 | + @if ! [ -f build/node0/diversifid/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/diversifid:Z lottery/core testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test --chain-id test ; fi |
| 68 | + ./scripts/import-localnet-seeds.sh |
| 69 | + docker-compose up |
| 70 | + |
| 71 | +# Stop testnet |
| 72 | +localnet-stop: |
| 73 | + docker-compose down |
| 74 | + |
| 75 | +localnet: clean build-linux build-docker localnet-start |
| 76 | + |
| 77 | +############################################################################### |
| 78 | +### Tests & Simulation ### |
| 79 | +############################################################################### |
| 80 | + |
| 81 | +runsim: |
| 82 | + go install github.com/cosmos/tools/cmd/runsim@latest |
| 83 | + |
| 84 | +PACKAGES_SIM=$(shell go list ./... | grep '/app') |
| 85 | + |
| 86 | +test-sim-suite: |
| 87 | + @VERSION=$(VERSION) go test -mod=readonly $(PACKAGES_SIM) |
| 88 | + |
| 89 | +test-sim-app: |
| 90 | + @VERSION=$(VERSION) go test -mod=readonly -run ^TestFullAppSimulation ./app -Enabled=true -v -NumBlocks=10 -BlockSize=200 -Commit=true -Period=0 |
| 91 | + |
| 92 | +test-sim-full-app: runsim |
| 93 | + @echo "Running short multi-seed application simulation. This may take awhile!" |
| 94 | + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 50 10 TestFullAppSimulation |
| 95 | + |
| 96 | +test-sim-multi-seed-long: runsim |
| 97 | + @echo "Running long multi-seed application simulation. This may take awhile!" |
| 98 | + @cd ${CURRENT_DIR}/simapp && $(BINDIR)/runsim -Jobs=4 -SimAppPkg=. -ExitOnFail 500 50 TestFullAppSimulation |
| 99 | + |
| 100 | +test-sim-nondeterminism: |
| 101 | + @echo "Running non-determinism test..." |
| 102 | + go test -mod=readonly -run ^TestAppStateDeterminism ./app -Enabled=true -NumBlocks=10 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h |
| 103 | + |
| 104 | +test-sim-import-export: runsim |
| 105 | + @echo "Running application import/export simulation. This may take several minutes..." |
| 106 | + @cd ${CURRENT_DIR}/app && $(BINDIR)/runsim -Jobs=4 -SimAppPkg=. -ExitOnFail 50 5 TestAppImportExport |
| 107 | + |
| 108 | +test-sim-after-import: runsim |
| 109 | + @echo "Running application simulation-after-import. This may take several minutes..." |
| 110 | + @cd ${CURRENT_DIR}/app && $(BINDIR)/runsim -Jobs=4 -SimAppPkg=. -ExitOnFail 50 5 TestAppSimulationAfterImport |
| 111 | + |
| 112 | +test-sim-bench: |
| 113 | + @VERSION=$(VERSION) go test -benchmem -run ^BenchmarkFullAppSimulation -bench ^BenchmarkFullAppSimulation -cpuprofile cpu.out $(PACKAGES_SIM) |
| 114 | + |
| 115 | + |
| 116 | +############################################################################### |
| 117 | +### Protobuf ### |
| 118 | +############################################################################### |
| 119 | + |
| 120 | +protoVer=v0.3 |
| 121 | +protoImageName=tendermintdev/sdk-proto-gen:$(protoVer) |
| 122 | +containerProtoGen=$(PROJECT_NAME)-proto-gen-$(protoVer) |
| 123 | +containerProtoGenAny=$(PROJECT_NAME)-proto-gen-any-$(protoVer) |
| 124 | +containerProtoGenSwagger=$(PROJECT_NAME)-proto-gen-swagger-$(protoVer) |
| 125 | +containerProtoFmt=$(PROJECT_NAME)-proto-fmt-$(protoVer) |
| 126 | + |
| 127 | +proto-all: proto-format proto-lint proto-gen |
| 128 | + |
| 129 | +proto-gen: |
| 130 | + docker run --rm -v $(CURDIR):/workspace --workdir /workspace bharvest/liquidity-proto-gen sh ./scripts/protocgen.sh |
| 131 | + go mod tidy |
| 132 | + |
| 133 | +# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed |
| 134 | +proto-gen-js: |
| 135 | + @echo "Generating Protobuf Typescript" |
| 136 | + bash ./scripts/protocgen-js.sh |
| 137 | + |
| 138 | +proto-swagger-gen: |
| 139 | + @echo "Generating Protobuf Swagger" |
| 140 | + @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \ |
| 141 | + sh ./scripts/protoc-swagger-gen.sh; fi |
| 142 | + |
| 143 | +proto-format: |
| 144 | + @echo "Formatting Protobuf files" |
| 145 | + @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 \ |
| 146 | + find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi |
| 147 | + |
| 148 | +proto-lint: |
| 149 | + @$(DOCKER_BUF) lint --error-format=json |
| 150 | + |
| 151 | +proto-check-breaking: |
| 152 | + @$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master |
| 153 | + |
| 154 | +# Create log files |
| 155 | +log-files: |
| 156 | + sudo mkdir -p /var/log/mund && sudo touch /var/log/mund/mund.log && sudo touch /var/log/mund/mund_error.log |
0 commit comments