-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7d269d
commit 6b7dfaa
Showing
3 changed files
with
292 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/usr/bin/make -f | ||
|
||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | ||
COMMIT := $(shell git log -1 --format='%H') | ||
|
||
# don't override user values | ||
ifeq (,$(VERSION)) | ||
VERSION := $(shell git describe --tags | sed 's/^v//') | ||
# if VERSION is empty, then populate it with branch's name and raw commit hash | ||
ifeq (,$(VERSION)) | ||
VERSION := $(BRANCH)-$(COMMIT) | ||
endif | ||
endif | ||
|
||
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') | ||
LEDGER_ENABLED ?= true | ||
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g') | ||
TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7" | ||
DOCKER := $(shell which docker) | ||
BUILDDIR ?= $(CURDIR)/build | ||
TEST_DOCKER_REPO=jackzampolin/gaiatest | ||
|
||
export GO111MODULE = on | ||
|
||
# process build tags | ||
|
||
build_tags = netgo | ||
ifeq ($(LEDGER_ENABLED),true) | ||
ifeq ($(OS),Windows_NT) | ||
GCCEXE = $(shell where gcc.exe 2> NUL) | ||
ifeq ($(GCCEXE),) | ||
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false) | ||
else | ||
build_tags += ledger | ||
endif | ||
else | ||
UNAME_S = $(shell uname -s) | ||
ifeq ($(UNAME_S),OpenBSD) | ||
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)) | ||
else | ||
GCC = $(shell command -v gcc 2> /dev/null) | ||
ifeq ($(GCC),) | ||
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false) | ||
else | ||
build_tags += ledger | ||
endif | ||
endif | ||
endif | ||
endif | ||
|
||
ifeq (cleveldb,$(findstring cleveldb,$(GAIA_BUILD_OPTIONS))) | ||
build_tags += gcc cleveldb | ||
endif | ||
build_tags += $(BUILD_TAGS) | ||
build_tags := $(strip $(build_tags)) | ||
|
||
whitespace := | ||
whitespace += $(whitespace) | ||
comma := , | ||
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) | ||
|
||
# process linker flags | ||
|
||
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=bcna \ | ||
-X github.com/cosmos/cosmos-sdk/version.AppName=bcnad \ | ||
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ | ||
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ | ||
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \ | ||
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION) | ||
|
||
ifeq (cleveldb,$(findstring cleveldb,$(GAIA_BUILD_OPTIONS))) | ||
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb | ||
endif | ||
ifeq (,$(findstring nostrip,$(GAIA_BUILD_OPTIONS))) | ||
ldflags += -w -s | ||
endif | ||
ldflags += $(LDFLAGS) | ||
ldflags := $(strip $(ldflags)) | ||
|
||
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' | ||
# check for nostrip option | ||
ifeq (,$(findstring nostrip,$(GAIA_BUILD_OPTIONS))) | ||
BUILD_FLAGS += -trimpath | ||
endif | ||
|
||
#$(info $$BUILD_FLAGS is [$(BUILD_FLAGS)]) | ||
|
||
# The below include contains the tools target. | ||
include contrib/devtools/Makefile | ||
|
||
############################################################################### | ||
### Documentation ### | ||
############################################################################### | ||
|
||
all: install lint test | ||
|
||
BUILD_TARGETS := build install | ||
|
||
build: BUILD_ARGS=-o $(BUILDDIR)/ | ||
|
||
$(BUILD_TARGETS): go.sum $(BUILDDIR)/ | ||
#go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... Don't overwrite go.sum | ||
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./... | ||
|
||
$(BUILDDIR)/: | ||
mkdir -p $(BUILDDIR)/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Hardware Requirements | ||
Here are the minimal hardware configs required for running a validator/sentry node | ||
|
||
* 8GB RAM | ||
* 4vCPUs | ||
* 200GB Disk space | ||
|
||
# Software Requirements | ||
Install deps | ||
``` | ||
sudo apt-get install build-essential jq | ||
``` | ||
|
||
# Compile instructions: install GoLang | ||
|
||
Install Go 1.15.x (there are some issues with SDK keyring and 1.16.x) | ||
The official instructions can be found here: https://golang.org/doc/install | ||
|
||
First remove any existing old Go installation as root | ||
``` | ||
sudo rm -rf /usr/local/go | ||
``` | ||
|
||
Download the software: | ||
``` | ||
curl https://dl.google.com/go/go1.15.11.linux-amd64.tar.gz | sudo tar -C/usr/local -zxvf - | ||
``` | ||
Update environment variables to include go (copy everything and paste) | ||
``` | ||
cat <<'EOF' >>$HOME/.profile | ||
export GOROOT=/usr/local/go | ||
export GOPATH=$HOME/go | ||
export GO111MODULE=on | ||
export GOBIN=$HOME/go/bin | ||
export PATH=$PATH:/usr/local/go/bin:$GOBIN | ||
EOF | ||
source $HOME/.profile | ||
``` | ||
To verify that Go is installed: | ||
``` | ||
go version | ||
``` | ||
Should return go version go1.15.11 linux/amd64 | ||
|
||
# Compile BCNAD source code by yourself | ||
## Download source code and compile | ||
``` | ||
git clone https://github.com/BitCannaGlobal/testnet-bcna-cosmos.git | ||
cd testnet-bcna-cosmos | ||
git checkout v0.testnet7 | ||
make build #it build the binary in build/ folder | ||
``` | ||
To know the version: | ||
``` | ||
build/bcnad version | ||
``` | ||
The output must be `0.testnet7` | ||
|
||
Is the versión match, now you have two options | ||
* Move the binary to the /usr/local/bin path with: `sudo mv build/bcnad /usr/local/bin/` | ||
* Compile and install the binary in the $GOPATH path: `make install` | ||
|
||
# Cosmosvisor Quick Start | ||
Cosmovisor is a small process manager for Cosmos SDK binaries that monitors the governance module via stdout for incoming chain upgrade proposals. If it sees a proposal that gets approved, it can be run manually or automatically to download the new binary, stop the current binary, run the migration script, replace the old node binary with the new one, and finally restart the node with the new genesis file. | ||
|
||
## Installation | ||
To install cosmovisor, run the following command (it takes some minutes): | ||
``` | ||
go get github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor | ||
``` | ||
* [more info about Cosmovisor](https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor#readme) | ||
* [how BitCanna implements Cosmovisor](https://github.com/BitCannaGlobal/testnet-bcna-cosmos/blob/main/instructions/stage4/task4.4.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
### | ||
# Find OS and Go environment | ||
# GO contains the Go binary | ||
# FS contains the OS file separator | ||
### | ||
ifeq ($(OS),Windows_NT) | ||
GO := $(shell where go.exe 2> NUL) | ||
FS := \\ | ||
else | ||
GO := $(shell command -v go 2> /dev/null) | ||
FS := / | ||
endif | ||
|
||
ifeq ($(GO),) | ||
$(error could not find go. Is it in PATH? $(GO)) | ||
endif | ||
|
||
GOPATH ?= $(shell $(GO) env GOPATH) | ||
GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com | ||
|
||
### | ||
# Functions | ||
### | ||
|
||
go_get = $(if $(findstring Windows_NT,$(OS)),\ | ||
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS) ( mkdir $(GITHUBDIR)$(FS)$(1) ) else (cd .) &\ | ||
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS)$(2)$(FS) ( cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2) ) else (cd .) &\ | ||
,\ | ||
mkdir -p $(GITHUBDIR)$(FS)$(1) &&\ | ||
(test ! -d $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2)) || true &&\ | ||
)\ | ||
cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && git fetch origin && git checkout -q $(3) | ||
|
||
go_install = $(call go_get,$(1),$(2),$(3)) && cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && $(GO) install | ||
|
||
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd) | ||
|
||
############################################################################### | ||
### Tools ### | ||
############################################################################### | ||
|
||
BIN ?= /usr/local/bin | ||
UNAME_S ?= $(shell uname -s) | ||
UNAME_M ?= $(shell uname -m) | ||
|
||
TOOLS_DESTDIR ?= $(GOPATH)/bin | ||
RUNSIM = $(TOOLS_DESTDIR)/runsim | ||
|
||
BUF_VERSION ?= 0.7.0 | ||
PROTOC_VERSION ?= 3.11.2 | ||
|
||
ifeq ($(UNAME_S),Linux) | ||
PROTOC_ZIP ?= protoc-3.11.2-linux-x86_64.zip | ||
endif | ||
ifeq ($(UNAME_S),Darwin) | ||
PROTOC_ZIP ?= protoc-3.11.2-osx-x86_64.zip | ||
endif | ||
|
||
all: tools | ||
|
||
tools: tools-stamp | ||
|
||
tools-stamp: $(RUNSIM) | ||
touch $@ | ||
|
||
# Install the runsim binary with a temporary workaround of entering an outside | ||
# directory as the "go get" command ignores the -mod option and will polute the | ||
# go.{mod, sum} files. | ||
# | ||
# ref: https://github.com/golang/go/issues/30515 | ||
runsim: $(RUNSIM) | ||
$(RUNSIM): | ||
@echo "Installing runsim..." | ||
@(cd /tmp && go get github.com/cosmos/tools/cmd/[email protected]) | ||
|
||
protoc: | ||
@echo "Installing protoc compiler..." | ||
@(cd /tmp; \ | ||
curl -sSOL "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP}"; \ | ||
unzip -o ${PROTOC_ZIP} -d /usr/local bin/protoc; \ | ||
unzip -o ${PROTOC_ZIP} -d /usr/local 'include/*'; \ | ||
rm -f ${PROTOC_ZIP}) | ||
|
||
protoc-gen-gocosmos: | ||
@echo "Installing protoc-gen-gocosmos..." | ||
@go install github.com/regen-network/cosmos-proto/protoc-gen-gocosmos | ||
|
||
buf: protoc-gen-buf-check-breaking protoc-gen-buf-check-lint | ||
@echo "Installing buf..." | ||
@(cd /tmp; \ | ||
curl -sSOL "https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-${UNAME_S}-${UNAME_M}"; \ | ||
mv buf-${UNAME_S}-${UNAME_M} "${BIN}/buf"; \ | ||
chmod +x "${BIN}/buf") | ||
|
||
protoc-gen-buf-check-breaking: | ||
@echo "Installing protoc-gen-buf-check-breaking..." | ||
@(cd /tmp; \ | ||
curl -sSOL "https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/protoc-gen-buf-check-breaking-${UNAME_S}-${UNAME_M}"; \ | ||
mv protoc-gen-buf-check-breaking-${UNAME_S}-${UNAME_M} "${BIN}/protoc-gen-buf-check-breaking"; \ | ||
chmod +x "${BIN}/protoc-gen-buf-check-breaking") | ||
|
||
protoc-gen-buf-check-lint: | ||
@echo "Installing protoc-gen-buf-check-lint..." | ||
@(cd /tmp; \ | ||
curl -sSOL "https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/protoc-gen-buf-check-lint-${UNAME_S}-${UNAME_M}"; \ | ||
mv protoc-gen-buf-check-lint-${UNAME_S}-${UNAME_M} "${BIN}/protoc-gen-buf-check-lint"; \ | ||
chmod +x "${BIN}/protoc-gen-buf-check-lint") | ||
|
||
tools-clean: | ||
rm -f $(RUNSIM) | ||
rm -f tools-stamp | ||
|
||
.PHONY: all tools tools-clean protoc buf protoc-gen-buf-check-breaking protoc-gen-buf-check-lint protoc-gen-gocosmos |