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.

278 lines
9.8 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. ###############################################################################
  166. ### Docker image ###
  167. ###############################################################################
  168. build-docker: build-linux
  169. cp $(BUILDDIR)/tendermint DOCKER/tendermint
  170. docker build --label=tendermint --tag="tendermint/tendermint" DOCKER
  171. rm -rf DOCKER/tendermint
  172. .PHONY: build-docker
  173. ###############################################################################
  174. ### Local testnet using docker ###
  175. ###############################################################################
  176. # Build linux binary on other platforms
  177. build-linux: tools
  178. GOOS=linux GOARCH=amd64 $(MAKE) build
  179. .PHONY: build-linux
  180. build-docker-localnode:
  181. @cd networks/local && make
  182. .PHONY: build-docker-localnode
  183. # Runs `make build TENDERMINT_BUILD_OPTIONS=cleveldb` from within an Amazon
  184. # Linux (v2)-based Docker build container in order to build an Amazon
  185. # Linux-compatible binary. Produces a compatible binary at ./build/tendermint
  186. build_c-amazonlinux:
  187. $(MAKE) -C ./DOCKER build_amazonlinux_buildimage
  188. docker run --rm -it -v `pwd`:/tendermint tendermint/tendermint:build_c-amazonlinux
  189. .PHONY: build_c-amazonlinux
  190. # Run a 4-node testnet locally
  191. localnet-start: localnet-stop build-docker-localnode
  192. @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
  193. docker-compose up
  194. .PHONY: localnet-start
  195. # Stop testnet
  196. localnet-stop:
  197. docker-compose down
  198. .PHONY: localnet-stop
  199. # Build hooks for dredd, to skip or add information on some steps
  200. build-contract-tests-hooks:
  201. ifeq ($(OS),Windows_NT)
  202. go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests.exe ./cmd/contract_tests
  203. else
  204. go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests
  205. endif
  206. .PHONY: build-contract-tests-hooks
  207. # Run a nodejs tool to test endpoints against a localnet
  208. # The command takes care of starting and stopping the network
  209. # prerequisits: build-contract-tests-hooks build-linux
  210. # the two build commands were not added to let this command run from generic containers or machines.
  211. # The binaries should be built beforehand
  212. contract-tests:
  213. dredd
  214. .PHONY: contract-tests
  215. clean:
  216. rm -rf $(CURDIR)/artifacts/ $(BUILDDIR)/
  217. build-reproducible:
  218. docker rm latest-build || true
  219. docker run --volume=$(CURDIR):/sources:ro \
  220. --env TARGET_PLATFORMS='linux/amd64 linux/arm64 darwin/amd64 windows/amd64' \
  221. --env APP=tendermint \
  222. --env COMMIT=$(shell git rev-parse --short=8 HEAD) \
  223. --env VERSION=$(shell git describe --tags) \
  224. --name latest-build cosmossdk/rbuilder:latest
  225. docker cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/
  226. .PHONY: build-reproducible