Skip to content

Commit

Permalink
chore(tests) deprecate usage of aphoton on tests (evmos#1352)
Browse files Browse the repository at this point in the history
* chore(tests): refactor fee_checker tests

* chore(migration) rename imports and variables

* chore (tests): replace denom to aevmos on rpc/backend test

* chore(tests) refactor denom on kv_indexer_test

* chore(tests) replace denom on evm module tests

* chore(tests) fix inflation keeper tests (evmos#1357)

* chore(tests) fix inflation keeper tests

* chore(tests) fix lint issues

* chore(tests) change evm denom for claims keeper tests (evmos#1356)

* chore(tests): refactor claims_test

* chore(tests) add fees on claims keeper tests

* chore(tests) add initial comm pool balance for the checks

* chore(tests) track fees for balance checks

* chore(tests) fix claims keeper tests

* chore(tests) add changelog entry
  • Loading branch information
GAtom22 authored Feb 9, 2023
1 parent 408ada6 commit f930dd7
Show file tree
Hide file tree
Showing 36 changed files with 188 additions and 148 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (vesting) [#1155](https://github.com/evmos/evmos/pull/1155) Migrate deprecated event emitting to new `TypedEvent`
- (docs) [#1361](https://github.com/evmos/evmos/pull/1361) Update `vesting` module docs with new behavior for `ClawbackVestingAccounts`
- (evm) [#1349](https://github.com/evmos/evmos/pull/1349) Restrict the Evmos codebase from working with chain IDs other than `9000` and `9001`
- (test) [#1352](https://github.com/evmos/evmos/pull/1352) Deprecate usage of `aphoton` as denomination on tests

## [v11.0.1] - 2023-02-04

Expand Down
14 changes: 7 additions & 7 deletions app/ante/cosmos/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ import (
"github.com/ethereum/go-ethereum/signer/core/apitypes"
"github.com/evmos/evmos/v11/crypto/ethsecp256k1"
"github.com/evmos/evmos/v11/ethereum/eip712"
ethermint "github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/types"

evmtypes "github.com/evmos/evmos/v11/x/evm/types"
)

var ethermintCodec codec.ProtoCodecMarshaler
var evmosCodec codec.ProtoCodecMarshaler

func init() {
registry := codectypes.NewInterfaceRegistry()
ethermint.RegisterInterfaces(registry)
ethermintCodec = codec.NewProtoCodec(registry)
types.RegisterInterfaces(registry)
evmosCodec = codec.NewProtoCodec(registry)
}

// Deprecated: LegacyEip712SigVerificationDecorator Verify all signatures for a tx and return an error if any are invalid. Note,
Expand Down Expand Up @@ -204,7 +204,7 @@ func VerifySignature(
msgs, tx.GetMemo(), tx.GetTip(),
)

signerChainID, err := ethermint.ParseChainID(signerData.ChainID)
signerChainID, err := types.ParseChainID(signerData.ChainID)
if err != nil {
return errorsmod.Wrapf(err, "failed to parse chain-id: %s", signerData.ChainID)
}
Expand All @@ -218,7 +218,7 @@ func VerifySignature(
return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx doesnt contain expected amount of extension options")
}

extOpt, ok := opts[0].GetCachedValue().(*ethermint.ExtensionOptionsWeb3Tx)
extOpt, ok := opts[0].GetCachedValue().(*types.ExtensionOptionsWeb3Tx)
if !ok {
return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "unknown extension option")
}
Expand All @@ -239,7 +239,7 @@ func VerifySignature(
FeePayer: feePayer,
}

typedData, err := eip712.WrapTxToTypedData(ethermintCodec, extOpt.TypedDataChainID, msgs[0], txBytes, feeDelegation)
typedData, err := eip712.WrapTxToTypedData(evmosCodec, extOpt.TypedDataChainID, msgs[0], txBytes, feeDelegation)
if err != nil {
return errorsmod.Wrap(err, "failed to create EIP-712 typed data from tx")
}
Expand Down
2 changes: 1 addition & 1 deletion app/ante/cosmos/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (suite *AnteTestSuite) SetupTest() {
return genesis
})

suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 2, ChainID: "ethermint_9000-1", Time: time.Now().UTC()})
suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 2, ChainID: "evmos_9000-1", Time: time.Now().UTC()})
suite.ctx = suite.ctx.WithMinGasPrices(sdk.NewDecCoins(sdk.NewDecCoin(evmtypes.DefaultEVMDenom, sdk.OneInt())))
suite.ctx = suite.ctx.WithBlockGasMeter(sdk.NewGasMeter(1000000000000000000))
suite.app.EvmKeeper.WithChainID(suite.ctx)
Expand Down
8 changes: 4 additions & 4 deletions app/ante/evm/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"

ethermint "github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/x/evm/keeper"
"github.com/evmos/evmos/v11/x/evm/statedb"
evmtypes "github.com/evmos/evmos/v11/x/evm/types"
Expand Down Expand Up @@ -145,7 +145,7 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
// Error: "gas wanted -1 is negative"
// For more information, see issue #1554
// https://github.com/evmos/ethermint/issues/1554
newCtx := ctx.WithGasMeter(ethermint.NewInfiniteGasMeterWithLimit(gasWanted))
newCtx := ctx.WithGasMeter(types.NewInfiniteGasMeterWithLimit(gasWanted))
return next(newCtx, tx, simulate)
}

