Skip to content

Commit

Permalink
v1.7.0 - Upgrade Cosmos SDK to v0.47.5, CometBFT to v0.37.3, IBC to v…
Browse files Browse the repository at this point in the history
…7.3.1 (#262)

* chore: remove old upgrades

* build(upgrade)!: upgrade cosmos sdk, cometbft and ibc versions

BREAKING CHANGE:
Some modules have been changed due to SDK upgrade (v0.47) as old initialization and structure is not compatible with new SDK.
All references to Tendermint have been replaced with CometBFT. Cosmos SDK v0.47+ requires CometBFT v0.37+ and does not support Tendermint anymore.
IBC version has been bumped due to SDK upgrade.

* chore: update buf dependencies

* fix: fixes due to recent rebase

* fix: remove default value for chain-id flag

* test: add 2 txs erc20 spend test for bank keeper

* fix(test): fix tx sequence in bank keeper test

* chore: update swagger

* chore: bump go version

* chore: clean errors

* [HQC-50] Increase test coverage for erc20/cli and evm/cli (#271)

* add query tests
* add tx tests

---------

Co-authored-by: Petr Ivanov <petr.ivanov@tendermint.com>

* fix: keys migration on upgrade

---------

Co-authored-by: Evgeniy Abramov <i@kio.ninja>
Co-authored-by: Petr Ivanov <krest2005@yandex.ru>
Co-authored-by: Petr Ivanov <petr.ivanov@tendermint.com>
Co-authored-by: Evgeniy Abramov <5331145+kioqq@users.noreply.github.com>
  • Loading branch information
5 people authored Jan 8, 2024
1 parent eac37ea commit 1cdd044
Show file tree
Hide file tree
Showing 219 changed files with 3,680 additions and 2,133 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ node_modules
swagger-proto
tmp-swagger-gen
.devenv
.direnv
.secrets
.env
.dccache
52 changes: 26 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ DIFF_TAG=$(shell git rev-list --tags="v*" --max-count=1 --not $(shell git rev-li
DEFAULT_TAG=$(shell git rev-list --tags="v*" --max-count=1)
# VERSION ?= $(shell echo $(shell git describe --tags $(or $(DIFF_TAG), $(DEFAULT_TAG))) | sed 's/^v//')

VERSION := "1.6.4"
TMVERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
VERSION := "1.7.0"
CBFTVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
Expand Down Expand Up @@ -75,7 +75,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=haqq \
-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=$(TMVERSION)
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(CBFTVERSION)

# DB backend selection
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
Expand Down Expand Up @@ -184,24 +184,24 @@ STATIK = $(TOOLS_DESTDIR)/statik
RUNSIM = $(TOOLS_DESTDIR)/runsim

# 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
# directory as the "go install" 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_MOD} go get github.com/cosmos/tools/cmd/runsim@master)
@(cd /tmp && ${GO_MOD} go install github.com/cosmos/tools/cmd/runsim@master)

statik: $(STATIK)
$(STATIK):
@echo "Installing statik..."
@(cd /tmp && go get github.com/rakyll/statik@v0.1.6)
@(cd /tmp && go install github.com/rakyll/statik@v0.1.6)

contract-tools:
ifeq (, $(shell which stringer))
@echo "Installing stringer..."
@go get golang.org/x/tools/cmd/stringer
@go install golang.org/x/tools/cmd/stringer
else
@echo "stringer already installed; skipping..."
endif
Expand All @@ -215,14 +215,14 @@ endif

ifeq (, $(shell which gencodec))
@echo "Installing gencodec..."
@go get github.com/fjl/gencodec
@go install github.com/fjl/gencodec
else
@echo "gencodec already installed; skipping..."
endif

ifeq (, $(shell which protoc-gen-go))
@echo "Installing protoc-gen-go..."
@go get github.com/fjl/gencodec github.com/golang/protobuf/protoc-gen-go
@go install github.com/fjl/gencodec github.com/golang/protobuf/protoc-gen-go
else
@echo "protoc-gen-go already installed; skipping..."
endif
Expand Down Expand Up @@ -447,9 +447,9 @@ format:
### Protobuf ###
###############################################################################

protoVer=v0.7
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
protoImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
protoVer=0.14.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace --user 0 $(protoImageName)
# ------
# NOTE: Link to the yoheimuta/protolint docker images:
# https://hub.docker.com/r/yoheimuta/protolint/tags
Expand Down Expand Up @@ -485,20 +485,20 @@ proto-lint:
proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master

TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.15/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_SDK_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.45.1
ETHERMINT_URL = https://raw.githubusercontent.com/evmos/ethermint/v0.18.0
IBC_GO_URL = https://raw.githubusercontent.com/cosmos/ibc-go/v3.0.0-rc0
COSMOS_PROTO_URL = https://raw.githubusercontent.com/cosmos/cosmos-proto/main

TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
TM_ABCI_TYPES = third_party/proto/tendermint/abci
TM_TYPES = third_party/proto/tendermint/types

GOGO_PROTO_TYPES = third_party/proto/gogoproto

COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto
# TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.15/proto/tendermint
# GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
# COSMOS_SDK_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.45.1
# ETHERMINT_URL = https://raw.githubusercontent.com/evmos/ethermint/v0.18.0
# IBC_GO_URL = https://raw.githubusercontent.com/cosmos/ibc-go/v3.0.0-rc0
# COSMOS_PROTO_URL = https://raw.githubusercontent.com/cosmos/cosmos-proto/main
#
# TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
# TM_ABCI_TYPES = third_party/proto/tendermint/abci
# TM_TYPES = third_party/proto/tendermint/types
#
# GOGO_PROTO_TYPES = third_party/proto/gogoproto
#
# COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto

# proto-update-deps:
# @mkdir -p $(GOGO_PROTO_TYPES)
Expand Down
24 changes: 19 additions & 5 deletions app/ante/cosmos/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ package cosmos_test

import (
"fmt"
"math/big"
"testing"
"time"

"github.com/stretchr/testify/require"

abci "github.com/cometbft/cometbft/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
abci "github.com/tendermint/tendermint/abci/types"
ethtypes "github.com/ethereum/go-ethereum/core/types"

cosmosante "github.com/haqq-network/haqq/app/ante/cosmos"
"github.com/haqq-network/haqq/testutil"
Expand All @@ -25,7 +27,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
testPrivKeys, testAddresses, err := generatePrivKeyAddressPairs(5)
require.NoError(t, err)

distantFuture := time.Date(9000, 1, 1, 0, 0, 0, 0, time.UTC)
distantFuture := time.Date(5321, 1, 1, 0, 0, 0, 0, time.UTC)

validator := sdk.ValAddress(testAddresses[4])
stakingAuthDelegate, err := stakingtypes.NewStakeAuthorization([]sdk.ValAddress{validator}, nil, stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, nil)
Expand Down Expand Up @@ -278,7 +280,19 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
_, testAddresses, err := generatePrivKeyAddressPairs(10)
suite.Require().NoError(err)

distantFuture := time.Date(9000, 1, 1, 0, 0, 0, 0, time.UTC)
distantFuture := time.Date(5321, 1, 1, 0, 0, 0, 0, time.UTC)

// create a dummy MsgEthereumTx for the test
// otherwise throws error that cannot unpack tx data
msgEthereumTx := evmtypes.NewTx(&evmtypes.EvmTxArgs{
ChainID: big.NewInt(54211),
Nonce: 0,
GasLimit: 1000000,
GasFeeCap: suite.app.FeeMarketKeeper.GetBaseFee(suite.ctx),
GasTipCap: big.NewInt(1),
Input: nil,
Accesses: &ethtypes.AccessList{},
})

newMsgGrant := func(msgTypeUrl string) *authz.MsgGrant {
msg, err := authz.NewMsgGrant(
Expand Down Expand Up @@ -326,7 +340,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
),
&evmtypes.MsgEthereumTx{},
msgEthereumTx,
},
),
},
Expand All @@ -339,7 +353,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
testAddresses[1],
2,
[]sdk.Msg{
&evmtypes.MsgEthereumTx{},
msgEthereumTx,
},
),
},
Expand Down
1 change: 1 addition & 0 deletions app/ante/cosmos/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ type BankKeeper interface {
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
SendCoins(ctx sdk.Context, from, to sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error
}
11 changes: 6 additions & 5 deletions app/ante/cosmos/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import (
"github.com/stretchr/testify/suite"

sdkmath "cosmossdk.io/math"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/haqq-network/haqq/app"
"github.com/haqq-network/haqq/app/ante"
Expand Down Expand Up @@ -60,7 +59,7 @@ func (suite *AnteTestSuite) SetupTest() {
suite.Require().NoError(err)
suite.priv = priv

suite.app = app.EthSetup(checkTx, func(app *app.Haqq, genesis simapp.GenesisState) simapp.GenesisState {
suite.app = app.EthSetup(checkTx, func(app *app.Haqq, genesis types.GenesisState) types.GenesisState {
if suite.enableFeemarket {
// setup feemarketGenesis params
feemarketGenesis := feemarkettypes.DefaultGenesisState()
Expand Down Expand Up @@ -96,10 +95,12 @@ func (suite *AnteTestSuite) SetupTest() {

stakingParams := suite.app.StakingKeeper.GetParams(suite.ctx)
stakingParams.BondDenom = utils.BaseDenom
suite.app.StakingKeeper.SetParams(suite.ctx, stakingParams)
err = suite.app.StakingKeeper.SetParams(suite.ctx, stakingParams)
suite.Require().NoError(err)

infCtx := suite.ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
suite.app.AccountKeeper.SetParams(infCtx, authtypes.DefaultParams())
err = suite.app.AccountKeeper.SetParams(infCtx, authtypes.DefaultParams())
suite.Require().NoError(err)

encodingConfig := encoding.MakeConfig(app.ModuleBasics)
// We're using TestMsg amino encoding in some tests, so register it here.
Expand Down
4 changes: 2 additions & 2 deletions app/ante/evm/fee_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (

"github.com/stretchr/testify/require"

"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/ethereum/go-ethereum/params"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/haqq-network/haqq/encoding"
"github.com/haqq-network/haqq/types"
Expand Down
12 changes: 7 additions & 5 deletions app/ante/evm/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import (
"github.com/stretchr/testify/suite"

sdkmath "cosmossdk.io/math"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ethereum/go-ethereum/core/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/haqq-network/haqq/app"
"github.com/haqq-network/haqq/app/ante"
"github.com/haqq-network/haqq/encoding"
"github.com/haqq-network/haqq/ethereum/eip712"
haqqtypes "github.com/haqq-network/haqq/types"
"github.com/haqq-network/haqq/utils"
evmtypes "github.com/haqq-network/haqq/x/evm/types"
feemarkettypes "github.com/haqq-network/haqq/x/feemarket/types"
Expand All @@ -45,7 +45,7 @@ const TestGasLimit uint64 = 100000
func (suite *AnteTestSuite) SetupTest() {
checkTx := false

suite.app = app.EthSetup(checkTx, func(app *app.Haqq, genesis simapp.GenesisState) simapp.GenesisState {
suite.app = app.EthSetup(checkTx, func(app *app.Haqq, genesis haqqtypes.GenesisState) haqqtypes.GenesisState {
if suite.enableFeemarket {
// setup feemarketGenesis params
feemarketGenesis := feemarkettypes.DefaultGenesisState()
Expand Down Expand Up @@ -82,10 +82,12 @@ func (suite *AnteTestSuite) SetupTest() {
// set staking denomination to Evmos denom
params := suite.app.StakingKeeper.GetParams(suite.ctx)
params.BondDenom = utils.BaseDenom
suite.app.StakingKeeper.SetParams(suite.ctx, params)
err := suite.app.StakingKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

infCtx := suite.ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
suite.app.AccountKeeper.SetParams(infCtx, authtypes.DefaultParams())
err = suite.app.AccountKeeper.SetParams(infCtx, authtypes.DefaultParams())
suite.Require().NoError(err)

encodingConfig := encoding.MakeConfig(app.ModuleBasics)
// We're using TestMsg amino encoding in some tests, so register it here.
Expand Down
6 changes: 3 additions & 3 deletions app/ante/evm/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibctypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
ibcclienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
ibctypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"

Expand Down Expand Up @@ -317,7 +317,7 @@ func (suite *AnteTestSuite) CreateTestEIP712SubmitProposalV1(from sdk.AccAddress
proposalMsgs,
sdk.NewCoins(sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(100))),
sdk.MustBech32ifyAddressBytes(sdk.GetConfig().GetBech32AccountAddrPrefix(), from.Bytes()),
"Metadata",
"Metadata", "title", "summary",
)

suite.Require().NoError(err)
Expand Down
4 changes: 2 additions & 2 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
ibcante "github.com/cosmos/ibc-go/v6/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

cosmosante "github.com/haqq-network/haqq/app/ante/cosmos"
evmante "github.com/haqq-network/haqq/app/ante/evm"
Expand Down
14 changes: 7 additions & 7 deletions app/ante/utils/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import (
"github.com/stretchr/testify/suite"

sdkmath "cosmossdk.io/math"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ethereum/go-ethereum/core/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/haqq-network/haqq/app"
"github.com/haqq-network/haqq/app/ante"
"github.com/haqq-network/haqq/encoding"
"github.com/haqq-network/haqq/ethereum/eip712"
"github.com/haqq-network/haqq/testutil"
haqqtypes "github.com/haqq-network/haqq/types"
"github.com/haqq-network/haqq/utils"
evmtypes "github.com/haqq-network/haqq/x/evm/types"
feemarkettypes "github.com/haqq-network/haqq/x/feemarket/types"
Expand All @@ -42,7 +42,7 @@ type AnteTestSuite struct {
func (suite *AnteTestSuite) SetupTest() {
checkTx := false

suite.app = app.EthSetup(checkTx, func(app *app.Haqq, genesis simapp.GenesisState) simapp.GenesisState {
suite.app = app.EthSetup(checkTx, func(app *app.Haqq, genesis haqqtypes.GenesisState) haqqtypes.GenesisState {
if suite.enableFeemarket {
// setup feemarketGenesis params
feemarketGenesis := feemarkettypes.DefaultGenesisState()
Expand Down Expand Up @@ -79,10 +79,12 @@ func (suite *AnteTestSuite) SetupTest() {
// set staking denomination to Haqq Network denom
params := suite.app.StakingKeeper.GetParams(suite.ctx)
params.BondDenom = utils.BaseDenom
suite.app.StakingKeeper.SetParams(suite.ctx, params)
err := suite.app.StakingKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

infCtx := suite.ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
suite.app.AccountKeeper.SetParams(infCtx, authtypes.DefaultParams())
err = suite.app.AccountKeeper.SetParams(infCtx, authtypes.DefaultParams())
suite.Require().NoError(err)

encodingConfig := encoding.MakeConfig(app.ModuleBasics)
// We're using TestMsg amino encoding in some tests, so register it here.
Expand All @@ -109,8 +111,6 @@ func (suite *AnteTestSuite) SetupTest() {

suite.anteHandler = anteHandler
suite.ethSigner = types.LatestSignerForChainID(suite.app.EvmKeeper.ChainID())

var err error
suite.ctx, err = testutil.Commit(suite.ctx, suite.app, time.Second*0, nil)
suite.Require().NoError(err)
}
Expand Down
Loading

2 comments on commit 1cdd044

@cshintov
Copy link

@cshintov cshintov commented on 1cdd044 Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I need a new genesis for this upgrade?

Tried haqqd export but with 64GB RAM it was getting OOM killed!

Also should I be exporting with with old version and run the migrate command with new version?

I'm following upgrade genesis file for manual upgrade.

@cshintov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With 20GB swap it finished. But when I tried to run the migrate command, it failed!

haqqd migrate v1.7.0 --chain-id=haqq_11235-1 genesis.json
Error: unknown migration function for version: v1
Usage:
  haqqd migrate TARGET_VERSION GENESIS_FILE [flags]

Please sign in to comment.