github.com/evdatsion/aphelion-dpos-bft@v0.32.1/Makefile (about) 1 GOTOOLS = \ 2 github.com/mitchellh/gox \ 3 github.com/golangci/golangci-lint/cmd/golangci-lint \ 4 github.com/gogo/protobuf/protoc-gen-gogo \ 5 github.com/square/certstrap 6 GOBIN?=${GOPATH}/bin 7 PACKAGES=$(shell go list ./...) 8 OUTPUT?=build/tendermint 9 10 export GO111MODULE = on 11 12 INCLUDE = -I=. -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf 13 BUILD_TAGS?='tendermint' 14 LD_FLAGS = -X github.com/evdatsion/aphelion-dpos-bft/version.GitCommit=`git rev-parse --short=8 HEAD` -s -w 15 BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)" 16 17 all: check build test install 18 19 check: check_tools 20 21 ######################################## 22 ### Build Tendermint 23 24 build: 25 CGO_ENABLED=0 go build $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/ 26 27 build_c: 28 CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags "$(BUILD_TAGS) cleveldb" -o $(OUTPUT) ./cmd/tendermint/ 29 30 build_race: 31 CGO_ENABLED=0 go build -race $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint 32 33 install: 34 CGO_ENABLED=0 go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint 35 36 install_c: 37 CGO_ENABLED=1 go install $(BUILD_FLAGS) -tags "$(BUILD_TAGS) cleveldb" ./cmd/tendermint 38 39 ######################################## 40 ### Protobuf 41 42 protoc_all: protoc_libs protoc_merkle protoc_abci protoc_grpc protoc_proto3types 43 44 %.pb.go: %.proto 45 ## If you get the following error, 46 ## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory" 47 ## See https://stackoverflow.com/a/25518702 48 ## Note the $< here is substituted for the %.proto 49 ## Note the $@ here is substituted for the %.pb.go 50 protoc $(INCLUDE) $< --gogo_out=Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,plugins=grpc:. 51 52 ######################################## 53 ### Build ABCI 54 55 # see protobuf section above 56 protoc_abci: abci/types/types.pb.go 57 58 protoc_proto3types: types/proto3/block.pb.go 59 60 build_abci: 61 @go build -mod=readonly -i ./abci/cmd/... 62 63 install_abci: 64 @go install -mod=readonly ./abci/cmd/... 65 66 ######################################## 67 ### Distribution 68 69 # dist builds binaries for all platforms and packages them for distribution 70 # TODO add abci to these scripts 71 dist: 72 @BUILD_TAGS=$(BUILD_TAGS) sh -c "'$(CURDIR)/scripts/dist.sh'" 73 74 ######################################## 75 ### Tools & dependencies 76 77 check_tools: 78 @# https://stackoverflow.com/a/25668869 79 @echo "Found tools: $(foreach tool,$(notdir $(GOTOOLS)),\ 80 $(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))" 81 82 get_tools: 83 @echo "--> Installing tools" 84 ./scripts/get_tools.sh 85 86 update_tools: 87 @echo "--> Updating tools" 88 ./scripts/get_tools.sh 89 90 #For ABCI and libs 91 get_protoc: 92 @# https://github.com/google/protobuf/releases 93 curl -L https://github.com/google/protobuf/releases/download/v3.6.1/protobuf-cpp-3.6.1.tar.gz | tar xvz && \ 94 cd protobuf-3.6.1 && \ 95 DIST_LANG=cpp ./configure && \ 96 make && \ 97 make check && \ 98 sudo make install && \ 99 sudo ldconfig && \ 100 cd .. && \ 101 rm -rf protobuf-3.6.1 102 103 draw_deps: 104 @# requires brew install graphviz or apt-get install graphviz 105 go get github.com/RobotsAndPencils/goviz 106 @goviz -i github.com/evdatsion/aphelion-dpos-bft/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png 107 108 get_deps_bin_size: 109 @# Copy of build recipe with additional flags to perform binary size analysis 110 $(eval $(shell go build -work -a $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/ 2>&1)) 111 @find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log 112 @echo "Results can be found here: $(CURDIR)/deps_bin_size.log" 113 114 ######################################## 115 ### Libs 116 117 protoc_libs: libs/common/types.pb.go 118 119 # generates certificates for TLS testing in remotedb and RPC server 120 gen_certs: clean_certs 121 certstrap init --common-name "tendermint.com" --passphrase "" 122 certstrap request-cert --common-name "remotedb" -ip "127.0.0.1" --passphrase "" 123 certstrap sign "remotedb" --CA "tendermint.com" --passphrase "" 124 mv out/remotedb.crt libs/db/remotedb/test.crt 125 mv out/remotedb.key libs/db/remotedb/test.key 126 certstrap request-cert --common-name "server" -ip "127.0.0.1" --passphrase "" 127 certstrap sign "server" --CA "tendermint.com" --passphrase "" 128 mv out/server.crt rpc/lib/server/test.crt 129 mv out/server.key rpc/lib/server/test.key 130 rm -rf out 131 132 # deletes generated certificates 133 clean_certs: 134 rm -f libs/db/remotedb/test.crt 135 rm -f libs/db/remotedb/test.key 136 rm -f rpc/lib/server/test.crt 137 rm -f rpc/lib/server/test.key 138 139 test_libs: 140 go test -tags clevedb boltdb $(PACKAGES) 141 142 grpc_dbserver: 143 protoc -I libs/db/remotedb/proto/ libs/db/remotedb/proto/defs.proto --go_out=plugins=grpc:libs/db/remotedb/proto 144 145 protoc_grpc: rpc/grpc/types.pb.go 146 147 protoc_merkle: crypto/merkle/merkle.pb.go 148 149 ######################################## 150 ### Testing 151 152 ## required to be run first by most tests 153 build_docker_test_image: 154 docker build -t tester -f ./test/docker/Dockerfile . 155 156 ### coverage, app, persistence, and libs tests 157 test_cover: 158 # run the go unit tests with coverage 159 bash test/test_cover.sh 160 161 test_apps: 162 # run the app tests using bash 163 # requires `abci-cli` and `tendermint` binaries installed 164 bash test/app/test.sh 165 166 test_abci_apps: 167 bash abci/tests/test_app/test.sh 168 169 test_abci_cli: 170 # test the cli against the examples in the tutorial at: 171 # ./docs/abci-cli.md 172 # if test fails, update the docs ^ 173 @ bash abci/tests/test_cli/test.sh 174 175 test_persistence: 176 # run the persistence tests using bash 177 # requires `abci-cli` installed 178 docker run --name run_persistence -t tester bash test/persist/test_failure_indices.sh 179 180 # TODO undockerize 181 # bash test/persist/test_failure_indices.sh 182 183 test_p2p: 184 docker rm -f rsyslog || true 185 rm -rf test/logs || true 186 mkdir test/logs 187 cd test/ 188 docker run -d -v "logs:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog 189 cd .. 190 # requires 'tester' the image from above 191 bash test/p2p/test.sh tester 192 # the `docker cp` takes a really long time; uncomment for debugging 193 # 194 # mkdir -p test/p2p/logs && docker cp rsyslog:/var/log test/p2p/logs 195 196 test_integrations: 197 make build_docker_test_image 198 make get_tools 199 make install 200 make test_cover 201 make test_apps 202 make test_abci_apps 203 make test_abci_cli 204 make test_libs 205 make test_persistence 206 make test_p2p 207 208 test_release: 209 @go test -tags release $(PACKAGES) 210 211 test100: 212 @for i in {1..100}; do make test; done 213 214 vagrant_test: 215 vagrant up 216 vagrant ssh -c 'make test_integrations' 217 218 ### go tests 219 test: 220 @echo "--> Running go test" 221 @go test -p 1 $(PACKAGES) 222 223 test_race: 224 @echo "--> Running go test --race" 225 @go test -p 1 -v -race $(PACKAGES) 226 227 # uses https://github.com/sasha-s/go-deadlock/ to detect potential deadlocks 228 test_with_deadlock: 229 make set_with_deadlock 230 make test 231 make cleanup_after_test_with_deadlock 232 233 set_with_deadlock: 234 find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/sync.RWMutex/deadlock.RWMutex/' 235 find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/sync.Mutex/deadlock.Mutex/' 236 find . -name "*.go" | grep -v "vendor/" | xargs -n 1 goimports -w 237 238 # cleanes up after you ran test_with_deadlock 239 cleanup_after_test_with_deadlock: 240 find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/deadlock.RWMutex/sync.RWMutex/' 241 find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/deadlock.Mutex/sync.Mutex/' 242 find . -name "*.go" | grep -v "vendor/" | xargs -n 1 goimports -w 243 244 ######################################## 245 ### Formatting, linting, and vetting 246 247 fmt: 248 @go fmt ./... 249 250 lint: 251 @echo "--> Running linter" 252 @golangci-lint run 253 254 DESTINATION = ./index.html.md 255 256 rpc-docs: 257 cat rpc/core/slate_header.txt > $(DESTINATION) 258 godoc2md -template rpc/core/doc_template.txt github.com/evdatsion/aphelion-dpos-bft/rpc/core | grep -v -e "pipe.go" -e "routes.go" -e "dev.go" | sed 's,/src/target,https://github.com/evdatsion/aphelion-dpos-bft/tree/master/rpc/core,' >> $(DESTINATION) 259 260 ########################################################### 261 ### Docker image 262 263 build-docker: 264 cp $(OUTPUT) DOCKER/tendermint 265 docker build --label=tendermint --tag="tendermint/tendermint" DOCKER 266 rm -rf DOCKER/tendermint 267 268 ########################################################### 269 ### Local testnet using docker 270 271 # Build linux binary on other platforms 272 build-linux: get_tools 273 GOOS=linux GOARCH=amd64 $(MAKE) build 274 275 build-docker-localnode: 276 @cd networks/local && make 277 278 # Run a 4-node testnet locally 279 localnet-start: localnet-stop build-docker-localnode 280 @if ! [ -f build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/tendermint:Z tendermint/localnode testnet --config /etc/tendermint/config-template.toml --v 4 --o . --populate-persistent-peers --starting-ip-address 192.167.10.2; fi 281 docker-compose up 282 283 # Stop testnet 284 localnet-stop: 285 docker-compose down 286 287 ########################################################### 288 ### Remote full-nodes (sentry) using terraform and ansible 289 290 # Server management 291 sentry-start: 292 @if [ -z "$(DO_API_TOKEN)" ]; then echo "DO_API_TOKEN environment variable not set." ; false ; fi 293 @if ! [ -f $(HOME)/.ssh/id_rsa.pub ]; then ssh-keygen ; fi 294 cd networks/remote/terraform && terraform init && terraform apply -var DO_API_TOKEN="$(DO_API_TOKEN)" -var SSH_KEY_FILE="$(HOME)/.ssh/id_rsa.pub" 295 @if ! [ -f $(CURDIR)/build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/tendermint:Z tendermint/localnode testnet --v 0 --n 4 --o . ; fi 296 cd networks/remote/ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/digital_ocean.py -l sentrynet install.yml 297 @echo "Next step: Add your validator setup in the genesis.json and config.tml files and run \"make sentry-config\". (Public key of validator, chain ID, peer IP and node ID.)" 298 299 # Configuration management 300 sentry-config: 301 cd networks/remote/ansible && ansible-playbook -i inventory/digital_ocean.py -l sentrynet config.yml -e BINARY=$(CURDIR)/build/tendermint -e CONFIGDIR=$(CURDIR)/build 302 303 sentry-stop: 304 @if [ -z "$(DO_API_TOKEN)" ]; then echo "DO_API_TOKEN environment variable not set." ; false ; fi 305 cd networks/remote/terraform && terraform destroy -var DO_API_TOKEN="$(DO_API_TOKEN)" -var SSH_KEY_FILE="$(HOME)/.ssh/id_rsa.pub" 306 307 # meant for the CI, inspect script & adapt accordingly 308 build-slate: 309 bash scripts/slate.sh 310 311 # To avoid unintended conflicts with file names, always add to .PHONY 312 # unless there is a reason not to. 313 # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html 314 .PHONY: check build build_race build_abci dist install install_abci check_tools get_tools update_tools draw_deps get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver test_cover test_apps test_persistence test_p2p test test_race test_integrations test_release test100 vagrant_test fmt rpc-docs build-linux localnet-start localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop build-slate protoc_grpc protoc_all build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint