Skip to content

Commit

Permalink
test tx replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Sep 2, 2024
1 parent 0ab3868 commit 14b147f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions integration_tests/test_mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,37 @@ def test_blocked_address(cronos_mempool):
rsp = cli.transfer("signer1", cli.address("validator"), "1basecro")
assert rsp["code"] != 0
assert "signer is blocked" in rsp["raw_log"]


@pytest.mark.flaky(max_runs=5)
def test_tx_replacement(cronos_mempool):
w3: Web3 = cronos_mempool.w3
account = "community"
nonce = w3.eth.get_transaction_count(ADDRS[account])
gas_price = w3.eth.gas_price
reduction = 1000000
# the second tx should replace the first tx with higher priority,
# but the third one shouldn't replace the second one.
prices = [
gas_price,
gas_price + 2 * reduction,
gas_price + reduction,
]
txs = [
sign_transaction(
w3,
{
"to": ADDRS[account],
"value": 1,
"gas": 21000,
"gasPrice": price,
"nonce": nonce,
},
KEYS[account],
)
for price in prices
]

txhashes = [w3.eth.send_raw_transaction(tx.rawTransaction) for tx in txs]

Check failure on line 114 in integration_tests/test_mempool.py

View workflow job for this annotation

GitHub Actions / integration_tests (slow)

test_tx_replacement ValueError: {'code': -32000, 'message': '\ngithub.com/evmos/ethermint/app/ante.CheckAndSetEthSenderNonce\n\tgithub.com/evmos/ethermint/app/ante/eth.go:298\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.newEthAnteHandler.func2\n\tgithub.com/evmos/ethermint/app/ante/handler_options.go:148\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.func1\n\tgithub.com/evmos/ethermint/app/ante/ante.go:93\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTxWithMultiStore\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:929\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:842\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).CheckTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/abci.go:350\ngithub.com/cosmos/cosmos-sdk/server.cometABCIWrapper.CheckTx\n\tgithub.com/cosmos/cosmos-sdk/server/cmt_abci.go:28\ngithub.com/cometbft/cometbft/abci/client.(*localClient).CheckTxAsync\n\tgithub.com/cometbft/cometbft/abci/client/local_client.go:51\ngithub.com/cometbft/cometbft/proxy.(*appConnMempool).CheckTxAsync\n\tgithub.com/cometbft/cometbft/proxy/app_conn.go:147\ngithub.com/cometbft/cometbft/mempool.(*CListMempool).CheckTx\n\tgithub.com/cometbft/cometbft/mempool/clist_mempool.go:270\ngithub.com/cometbft/cometbft/rpc/core.(*Environment).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/core/mempool.go:35\ngithub.com/cometbft/cometbft/rpc/client/local.(*Local).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/client/local/local.go:98\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTxSync\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:94\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTx\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:26\ngithub.com/evmos/ethermint/rpc/backend.(*Backend).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/backend/call_tx.go:167\ngithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth.(*PublicAPI).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth/api.go:232\nreflect.Value.call\n\treflect/value.go:596\nreflect.Value.Call\n\treflect/value.go:380\ngithub.com/ethereum/go-ethereum/rpc.(*callback).call\n\tgithub.com/ethereum/go-ethereum/rpc/service.go:205\ngithub.com/ethereum/go-ethereum/rpc.(*handler).runMethod\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:513\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCall\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:459\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:420\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:256\ngithub.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:348\ninvalid nonce; got 0, expected 1: invalid sequence: invalid sequence'}

Check failure on line 114 in integration_tests/test_mempool.py

View workflow job for this annotation

GitHub Actions / integration_tests (slow)

test_tx_replacement ValueError: {'code': -32000, 'message': '\ngithub.com/evmos/ethermint/app/ante.CheckAndSetEthSenderNonce\n\tgithub.com/evmos/ethermint/app/ante/eth.go:298\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.newEthAnteHandler.func2\n\tgithub.com/evmos/ethermint/app/ante/handler_options.go:148\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.func1\n\tgithub.com/evmos/ethermint/app/ante/ante.go:93\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTxWithMultiStore\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:929\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:842\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).CheckTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/abci.go:350\ngithub.com/cosmos/cosmos-sdk/server.cometABCIWrapper.CheckTx\n\tgithub.com/cosmos/cosmos-sdk/server/cmt_abci.go:28\ngithub.com/cometbft/cometbft/abci/client.(*localClient).CheckTxAsync\n\tgithub.com/cometbft/cometbft/abci/client/local_client.go:51\ngithub.com/cometbft/cometbft/proxy.(*appConnMempool).CheckTxAsync\n\tgithub.com/cometbft/cometbft/proxy/app_conn.go:147\ngithub.com/cometbft/cometbft/mempool.(*CListMempool).CheckTx\n\tgithub.com/cometbft/cometbft/mempool/clist_mempool.go:270\ngithub.com/cometbft/cometbft/rpc/core.(*Environment).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/core/mempool.go:35\ngithub.com/cometbft/cometbft/rpc/client/local.(*Local).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/client/local/local.go:98\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTxSync\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:94\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTx\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:26\ngithub.com/evmos/ethermint/rpc/backend.(*Backend).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/backend/call_tx.go:167\ngithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth.(*PublicAPI).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth/api.go:232\nreflect.Value.call\n\treflect/value.go:596\nreflect.Value.Call\n\treflect/value.go:380\ngithub.com/ethereum/go-ethereum/rpc.(*callback).call\n\tgithub.com/ethereum/go-ethereum/rpc/service.go:205\ngithub.com/ethereum/go-ethereum/rpc.(*handler).runMethod\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:513\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCall\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:459\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:420\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:256\ngithub.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:348\ninvalid nonce; got 0, expected 1: invalid sequence: invalid sequence'}

Check failure on line 114 in integration_tests/test_mempool.py

View workflow job for this annotation

GitHub Actions / integration_tests (slow)

test_tx_replacement ValueError: {'code': -32000, 'message': '\ngithub.com/evmos/ethermint/app/ante.CheckAndSetEthSenderNonce\n\tgithub.com/evmos/ethermint/app/ante/eth.go:298\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.newEthAnteHandler.func2\n\tgithub.com/evmos/ethermint/app/ante/handler_options.go:148\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.func1\n\tgithub.com/evmos/ethermint/app/ante/ante.go:93\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTxWithMultiStore\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:929\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:842\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).CheckTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/abci.go:350\ngithub.com/cosmos/cosmos-sdk/server.cometABCIWrapper.CheckTx\n\tgithub.com/cosmos/cosmos-sdk/server/cmt_abci.go:28\ngithub.com/cometbft/cometbft/abci/client.(*localClient).CheckTxAsync\n\tgithub.com/cometbft/cometbft/abci/client/local_client.go:51\ngithub.com/cometbft/cometbft/proxy.(*appConnMempool).CheckTxAsync\n\tgithub.com/cometbft/cometbft/proxy/app_conn.go:147\ngithub.com/cometbft/cometbft/mempool.(*CListMempool).CheckTx\n\tgithub.com/cometbft/cometbft/mempool/clist_mempool.go:270\ngithub.com/cometbft/cometbft/rpc/core.(*Environment).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/core/mempool.go:35\ngithub.com/cometbft/cometbft/rpc/client/local.(*Local).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/client/local/local.go:98\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTxSync\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:94\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTx\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:26\ngithub.com/evmos/ethermint/rpc/backend.(*Backend).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/backend/call_tx.go:167\ngithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth.(*PublicAPI).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth/api.go:232\nreflect.Value.call\n\treflect/value.go:596\nreflect.Value.Call\n\treflect/value.go:380\ngithub.com/ethereum/go-ethereum/rpc.(*callback).call\n\tgithub.com/ethereum/go-ethereum/rpc/service.go:205\ngithub.com/ethereum/go-ethereum/rpc.(*handler).runMethod\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:513\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCall\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:459\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:420\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:256\ngithub.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:348\ninvalid nonce; got 0, expected 1: invalid sequence: invalid sequence'}

Check failure on line 114 in integration_tests/test_mempool.py

View workflow job for this annotation

GitHub Actions / integration_tests (slow)

