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.

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