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.

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