2020-09-30 16:28:36 +07:00
GOBIN = $( CURDIR) /build/bin
2020-10-28 13:17:18 +01:00
GOTEST = go test ./... -p 1 --tags 'mdbx'
2015-11-20 16:06:35 +02:00
2020-10-30 09:43:24 +01:00
GIT_COMMIT ?= $( shell git rev-list -1 HEAD)
2021-04-11 11:23:50 +07:00
GIT_BRANCH ?= $( shell git rev-parse --abbrev-ref HEAD)
2021-04-29 21:29:58 +07:00
GOBUILD = env GO111MODULE = on CGO_CFLAGS = '-DMDBX_BUILD_FLAGS_CONFIG="config.h"' go build -trimpath -tags= mdbx -ldflags " -X main.gitCommit= ${ GIT_COMMIT } -X main.gitBranch= ${ GIT_BRANCH } "
GO_DBG_BUILD = env CGO_CFLAGS = '-O0 -g -DMDBX_BUILD_FLAGS_CONFIG="config.h"' go build -trimpath -tags= mdbx,debug -ldflags " -X main.gitCommit= ${ GIT_COMMIT } -X main.gitBranch= ${ GIT_BRANCH } " -gcflags= all = "-N -l" # see delve docs
2020-09-06 12:35:32 +01:00
2021-04-19 17:54:56 +07:00
GO_MAJOR_VERSION = $( shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $( shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
2020-09-29 21:09:50 +07:00
OS = $( shell uname -s)
ARCH = $( shell uname -m)
i f e q ( $( OS ) , D a r w i n )
PROTOC_OS := osx
e n d i f
i f e q ( $( OS ) , L i n u x )
PROTOC_OS = linux
e n d i f
2021-03-14 19:07:19 +00:00
all : tg hack rpctest state pics rpcdaemon integration db -tools
2020-08-21 14:38:11 +02:00
2021-04-19 17:54:56 +07:00
go-version :
@if [ $( GO_MINOR_VERSION) -lt 16 ] ; then \
echo "minimum required Golang version is 1.16" ; \
exit 1 ; \
fi
2020-08-21 14:38:11 +02:00
docker :
2021-03-01 11:02:06 +07:00
docker build -t turbo-geth:latest --build-arg git_commit = '${GIT_COMMIT}' --build-arg git_branch = '${GIT_BRANCH}' .
2020-08-21 14:38:11 +02:00
docker-compose :
docker-compose up
2019-05-27 14:51:49 +01:00
2021-04-29 21:29:58 +07:00
# debug build allows see C stack traces, run it with GOTRACEBACK=crash. You don't need debug build for C pit for profiling. To profile C code use SETCGOTRCKEBACK=1
dbg : mdbx -dbg
$( GO_DBG_BUILD) -o $( GOBIN) / ./cmd/...
2015-04-18 23:21:45 +02:00
geth :
2021-03-01 11:02:06 +07:00
$( GOBUILD) -o $( GOBIN) /tg ./cmd/tg
2015-04-18 23:21:45 +02:00
@echo "Done building."
2020-07-29 21:53:16 +01:00
@echo " Run \" $( GOBIN) /tg\" to launch turbo-geth. "
2015-04-18 23:21:45 +02:00
2021-04-19 17:54:56 +07:00
tg : go -version mdbx
2021-03-31 08:26:01 +07:00
@echo "Building tg"
2021-03-01 11:02:06 +07:00
$( GOBUILD) -o $( GOBIN) /tg ./cmd/tg
2020-07-30 17:37:46 +02:00
@echo "Done building."
@echo " Run \" $( GOBIN) /tg\" to launch turbo-geth. "
2019-05-27 14:51:49 +01:00
hack :
2021-03-01 11:02:06 +07:00
$( GOBUILD) -o $( GOBIN) /hack ./cmd/hack
2019-05-27 14:51:49 +01:00
@echo "Done building."
@echo " Run \" $( GOBIN) /hack\" to launch hack. "
rpctest :
2021-03-01 11:02:06 +07:00
$( GOBUILD) -o $( GOBIN) /rpctest ./cmd/rpctest
2019-05-27 14:51:49 +01:00
@echo "Done building."
@echo " Run \" $( GOBIN) /rpctest\" to launch rpctest. "
state :
2021-03-15 12:21:41 -05:00
$( GOBUILD) -o $( GOBIN) /state ./cmd/state
2019-05-27 14:51:49 +01:00
@echo "Done building."
@echo " Run \" $( GOBIN) /state\" to launch state. "
2020-02-09 13:31:52 +03:00
2020-10-28 10:18:10 +07:00
2019-05-27 14:51:49 +01:00
pics :
2021-03-01 11:02:06 +07:00
$( GOBUILD) -o $( GOBIN) /pics ./cmd/pics
2019-05-27 14:51:49 +01:00
@echo "Done building."
@echo " Run \" $( GOBIN) /pics\" to launch pics. "
2019-12-02 13:47:00 +00:00
rpcdaemon :
2021-03-01 11:02:06 +07:00
$( GOBUILD) -o $( GOBIN) /rpcdaemon ./cmd/rpcdaemon
2019-12-02 13:47:00 +00:00
@echo "Done building."
@echo " Run \" $( GOBIN) /rpcdaemon\" to launch rpcdaemon. "
2020-07-10 13:03:18 +07:00
integration :
2021-03-01 11:02:06 +07:00
$( GOBUILD) -o $( GOBIN) /integration ./cmd/integration
2020-07-10 13:03:18 +07:00
@echo "Done building."
@echo " Run \" $( GOBIN) /integration\" to launch integration tests. "
2020-09-07 07:03:12 +01:00
headers :
2021-03-01 11:02:06 +07:00
$( GOBUILD) -o $( GOBIN) /headers ./cmd/headers
2020-09-07 07:03:12 +01:00
@echo "Done building."
2021-02-15 18:54:45 +00:00
@echo " Run \" $( GOBIN) /headers\" to run headers download PoC. "
2016-11-25 12:34:19 +02:00
2021-04-29 16:14:10 +01:00
cons :
$( GOBUILD) -o $( GOBIN) /cons ./cmd/cons
@echo "Done building."
@echo " Run \" $( GOBIN) /cons\" to run consensus engine PoC. "
2021-05-05 23:55:15 +03:00
evm :
$( GOBUILD) -o $( GOBIN) /evm ./cmd/evm
@echo "Done building."
@echo " Run \" $( GOBIN) /evm\" to run EVM "
2021-02-28 11:11:28 +07:00
db-tools : mdbx
2021-03-31 08:26:01 +07:00
@echo "Building bb-tools"
2021-04-10 15:38:02 +07:00
go mod vendor; cd vendor/github.com/ledgerwatch/lmdb-go/dist; make clean mdb_stat mdb_copy mdb_dump mdb_drop mdb_load; cp mdb_stat $( GOBIN) ; cp mdb_copy $( GOBIN) ; cp mdb_dump $( GOBIN) ; cp mdb_drop $( GOBIN) ; cp mdb_load $( GOBIN) ; cd ../../../../..; rm -rf vendor
2020-10-28 10:18:10 +07:00
cd ethdb/mdbx/dist/ && make tools
2020-10-29 20:19:46 +07:00
cp ethdb/mdbx/dist/mdbx_chk $( GOBIN)
2020-10-28 10:18:10 +07:00
cp ethdb/mdbx/dist/mdbx_copy $( GOBIN)
cp ethdb/mdbx/dist/mdbx_dump $( GOBIN)
2021-04-10 15:38:02 +07:00
cp ethdb/mdbx/dist/mdbx_drop $( GOBIN)
2020-10-28 10:18:10 +07:00
cp ethdb/mdbx/dist/mdbx_load $( GOBIN)
2020-10-29 20:19:46 +07:00
cp ethdb/mdbx/dist/mdbx_stat $( GOBIN)
2020-10-08 14:11:36 +07:00
@echo " Run \" $( GOBIN) /lmdb_stat -h\" to get info about lmdb file. "
2021-02-28 11:11:28 +07:00
mdbx :
2021-03-31 08:26:01 +07:00
@echo "Building mdbx"
@cd ethdb/mdbx/dist/ \
2020-11-28 21:26:28 +07:00
&& make clean && make config.h \
2020-12-16 21:35:14 +07:00
&& echo '#define MDBX_DEBUG 0' >> config.h \
&& echo '#define MDBX_FORCE_ASSERTIONS 0' >> config.h \
&& CFLAGS_EXTRA = "-Wno-deprecated-declarations" make mdbx-static.o
2020-10-28 10:18:10 +07:00
2021-04-29 21:29:58 +07:00
mdbx-dbg :
@echo "Building mdbx"
@cd ethdb/mdbx/dist/ \
&& make clean && make config.h \
&& echo '#define MDBX_DEBUG 1' >> config.h \
&& echo '#define MDBX_FORCE_ASSERTIONS 1' >> config.h \
&& CFLAGS_EXTRA = "-Wno-deprecated-declarations" CFLAGS = '-O0 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread -Wno-error=attributes' make mdbx-static.o
2021-02-28 11:11:28 +07:00
test : mdbx
2021-04-21 20:03:08 +07:00
TEST_DB = mdbx $( GOTEST) --timeout 15m
2020-06-05 16:25:33 +07:00
2020-10-28 17:52:00 +00:00
test-lmdb :
2020-08-21 14:38:11 +02:00
TEST_DB = lmdb $( GOTEST)
2020-06-05 16:25:33 +07:00
2020-12-16 21:35:14 +07:00
2021-02-28 11:11:28 +07:00
test-mdbx : mdbx
2020-11-28 21:26:28 +07:00
TEST_DB = mdbx $( GOTEST)
2020-06-12 16:31:21 +07:00
2021-04-27 14:48:59 +07:00
lint :
@./build/bin/golangci-lint run --build-tags= "mdbx" --config ./.golangci.yml
2019-05-27 14:51:49 +01:00
2021-02-28 11:11:28 +07:00
lintci : mdbx
2021-03-30 02:17:19 +03:00
@echo "--> Running linter for code"
2021-04-02 13:36:49 +07:00
@./build/bin/golangci-lint run --build-tags= "mdbx" --config ./.golangci.yml
2019-11-05 09:12:49 +01:00
2019-05-27 14:51:49 +01:00
lintci-deps :
2019-11-06 15:34:35 +03:00
rm -f ./build/bin/golangci-lint
2021-04-02 13:36:49 +07:00
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b ./build/bin v1.38.0
2018-04-18 00:53:50 +02:00
2016-05-25 14:07:57 +02:00
clean :
2020-01-14 13:13:14 +01:00
env GO111MODULE = on go clean -cache
2020-10-28 10:18:10 +07:00
rm -fr build/*
cd ethdb/mdbx/dist/ && make clean
2016-05-25 14:07:57 +02:00
2017-02-26 23:52:10 +01:00
# The devtools target installs tools required for 'go generate'.
# You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'.
devtools :
2020-10-02 10:56:13 +07:00
# Notice! If you adding new binary - add it also to cmd/hack/binary-deps/main.go file
$( GOBUILD) -o $( GOBIN) /stringer golang.org/x/tools/cmd/stringer
$( GOBUILD) -o $( GOBIN) /go-bindata github.com/kevinburke/go-bindata/go-bindata
$( GOBUILD) -o $( GOBIN) /gencodec github.com/fjl/gencodec
$( GOBUILD) -o $( GOBIN) /codecgen github.com/ugorji/go/codec/codecgen
$( GOBUILD) -o $( GOBIN) /abigen ./cmd/abigen
PATH = $( GOBIN) :$( PATH) go generate ./common
PATH = $( GOBIN) :$( PATH) go generate ./core/types
2018-01-08 13:15:57 +01:00
@type "npm" 2> /dev/null || echo 'Please install node.js and npm'
@type "solc" 2> /dev/null || echo 'Please install solc'
@type "protoc" 2> /dev/null || echo 'Please install protoc'
2017-02-26 23:52:10 +01:00
2019-05-27 14:51:49 +01:00
bindings :
2020-10-02 10:56:13 +07:00
PATH = $( GOBIN) :$( PATH) go generate ./tests/contracts/
PATH = $( GOBIN) :$( PATH) go generate ./core/state/contracts/
2020-09-03 10:51:19 +03:00
grpc :
# See also: ./cmd/hack/binary-deps/main.go
2020-11-17 20:13:41 +01:00
mkdir -p ./build/bin/
2020-09-29 21:09:50 +07:00
rm -f ./build/bin/protoc*
rm -rf ./build/include*
$( eval PROTOC_TMP := $( shell mktemp -d) )
2021-04-15 17:06:05 +07:00
cd $( PROTOC_TMP) ; curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-$( PROTOC_OS) -$( ARCH) .zip -o protoc.zip
2020-09-29 21:09:50 +07:00
cd $( PROTOC_TMP) ; unzip protoc.zip && mv bin/protoc $( GOBIN) && mv include $( GOBIN) /..
2020-09-29 16:55:41 +07:00
$( GOBUILD) -o $( GOBIN) /protoc-gen-go google.golang.org/protobuf/cmd/protoc-gen-go # generates proto messages
$( GOBUILD) -o $( GOBIN) /protoc-gen-go-grpc google.golang.org/grpc/cmd/protoc-gen-go-grpc # generates grpc services
2021-04-24 16:46:29 +01:00
PATH = $( GOBIN) :$( PATH) protoc --proto_path= interfaces --go_out= gointerfaces -I= build/include/google \
types/types.proto
2021-03-19 21:24:49 +00:00
PATH = $( GOBIN) :$( PATH) protoc --proto_path= interfaces --go_out= gointerfaces --go-grpc_out= gointerfaces -I= build/include/google \
--go_opt= Mtypes/types.proto= github.com/ledgerwatch/turbo-geth/gointerfaces/types \
2021-04-24 16:46:29 +01:00
--go-grpc_opt= Mtypes/types.proto= github.com/ledgerwatch/turbo-geth/gointerfaces/types \
2021-03-19 21:24:49 +00:00
p2psentry/sentry.proto \
2021-04-03 10:30:28 +07:00
remote/kv.proto remote/ethbackend.proto \
2021-04-15 17:06:05 +07:00
snapshot_downloader/external_downloader.proto \
2021-04-29 16:14:10 +01:00
consensus_engine/consensus.proto \
2021-05-04 08:37:17 +07:00
testing/testing.proto \
txpool/txpool.proto
2020-11-13 19:16:47 +03:00
2020-04-29 17:51:07 +07:00
prometheus :
2020-08-01 22:05:48 +07:00
docker-compose up prometheus grafana
2020-06-05 19:46:34 +03:00
2021-02-28 11:11:28 +07:00
2020-06-05 19:46:34 +03:00
escape :
2020-06-15 19:39:34 +03:00
cd $( path) && go test -gcflags "-m -m" -run none -bench= BenchmarkJumpdest* -benchmem -memprofile mem.out
2021-05-05 23:55:15 +03:00