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.

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