Expand Down Expand Up @@ -212,7 +212,7 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula

ctx.EventManager().EmitEvents(events)

blockGasLimit := ethermint.BlockGasLimit(ctx)
blockGasLimit := types.BlockGasLimit(ctx)

// return error if the tx gas is greater than the block limit (max gas)

Expand All @@ -235,7 +235,7 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
// FIXME: use a custom gas configuration that doesn't add any additional gas and only
// takes into account the gas consumed at the end of the EVM transaction.
newCtx := ctx.
WithGasMeter(ethermint.NewInfiniteGasMeterWithLimit(gasWanted)).
WithGasMeter(types.NewInfiniteGasMeterWithLimit(gasWanted)).
WithPriority(minPriority)

// we know that we have enough gas on the pool to cover the intrinsic gas
Expand Down
4 changes: 2 additions & 2 deletions app/ante/evm/eth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
ethante "github.com/evmos/evmos/v11/app/ante/evm"
"github.com/evmos/evmos/v11/server/config"
"github.com/evmos/evmos/v11/tests"
ethermint "github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/x/evm/statedb"
evmtypes "github.com/evmos/evmos/v11/x/evm/types"

Expand Down Expand Up @@ -181,7 +181,7 @@ func (suite *AnteTestSuite) TestEthGasConsumeDecorator() {
tx2.From = addr.Hex()
tx2Priority := int64(1)

tx3GasLimit := ethermint.BlockGasLimit(suite.ctx) + uint64(1)
tx3GasLimit := types.BlockGasLimit(suite.ctx) + uint64(1)
tx3 := evmtypes.NewTxContract(suite.app.EvmKeeper.ChainID(), 1, big.NewInt(10), tx3GasLimit, gasPrice, nil, nil, nil, &ethtypes.AccessList{{Address: addr, StorageKeys: nil}})

dynamicFeeTx := evmtypes.NewTxContract(suite.app.EvmKeeper.ChainID(), 1, big.NewInt(10), tx2GasLimit,
Expand Down
4 changes: 2 additions & 2 deletions app/ante/evm/fee_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
ethermint "github.com/evmos/evmos/v11/types"
evmostypes "github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/x/evm/types"
)

Expand Down Expand Up @@ -65,7 +65,7 @@ func NewDynamicFeeChecker(k DynamicFeeEVMKeeper) authante.TxFeeChecker {
// get the priority tip cap from the extension option.
if hasExtOptsTx, ok := tx.(authante.HasExtensionOptionsTx); ok {
for _, opt := range hasExtOptsTx.GetExtensionOptions() {
if extOpt, ok := opt.GetCachedValue().(*ethermint.ExtensionOptionDynamicFeeTx); ok {
if extOpt, ok := opt.GetCachedValue().(*evmostypes.ExtensionOptionDynamicFeeTx); ok {
maxPriorityPrice = extOpt.MaxPriorityPrice
break
}
Expand Down
28 changes: 14 additions & 14 deletions app/ante/evm/fee_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/ethereum/go-ethereum/params"
"github.com/evmos/evmos/v11/encoding"
ethermint "github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/types"
evmtypes "github.com/evmos/evmos/v11/x/evm/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestSDKTxFeeChecker(t *testing.T) {
// without extension option
// london hardfork enableness
encodingConfig := encoding.MakeConfig(module.NewBasicManager())
minGasPrices := sdk.NewDecCoins(sdk.NewDecCoin("aphoton", sdk.NewInt(10)))
minGasPrices := sdk.NewDecCoins(sdk.NewDecCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(10)))

genesisCtx := sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger())
checkTxCtx := sdk.NewContext(nil, tmproto.Header{Height: 1}, true, log.NewNopLogger()).WithMinGasPrices(minGasPrices)
Expand Down Expand Up @@ -95,10 +95,10 @@ func TestSDKTxFeeChecker(t *testing.T) {
func() sdk.Tx {
txBuilder := encodingConfig.TxConfig.NewTxBuilder()
txBuilder.SetGasLimit(1)
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdk.NewInt(10))))
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(10))))
return txBuilder.GetTx()
},
"10aphoton",
"10aevmos",
0,
true,
},
Expand Down Expand Up @@ -137,10 +137,10 @@ func TestSDKTxFeeChecker(t *testing.T) {
func() sdk.Tx {
txBuilder := encodingConfig.TxConfig.NewTxBuilder()
txBuilder.SetGasLimit(1)
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdk.NewInt(10))))
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(10))))
return txBuilder.GetTx()
},
"10aphoton",
"10aevmos",
0,
true,
},
Expand All @@ -153,10 +153,10 @@ func TestSDKTxFeeChecker(t *testing.T) {
func() sdk.Tx {
txBuilder := encodingConfig.TxConfig.NewTxBuilder()
txBuilder.SetGasLimit(1)
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdk.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(sdk.NewInt(10)))))
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(sdk.NewInt(10)))))
return txBuilder.GetTx()
},
"10000010aphoton",
"10000010aevmos",
10,
true,
},
Expand All @@ -169,14 +169,14 @@ func TestSDKTxFeeChecker(t *testing.T) {
func() sdk.Tx {
txBuilder := encodingConfig.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder)
txBuilder.SetGasLimit(1)
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdk.NewInt(10).Mul(evmtypes.DefaultPriorityReduction))))
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(10).Mul(evmtypes.DefaultPriorityReduction))))

