Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrating cosmos-sdk from v0.47 to v0.50 #2567

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d1acbe7
WIP: upgrade cosmos-sdk from v0.47 to v0.50
Jan 15, 2024
04a12c2
Merge branch 'main' into sai/csdk_v50
Jan 15, 2024
c32cae1
fix the build issue
Jan 15, 2024
fff5e6b
Merge branch 'main' into sai/csdk_v50
gsk967 Jan 17, 2024
78e2cea
fixing the test cases and update the cosmos-sdk to 0.50.3
gsk967 Jan 17, 2024
b4f2ec7
fix the golangci lint
gsk967 Jan 17, 2024
907b639
Merge branch 'main' into sai/csdk_v50
gsk967 Jan 19, 2024
2db6148
Merge branch 'main' into sai/csdk_v50
gsk967 Jan 19, 2024
0416eb0
Merge branch 'main' into sai/csdk_v50
gsk967 Jan 22, 2024
4d4cd1b
fix the msg deserilization
gsk967 Jan 25, 2024
4ea7c59
fix the tests on oracle and leverage
gsk967 Jan 25, 2024
1ae3c54
Merge branch 'main' into sai/csdk_v50
gsk967 Jan 25, 2024
f0cd05c
add upgrade handler from v0.47 to v0.50
gsk967 Jan 26, 2024
2e81114
Merge branch 'main' into sai/csdk_v50
gsk967 Feb 9, 2024
0edfa4d
fix the build issue
gsk967 Feb 9, 2024
8d059c2
fix the lint
gsk967 Feb 9, 2024
a372633
Merge branch 'main' into sai/csdk_v50
gsk967 Jun 26, 2024
965040e
++
gsk967 Jun 27, 2024
956e5df
Merge branch 'main' into sai/csdk_v50
gsk967 Jul 2, 2024
49e863e
fix: fix the build issue
gsk967 Jul 2, 2024
b2105d7
fix: fix the tests for app
gsk967 Jul 3, 2024
1eb8836
update tx.proto files and packet-forward-middleware to v8.0.2
gsk967 Jul 3, 2024
d3dd26a
Merge branch 'main' into sai/csdk_v50
gsk967 Jul 3, 2024
01019e4
fix: fix the e2e tests setup
gsk967 Jul 4, 2024
d8437c3
Merge branch 'main' into sai/csdk_v50
gsk967 Jul 4, 2024
42bf009
add config cmd for app
gsk967 Jul 4, 2024
6b6c75b
Merge branch 'main' into sai/csdk_v50
gsk967 Aug 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 8 additions & 7 deletions ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package ante

import (
storetypes "cosmossdk.io/store/types"
txsigning "cosmossdk.io/x/tx/signing"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/runtime"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
cosmosante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/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"
)

type HandlerOptions struct {
Expand All @@ -19,10 +20,10 @@ type HandlerOptions struct {
FeegrantKeeper cosmosante.FeegrantKeeper
OracleKeeper OracleKeeper
IBCKeeper *ibckeeper.Keeper
SignModeHandler signing.SignModeHandler
SignModeHandler *txsigning.HandlerMap
SigGasConsumer cosmosante.SignatureVerificationGasConsumer
WasmConfig *wasmTypes.WasmConfig
TXCounterStoreKey storetypes.StoreKey
TXCounterStoreKey *storetypes.KVStoreKey
}

// NewAnteHandler returns an AnteHandler that checks and increments sequence
Expand All @@ -48,7 +49,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
wasmkeeper.NewLimitSimulationGasDecorator(
options.WasmConfig.SimulationGasLimit,
), // after setup context to enforce limits early
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey),
wasmkeeper.NewCountTXDecorator(runtime.NewKVStoreService(options.TXCounterStoreKey)),
cosmosante.NewExtensionOptionsDecorator(nil), // nil=reject extensions
NewSpamPreventionDecorator(options.OracleKeeper), // spam prevention
cosmosante.NewValidateBasicDecorator(),
Expand Down
17 changes: 12 additions & 5 deletions ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/stretchr/testify/suite"

