Skip to content

Commit

Permalink
v0.21 - [email protected], wasmvm@v2, ibc-go@v8 (#265)
Browse files Browse the repository at this point in the history
* add stargate queries to wasmOpts

* log upgrade

* move govPropHandlers to modules file, rename AppModuleBasic type, only include impacted delegators in upgrade, ugrade go simulation test layout

* remove printing log file

* e2e localbitsong without state

* add upgrade test for v020

* bump

* clean e2e repo format

* migrate to cosmos-sdk:v0.50.11

* dev: bump proto gen commands

* dev: add v021 upgrade

* dev: add icq & ibc-wasm modules

* dev: add ibc_hooks module, bump [email protected] & [email protected]

* dev: add x/cadance module

* dev: go mod tidy

* dev: add smart-account module

* dev: add smart-account

* dev: add smart-accounts into apps anteHandler, bump keeper test-suite,

* dev: x/smart-account tests

* dev: add simulation ibctest library, validate feegrant if possible during ValidateAuthenticatorFeePayer, configure expidited props,

* dev: SetOrderPreBlockers , reimplement ibc-wasm

* dev: move e2e-folder into test folder

* dev: update BaseApp sequence, add PreBlocker, custom PostHandler for x/accounts, PreComitter, add v021 upgrade unit tests

* dev: bump gen cmd types

* dev + chore: bump ict go.mod , bump go min requirement to 1.23

* dev: bump dependencie, update pfm in app

* chore: bump go & alpine images

* dev: topologically sort app logic

* dev: add swagger config yaml

* dev: prep fantoken interfact for simulation module

* dev: remove redundant antehandler logic

* dev: sorted cadance keeper after wasmkeeper

* dev: smart-account integration tests

* dev: sort keepers correctly

* fix pfm & transfer module order

* dev: add ibchost legacy key subspace for migration, v021 upgrade unit tests, v021 upgradHandler logic

* dev: run migrations first before update store params

* bump wasm-vm for CWA-2025-001

* chore: bump actions/upload-artifact@v4

* update height to upgrade block

* enable vote extensions for block after upgrade

* dev: use 1 wasmvm for x/wasm & wasm light client,

* dev:compare del shares with legacyzerodec, include patch to remove specific delegations from store

* use lte smallest dec

* bump

* chore: remove init-from-state,  go mod tidy ict

* Update Makefile to check Go version before compiling #226

* dev: use sdkCtx for all logic in upgradeHandler

* dev: include: 13e-17  staking shares in being removed during the patch

* dev:  add mainnet seeds to initCmd

* chore: coderabbit suggestions, fix ci actions step2

* chore: rename tmttypes to cmttypes, add init function to automate mainnet init

* dev: continue if no delInfo found.

---------

Co-authored-by: hard-nett <[email protected]>
Co-authored-by: simi <[email protected]>
  • Loading branch information
3 people authored Feb 12, 2025
1 parent 3f17bd7 commit 8928250
Show file tree
Hide file tree
Showing 269 changed files with 30,425 additions and 3,182 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/interchaintest-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:
packages: write

env:
GO_VERSION: 1.22.4
GO_VERSION: 1.23.0
TAR_PATH: /tmp/bitsong-docker-image.tar
IMAGE_NAME: bitsong-docker-image

Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
outputs: type=docker,dest=${{ env.TAR_PATH }}

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.IMAGE_NAME }}
path: ${{ env.TAR_PATH }}
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
uses: actions/checkout@v4

- name: Download Tarball Artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ env.IMAGE_NAME }}
path: /tmp
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ name: Push Docker Images

env:
DOCKER_REPOSITORY: bitsongofficial/go-bitsong
RUNNER_BASE_IMAGE_DISTROLESS: gcr.io/distroless/static-debian11
RUNNER_BASE_IMAGE_NONROOT: gcr.io/distroless/static-debian11:nonroot
RUNNER_BASE_IMAGE_ALPINE: alpine:3.17
RUNNER_BASE_IMAGE_DISTROLESS: gcr.io/distroless/static-debian12
RUNNER_BASE_IMAGE_NONROOT: gcr.io/distroless/static-debian12:nonroot
RUNNER_BASE_IMAGE_ALPINE: alpine:3.21

on:
release:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Go 🧰
uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: 1.23

- name: Unshallow
run: git fetch --prune --unshallow --tags --force
Expand Down Expand Up @@ -49,14 +49,14 @@ jobs:
- name: Setup Go 🧰
uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: 1.23

- name: Build the binary 🏭
run: |
LEDGER_ENABLED=true make build
mv build/bitsongd "build/bitsongd-$VERSION-darwin-amd64"
- name: Upload the artifacts 📤
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "darwin-amd64"
path: "build/*darwin*amd64*"
Expand All @@ -80,7 +80,7 @@ jobs:
- name: Setup Go 🧰
uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: 1.23

