WIP: upgrade cosmos-sdk from 0.45 to SMT 0.46

This commit is contained in:
Sai Kumar
2022-04-11 13:39:39 +05:30
parent 4ddc8afd18
commit a0e2858d4f
56 changed files with 1124 additions and 3255 deletions
+7 -6
View File
@@ -7,7 +7,8 @@ import (
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
// authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
// authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
@@ -63,12 +64,12 @@ func DoBenchmark(b *testing.B, txBuilder TxBuilder) {
ctx, _ := suite.ctx.CacheContext()
// deduct fee first
txData, err := types.UnpackTxData(msg.Data)
require.NoError(b, err)
// txData, err := types.UnpackTxData(msg.Data)
// require.NoError(b, err)
fees := sdk.Coins{sdk.NewCoin(suite.EvmDenom(), sdk.NewIntFromBigInt(txData.Fee()))}
err = authante.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees)
require.NoError(b, err)
// fees := sdk.Coins{sdk.NewCoin(suite.EvmDenom(), sdk.NewIntFromBigInt(txData.Fee()))}
// err = authante.DeductFees(suite.app.BankKeeper, suite.ctx, suite.app.AccountKeeper.GetAccount(ctx, msg.GetFrom()), fees)
// require.NoError(b, err)
rsp, err := suite.app.EvmKeeper.EthereumTx(sdk.WrapSDKContext(ctx), msg)
require.NoError(b, err)
+4 -3
View File
@@ -5,6 +5,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
@@ -29,10 +30,10 @@ type Keeper struct {
// - storing account's Code
// - storing transaction Logs
// - storing Bloom filters by block height. Needed for the Web3 API.
storeKey sdk.StoreKey
storeKey storetypes.StoreKey
// key to access the transient store, which is reset on every block during Commit
transientKey sdk.StoreKey
transientKey storetypes.StoreKey
// module specific parameter space that can be configured through governance
paramSpace paramtypes.Subspace
@@ -58,7 +59,7 @@ type Keeper struct {
// NewKeeper generates new evm module keeper
func NewKeeper(
cdc codec.BinaryCodec,
storeKey, transientKey sdk.StoreKey, paramSpace paramtypes.Subspace,
storeKey, transientKey storetypes.StoreKey, paramSpace paramtypes.Subspace,
ak types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper,
fmk types.FeeMarketKeeper,
tracer string,
+1 -1
View File
@@ -183,7 +183,7 @@ func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) {
encodingConfig := encoding.MakeConfig(app.ModuleBasics)
suite.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig)
suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID())
suite.appCodec = encodingConfig.Marshaler
suite.appCodec = encodingConfig.Codec
}
func (suite *KeeperTestSuite) SetupTest() {
+14 -13
View File
@@ -5,7 +5,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
// authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
@@ -24,10 +25,10 @@ func (k Keeper) DeductTxCostsFromUserBalance(
isContractCreation := txData.GetTo() == nil
// fetch sender account from signature
signerAcc, err := authante.GetSignerAcc(ctx, k.accountKeeper, msgEthTx.GetFrom())
if err != nil {
return nil, sdkerrors.Wrapf(err, "account not found for sender %s", msgEthTx.From)
}
// signerAcc, err := authante.GetSignerAcc(ctx, k.accountKeeper, msgEthTx.GetFrom())
// if err != nil {
// return nil, sdkerrors.Wrapf(err, "account not found for sender %s", msgEthTx.From)
// }
gasLimit := txData.GetGas()
@@ -73,14 +74,14 @@ func (k Keeper) DeductTxCostsFromUserBalance(
fees := sdk.Coins{sdk.NewCoin(denom, sdk.NewIntFromBigInt(feeAmt))}
// deduct the full gas cost from the user balance
if err := authante.DeductFees(k.bankKeeper, ctx, signerAcc, fees); err != nil {
return nil, sdkerrors.Wrapf(
err,
"failed to deduct full gas cost %s from the user %s balance",
fees, msgEthTx.From,
)
}
// // deduct the full gas cost from the user balance
// if err := authante.DeductFees(k.bankKeeper, ctx, signerAcc, fees); err != nil {
// return nil, sdkerrors.Wrapf(
// err,
// "failed to deduct full gas cost %s from the user %s balance",
// fees, msgEthTx.From,
// )
// }
return fees, nil
}