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.

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