- name: Compute diff 📜
uses: technote-space/[email protected]
Expand All @@ -95,13 +95,13 @@ jobs:
GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=true make build
mv build/bitsongd "build/bitsongd-$VERSION-linux-${{ matrix.go-arch }}"
- name: Upload the linux/amd64 artifact 📤
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "linux-amd64"
path: "build/*linux*amd64*"

- name: Upload the linux/arm64 artifact 📤
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "linux-arm64"
path: "build/*linux*arm64*"
Expand All @@ -125,15 +125,15 @@ jobs:
- name: Setup Go 🧰
uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: 1.23

- name: Build the binary 🏭
run: |
make LEDGER_ENABLED=true build
echo "build/bitsongd-$env:VERSION-$env:COMMIT-windows-amd64.exe"
mv build/bitsongd.exe "build/bitsongd-$env:VERSION-windows-amd64.exe"
- name: Upload the artifacts 📤
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "windows-amd64"
path: "build/*windows*amd64*"
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# docker build . -t bitsongofficial/go-bitsong:latest
# docker run --rm -it bitsongofficial/go-bitsong:latest /bin/sh
FROM golang:1.22-alpine AS go-builder
FROM golang:1.23-alpine AS go-builder

# this comes from standard alpine nightly file
# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile
Expand All @@ -17,13 +17,14 @@ WORKDIR /code

# Download dependencies and CosmWasm libwasmvm if found.
ADD go.mod go.sum ./
RUN set -eux; \
export ARCH=$(uname -m); \
WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm | awk '{print $2}'); \
if [ ! -z "${WASM_VERSION}" ]; then \
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.${ARCH}.a; \
fi; \
go mod download;

# Cosmwasm - Download correct libwasmvm version
RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$ARCH.a \
-O /lib/libwasmvm_muslc.$ARCH.a && \
# verify checksum
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
sha256sum /lib/libwasmvm_muslc.$ARCH.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$ARCH | cut -d ' ' -f 1)

# Copy over code
COPY . /code/
Expand Down
47 changes: 8 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
#!/usr/bin/make -f

include contrib/devtools/Makefile
include scripts/makefiles/build.mk
include scripts/makefiles/docker.mk
include scripts/makefiles/e2e.mk
include scripts/makefiles/format.mk
include scripts/makefiles/hl.mk
include scripts/makefiles/proto.mk
include scripts/makefiles/localnet.mk
include contrib/devtools/Makefile
include scripts/makefiles/proto.mk
include scripts/makefiles/tests.mk

.DEFAULT_GOAL := help
help:
@echo "Available top-level commands:"
@echo ""
@echo "Usage:"
@echo "To run commands, use:"
@echo " make [command]"
@echo ""
@echo " make build Build Bitsong node binary"
@echo " make docker Show available docker related commands"
@echo " make e2e Show available e2e commands"
@echo " make format Show available formatting commands"
@echo " make hl Show available docker commands (via Strangelove's Heighliner Tooling)"
@echo " make install Install Bitsong node binary"
@echo " make localnet Show available localnet commands"
@echo ""
@echo " make proto Show available protobuf commands"
@echo " make test Show available testing commands"
@echo "Run 'make [subcommand]' to see the available commands for each subcommand."

APP_DIR = ./app
Expand Down Expand Up @@ -119,15 +123,6 @@ ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'

