You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

253 lines
9.3 KiB

[RPC] Static swagger (#3880) * manually swagging Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * three definitions with polymorphism Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * added blockchain and block Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * low quality generation, commit, block_response and validators Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * genesis and consensus states endpoints Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * fix indentation Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * consensus parameters Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * fix indentation Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add height to consensus parameters endpoint Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * unconfirmed_txs and num_unconfirmed_txs Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add missing query parameter Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add ABCI queries Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * added index document for swagger documentation Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add missing routes Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * contract tests added on CCI Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * contract tests job should be in the test suite Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * simplify requirements to test Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * typo Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * build is a prerequisite to start localnet Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * reduce nodejs size, move goodman to get_tools, add docs, fix comments Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * Update scripts/get_tools.sh That's cleaner, thanks! Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * xz not supported by cci image, let's keep it simple Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * REMOVE-indirect debug of CCI paths Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * dirty experiment, volume is empty but binary has been produced Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * dirty experiment, volume is empty but binary has been produced Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * dirty experiment going on Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * locally works, CCI have difficulties with second layaer containers volumes Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * restore experiment, use machine instead of docker for contract tests Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * simplify a bit Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * rollback on machine golang Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * Document the changes Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * Changelog Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * comments Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com>
5 years ago
  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. INCLUDE = -I=${GOPATH}/src/github.com/tendermint/tendermint -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf
  10. BUILD_TAGS?='tendermint'
  11. LD_FLAGS = -X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD` -s -w
  12. BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)"
  13. all: check build test install
  14. # The below include contains the tools.
  15. include tools.mk
  16. include tests.mk
  17. ########################################
  18. ### Build Tendermint
  19. build:
  20. CGO_ENABLED=0 go build $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/
  21. build_c:
  22. CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags "$(BUILD_TAGS) cleveldb" -o $(OUTPUT) ./cmd/tendermint/
  23. build_race:
  24. CGO_ENABLED=1 go build -race $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint
  25. install:
  26. CGO_ENABLED=0 go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint
  27. install_c:
  28. CGO_ENABLED=1 go install $(BUILD_FLAGS) -tags "$(BUILD_TAGS) cleveldb" ./cmd/tendermint
  29. ########################################
  30. ### Protobuf
  31. protoc_all: protoc_libs protoc_merkle protoc_abci protoc_grpc protoc_proto3types
  32. %.pb.go: %.proto
  33. ## If you get the following error,
  34. ## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory"
  35. ## See https://stackoverflow.com/a/25518702
  36. ## Note the $< here is substituted for the %.proto
  37. ## Note the $@ here is substituted for the %.pb.go
  38. protoc $(INCLUDE) $< --gogo_out=Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,plugins=grpc:../../..
  39. ########################################
  40. ### Build ABCI
  41. # see protobuf section above
  42. protoc_abci: abci/types/types.pb.go
  43. protoc_proto3types: types/proto3/block.pb.go
  44. build_abci:
  45. @go build -mod=readonly -i ./abci/cmd/...
  46. install_abci:
  47. @go install -mod=readonly ./abci/cmd/...
  48. ########################################
  49. ### Distribution
  50. # dist builds binaries for all platforms and packages them for distribution
  51. # TODO add abci to these scripts
  52. dist:
  53. @BUILD_TAGS=$(BUILD_TAGS) sh -c "'$(CURDIR)/scripts/dist.sh'"
  54. #For ABCI and libs
  55. get_protoc:
  56. @# https://github.com/google/protobuf/releases
  57. curl -L https://github.com/google/protobuf/releases/download/v3.6.1/protobuf-cpp-3.6.1.tar.gz | tar xvz && \
  58. cd protobuf-3.6.1 && \
  59. DIST_LANG=cpp ./configure && \
  60. make && \
  61. make check && \
  62. sudo make install && \
  63. sudo ldconfig && \
  64. cd .. && \
  65. rm -rf protobuf-3.6.1
  66. go-mod-cache: go.sum
  67. @echo "--> Download go modules to local cache"
  68. @go mod download
  69. .PHONY: go-mod-cache
  70. go.sum: go.mod
  71. @echo "--> Ensure dependencies have not been modified"
  72. @go mod verify
  73. @go mod tidy
  74. draw_deps:
  75. @# requires brew install graphviz or apt-get install graphviz
  76. go get github.com/RobotsAndPencils/goviz
  77. @goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
  78. get_deps_bin_size:
  79. @# Copy of build recipe with additional flags to perform binary size analysis
  80. $(eval $(shell go build -work -a $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/ 2>&1))
  81. @find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log
  82. @echo "Results can be found here: $(CURDIR)/deps_bin_size.log"
  83. ########################################
  84. ### Libs
  85. protoc_libs: libs/common/types.pb.go
  86. # generates certificates for TLS testing in remotedb and RPC server
  87. gen_certs: clean_certs
  88. certstrap init --common-name "tendermint.com" --passphrase ""
  89. certstrap request-cert --common-name "remotedb" -ip "127.0.0.1" --passphrase ""
  90. certstrap sign "remotedb" --CA "tendermint.com" --passphrase ""
  91. mv out/remotedb.crt libs/db/remotedb/test.crt
  92. mv out/remotedb.key libs/db/remotedb/test.key
  93. certstrap request-cert --common-name "server" -ip "127.0.0.1" --passphrase ""
  94. certstrap sign "server" --CA "tendermint.com" --passphrase ""
  95. mv out/server.crt rpc/lib/server/test.crt
  96. mv out/server.key rpc/lib/server/test.key
  97. rm -rf out
  98. # deletes generated certificates
  99. clean_certs:
  100. rm -f libs/db/remotedb/test.crt
  101. rm -f libs/db/remotedb/test.key
  102. rm -f rpc/lib/server/test.crt
  103. rm -f rpc/lib/server/test.key
  104. test_libs:
  105. go test -tags clevedb boltdb $(PACKAGES)
  106. grpc_dbserver:
  107. protoc -I libs/db/remotedb/proto/ libs/db/remotedb/proto/defs.proto --go_out=plugins=grpc:libs/db/remotedb/proto
  108. protoc_grpc: rpc/grpc/types.pb.go
  109. protoc_merkle: crypto/merkle/merkle.pb.go
  110. ########################################
  111. ### Formatting, linting, and vetting
  112. fmt:
  113. @go fmt ./...
  114. lint:
  115. @echo "--> Running linter"
  116. @golangci-lint run
  117. DESTINATION = ./index.html.md
  118. ###########################################################
  119. ### Documentation
  120. build-docs:
  121. cd docs && \
  122. while read p; do \
  123. (git checkout $${p} && npm install && VUEPRESS_BASE="/$${p}/" npm run build) ; \
  124. mkdir -p ~/output/$${p} ; \
  125. cp -r .vuepress/dist/* ~/output/$${p}/ ; \
  126. cp ~/output/$${p}/index.html ~/output ; \
  127. done < versions ;
  128. sync-docs:
  129. cd ~/output && \
  130. echo "role_arn = ${DEPLOYMENT_ROLE_ARN}" >> /root/.aws/config ; \
  131. echo "CI job = ${CIRCLE_BUILD_URL}" >> version.html ; \
  132. aws s3 sync . s3://${WEBSITE_BUCKET} --profile terraform --delete ; \
  133. aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --profile terraform --path "/*" ;
  134. .PHONY: sync-docs
  135. ###########################################################
  136. ### Docker image
  137. build-docker:
  138. cp $(OUTPUT) DOCKER/tendermint
  139. docker build --label=tendermint --tag="tendermint/tendermint" DOCKER
  140. rm -rf DOCKER/tendermint
  141. ###########################################################
  142. ### Local testnet using docker
  143. # Build linux binary on other platforms
  144. build-linux: tools
  145. GOOS=linux GOARCH=amd64 $(MAKE) build
  146. build-docker-localnode:
  147. @cd networks/local && make
  148. # Runs `make build_c` from within an Amazon Linux (v2)-based Docker build
  149. # container in order to build an Amazon Linux-compatible binary. Produces a
  150. # compatible binary at ./build/tendermint
  151. build_c-amazonlinux:
  152. $(MAKE) -C ./DOCKER build_amazonlinux_buildimage
  153. docker run --rm -it -v `pwd`:/tendermint tendermint/tendermint:build_c-amazonlinux
  154. # Run a 4-node testnet locally
  155. localnet-start: localnet-stop build-docker-localnode
  156. @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
  157. docker-compose up
  158. # Stop testnet
  159. localnet-stop:
  160. docker-compose down
  161. ###########################################################
  162. ### Remote full-nodes (sentry) using terraform and ansible
  163. # Server management
  164. sentry-start:
  165. @if [ -z "$(DO_API_TOKEN)" ]; then echo "DO_API_TOKEN environment variable not set." ; false ; fi
  166. @if ! [ -f $(HOME)/.ssh/id_rsa.pub ]; then ssh-keygen ; fi
  167. cd networks/remote/terraform && terraform init && terraform apply -var DO_API_TOKEN="$(DO_API_TOKEN)" -var SSH_KEY_FILE="$(HOME)/.ssh/id_rsa.pub"
  168. @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
  169. cd networks/remote/ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/digital_ocean.py -l sentrynet install.yml
  170. @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.)"
  171. # Configuration management
  172. sentry-config:
  173. cd networks/remote/ansible && ansible-playbook -i inventory/digital_ocean.py -l sentrynet config.yml -e BINARY=$(CURDIR)/build/tendermint -e CONFIGDIR=$(CURDIR)/build
  174. sentry-stop:
  175. @if [ -z "$(DO_API_TOKEN)" ]; then echo "DO_API_TOKEN environment variable not set." ; false ; fi
  176. cd networks/remote/terraform && terraform destroy -var DO_API_TOKEN="$(DO_API_TOKEN)" -var SSH_KEY_FILE="$(HOME)/.ssh/id_rsa.pub"
  177. # Build hooks for dredd, to skip or add information on some steps
  178. build-contract-tests-hooks:
  179. ifeq ($(OS),Windows_NT)
  180. go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests.exe ./cmd/contract_tests
  181. else
  182. go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests
  183. endif
  184. # Run a nodejs tool to test endpoints against a localnet
  185. # The command takes care of starting and stopping the network
  186. # prerequisits: build-contract-tests-hooks build-linux
  187. # the two build commands were not added to let this command run from generic containers or machines.
  188. # The binaries should be built beforehand
  189. contract-tests:
  190. dredd
  191. # To avoid unintended conflicts with file names, always add to .PHONY
  192. # unless there is a reason not to.
  193. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  194. .PHONY: check build build_race build_abci dist install install_abci check_tools tools update_tools draw_deps \
  195. get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver fmt build-linux localnet-start \
  196. localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop protoc_grpc protoc_all \
  197. build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint build-contract-tests-hooks contract-tests \
  198. build_c-amazonlinux