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.

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