Skip to content

Commit

Permalink
Merge pull request #72 from TERITORI/sdk_upgrade
Browse files Browse the repository at this point in the history
Cosmos SDK upgrade to v0.47.6
  • Loading branch information
go7066 authored Jan 11, 2024
2 parents f0a774e + 41d398c commit d7e89c5
Show file tree
Hide file tree
Showing 78 changed files with 3,525 additions and 1,335 deletions.
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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"
TM_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') # grab everything after the space in "github.com/cometbft/cometbft v0.34.7"
DOCKER := $(shell which docker)
BUILDDIR ?= $(CURDIR)/build
TEST_DOCKER_REPO=jackzampolin/teritoritest
Expand Down Expand Up @@ -66,7 +66,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=teritori \
-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/cometbft/cometbft/version.TMCoreSemVer=$(TM_VERSION)

ifeq (cleveldb,$(findstring cleveldb,$(NXTPOP_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
Expand Down Expand Up @@ -233,14 +233,13 @@ test-docker-push: test-docker
build-docker-teritoridnode localnet-start localnet-stop \
docker-single-node

protoVer=v0.2
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
containerProtoGen=teritori-proto-gen-$(protoVer)
protoVer=0.11.6
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

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 $(protoImageName) \
sh ./scripts/protocgen.sh; fi
@$(protoImage) sh ./scripts/protocgen.sh

init-hermes: kill-dev install
@echo "Initializing both blockchains..."
Expand Down
21 changes: 11 additions & 10 deletions app/ante_handler.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package teritori

import (
"cosmossdk.io/math"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
airdropkeeper "github.com/TERITORI/teritori-chain/x/airdrop/keeper"
"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"
Expand All @@ -13,8 +15,8 @@ import (
disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
)

var minCommissionRate = sdk.NewDecWithPrec(5, 2) // 5%
Expand All @@ -26,21 +28,21 @@ type HandlerOptions struct {
ante.HandlerOptions

BankKeeper bankkeeper.Keeper
StakingKeeper stakingkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
AirdropKeeper *airdropkeeper.Keeper
IBCKeeper *ibckeeper.Keeper
TxCounterStoreKey sdk.StoreKey
TxCounterStoreKey storetypes.StoreKey
WasmConfig wasmTypes.WasmConfig
Cdc codec.BinaryCodec
}

type MinCommissionDecorator struct {
cdc codec.BinaryCodec
sk stakingkeeper.Keeper
sk *stakingkeeper.Keeper
bk bankkeeper.Keeper
}

func NewMinCommissionDecorator(cdc codec.BinaryCodec, sk stakingkeeper.Keeper, bk bankkeeper.Keeper) MinCommissionDecorator {
func NewMinCommissionDecorator(cdc codec.BinaryCodec, sk *stakingkeeper.Keeper, bk bankkeeper.Keeper) MinCommissionDecorator {
return MinCommissionDecorator{
cdc: cdc,
sk: sk,
Expand Down Expand Up @@ -159,7 +161,7 @@ func (min MinCommissionDecorator) getValidator(ctx sdk.Context, bech32ValAddr st
return val, nil
}

func (min MinCommissionDecorator) getTotalDelegatedTokens(ctx sdk.Context) sdk.Int {
func (min MinCommissionDecorator) getTotalDelegatedTokens(ctx sdk.Context) math.Int {
bondDenom := min.sk.BondDenom(ctx)
bondedPool := min.sk.GetBondedPool(ctx)
notBondedPool := min.sk.GetNotBondedPool(ctx)
Expand Down Expand Up @@ -217,8 +219,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
NewMinCommissionDecorator(options.Cdc, options.StakingKeeper, options.BankKeeper),
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey),
ante.NewRejectExtensionOptionsDecorator(),
ante.NewMempoolFeeDecorator(),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
Expand All @@ -230,7 +231,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewAnteDecorator(options.IBCKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
}

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

0 comments on commit d7e89c5

Please sign in to comment.