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.

245 lines
8.8 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
[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. PACKAGES=$(shell go list ./...)
  2. OUTPUT?=build/tendermint
  3. BUILD_TAGS?=tendermint
  4. LD_FLAGS = -X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`
  5. BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)"
  6. HTTPS_GIT := https://github.com/tendermint/tendermint.git
  7. DOCKER_BUF := docker run -v $(shell pwd):/workspace --workdir /workspace bufbuild/buf
  8. CGO_ENABLED ?= 0
  9. # handle nostrip
  10. ifeq (,$(findstring nostrip,$(TENDERMINT_BUILD_OPTIONS)))
  11. BUILD_FLAGS += -trimpath
  12. LD_FLAGS += -s -w
  13. endif
  14. # handle race
  15. ifeq (race,$(findstring race,$(TENDERMINT_BUILD_OPTIONS)))
  16. CGO_ENABLED=1
  17. BUILD_FLAGS += -race
  18. endif
  19. # handle cleveldb
  20. ifeq (cleveldb,$(findstring cleveldb,$(TENDERMINT_BUILD_OPTIONS)))
  21. CGO_ENABLED=1
  22. BUILD_TAGS += cleveldb
  23. endif
  24. # allow users to pass additional flags via the conventional LDFLAGS variable
  25. LD_FLAGS += $(LDFLAGS)
  26. all: check build test install
  27. .PHONY: all
  28. # The below include contains the tools.
  29. include tools.mk
  30. include tests.mk
  31. ###############################################################################
  32. ### Build Tendermint ###
  33. ###############################################################################
  34. build:
  35. CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o $(OUTPUT) ./cmd/tendermint/
  36. .PHONY: build
  37. install:
  38. CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint
  39. .PHONY: install
  40. ###############################################################################
  41. ### Protobuf ###
  42. ###############################################################################
  43. proto-all: proto-gen proto-lint proto-check-breaking
  44. .PHONY: proto-all
  45. proto-gen:
  46. ## If you get the following error,
  47. ## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory"
  48. ## See https://stackoverflow.com/a/25518702
  49. ## Note the $< here is substituted for the %.proto
  50. ## Note the $@ here is substituted for the %.pb.go
  51. @sh scripts/protocgen.sh
  52. .PHONY: proto-gen
  53. proto-gen-docker:
  54. @echo "Generating Protobuf files"
  55. @docker run -v $(shell pwd):/workspace --workdir /workspace tendermintdev/docker-build-proto sh ./scripts/protocgen.sh
  56. .PHONY: proto-gen-docker
  57. proto-lint:
  58. @$(DOCKER_BUF) check lint --error-format=json
  59. .PHONY: proto-lint
  60. proto-check-breaking:
  61. @$(DOCKER_BUF) check breaking --against-input .git#branch=master
  62. .PHONY: proto-check-breaking
  63. proto-check-breaking-ci:
  64. @$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master
  65. .PHONY: proto-check-breaking-ci
  66. ###############################################################################
  67. ### Build ABCI ###
  68. ###############################################################################
  69. build_abci:
  70. @go build -mod=readonly -i ./abci/cmd/...
  71. .PHONY: build_abci
  72. install_abci:
  73. @go install -mod=readonly ./abci/cmd/...
  74. .PHONY: install_abci
  75. ###############################################################################
  76. ### Distribution ###
  77. ###############################################################################
  78. # dist builds binaries for all platforms and packages them for distribution
  79. # TODO add abci to these scripts
  80. dist:
  81. @BUILD_TAGS=$(BUILD_TAGS) sh -c "'$(CURDIR)/scripts/dist.sh'"
  82. .PHONY: dist
  83. go-mod-cache: go.sum
  84. @echo "--> Download go modules to local cache"
  85. @go mod download
  86. .PHONY: go-mod-cache
  87. go.sum: go.mod
  88. @echo "--> Ensure dependencies have not been modified"
  89. @go mod verify
  90. @go mod tidy
  91. draw_deps:
  92. @# requires brew install graphviz or apt-get install graphviz
  93. go get github.com/RobotsAndPencils/goviz
  94. @goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
  95. .PHONY: draw_deps
  96. get_deps_bin_size:
  97. @# Copy of build recipe with additional flags to perform binary size analysis
  98. $(eval $(shell go build -work -a $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/ 2>&1))
  99. @find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log
  100. @echo "Results can be found here: $(CURDIR)/deps_bin_size.log"
  101. .PHONY: get_deps_bin_size
  102. ###############################################################################
  103. ### Libs ###
  104. ###############################################################################
  105. # generates certificates for TLS testing in remotedb and RPC server
  106. gen_certs: clean_certs
  107. certstrap init --common-name "tendermint.com" --passphrase ""
  108. certstrap request-cert --common-name "server" -ip "127.0.0.1" --passphrase ""
  109. certstrap sign "server" --CA "tendermint.com" --passphrase ""
  110. mv out/server.crt rpc/jsonrpc/server/test.crt
  111. mv out/server.key rpc/jsonrpc/server/test.key
  112. rm -rf out
  113. .PHONY: gen_certs
  114. # deletes generated certificates
  115. clean_certs:
  116. rm -f rpc/jsonrpc/server/test.crt
  117. rm -f rpc/jsonrpc/server/test.key
  118. .PHONY: clean_certs
  119. ###############################################################################
  120. ### Formatting, linting, and vetting ###
  121. ###############################################################################
  122. format:
  123. find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s
  124. find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local github.com/tendermint/tendermint
  125. .PHONY: format
  126. lint:
  127. @echo "--> Running linter"
  128. @golangci-lint run
  129. .PHONY: lint
  130. DESTINATION = ./index.html.md
  131. ###############################################################################
  132. ### Documentation ###
  133. ###############################################################################
  134. build-docs:
  135. cd docs && \
  136. while read p; do \
  137. (git checkout $${p} && npm install && VUEPRESS_BASE="/$${p}/" npm run build) ; \
  138. mkdir -p ~/output/$${p} ; \
  139. cp -r .vuepress/dist/* ~/output/$${p}/ ; \
  140. cp ~/output/$${p}/index.html ~/output ; \
  141. done < versions ;
  142. .PHONY: build-docs
  143. sync-docs:
  144. cd ~/output && \
  145. echo "role_arn = ${DEPLOYMENT_ROLE_ARN}" >> /root/.aws/config ; \
  146. echo "CI job = ${CIRCLE_BUILD_URL}" >> version.html ; \
  147. aws s3 sync . s3://${WEBSITE_BUCKET} --profile terraform --delete ; \
  148. aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --profile terraform --path "/*" ;
  149. .PHONY: sync-docs
  150. ###############################################################################
  151. ### Docker image ###
  152. ###############################################################################
  153. build-docker: build-linux
  154. cp $(OUTPUT) DOCKER/tendermint
  155. docker build --label=tendermint --tag="tendermint/tendermint" DOCKER
  156. rm -rf DOCKER/tendermint
  157. .PHONY: build-docker
  158. ###############################################################################
  159. ### Local testnet using docker ###
  160. ###############################################################################
  161. # Build linux binary on other platforms
  162. build-linux: tools
  163. GOOS=linux GOARCH=amd64 $(MAKE) build
  164. .PHONY: build-linux
  165. build-docker-localnode:
  166. @cd networks/local && make
  167. .PHONY: build-docker-localnode
  168. # Runs `make build TENDERMINT_BUILD_OPTIONS=cleveldb` from within an Amazon
  169. # Linux (v2)-based Docker build container in order to build an Amazon
  170. # Linux-compatible binary. Produces a compatible binary at ./build/tendermint
  171. build_c-amazonlinux:
  172. $(MAKE) -C ./DOCKER build_amazonlinux_buildimage
  173. docker run --rm -it -v `pwd`:/tendermint tendermint/tendermint:build_c-amazonlinux
  174. .PHONY: build_c-amazonlinux
  175. # Run a 4-node testnet locally
  176. localnet-start: localnet-stop build-linux
  177. @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 --o . --starting-ip-address 192.167.10.2; fi
  178. docker-compose up
  179. .PHONY: localnet-start
  180. # Stop testnet
  181. localnet-stop:
  182. docker-compose down
  183. .PHONY: localnet-stop
  184. # Build hooks for dredd, to skip or add information on some steps
  185. build-contract-tests-hooks:
  186. ifeq ($(OS),Windows_NT)
  187. go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests.exe ./cmd/contract_tests
  188. else
  189. go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests
  190. endif
  191. .PHONY: build-contract-tests-hooks
  192. # Run a nodejs tool to test endpoints against a localnet
  193. # The command takes care of starting and stopping the network
  194. # prerequisits: build-contract-tests-hooks build-linux
  195. # the two build commands were not added to let this command run from generic containers or machines.
  196. # The binaries should be built beforehand
  197. contract-tests:
  198. dredd
  199. .PHONY: contract-tests