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.

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