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