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.

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