Skip to content

Commit 82302cc

Browse files
committed
Merge branch 'main' into releases/v2.0.0
2 parents acbf6d7 + 13c71a7 commit 82302cc

File tree

122 files changed

+7585
-3078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+7585
-3078
lines changed

CHANGELOG.md

Lines changed: 67 additions & 869 deletions
Large diffs are not rendered by default.

LEGACY-CHANGELOG.md

Lines changed: 837 additions & 0 deletions
Large diffs are not rendered by default.

app/ante/fixed_gas_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
197197
Amount: sdk.NewCoins(sdk.NewInt64Coin(appconst.BondDenom, 200)),
198198
},
199199
},
200-
expectedGas: 38175,
200+
expectedGas: 67193,
201201
expectedErr: nil,
202202
},
203203
}

app/evmante/evmante_can_transfer.go

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import (
77
"cosmossdk.io/errors"
88
sdk "github.com/cosmos/cosmos-sdk/types"
99
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
10-
gethcommon "github.com/ethereum/go-ethereum/common"
1110
gethcore "github.com/ethereum/go-ethereum/core/types"
1211

12+
"github.com/NibiruChain/nibiru/v2/eth"
1313
"github.com/NibiruChain/nibiru/v2/x/evm"
14-
"github.com/NibiruChain/nibiru/v2/x/evm/statedb"
1514
)
1615

