Skip to content

Commit

Permalink
Merge pull request #175 from BitCannaGlobal/SDK_046
Browse files Browse the repository at this point in the history
BCNAD v2 - SDK v0.46
  • Loading branch information
RaulBernal authored May 19, 2023
2 parents 6a909cc + 8ed84c1 commit c03a233
Show file tree
Hide file tree
Showing 60 changed files with 45,691 additions and 20,662 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.6
- uses: actions/checkout@v3

- name: golangci-lint-bcnad
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 30m
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
config.yml
.DS_Store
ts-client/*
23 changes: 12 additions & 11 deletions 1.install-compile.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Install / Compile last BitCanna binary
**bcnad** is a blockchain application built using Cosmos SDK v.0.45.15 and Comet-BFT v.0.34.27 and IBC-go v3.4.0.
**bcnad** is a blockchain application built using Cosmos SDK v.0.46.12 and Comet-BFT v.0.34.27 and IBC-go v6.1.0.

In this guide you will find how to install the last binary or compile it by yourself.

Expand All @@ -18,18 +18,18 @@ If we don't raise this value, nodes will crash once the network grows large enou
```
## Option 1. Download and install the last binary
By downloading the binary we avoid compiling the source code.
1. Download the latest version (v.1.6.3) from Github:
1. Download the latest version (v.2.0.1) from Github:
```
cd $HOME
wget -nc https://github.com/BitCannaGlobal/bcna/releases/download/v1.6.3/bcna_linux_amd64.tar.gz
wget -nc https://github.com/BitCannaGlobal/bcna/releases/download/v2.0.1/bcna_linux_amd64.tar.gz
```
2. Check the sha256sum for the downloaded file.
```
sha256sum bcna_linux_amd64.tar.gz
```
It must return: `21e7f032244362c0eeb43d477e39ab5b1f2ae12cd5b2799468444fb32f39da5e`
It must return: `-----------------`
3. Verify that the version is `1.6.3`
3. Verify that the version is `2.0.1`
```
rm -f ./bcnad #delete old file if exist
tar zxvf bcna_linux_amd64.tar.gz
Expand All @@ -47,17 +47,18 @@ By downloading the binary we avoid compiling the source code.
```
## Option 2. Compile instructions:
### Install GoLang v1.19.x
### Install GoLang v1.20.4
The official instructions can be found here: https://golang.org/doc/install
1. Firstly, remove any existing old Go installation as root
```
sudo rm -rf /usr/local/go
```
2. Download the software:
2. Download the software and unpack:
```
curl https://dl.google.com/go/go1.19.6.linux-amd64.tar.gz | sudo tar -C/usr/local -zxvf -
wget https://go.dev/dl/go1.20.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzvf go1.20.4.linux-amd64.tar.gz
```
3. Update environment variables to include Go (copy everything & paste)
```
Expand All @@ -74,21 +75,21 @@ The official instructions can be found here: https://golang.org/doc/install
```
go version
```
Should return `go version go1.19.6 linux/amd64`
Should return `go version go1.20.4 linux/amd64`
### Download source code and compile
5. Download the source code using `git`
```
git clone https://github.com/BitCannaGlobal/bcna.git
cd bcna
git checkout v1.6.3
git checkout v2.0.1
make build #it build the binary in build/ folder
```
6. Verify the version:
```
build/bcnad version
```
The output must be `1.6.3`
The output must be `2.0.1`
7. You now have two options:
* Move the binary to the /usr/local/bin path with:
Expand Down
130 changes: 81 additions & 49 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
#!/usr/bin/make -f

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
BUILD_DIR ?= $(CURDIR)/build
DIST_DIR ?= $(CURDIR)/dist
LEDGER_ENABLED ?= true
TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
DOCKER := $(shell which docker)
PROJECT_NAME := bitcanna
HTTPS_GIT := https://github.com/BitCannaGlobal/bcna.git

###############################################################################
## Version ##
###############################################################################

# 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
Expand All @@ -12,19 +22,12 @@ ifeq (,$(VERSION))
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 ##
###############################################################################

build_tags = netgo

ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
Expand All @@ -48,64 +51,93 @@ ifeq ($(LEDGER_ENABLED),true)
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)
-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

check_version:
ifneq ($(GO_MINOR_VERSION),20)
@echo "ERROR: Go version 1.20 is required for building BCNAD."
exit 1
endif

#$(info $$BUILD_FLAGS is [$(BUILD_FLAGS)])
build: go.sum
@echo "--> Building..."
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILD_DIR)/ ./...

install: go.sum
@echo "--> Installing..."
go install -mod=readonly $(BUILD_FLAGS) ./...

build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build

go-mod-cache: go.sum
@echo "--> Download go modules to local cache"
@go mod download

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify

go-mod-tidy:
@contrib/scripts/go-mod-tidy-all.sh

clean:
@echo "--> Cleaning..."
@rm -rf $(BUILD_DIR)/** $(DIST_DIR)/**

# The below include contains the tools target.
include contrib/devtools/Makefile
.PHONY: install build build-linux clean

###############################################################################
### Documentation ###
## Protobuf ##
###############################################################################
check_version:
ifneq ($(GO_MINOR_VERSION),19)
@echo "ERROR: Go version 1.19 is required for building BCNAD. There are consensus breaking changes between binaries compiled with Go 1.18 and Go 1.19."
exit 1
endif

all: install lint test
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf

containerProtoVer=v0.2
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
containerProtoGen=$(PROJECT_NAME)-proto-gen-$(containerProtoVer)
containerProtoFmt=$(PROJECT_NAME)-proto-fmt-$(containerProtoVer)
containerProtoGenSwagger=$(PROJECT_NAME)-proto-gen-swagger-$(containerProtoVer)

proto-all: proto-format proto-lint proto-gen proto-swagger-gen

proto-gen:
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./scripts/protocgen.sh; fi

proto-swagger-gen:
@echo "Generating Swagger of Protobuf"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./scripts/protoc-swagger-gen.sh; fi

proto-format:
@echo "Formatting Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find ./ -name "*.proto" -exec sh -c 'clang-format -style=file -i {}' \; ; fi

BUILD_TARGETS := build install
proto-lint:
@echo "Linting Protobuf files"
@$(DOCKER_BUF) lint --error-format=json

build: BUILD_ARGS=-o $(BUILDDIR)/
proto-check-breaking:
@echo "Checking for breaking changes"
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main

$(BUILD_TARGETS): check_version go.sum $(BUILDDIR)/
#go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... Don't overwrite go.sum
go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./...

$(BUILDDIR)/:
mkdir -p $(BUILDDIR)/
.PHONY: proto-all proto-gen proto-lint proto-check-breaking proto-format proto-swagger-gen
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

BitCanna provides a decentralized payment network, supply chain and trust network for the legal cannabis industry by utilizing the BCNA coin.

> Current version (v1.6.3 Vigorous-Grow-fix) of our development uses Cosmos SDK v0.45.15 & Comet-BFT v0.34.27 & IBC-go v3.4.0
> Current version (`v2.0.1` codename: `Wake And Bake`) of our development uses Cosmos SDK v0.46.12 & Comet-BFT v0.34.27 & IBC-go v6.1.0
> Last breaking consensus upgrade info: [Update scheduled for 10th March 2023](https://github.com/BitCannaGlobal/bcna/blob/main/last_upgrade.md) v1.6.1
> Last breaking consensus upgrade info: [Update scheduled for XYth June 2023](https://github.com/BitCannaGlobal/bcna/blob/main/last_upgrade.md) v2.0.1
> Last compatible update is here ([v1.6.3](https://github.com/BitCannaGlobal/bcna/releases/tag/v1.6.3))
> Last compatible update is here ([v2.0.1](https://github.com/BitCannaGlobal/bcna/releases/tag/v2.0.1))
These docs at Github are chain related. For more information about our coin, partners and roadmap visit:
* Our website: https://www.bitcanna.io
Expand All @@ -22,7 +22,7 @@ Here are the minimal hardware configs required for running a validator/sentry no

## Software Requirements
* Linux server (Ubuntu 20/22 server recommended)
* Go version v1.19.5
* Go version v1.20.x

> Please avoid cheap VPS providers as a main validator (we suggest using it as a cheap backup). We advise to use a shared dedicated server or a high-end NVMe VPS.
Expand All @@ -36,8 +36,9 @@ Here are the minimal hardware configs required for running a validator/sentry no
| 7th Nov 2022 15.00h CET | 5.787.420 | [v1.5.3](https://github.com/BitCannaGlobal/bcna/releases/download/v1.5.3/bcna_linux_amd64.tar.gz) | [Link](https://github.com/BitCannaGlobal/bcna/releases/tag/v1.5.3) | [Doc](https://github.com/BitCannaGlobal/bcna/blob/main/last_upgrade.md#v153-codename-trichomemonster-ica---from-v145) |
| 2nd Mar 2023 16.20h CET | 7.467.420 | [v1.6.0-fix](https://github.com/BitCannaGlobal/bcna/releases/download/v1.6.0-fix/bcna_linux_amd64.tar.gz) | [Link](https://github.com/BitCannaGlobal/bcna/releases/tag/v1.6.0-fix) | [Doc](https://github.com/BitCannaGlobal/bcna/blob/main/last_upgrade.md#v160-fix-codename-vigorous-grow---from-v153) |
| 10th Mar 2023 18.40h CET | 7.585.420 | [v1.6.1](https://github.com/BitCannaGlobal/bcna/releases/download/v1.6.1/bcna_linux_amd64.tar.gz) | [Link](https://github.com/BitCannaGlobal/bcna/releases/tag/v1.6.1) | [Doc](https://github.com/BitCannaGlobal/bcna/blob/main/last_upgrade.md#v161-codename-vigorous-grow-fix---from-v161) |
| XYth Jun 2023 16.20h CEST | X.ABC.420 | [v2.0.1](https://github.com/BitCannaGlobal/bcna/releases/download/v2.0.1/bcna_linux_amd64.tar.gz) | [Link](https://github.com/BitCannaGlobal/bcna/releases/tag/v2.0.1) | [Doc](https://github.com/BitCannaGlobal/bcna/blob/main/last_upgrade.md#v201-codename-wakeandbake---from-v163) |

Current compatible release: https://github.com/BitCannaGlobal/bcna/releases/tag/v1.6.3
Current compatible release: https://github.com/BitCannaGlobal/bcna/releases/tag/v2.0.1


# How to join `bitcanna-1` chain
Expand Down
18 changes: 10 additions & 8 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package app

import (
"errors"
"fmt"

decorators "github.com/BitCannaGlobal/bcna/app/decorators"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
)
Expand All @@ -23,31 +25,31 @@ type HandlerOptions struct {
// signer.
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder")
return nil, fmt.Errorf("%w: account keeper is required for ante builder", errors.New("logic error"))
}
if options.BankKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder")
return nil, fmt.Errorf("%w: bank keeper is required for ante builder", errors.New("logic error"))
}
if options.SignModeHandler == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
return nil, fmt.Errorf("%w:sign mode handler is required for ante builder", errors.New("logic error"))
}
if options.GovKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "gov keeper is required for AnteHandler")
return nil, fmt.Errorf("%w:gov keeper is required for AnteHandler", errors.New("logic error"))
}
sigGasConsumer := options.SigGasConsumer
if sigGasConsumer == nil {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
}
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewRejectExtensionOptionsDecorator(),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
decorators.NewGovPreventSpamDecorator(options.Cdc, options.GovKeeper),
ante.NewMempoolFeeDecorator(),
// ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
Expand Down
Loading

0 comments on commit c03a233

Please sign in to comment.