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.

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