test_tx_replacement ValueError: {'code': -32000, 'message': '\ngithub.com/evmos/ethermint/app/ante.CheckAndSetEthSenderNonce\n\tgithub.com/evmos/ethermint/app/ante/eth.go:298\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.newEthAnteHandler.func2\n\tgithub.com/evmos/ethermint/app/ante/handler_options.go:148\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.func1\n\tgithub.com/evmos/ethermint/app/ante/ante.go:93\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTxWithMultiStore\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:929\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:842\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).CheckTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/abci.go:350\ngithub.com/cosmos/cosmos-sdk/server.cometABCIWrapper.CheckTx\n\tgithub.com/cosmos/cosmos-sdk/server/cmt_abci.go:28\ngithub.com/cometbft/cometbft/abci/client.(*localClient).CheckTxAsync\n\tgithub.com/cometbft/cometbft/abci/client/local_client.go:51\ngithub.com/cometbft/cometbft/proxy.(*appConnMempool).CheckTxAsync\n\tgithub.com/cometbft/cometbft/proxy/app_conn.go:147\ngithub.com/cometbft/cometbft/mempool.(*CListMempool).CheckTx\n\tgithub.com/cometbft/cometbft/mempool/clist_mempool.go:270\ngithub.com/cometbft/cometbft/rpc/core.(*Environment).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/core/mempool.go:35\ngithub.com/cometbft/cometbft/rpc/client/local.(*Local).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/client/local/local.go:98\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTxSync\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:94\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTx\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:26\ngithub.com/evmos/ethermint/rpc/backend.(*Backend).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/backend/call_tx.go:167\ngithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth.(*PublicAPI).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth/api.go:232\nreflect.Value.call\n\treflect/value.go:596\nreflect.Value.Call\n\treflect/value.go:380\ngithub.com/ethereum/go-ethereum/rpc.(*callback).call\n\tgithub.com/ethereum/go-ethereum/rpc/service.go:205\ngithub.com/ethereum/go-ethereum/rpc.(*handler).runMethod\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:513\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCall\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:459\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:420\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:256\ngithub.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:348\ninvalid nonce; got 0, expected 1: invalid sequence: invalid sequence'}

Check failure on line 114 in integration_tests/test_mempool.py

View workflow job for this annotation

GitHub Actions / integration_tests (slow)

test_tx_replacement ValueError: {'code': -32000, 'message': '\ngithub.com/evmos/ethermint/app/ante.CheckAndSetEthSenderNonce\n\tgithub.com/evmos/ethermint/app/ante/eth.go:298\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.newEthAnteHandler.func2\n\tgithub.com/evmos/ethermint/app/ante/handler_options.go:148\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.func1\n\tgithub.com/evmos/ethermint/app/ante/ante.go:93\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTxWithMultiStore\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:929\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:842\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).CheckTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/abci.go:350\ngithub.com/cosmos/cosmos-sdk/server.cometABCIWrapper.CheckTx\n\tgithub.com/cosmos/cosmos-sdk/server/cmt_abci.go:28\ngithub.com/cometbft/cometbft/abci/client.(*localClient).CheckTxAsync\n\tgithub.com/cometbft/cometbft/abci/client/local_client.go:51\ngithub.com/cometbft/cometbft/proxy.(*appConnMempool).CheckTxAsync\n\tgithub.com/cometbft/cometbft/proxy/app_conn.go:147\ngithub.com/cometbft/cometbft/mempool.(*CListMempool).CheckTx\n\tgithub.com/cometbft/cometbft/mempool/clist_mempool.go:270\ngithub.com/cometbft/cometbft/rpc/core.(*Environment).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/core/mempool.go:35\ngithub.com/cometbft/cometbft/rpc/client/local.(*Local).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/client/local/local.go:98\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTxSync\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:94\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTx\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:26\ngithub.com/evmos/ethermint/rpc/backend.(*Backend).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/backend/call_tx.go:167\ngithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth.(*PublicAPI).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth/api.go:232\nreflect.Value.call\n\treflect/value.go:596\nreflect.Value.Call\n\treflect/value.go:380\ngithub.com/ethereum/go-ethereum/rpc.(*callback).call\n\tgithub.com/ethereum/go-ethereum/rpc/service.go:205\ngithub.com/ethereum/go-ethereum/rpc.(*handler).runMethod\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:513\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCall\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:459\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:420\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:256\ngithub.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1\n\tgithub.com/ethereum/go-ethereum/rpc/handler.go:348\ninvalid nonce; got 0, expected 1: invalid sequence: invalid sequence'}
receipt = w3.eth.wait_for_transaction_receipt(txhashes[1])
assert receipt.status == 1

0 comments on commit 14b147f

Please sign in to comment.