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.

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