Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fca99f2
WIP: test(mempool): add integration test
cloudgray Aug 21, 2025
3591815
WIP: test(mempool): add integration test
cloudgray Aug 22, 2025
ad31857
test(mempool): refactor integration test
cloudgray Aug 25, 2025
a656805
test(mempool): fix integration test
cloudgray Aug 25, 2025
5a384a7
test(mempool): refactor integration test
cloudgray Aug 25, 2025
d74f5ad
chore: modify comments
cloudgray Aug 25, 2025
9a4d096
Merge branch 'main' into test/appside-mempool
cloudgray Aug 25, 2025
abbe071
test(mempool): add PrepareProposal check to integration test
cloudgray Aug 26, 2025
603c890
chore: fix lint
cloudgray Aug 26, 2025
bc522eb
chore: update changelog
cloudgray Aug 26, 2025
375fee6
Merge branch 'main' into test/appside-mempool
cloudgray Aug 26, 2025
dbe047b
test(mempool): modify testcode
cloudgray Aug 26, 2025
29fd29f
chore: fix lint
cloudgray Aug 26, 2025
142fbca
chore: fix lint
cloudgray Aug 26, 2025
c6054ca
Merge branch 'main' into test/appside-mempool
cloudgray Aug 29, 2025
fd4e829
chore: remove fmt unnecessary logs
cloudgray Aug 29, 2025
b39c89d
chore: change file name
cloudgray Aug 29, 2025
8e1f74a
Merge branch 'main' into test/appside-mempool
aljo242 Aug 29, 2025
8f43b76
Merge branch 'main' into test/appside-mempool
cloudgray Sep 1, 2025
1f252b0
Update CHANGELOG.md
aljo242 Sep 2, 2025
606d801
Merge branch 'main' into test/appside-mempool
aljo242 Sep 2, 2025
e0ff4d1
Merge branch 'main' into test/appside-mempool
aljo242 Sep 3, 2025
550b0a4
Merge branch 'main' into test/appside-mempool
aljo242 Sep 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [\#467](https://github.com/cosmos/evm/pull/467) Replace GlobalEVMMempool by passing to JSONRPC on initiate.
- [\#352](https://github.com/cosmos/evm/pull/352) Remove the creation of a Geth EVM instance, stateDB during the AnteHandler balance check.
- [\#496](https://github.com/cosmos/evm/pull/496) Simplify mempool instantiation by using configs instead of objects.
- [\#512](https://github.com/cosmos/evm/pull/512) Add integration test for appside mempool.
- [\#568](https://github.com/cosmos/evm/pull/568) Avoid unnecessary block notifications when the event bus is already set up.
- [\#511](https://github.com/cosmos/evm/pull/511) Minor code cleanup for `AddPrecompileFn`.
- [\#544](https://github.com/cosmos/evm/pull/544) Parse logs from the txResult.Data and avoid emitting EVM events to cosmos-sdk events.
Expand Down
3 changes: 2 additions & 1 deletion evmd/tests/integration/mempool/mempool_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package mempool

import (
"github.com/cosmos/evm/evmd/tests/integration"
"testing"

"github.com/cosmos/evm/evmd/tests/integration"

"github.com/stretchr/testify/suite"

"github.com/cosmos/evm/tests/integration/mempool"
Expand Down
152 changes: 152 additions & 0 deletions tests/integration/mempool/test_helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package mempool

import (
"encoding/hex"
"fmt"
"math/big"

abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto/tmhash"

"github.com/cosmos/evm/testutil/integration/base/factory"
"github.com/cosmos/evm/testutil/keyring"
evmtypes "github.com/cosmos/evm/x/vm/types"

sdkmath "cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

// Constants
const (
TxGas = 100_000
)

// createCosmosSendTransactionWithKey creates a simple bank send transaction with the specified key
func (s *IntegrationTestSuite) createCosmosSendTx(key keyring.Key, gasPrice *big.Int) sdk.Tx {
feeDenom := "aatom"

fromAddr := key.AccAddr
toAddr := s.keyring.GetKey(1).AccAddr
amount := sdk.NewCoins(sdk.NewInt64Coin(feeDenom, 1000))

bankMsg := banktypes.NewMsgSend(fromAddr, toAddr, amount)

gasPriceConverted := sdkmath.NewIntFromBigInt(gasPrice)

txArgs := factory.CosmosTxArgs{
Msgs: []sdk.Msg{bankMsg},
GasPrice: &gasPriceConverted,
}
tx, err := s.factory.BuildCosmosTx(key.Priv, txArgs)
s.Require().NoError(err)

return tx
}

// createEVMTransaction creates an EVM transaction using the provided key
func (s *IntegrationTestSuite) createEVMValueTransferTx(key keyring.Key, nonce int, gasPrice *big.Int) sdk.Tx {
to := s.keyring.GetKey(1).Addr

if nonce < 0 {
s.Require().NoError(fmt.Errorf("nonce must be non-negative"))
}

ethTxArgs := evmtypes.EvmTxArgs{
Nonce: uint64(nonce),
To: &to,
Amount: big.NewInt(1000),
GasLimit: TxGas,
GasPrice: gasPrice,
Input: nil,
}
tx, err := s.factory.GenerateSignedEthTx(key.Priv, ethTxArgs)
s.Require().NoError(err)

return tx
}

// createEVMContractDeployTx creates an EVM transaction for contract deployment
func (s *IntegrationTestSuite) createEVMContractDeployTx(key keyring.Key, gasPrice *big.Int, data []byte) sdk.Tx {
ethTxArgs := evmtypes.EvmTxArgs{
Nonce: 0,
To: nil,
Amount: nil,
GasLimit: TxGas,
GasPrice: gasPrice,
Input: data,
}
tx, err := s.factory.GenerateSignedEthTx(key.Priv, ethTxArgs)
s.Require().NoError(err)

return tx
}

// checkTxs call abci CheckTx for multipile transactions
func (s *IntegrationTestSuite) checkTxs(txs []sdk.Tx) error {
for _, tx := range txs {
if err := s.checkTx(tx); err != nil {
return err
}
}
return nil
}

// checkTxs call abci CheckTx for a transaction
func (s *IntegrationTestSuite) checkTx(tx sdk.Tx) error {
txBytes, err := s.network.App.GetTxConfig().TxEncoder()(tx)
if err != nil {
return fmt.Errorf("failed to encode cosmos tx: %w", err)
}

_, err = s.network.App.CheckTx(&abci.RequestCheckTx{
Tx: txBytes,
Type: abci.CheckTxType_New,
})
if err != nil {
return fmt.Errorf("failed to encode cosmos tx: %w", err)
}

return nil
}

// getTxHashes returns transaction hashes for multiple transactions
func (s *IntegrationTestSuite) getTxHashes(txs []sdk.Tx) []string {
txHashes := []string{}
for _, tx := range txs {
txHash := s.getTxHash(tx)
txHashes = append(txHashes, txHash)
}

return txHashes
}

// getTxHash returns transaction hash for a transaction
func (s *IntegrationTestSuite) getTxHash(tx sdk.Tx) string {
txEncoder := s.network.App.GetTxConfig().TxEncoder()
txBytes, err := txEncoder(tx)
s.Require().NoError(err)

return hex.EncodeToString(tmhash.Sum(txBytes))
}

// calculateCosmosGasPrice calculates the gas price for a Cosmos transaction
func (s *IntegrationTestSuite) calculateCosmosGasPrice(feeAmount int64, gasLimit uint64) *big.Int {
return new(big.Int).Div(big.NewInt(feeAmount), big.NewInt(int64(gasLimit))) //#nosec G115 -- not concern, test
}

// calculateCosmosEffectiveTip calculates the effective tip for a Cosmos transaction
// This aligns with EVM transaction prioritization: effective_tip = gas_price - base_fee
func (s *IntegrationTestSuite) calculateCosmosEffectiveTip(feeAmount int64, gasLimit uint64, baseFee *big.Int) *big.Int {
gasPrice := s.calculateCosmosGasPrice(feeAmount, gasLimit)
if baseFee == nil || baseFee.Sign() == 0 {
return gasPrice // No base fee, effective tip equals gas price
}

if gasPrice.Cmp(baseFee) < 0 {
return big.NewInt(0) // Gas price lower than base fee, effective tip is zero
}

return new(big.Int).Sub(gasPrice, baseFee)
}
Loading
Loading