Skip to content

Commit

Permalink
Merge pull request #147 from EscanBE/chores/minor-deps-refactor
Browse files Browse the repository at this point in the history
chores(deps): minor dependency refactor, remove `cosmossdk.io/simapp`
  • Loading branch information
VictorTrustyDev committed Sep 7, 2024
2 parents 1c50646 + 0df0cd8 commit e2bd47c
Show file tree
Hide file tree
Showing 88 changed files with 605 additions and 725 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (rpc+indexer) [#138](https://github.com/EscanBE/evermint/pull/138) Improve check txs dropped pre-AnteHandle
- (rpc) [#142](https://github.com/EscanBE/evermint/pull/142) Support flag `--allow-insecure-unlock` to protect local accounts on node
- (refactor) [#146](https://github.com/EscanBE/evermint/pull/146) Refactor application
- (deps) [#147](https://github.com/EscanBE/evermint/pull/147) Minor dependency refactor, remove `cosmossdk.io/simapp`

### Bug Fixes

Expand Down
4 changes: 3 additions & 1 deletion app/ante/cosmos/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"testing"
"time"

sdkmath "cosmossdk.io/math"

"github.com/EscanBE/evermint/v12/app/ante"
"github.com/EscanBE/evermint/v12/constants"
ethtypes "github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -428,7 +430,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
)

if tc.isEIP712 {
coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20))
coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdkmath.NewInt(20))
fees := sdk.NewCoins(coinAmount)
cosmosTxArgs := utiltx.CosmosTxArgs{
TxCfg: suite.clientCtx.TxConfig,
Expand Down
4 changes: 3 additions & 1 deletion app/ante/cosmos/fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"math"

sdkmath "cosmossdk.io/math"

errorsmod "cosmossdk.io/errors"
anteutils "github.com/EscanBE/evermint/v12/app/ante/utils"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -170,7 +172,7 @@ func checkFeeCoinsAgainstMinGasPrices(ctx sdk.Context, feeCoins sdk.Coins, gas u

// Determine the required fees by multiplying each required minimum gas
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
glDec := sdk.NewDec(int64(gas)) //#nosec G701 -- gosec warning about integer overflow is not relevant here
glDec := sdkmath.LegacyNewDec(int64(gas)) //#nosec G701 -- gosec warning about integer overflow is not relevant here
for i, gp := range minGasPrices {
fee := gp.Amount.Mul(glDec)
requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())
Expand Down
16 changes: 8 additions & 8 deletions app/ante/cosmos/fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cosmos_test
import (
"fmt"

"cosmossdk.io/math"
sdkmath "cosmossdk.io/math"

cosmosante "github.com/EscanBE/evermint/v12/app/ante/cosmos"
"github.com/EscanBE/evermint/v12/constants"
Expand All @@ -21,17 +21,17 @@ func (suite *AnteTestSuite) TestDeductFeeDecorator() {
addr, priv = testutiltx.NewAccAddressAndKey()
// fee granter
fgAddr, _ = testutiltx.NewAccAddressAndKey()
initBalance = sdk.NewInt(1e18)
lowGasPrice = math.NewInt(1)
zero = sdk.ZeroInt()
initBalance = sdkmath.NewInt(1e18)
lowGasPrice = sdkmath.NewInt(1)
zero = sdkmath.ZeroInt()
)

// Testcase definitions
testcases := []struct {
name string
balance math.Int
balance sdkmath.Int
gas uint64
gasPrice *math.Int
gasPrice *sdkmath.Int
feeGranter sdk.AccAddress
checkTx bool
simulate bool
Expand Down Expand Up @@ -84,7 +84,7 @@ func (suite *AnteTestSuite) TestDeductFeeDecorator() {
malleate: func() {
suite.ctx = suite.ctx.WithMinGasPrices(
sdk.NewDecCoins(
sdk.NewDecCoin(constants.BaseDenom, sdk.NewInt(10_000)),
sdk.NewDecCoin(constants.BaseDenom, sdkmath.NewInt(10_000)),
),
)
},
Expand Down Expand Up @@ -117,7 +117,7 @@ func (suite *AnteTestSuite) TestDeductFeeDecorator() {
malleate: func() {
suite.ctx = suite.ctx.WithMinGasPrices(
sdk.NewDecCoins(
sdk.NewDecCoin(constants.BaseDenom, sdk.NewInt(100)),
sdk.NewDecCoin(constants.BaseDenom, sdkmath.NewInt(100)),
),
)
},
Expand Down
4 changes: 3 additions & 1 deletion app/ante/cosmos/min_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cosmos
import (
"math/big"

sdkmath "cosmossdk.io/math"

errorsmod "cosmossdk.io/errors"
evmante "github.com/EscanBE/evermint/v12/app/ante/evm"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -59,7 +61,7 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate

// Determine the required fees by multiplying each required minimum gas
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
gasLimit := sdk.NewDecFromBigInt(new(big.Int).SetUint64(gas))
gasLimit := sdkmath.LegacyNewDecFromBigInt(new(big.Int).SetUint64(gas))

for _, gp := range minGasPrices {
fee := gp.Amount.Mul(gasLimit).Ceil().RoundInt()
Expand Down
16 changes: 8 additions & 8 deletions app/ante/cosmos/min_price_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (suite *AnteTestSuite) TestMinGasPriceDecorator() {
"valid cosmos tx with MinGasPrices = 0, gasPrice = 0",
func() sdk.Tx {
params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
params.MinGasPrice = sdk.ZeroDec()
params.MinGasPrice = sdkmath.LegacyZeroDec()
err := suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

Expand All @@ -66,7 +66,7 @@ func (suite *AnteTestSuite) TestMinGasPriceDecorator() {
"valid cosmos tx with MinGasPrices = 0, gasPrice > 0",
func() sdk.Tx {
params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
params.MinGasPrice = sdk.ZeroDec()
params.MinGasPrice = sdkmath.LegacyZeroDec()
err := suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

Expand All @@ -81,7 +81,7 @@ func (suite *AnteTestSuite) TestMinGasPriceDecorator() {
"valid cosmos tx with MinGasPrices = 10, gasPrice = 10",
func() sdk.Tx {
params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
params.MinGasPrice = sdk.NewDec(10)
params.MinGasPrice = sdkmath.LegacyNewDec(10)
err := suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

Expand All @@ -96,7 +96,7 @@ func (suite *AnteTestSuite) TestMinGasPriceDecorator() {
"invalid cosmos tx with MinGasPrices = 10, gasPrice = 0",
func() sdk.Tx {
params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
params.MinGasPrice = sdk.NewDec(10)
params.MinGasPrice = sdkmath.LegacyNewDec(10)
err := suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

Expand All @@ -111,7 +111,7 @@ func (suite *AnteTestSuite) TestMinGasPriceDecorator() {
name: "invalid cosmos tx with wrong denom",
malleate: func() sdk.Tx {
params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
params.MinGasPrice = sdk.NewDec(10)
params.MinGasPrice = sdkmath.LegacyNewDec(10)
err := suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

Expand All @@ -126,7 +126,7 @@ func (suite *AnteTestSuite) TestMinGasPriceDecorator() {
name: "valid cosmos tx but wrong fee denom",
malleate: func() sdk.Tx {
params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
params.MinGasPrice = sdk.NewDec(10)
params.MinGasPrice = sdkmath.LegacyNewDec(10)
err := suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

Expand All @@ -142,7 +142,7 @@ func (suite *AnteTestSuite) TestMinGasPriceDecorator() {
name: "valid cosmos tx, multiple fee and contains at least one is wrong fee denom",
malleate: func() sdk.Tx {
params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
params.MinGasPrice = sdk.NewDec(10)
params.MinGasPrice = sdkmath.LegacyNewDec(10)
err := suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

Expand All @@ -158,7 +158,7 @@ func (suite *AnteTestSuite) TestMinGasPriceDecorator() {
name: "valid cosmos tx, insufficient fee",
malleate: func() sdk.Tx {
params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
params.MinGasPrice = sdk.NewDec(10)
params.MinGasPrice = sdkmath.LegacyNewDec(10)
err := suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)

Expand Down
7 changes: 3 additions & 4 deletions app/ante/cosmos/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/stretchr/testify/suite"

sdkmath "cosmossdk.io/math"
"cosmossdk.io/simapp"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand Down Expand Up @@ -62,7 +61,7 @@ func (suite *AnteTestSuite) SetupTest() {
suite.Require().NoError(err)
suite.priv = priv

suite.app = helpers.EthSetup(checkTx, func(app *chainapp.Evermint, genesis simapp.GenesisState) simapp.GenesisState {
suite.app = helpers.EthSetup(checkTx, func(app *chainapp.Evermint, genesis chainapp.GenesisState) chainapp.GenesisState {
if suite.enableFeemarket {
// setup feemarketGenesis params
feemarketGenesis := feemarkettypes.DefaultGenesisState()
Expand Down Expand Up @@ -91,7 +90,7 @@ func (suite *AnteTestSuite) SetupTest() {
})

suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 2, ChainID: chainID, Time: time.Now().UTC()})
suite.ctx = suite.ctx.WithMinGasPrices(sdk.NewDecCoins(sdk.NewDecCoin(constants.BaseDenom, sdk.OneInt())))
suite.ctx = suite.ctx.WithMinGasPrices(sdk.NewDecCoins(sdk.NewDecCoin(constants.BaseDenom, sdkmath.OneInt())))
suite.ctx = suite.ctx.WithBlockGasMeter(sdk.NewGasMeter(1000000000000000000))
suite.app.EvmKeeper.WithChainID(suite.ctx)

Expand Down Expand Up @@ -127,7 +126,7 @@ func (suite *AnteTestSuite) SetupTest() {
suite.ethSigner = ethtypes.LatestSignerForChainID(suite.app.EvmKeeper.ChainID())

// fund signer acc to pay for tx fees
amt := sdk.NewInt(int64(math.Pow10(18) * 2))
amt := sdkmath.NewInt(int64(math.Pow10(18) * 2))
err = testutil.FundAccount(
suite.ctx,
suite.app.BankKeeper,
Expand Down
Loading

0 comments on commit e2bd47c

Please sign in to comment.