2018-01-05 22:35:57 -08:00
GOTOOLS = \
2018-07-04 14:48:45 -04:00
github.com/mitchellh/gox \
2019-02-06 15:00:55 +04:00
github.com/golangci/golangci-lint/cmd/golangci-lint \
2018-07-04 14:48:45 -04:00
github.com/gogo/protobuf/protoc-gen-gogo \
2018-07-04 17:11:34 -04:00
github.com/square/certstrap
2018-10-09 10:28:15 -07:00
GOBIN ?= ${ GOPATH } /bin
2018-07-27 06:23:19 +04:00
PACKAGES = $( shell go list ./...)
2019-03-29 07:57:16 -04:00
OUTPUT ?= build/tendermint
2018-07-23 22:16:34 -04:00
2018-07-04 14:48:45 -04:00
INCLUDE = -I= . -I= ${ GOPATH } /src -I= ${ GOPATH } /src/github.com/gogo/protobuf/protobuf
2018-06-21 01:57:35 -07:00
BUILD_TAGS ?= 'tendermint'
2019-06-24 16:32:24 +02:00
LD_FLAGS = -X github.com/tendermint/tendermint/version.GitCommit= ` git rev-parse --short= 8 HEAD` -s -w
BUILD_FLAGS = -mod= readonly -ldflags " $( LD_FLAGS) "
2017-12-04 17:35:42 -06:00
2018-03-08 18:55:14 +04:00
all : check build test install
2015-07-13 11:49:09 -07:00
2019-09-13 18:52:35 +02:00
# The below include contains the tools.
2019-09-18 10:45:03 +02:00
i n c l u d e t o o l s . m k
2019-09-13 18:52:35 +02:00
i n c l u d e t e s t s . m k
2017-12-23 02:23:05 -08:00
########################################
2018-07-04 14:48:45 -04:00
### Build Tendermint
2014-12-28 16:26:53 -08:00
2017-01-04 00:32:39 +04:00
build :
2019-03-29 07:57:16 -04:00
CGO_ENABLED = 0 go build $( BUILD_FLAGS) -tags $( BUILD_TAGS) -o $( OUTPUT) ./cmd/tendermint/
2015-04-21 19:51:23 -07:00
2018-09-23 01:14:05 -04:00
build_c :
2019-05-07 12:33:47 +04:00
CGO_ENABLED = 1 go build $( BUILD_FLAGS) -tags " $( BUILD_TAGS) cleveldb " -o $( OUTPUT) ./cmd/tendermint/
2018-09-23 01:14:05 -04:00
2017-01-04 00:32:39 +04:00
build_race :
2019-08-16 15:45:19 +02:00
CGO_ENABLED = 1 go build -race $( BUILD_FLAGS) -tags $( BUILD_TAGS) -o $( OUTPUT) ./cmd/tendermint
2018-01-08 16:41:23 -06:00
install :
2019-06-09 05:27:48 -07:00
CGO_ENABLED = 0 go install $( BUILD_FLAGS) -tags $( BUILD_TAGS) ./cmd/tendermint
2018-01-08 16:41:23 -06:00
2018-11-28 17:25:23 +04:00
install_c :
2019-06-09 05:27:48 -07:00
CGO_ENABLED = 1 go install $( BUILD_FLAGS) -tags " $( BUILD_TAGS) cleveldb " ./cmd/tendermint
2018-11-28 17:25:23 +04:00
2018-07-04 14:48:45 -04:00
########################################
2018-07-17 13:56:42 +01:00
### Protobuf
2018-10-29 14:16:50 +01:00
protoc_all : protoc_libs protoc_merkle protoc_abci protoc_grpc protoc_proto 3types
2018-07-04 14:48:45 -04:00
2018-07-17 13:56:42 +01:00
%.pb.go : %.proto
2018-07-04 14:48:45 -04:00
## If you get the following error,
## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory"
## See https://stackoverflow.com/a/25518702
2018-08-05 23:22:09 -04:00
## Note the $< here is substituted for the %.proto
## Note the $@ here is substituted for the %.pb.go
2018-07-27 06:23:19 +04:00
protoc $( INCLUDE) $< --gogo_out= Mgoogle/protobuf/timestamp.proto= github.com/golang/protobuf/ptypes/timestamp,plugins= grpc:.
2018-07-17 13:56:42 +01:00
########################################
### Build ABCI
2018-08-05 23:22:09 -04:00
# see protobuf section above
2018-07-17 13:56:42 +01:00
protoc_abci : abci /types /types .pb .go
2018-07-04 14:48:45 -04:00
2018-10-29 14:16:50 +01:00
protoc_proto3types : types /proto 3/block .pb .go
2018-07-04 14:48:45 -04:00
build_abci :
2019-06-09 05:27:48 -07:00
@go build -mod= readonly -i ./abci/cmd/...
2018-07-04 14:48:45 -04:00
install_abci :
2019-06-09 05:27:48 -07:00
@go install -mod= readonly ./abci/cmd/...
2018-01-08 16:41:23 -06:00
########################################
### Distribution
2014-12-28 17:10:03 -08:00
2017-01-23 13:45:14 +04:00
# dist builds binaries for all platforms and packages them for distribution
2018-07-04 14:48:45 -04:00
# TODO add abci to these scripts
2017-01-23 13:45:14 +04:00
dist :
2018-06-21 01:57:35 -07:00
@BUILD_TAGS= $( BUILD_TAGS) sh -c " ' $( CURDIR) /scripts/dist.sh' "
2017-01-23 13:45:14 +04:00
2018-07-04 17:11:34 -04:00
#For ABCI and libs
2018-07-04 14:48:45 -04:00
get_protoc :
@# https://github.com/google/protobuf/releases
2018-08-10 09:14:17 +04:00
curl -L https://github.com/google/protobuf/releases/download/v3.6.1/protobuf-cpp-3.6.1.tar.gz | tar xvz && \
cd protobuf-3.6.1 && \
2018-07-04 14:48:45 -04:00
DIST_LANG = cpp ./configure && \
make && \
2018-08-10 09:14:17 +04:00
make check && \
sudo make install && \
sudo ldconfig && \
2018-07-04 14:48:45 -04:00
cd .. && \
2018-08-10 09:14:17 +04:00
rm -rf protobuf-3.6.1
2018-07-04 14:48:45 -04:00
2019-09-13 18:52:35 +02:00
go-mod-cache : go .sum
@echo "--> Download go modules to local cache"
@go mod download
.PHONY : go -mod -cache
go.sum : go .mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify
@go mod tidy
2017-12-23 02:23:05 -08:00
draw_deps :
@# requires brew install graphviz or apt-get install graphviz
go get github.com/RobotsAndPencils/goviz
@goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
2018-02-28 08:23:31 +01:00
get_deps_bin_size :
@# Copy of build recipe with additional flags to perform binary size analysis
2019-03-29 07:57:16 -04:00
$( eval $( shell go build -work -a $( BUILD_FLAGS) -tags $( BUILD_TAGS) -o $( OUTPUT) ./cmd/tendermint/ 2>& 1) )
2018-02-28 08:23:31 +01:00
@find $( WORK) -type f -name "*.a" | xargs -I{ } du -hxs "{}" | sort -rh | sed -e s:${ WORK } /::g > deps_bin_size.log
@echo " Results can be found here: $( CURDIR) /deps_bin_size.log "
2017-12-23 02:23:05 -08:00
2018-07-04 17:11:34 -04:00
########################################
### Libs
2018-07-17 13:56:42 +01:00
protoc_libs : libs /common /types .pb .go
2018-07-04 17:11:34 -04:00
2019-06-22 19:44:12 +04:00
# generates certificates for TLS testing in remotedb and RPC server
2018-07-04 17:11:34 -04:00
gen_certs : clean_certs
certstrap init --common-name "tendermint.com" --passphrase ""
2019-06-22 19:44:12 +04:00
certstrap request-cert --common-name "remotedb" -ip "127.0.0.1" --passphrase ""
certstrap sign "remotedb" --CA "tendermint.com" --passphrase ""
mv out/remotedb.crt libs/db/remotedb/test.crt
mv out/remotedb.key libs/db/remotedb/test.key
certstrap request-cert --common-name "server" -ip "127.0.0.1" --passphrase ""
certstrap sign "server" --CA "tendermint.com" --passphrase ""
mv out/server.crt rpc/lib/server/test.crt
mv out/server.key rpc/lib/server/test.key
rm -rf out
2018-07-04 17:11:34 -04:00
2019-06-22 19:44:12 +04:00
# deletes generated certificates
2018-07-04 17:11:34 -04:00
clean_certs :
2019-06-22 19:44:12 +04:00
rm -f libs/db/remotedb/test.crt
rm -f libs/db/remotedb/test.key
rm -f rpc/lib/server/test.crt
rm -f rpc/lib/server/test.key
2018-07-04 17:11:34 -04:00
2019-06-22 19:44:12 +04:00
test_libs :
2019-05-07 12:33:47 +04:00
go test -tags clevedb boltdb $( PACKAGES)
2018-07-04 17:11:34 -04:00
grpc_dbserver :
2019-06-22 19:44:12 +04:00
protoc -I libs/db/remotedb/proto/ libs/db/remotedb/proto/defs.proto --go_out= plugins = grpc:libs/db/remotedb/proto
2018-07-04 17:11:34 -04:00
2018-07-17 13:56:42 +01:00
protoc_grpc : rpc /grpc /types .pb .go
2018-09-29 09:03:19 +09:00
protoc_merkle : crypto /merkle /merkle .pb .go
2017-02-08 19:28:25 +01:00
2017-12-23 02:23:05 -08:00
########################################
2017-05-30 13:27:31 -04:00
### Formatting, linting, and vetting
2017-12-23 02:23:05 -08:00
fmt :
@go fmt ./...
2017-02-08 19:28:25 +01:00
2019-02-06 15:00:55 +04:00
lint :
2017-12-23 02:23:05 -08:00
@echo "--> Running linter"
2019-02-06 15:00:55 +04:00
@golangci-lint run
2017-12-23 02:23:05 -08:00
2018-07-25 17:37:08 -04:00
DESTINATION = ./index.html.md
2018-04-16 11:34:01 -04:00
###########################################################
### Docker image
build-docker :
2019-03-29 07:57:16 -04:00
cp $( OUTPUT) DOCKER/tendermint
2018-04-16 11:34:01 -04:00
docker build --label= tendermint --tag= "tendermint/tendermint" DOCKER
rm -rf DOCKER/tendermint
2018-04-12 13:15:16 +02:00
###########################################################
### Local testnet using docker
# Build linux binary on other platforms
2019-09-13 18:52:35 +02:00
build-linux : tools
2018-04-12 13:15:16 +02:00
GOOS = linux GOARCH = amd64 $( MAKE) build
2018-05-19 23:21:19 -04:00
build-docker-localnode :
2019-01-15 02:33:33 +04:00
@cd networks/local && make
2018-05-19 23:21:19 -04:00
2019-09-13 18:52:35 +02:00
# Runs `make build_c` from within an Amazon Linux (v2)-based Docker build
# container in order to build an Amazon Linux-compatible binary. Produces a
# compatible binary at ./build/tendermint
build_c-amazonlinux :
$( MAKE) -C ./DOCKER build_amazonlinux_buildimage
docker run --rm -it -v ` pwd ` :/tendermint tendermint/tendermint:build_c-amazonlinux
2018-04-12 13:15:16 +02:00
# Run a 4-node testnet locally
2019-06-24 10:32:12 -04:00
localnet-start : localnet -stop build -docker -localnode
@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 --v 4 --o . --populate-persistent-peers --starting-ip-address 192.167.10.2; fi
2018-04-12 13:15:16 +02:00
docker-compose up
# Stop testnet
2018-04-17 12:28:05 -04:00
localnet-stop :
2018-04-12 13:15:16 +02:00
docker-compose down
2018-04-13 21:03:25 -04:00
###########################################################
### Remote full-nodes (sentry) using terraform and ansible
# Server management
2018-04-24 14:22:19 -04:00
sentry-start :
2018-04-16 11:34:01 -04:00
@if [ -z " $( DO_API_TOKEN) " ] ; then echo "DO_API_TOKEN environment variable not set." ; false ; fi
2018-04-13 21:03:25 -04:00
@if ! [ -f $( HOME) /.ssh/id_rsa.pub ] ; then ssh-keygen ; fi
cd networks/remote/terraform && terraform init && terraform apply -var DO_API_TOKEN = " $( DO_API_TOKEN) " -var SSH_KEY_FILE = " $( HOME) /.ssh/id_rsa.pub "
2018-04-16 11:34:01 -04:00
@if ! [ -f $( CURDIR) /build/node0/config/genesis.json ] ; then docker run --rm -v $( CURDIR) /build:/tendermint:Z tendermint/localnode testnet --v 0 --n 4 --o . ; fi
2018-04-24 14:22:19 -04:00
cd networks/remote/ansible && ANSIBLE_HOST_KEY_CHECKING = False ansible-playbook -i inventory/digital_ocean.py -l sentrynet install.yml
2018-05-18 13:22:04 -04:00
@echo "Next step: Add your validator setup in the genesis.json and config.tml files and run \"make sentry-config\". (Public key of validator, chain ID, peer IP and node ID.)"
2018-04-13 21:03:25 -04:00
# Configuration management
2018-04-24 14:22:19 -04:00
sentry-config :
cd networks/remote/ansible && ansible-playbook -i inventory/digital_ocean.py -l sentrynet config.yml -e BINARY = $( CURDIR) /build/tendermint -e CONFIGDIR = $( CURDIR) /build
2018-04-16 11:34:01 -04:00
2018-04-24 14:22:19 -04:00
sentry-stop :
2018-04-16 11:34:01 -04:00
@if [ -z " $( DO_API_TOKEN) " ] ; then echo "DO_API_TOKEN environment variable not set." ; false ; fi
cd networks/remote/terraform && terraform destroy -var DO_API_TOKEN = " $( DO_API_TOKEN) " -var SSH_KEY_FILE = " $( HOME) /.ssh/id_rsa.pub "
2018-04-13 21:03:25 -04:00
[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>
2019-08-16 11:29:02 +02:00
# Build hooks for dredd, to skip or add information on some steps
build-contract-tests-hooks :
i f e q ( $( OS ) , W i n d o w s _ N T )
go build -mod= readonly $( BUILD_FLAGS) -o build/contract_tests.exe ./cmd/contract_tests
e l s e
go build -mod= readonly $( BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests
e n d i f
# Run a nodejs tool to test endpoints against a localnet
# The command takes care of starting and stopping the network
# prerequisits: build-contract-tests-hooks build-linux
# the two build commands were not added to let this command run from generic containers or machines.
# The binaries should be built beforehand
contract-tests :
dredd
2017-12-23 02:23:05 -08:00
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
2019-09-13 18:52:35 +02:00
.PHONY : check build build_race build_abci dist install install_abci check_tools tools update_tools draw_deps \
get_protoc protoc_abci protoc_libs gen_certs clean_certs grpc_dbserver fmt rpc-docs build-linux localnet-start \
localnet-stop build-docker build-docker-localnode sentry-start sentry-config sentry-stop protoc_grpc protoc_all \
build_c install_c test_with_deadlock cleanup_after_test_with_deadlock lint build-contract-tests-hooks contract-tests \
build_c-amazonlinux