build: go.sum
ifeq ($(OS),Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o build/bitsongd.exe ./cmd/bitsongd
else
go build $(BUILD_FLAGS) -o build/bitsongd ./cmd/bitsongd
endif

install: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/bitsongd



Expand All @@ -154,32 +149,6 @@ distclean: clean
rm -rf vendor/


########################################
### Testing

test: test-unit
test-all: test-race test-cover

test-unit:
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock' -ldflags '$(ldflags)' ${PACKAGES_UNITTEST}

test-race:
@VERSION=$(VERSION) go test -mod=readonly -race -tags='ledger test_ledger_mock' ./...

test-cover:
@go test -mod=readonly -timeout 30m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock' ./...

lint: golangci-lint
golangci-lint run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./swagger/*/statik.go" -not -path "*.pb.go" | xargs gofmt -d -s
go mod verify

benchmark:
@go test -mod=readonly -bench=. ./...

# include simulations
# include sims.mk

.PHONY: all build-linux install install-debug \
go-mod-cache draw-deps clean build \
build-docker-bitsongdnode localnet-start localnet-stop test-docker test-docker-push \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ After launching the main BitSong blockchain in August 2020, the bitsong-2b mainn

_NOTE: This is alpha software. Please contact us if you aim to run it in production._

**Note**: Requires [Go 1.22.x+](https://golang.org/dl/)
**Note**: Requires [Go 1.23.x+](https://golang.org/dl/)

# Install BitSong Blockchain

Expand All @@ -28,7 +28,7 @@ There are many ways you can install BitSong Blockchain Testnet node on your mach
sudo apt update
sudo apt install -y curl git jq lz4 build-essential
wget -q -O - https://git.io/vQhTU | bash -s -- --remove
wget -q -O - https://git.io/vQhTU | bash -s -- --version 1.22.9
wget -q -O - https://git.io/vQhTU | bash -s -- --version 1.23.5
```
2. **Clone BitSong source code to your machine**
```bash
Expand Down
67 changes: 47 additions & 20 deletions app/ante_handler.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
package app

import (
corestoretypes "cosmossdk.io/core/store"
"cosmossdk.io/errors"
"cosmossdk.io/math"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/authz"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

smartaccountante "github.com/bitsongofficial/go-bitsong/x/smart-account/ante"
smartaccountkeeper "github.com/bitsongofficial/go-bitsong/x/smart-account/keeper"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions

SmartAccount *smartaccountkeeper.Keeper
GovKeeper govkeeper.Keeper
IBCKeeper *ibckeeper.Keeper
TxCounterStoreKey storetypes.StoreKey
TxCounterStoreKey corestoretypes.KVStoreService
WasmConfig wasmTypes.WasmConfig
Cdc codec.BinaryCodec
Cdc codec.Codec

TxEncoder sdk.TxEncoder
}
Expand All @@ -41,7 +47,7 @@ func (min MinValCommissionDecorator) AnteHandle(
ctx sdk.Context, tx sdk.Tx,
simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
msgs := tx.GetMsgs()
minCommissionRate := sdk.NewDecWithPrec(5, 2)
minCommissionRate := math.LegacyNewDecWithPrec(5, 2)

validMsg := func(m sdk.Msg) error {
switch msg := m.(type) {
Expand All @@ -50,7 +56,7 @@ func (min MinValCommissionDecorator) AnteHandle(
// commission set below 5%
c := msg.Commission
if c.Rate.LT(minCommissionRate) {
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "commission can't be lower than 5%")
return errors.Wrap(sdkerrors.ErrUnauthorized, "commission can't be lower than 5%")
}
case *stakingtypes.MsgEditValidator:
// if commission rate is nil, it means only
Expand All @@ -59,7 +65,7 @@ func (min MinValCommissionDecorator) AnteHandle(
break
}
if msg.CommissionRate.LT(minCommissionRate) {
return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "commission can't be lower than 5%")
return errors.Wrap(sdkerrors.ErrUnauthorized, "commission can't be lower than 5%")
}
}

Expand All @@ -71,7 +77,7 @@ func (min MinValCommissionDecorator) AnteHandle(
var innerMsg sdk.Msg
err := min.cdc.UnpackAny(v, &innerMsg)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "cannot unmarshal authz exec msgs")
return errors.Wrapf(sdkerrors.ErrUnauthorized, "cannot unmarshal authz exec msgs")
}

err = validMsg(innerMsg)
Expand Down Expand Up @@ -103,20 +109,44 @@ func (min MinValCommissionDecorator) AnteHandle(

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
return nil, errors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
}
if options.BankKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
return nil, errors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
}
if options.SignModeHandler == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
return nil, errors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}

var sigGasConsumer = options.SigGasConsumer
if sigGasConsumer == nil {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
}

deductFeeDecorator := ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker)
// classicSignatureVerificationDecorator is the old flow to enable a circuit breaker
classicSignatureVerificationDecorator := sdk.ChainAnteDecorators(
deductFeeDecorator,
// We use the old pubkey decorator here to ensure that accounts work as expected,
// in SetPubkeyDecorator we set a pubkey in the account store, for authenticators
// we avoid this code path completely.
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
)
// authenticatorVerificationDecorator is the new authenticator flow that's embedded into the circuit breaker ante
authenticatorVerificationDecorator := sdk.ChainAnteDecorators(
smartaccountante.NewEmitPubKeyDecoratorEvents(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper), // we can probably remove this as multisigs are not supported here
// Both the signature verification, fee deduction, and gas consumption functionality
// is embedded in the authenticator decorator
smartaccountante.NewAuthenticatorDecorator(options.Cdc, options.SmartAccount, options.AccountKeeper, options.SignModeHandler, deductFeeDecorator),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
)

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(),
NewMinValCommissionDecorator(options.Cdc),
Expand All @@ -127,14 +157,11 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
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),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
smartaccountante.NewCircuitBreakerDecorator(
options.SmartAccount,
authenticatorVerificationDecorator,
classicSignatureVerificationDecorator,
),
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
Expand Down
Loading

0 comments on commit 8928250

Please sign in to comment.