1716
// CanTransferDecorator checks if the sender is allowed to transfer funds according to the EVM block
@@ -25,7 +24,6 @@ type CanTransferDecorator struct {
2524
func (ctd CanTransferDecorator) AnteHandle(
2625
ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler,
2726
) (sdk.Context, error) {
28-
params := ctd.GetParams(ctx)
2927
ethCfg := evm.EthereumConfig(ctd.EVMKeeper.EthChainID(ctx))
3028
signer := gethcore.MakeSigner(ethCfg, big.NewInt(ctx.BlockHeight()))
3129

@@ -40,7 +38,7 @@ func (ctd CanTransferDecorator) AnteHandle(
4038

4139
baseFeeWeiPerGas := evm.NativeToWei(ctd.EVMKeeper.BaseFeeMicronibiPerGas(ctx))
4240

43-
coreMsg, err := msgEthTx.AsMessage(signer, baseFeeWeiPerGas)
41+
evmMsg, err := msgEthTx.AsMessage(signer, baseFeeWeiPerGas)
4442
if err != nil {
4543
return ctx, errors.Wrapf(
4644
err,
@@ -59,37 +57,27 @@ func (ctd CanTransferDecorator) AnteHandle(
5957
return ctx, errors.Wrapf(
6058
sdkerrors.ErrInsufficientFee,
6159
"gas fee cap (wei) less than block base fee (wei); (%s < %s)",
62-
coreMsg.GasFeeCap(), baseFeeWeiPerGas,
60+
evmMsg.GasFeeCap(), baseFeeWeiPerGas,
6361
)
6462
}
6563

66-
cfg := &statedb.EVMConfig{
67-
ChainConfig: ethCfg,
68-
Params: params,
69-
// Note that we use an empty coinbase here because the field is not
70-
// used during this Ante Handler.
71-
BlockCoinbase: gethcommon.Address{},
72-
BaseFeeWei: baseFeeWeiPerGas,
73-
}
74-
75-
stateDB := ctd.NewStateDB(
76-
ctx,
77-
statedb.NewEmptyTxConfig(gethcommon.BytesToHash(ctx.HeaderHash().Bytes())),
78-
)
79-
evmInstance := ctd.EVMKeeper.NewEVM(ctx, coreMsg, cfg, evm.NewNoOpTracer(), stateDB)
80-
8164
// check that caller has enough balance to cover asset transfer for **topmost** call
8265
// NOTE: here the gas consumed is from the context with the infinite gas meter
83-
if coreMsg.Value().Sign() > 0 &&
84-
!evmInstance.Context.CanTransfer(stateDB, coreMsg.From(), coreMsg.Value()) {
85-
balanceWei := stateDB.GetBalance(coreMsg.From())
86-
return ctx, errors.Wrapf(
87-
sdkerrors.ErrInsufficientFunds,
88-
"failed to transfer %s wei (balance=%s) from address %s using the EVM block context transfer function",
89-
coreMsg.Value(),
90-
balanceWei,
91-
coreMsg.From(),
92-
)
66+
67+
if evmMsg.Value().Sign() > 0 {
68+
nibiruAddr := eth.EthAddrToNibiruAddr(evmMsg.From())
69+
balanceNative := ctd.Bank.GetBalance(ctx, nibiruAddr, evm.EVMBankDenom).Amount.BigInt()
70+
balanceWei := evm.NativeToWei(balanceNative)
71+
72+
if balanceWei.Cmp(evmMsg.Value()) < 0 {
73+
return ctx, errors.Wrapf(
74+
sdkerrors.ErrInsufficientFunds,
75+
"failed to transfer %s wei ( balance=%s )from address %s using the EVM block context transfer function",
76+
evmMsg.Value(),
77+
balanceWei,
78+
evmMsg.From(),
79+
)
80+
}
9381
}
9482
}
9583

app/evmante/evmante_can_transfer_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import (
1414
func (s *TestSuite) TestCanTransferDecorator() {
1515
testCases := []struct {
1616
name string
17-
txSetup func(deps *evmtest.TestDeps) sdk.FeeTx
18-
ctxSetup func(deps *evmtest.TestDeps)
1917
beforeTxSetup func(deps *evmtest.TestDeps, sdb *statedb.StateDB)
18+
txSetup func(deps *evmtest.TestDeps) sdk.FeeTx
2019
wantErr string
2120
}{
2221
{
@@ -92,9 +91,6 @@ func (s *TestSuite) TestCanTransferDecorator() {
9291
anteDec := evmante.CanTransferDecorator{deps.App.AppKeepers.EvmKeeper}
9392
tx := tc.txSetup(&deps)
9493

95-
if tc.ctxSetup != nil {
96-
tc.ctxSetup(&deps)
97-
}
9894
if tc.beforeTxSetup != nil {
9995
tc.beforeTxSetup(&deps, stateDB)
10096
err := stateDB.Commit()

app/evmante/evmante_setup_ctx.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,5 @@ func (esc EthSetupContextDecorator) AnteHandle(
4141
WithKVGasConfig(storetypes.GasConfig{}).
4242
WithTransientKVGasConfig(storetypes.GasConfig{})
4343

44-
// Reset transient gas used to prepare the execution of current cosmos tx.
45-
// Transient gas-used is necessary to sum the gas-used of cosmos tx, when it contains multiple eth msgs.
46-
esc.evmKeeper.ResetTransientGasUsed(ctx)
4744
return next(newCtx, tx, simulate)
4845
}

app/evmante/evmante_setup_ctx_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ func (s *TestSuite) TestEthSetupContextDecorator() {
1818
s.Require().NoError(stateDB.Commit())
1919
tx := evmtest.HappyCreateContractTx(&deps)
2020

21-
// Set block gas used to non 0 to check that handler resets it
22-
deps.App.EvmKeeper.EvmState.BlockGasUsed.Set(deps.Ctx, 1000)
23-
2421
// Ante handler returns new context
2522
newCtx, err := anteDec.AnteHandle(
2623
deps.Ctx, tx, false, evmtest.NextNoOpAnteHandler,
@@ -35,9 +32,4 @@ func (s *TestSuite) TestEthSetupContextDecorator() {
3532
defaultGasConfig := storetypes.GasConfig{}
3633
s.Require().Equal(defaultGasConfig, newCtx.KVGasConfig())
3734
s.Require().Equal(defaultGasConfig, newCtx.TransientKVGasConfig())
38-
39-
// Check that block gas used is reset to 0
40-
gas, err := deps.App.EvmKeeper.EvmState.BlockGasUsed.Get(newCtx)
41-
s.Require().NoError(err)
42-
s.Require().Equal(gas, uint64(0))
4335
}

app/evmante/evmante_validate_basic.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
122122
)
123123
}
124124

125+
// Compute fees using effective fee to enforce 1unibi minimum gas price
126+
effectiveFeeMicronibi := evm.WeiToNative(txData.EffectiveFeeWei(evm.BASE_FEE_WEI))
125127
txFee = txFee.Add(
126128
sdk.Coin{
127129
Denom: evm.EVMBankDenom,
128-
Amount: sdkmath.NewIntFromBigInt(txData.Fee()),
130+
Amount: sdkmath.NewIntFromBigInt(effectiveFeeMicronibi),
129131
},
130132
)
131133
}

app/keepers.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ import (
2929
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
3030
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
3131
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
32-
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
33-
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
3432
"github.com/cosmos/cosmos-sdk/x/authz"
3533
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
3634
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
@@ -610,7 +608,6 @@ func (app *NibiruApp) initAppModules(
610608
encodingConfig.TxConfig,
611609
),
612610
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)),
613-
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
614611
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
615612
capability.NewAppModule(appCodec, *app.capabilityKeeper, false),
616613
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
@@ -691,7 +688,6 @@ func orderedModuleNames() []string {
691688
authz.ModuleName,
692689
feegrant.ModuleName,
693690
paramstypes.ModuleName,
694-
vestingtypes.ModuleName,
695691

696692
// --------------------------------------------------------------------
697693
// Native x/ Modules
@@ -806,7 +802,6 @@ func ModuleBasicManager() module.BasicManager {
806802
evidence.AppModuleBasic{},
807803
authzmodule.AppModuleBasic{},
808804
groupmodule.AppModuleBasic{},
809-
vesting.AppModuleBasic{},
810805
// ibc 'AppModuleBasic's
811806
ibc.AppModuleBasic{},
812807
ibctransfer.AppModuleBasic{},

app/wasmext/wasm_cli_test/cli_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,7 @@ func (s *TestSuite) requiredDeployedContractsLen(total int) {
140140
}
141141

142142
func TestIntegrationTestSuite(t *testing.T) {
143-
suite.Run(t, new(TestSuite))
143+
testutil.RetrySuiteRunIfDbClosed(t, func() {
144+
suite.Run(t, new(TestSuite))
145+
}, 2)
144146
}

0 commit comments

Comments
 (0)