option, err := codectypes.NewAnyWithValue(&ethermint.ExtensionOptionDynamicFeeTx{})
option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionDynamicFeeTx{})
require.NoError(t, err)
txBuilder.SetExtensionOptions(option)
return txBuilder.GetTx()
},
"10aphoton",
"10aevmos",
0,
true,
},
Expand All @@ -189,16 +189,16 @@ func TestSDKTxFeeChecker(t *testing.T) {
func() sdk.Tx {
txBuilder := encodingConfig.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder)
txBuilder.SetGasLimit(1)
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("aphoton", sdk.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(sdk.NewInt(10)))))
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(sdk.NewInt(10)))))

option, err := codectypes.NewAnyWithValue(&ethermint.ExtensionOptionDynamicFeeTx{
option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionDynamicFeeTx{
MaxPriorityPrice: sdk.NewInt(5).Mul(evmtypes.DefaultPriorityReduction),
})
require.NoError(t, err)
txBuilder.SetExtensionOptions(option)
return txBuilder.GetTx()
},
"5000010aphoton",
"5000010aevmos",
5,
true,
},
Expand Down
8 changes: 4 additions & 4 deletions app/ante/evm/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,18 +485,18 @@ func (suite *AnteTestSuite) CreateTestEIP712CosmosTxBuilder(
ethChainID := pc.Uint64()

// GenerateTypedData TypedData
var ethermintCodec codec.ProtoCodecMarshaler
var evmosCodec codec.ProtoCodecMarshaler
registry := codectypes.NewInterfaceRegistry()
types.RegisterInterfaces(registry)
ethermintCodec = codec.NewProtoCodec(registry)
evmosCodec = codec.NewProtoCodec(registry)
cryptocodec.RegisterInterfaces(registry)

//nolint:staticcheck
fee := legacytx.NewStdFee(gas, gasAmount)
accNumber := suite.app.AccountKeeper.GetAccount(suite.ctx, from).GetAccountNumber()

data := legacytx.StdSignBytes(chainID, accNumber, nonce, 0, fee, msgs, "", nil)
typedData, err := eip712.WrapTxToTypedData(ethermintCodec, ethChainID, msgs[0], data, &eip712.FeeDelegationOptions{
typedData, err := eip712.WrapTxToTypedData(evmosCodec, ethChainID, msgs[0], data, &eip712.FeeDelegationOptions{
FeePayer: from,
})
suite.Require().NoError(err)
Expand Down Expand Up @@ -650,7 +650,7 @@ func (suite *AnteTestSuite) createBaseTxBuilder(msg sdk.Msg, gas uint64) client.

txBuilder.SetGasLimit(gas)
txBuilder.SetFeeAmount(sdk.NewCoins(
sdk.NewCoin("aphoton", sdk.NewInt(10000)),
sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(10000)),
))

err := txBuilder.SetMsgs(msg)
Expand Down
4 changes: 2 additions & 2 deletions app/ante/handler_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ante_test
import (
ethante "github.com/evmos/evmos/v11/app/ante/evm"
"github.com/evmos/evmos/v11/encoding"
ethermint "github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/types"

"github.com/evmos/evmos/v11/app"
"github.com/evmos/evmos/v11/app/ante"
Expand Down Expand Up @@ -118,7 +118,7 @@ func (suite *AnteTestSuite) TestValidateHandlerOptions() {
Cdc: suite.app.AppCodec(),
AccountKeeper: suite.app.AccountKeeper,
BankKeeper: suite.app.BankKeeper,
ExtensionOptionChecker: ethermint.HasDynamicFeeExtensionOption,
ExtensionOptionChecker: types.HasDynamicFeeExtensionOption,
EvmKeeper: suite.app.EvmKeeper,
StakingKeeper: suite.app.StakingKeeper,
FeegrantKeeper: suite.app.FeeGrantKeeper,
Expand Down
8 changes: 4 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ import (
"github.com/evmos/evmos/v11/encoding"
"github.com/evmos/evmos/v11/ethereum/eip712"
srvflags "github.com/evmos/evmos/v11/server/flags"
ethermint "github.com/evmos/evmos/v11/types"
evmostypes "github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/x/evm"
evmkeeper "github.com/evmos/evmos/v11/x/evm/keeper"
evmtypes "github.com/evmos/evmos/v11/x/evm/types"
Expand Down Expand Up @@ -191,7 +191,7 @@ func init() {
DefaultNodeHome = filepath.Join(userHomeDir, ".evmosd")

// manually update the power reduction by replacing micro (u) -> atto (a) evmos
sdk.DefaultPowerReduction = ethermint.PowerReduction
sdk.DefaultPowerReduction = evmostypes.PowerReduction
// modify fee market parameter defaults through global
feemarkettypes.DefaultMinGasPrice = MainnetMinGasPrices
feemarkettypes.DefaultMinGasMultiplier = MainnetMinGasMultiplier
Expand Down Expand Up @@ -427,7 +427,7 @@ func NewEvmos(

// use custom Ethermint account for contracts
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), ethermint.ProtoAccount, maccPerms, sdk.GetConfig().GetBech32AccountAddrPrefix(),
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), evmostypes.ProtoAccount, maccPerms, sdk.GetConfig().GetBech32AccountAddrPrefix(),
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.BlockedAddrs(),
Expand Down Expand Up @@ -860,7 +860,7 @@ func (app *Evmos) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64)
Cdc: app.appCodec,
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
ExtensionOptionChecker: ethermint.HasDynamicFeeExtensionOption,
ExtensionOptionChecker: evmostypes.HasDynamicFeeExtensionOption,
EvmKeeper: app.EvmKeeper,
StakingKeeper: app.StakingKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
Expand Down
10 changes: 5 additions & 5 deletions cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package config
import (
sdk "github.com/cosmos/cosmos-sdk/types"

ethermint "github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/types"
)

const (
Expand Down Expand Up @@ -56,9 +56,9 @@ func SetBech32Prefixes(config *sdk.Config) {

// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets.
func SetBip44CoinType(config *sdk.Config) {
config.SetCoinType(ethermint.Bip44CoinType)
config.SetPurpose(sdk.Purpose) // Shared
config.SetFullFundraiserPath(ethermint.BIP44HDPath) //nolint: staticcheck
config.SetCoinType(types.Bip44CoinType)
config.SetPurpose(sdk.Purpose) // Shared
config.SetFullFundraiserPath(types.BIP44HDPath) //nolint: staticcheck
}

// RegisterDenoms registers the base and display denominations to the SDK.
Expand All @@ -67,7 +67,7 @@ func RegisterDenoms() {
panic(err)
}

if err := sdk.RegisterDenom(BaseDenom, sdk.NewDecWithPrec(1, ethermint.BaseDenomUnit)); err != nil {
if err := sdk.RegisterDenom(BaseDenom, sdk.NewDecWithPrec(1, types.BaseDenomUnit)); err != nil {
panic(err)
}
}
4 changes: 2 additions & 2 deletions cmd/evmosd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"

ethermint "github.com/evmos/evmos/v11/types"
"github.com/evmos/evmos/v11/types"
evmtypes "github.com/evmos/evmos/v11/x/evm/types"

evmoskr "github.com/evmos/evmos/v11/crypto/keyring"
Expand Down Expand Up @@ -218,7 +218,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
)

default:
genAccount = &ethermint.EthAccount{
genAccount = &types.EthAccount{
BaseAccount: baseAccount,
CodeHash: common.BytesToHash(evmtypes.EmptyCodeHash).Hex(),
}
Expand Down
Loading

0 comments on commit f930dd7

Please sign in to comment.