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.

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