Expand All @@ -29,7 +30,7 @@ type IntegrationTestSuite struct {

func (s *IntegrationTestSuite) SetupTest() {
app := umeeapp.Setup(s.T())
ctx := app.BaseApp.NewContext(false, tmproto.Header{
ctx := app.BaseApp.NewContextLegacy(false, tmproto.Header{
ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)),
Height: 1,
})
Expand All @@ -46,20 +47,25 @@ func (s *IntegrationTestSuite) SetupTest() {

// CreateTestTx is a helper function to create a tx given multiple inputs.
func (suite *IntegrationTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) {
defaultSignMode, err := authsigning.APISignModeToInternal(suite.clientCtx.TxConfig.SignModeHandler().DefaultMode())
if err != nil {
return nil, err
}

var sigsV2 []signing.SignatureV2
for i, priv := range privs {
sigV2 := signing.SignatureV2{
PubKey: priv.PubKey(),
Data: &signing.SingleSignatureData{
SignMode: suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(),
SignMode: defaultSignMode,
Signature: nil,
},
Sequence: accSeqs[i],
}

sigsV2 = append(sigsV2, sigV2)
}
err := suite.txBuilder.SetSignatures(sigsV2...)
err = suite.txBuilder.SetSignatures(sigsV2...)
if err != nil {
return nil, err
}
Expand All @@ -71,8 +77,9 @@ func (suite *IntegrationTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, acc
AccountNumber: accNums[i],
Sequence: accSeqs[i],
}
sigV2, err := tx.SignWithPrivKey(
suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData,
sigV2, err := tx.SignWithPrivKey(suite.ctx,
defaultSignMode,
signerData,
suite.txBuilder, priv, suite.clientCtx.TxConfig, accSeqs[i])
if err != nil {
return nil, err
Expand Down
5 changes: 3 additions & 2 deletions ante/fee.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package ante

import (
sdkmath "cosmossdk.io/math"
evidencetypes "cosmossdk.io/x/evidence/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"

appparams "github.com/umee-network/umee/v6/app/params"
leveragetypes "github.com/umee-network/umee/v6/x/leverage/types"
Expand Down Expand Up @@ -57,7 +58,7 @@ func checkFees(minGasPrices sdk.DecCoins, fees sdk.Coins, gasLimit uint64) error
// Determine the required fees by multiplying each required minimum gas
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
// Zero fees are removed.
glDec := sdk.NewDec(int64(gasLimit))
glDec := sdkmath.LegacyNewDec(int64(gasLimit))
for _, gp := range minGasPrices {
if gasLimit == 0 || gp.IsZero() {
continue
Expand Down
7 changes: 4 additions & 3 deletions ante/fee_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ante_test

import (
sdkmath "cosmossdk.io/math"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -29,7 +30,7 @@ func (suite *IntegrationTestSuite) TestFeeAndPriority() {
if denom == "" {
denom = minGas.Denom
}
f := sdk.MustNewDecFromStr(factor)
f := sdkmath.LegacyMustNewDecFromStr(factor)
return sdk.DecCoins{sdk.NewDecCoinFromDec(denom, minGas.Amount.Mul(f))}
}
mkTx := func(fee sdk.Coins) signing.Tx {
Expand Down Expand Up @@ -66,7 +67,7 @@ func (suite *IntegrationTestSuite) TestFeeAndPriority() {
// suite.checkFeeFailed(tx, ctx.WithMinGasPrices(mkGas("other", "1")))

// should fail when some fee doesn't include all gas denoms
// ctx = ctx.WithMinGasPrices(sdk.DecCoins{minGas,sdk.NewDecCoinFromDec("other", sdk.NewDec(10))})
// ctx = ctx.WithMinGasPrices(sdk.DecCoins{minGas,sdk.NewDecCoinFromDec("other", sdkmath.LegacyNewDec(10))})
// suite.checkFeeFailed(tx, ctx)

//
Expand Down Expand Up @@ -119,6 +120,6 @@ func (suite *IntegrationTestSuite) checkFeeAnte(tx sdk.Tx, feeExpected sdk.Coins
if len(feeExpected) == 0 {
require.True(fee.IsZero(), "fee should be zero, got: %s", fee)
} else {
require.True(fee.IsEqual(feeExpected), "Fee expected %s, got: %s", feeExpected, fee)
require.True(fee.Equal(feeExpected), "Fee expected %s, got: %s", feeExpected, fee)
}
}
2 changes: 1 addition & 1 deletion ante/fee_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package ante
import (
"testing"

evidence "cosmossdk.io/x/evidence/types"
sdk "github.com/cosmos/cosmos-sdk/types"
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
evidence "github.com/cosmos/cosmos-sdk/x/evidence/types"
"gotest.tools/v3/assert"

leverage "github.com/umee-network/umee/v6/x/leverage/types"
Expand Down
Loading
Loading