Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Reject transaction sending a lot of transactions in a short period of time #544

Closed
nayuta-ueno opened this issue Sep 25, 2020 · 1 comment · Fixed by #550
Closed

Reject transaction sending a lot of transactions in a short period of time #544

nayuta-ueno opened this issue Sep 25, 2020 · 1 comment · Fixed by #550
Assignees

Comments

@nayuta-ueno
Copy link

System info: [Include Ethermint commit, operating system name, and other relevant details]

Ethermint: tags v0.2.0
Ubuntu 18.04 64bit

Steps to reproduce:

  1. make install
  2. ./init.sh
  3. ethermintcli rest-server --laddr "tcp://localhost:8545" --unlock-key mykey --chain-id "ethermint-1"
  4. run below JavaScript to send transactions(customize LOOP, ADDR_FROM, IPADDR).
/////////////////////
// send txs
const LOOP=50;
// ethermintcli q auth account $(ethermintcli keys show mykey -a) -o json | jq -r .value.eth_address
const ADDR_FROM="0xAc7eBb5efF7c508F44F846a8C9C2Eb9dC796CCfB";
// ethermintcli --laddr
const IPADDR='http://localhost:8545';
/////////////////////


const Web3 = require('web3');
const web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider(IPADDR));

const fn = async() => {
    let nonce = await web3.eth.getTransactionCount(ADDR_FROM);
    console.log("nonce=" + nonce);
    for (let loop=0; loop < LOOP; loop++) {
        const tx = {from: ADDR_FROM, to:"0x00112233445566778899aabbccddeeff00112233", value:"100", gasPrice:"1", nonce: nonce};
        web3.eth.sendTransaction(tx, function(err, hash) {
            if (!err) {
                console.log("hash=" + hash);
            } else {
                console.log("err=" + err);
            }
        })
        .on('receipt', function(receipt){
            console.log('receipt=' + JSON.stringify(receipt.transactionHash));
        })
        nonce++;
    }
}
fn();

Expected behavior: [What you expected to happen]

receive all transaction receipts.

Actual behavior: [What actually happened]

sometime fail receive transaction receipts but not detect error.

ethermintd log:

[2020-09-25|16:22:40.595] Rejected bad transaction                     module=mempool tx=4E8D7D41A3769F60DCA5388D6E56659F6783C1C5311686EA73621AC294C9BEB4 peerID= res="&{CheckTx:code:3 log:\"invalid sequence: invalid nonce; got 94, expected 90\" gas_used:75892 codespace:\"sdk\" }" err=null

Additional info: [Include gist of relevant config, logs, etc.]

Ethermint v0.1.0 too.

If the value of LOOP is small(1~3), it is often successful.

@ayeteng
Copy link

ayeteng commented Sep 26, 2020

I got similar issue when send multiple transactions at the same time. I got error message:

I[2020-09-26|02:53:13.244] Added good transaction                       module=mempool tx=1C92B463026E400A2F42276B1A1B1F924C867F0DA2E27AAF5B74A03CBCD48425 res="&{CheckTx:log:\"[]\" gas_wanted:6000000 }" height=88 total=1
I[2020-09-26|02:53:13.545] Executed block                               module=state height=89 validTxs=1 invalidTxs=0
I[2020-09-26|02:53:13.548] Committed state                              module=state height=89 txs=1 appHash=DF54B2E933E5D8DB1478356914EA244840AF67AEEAF31535050A15AD643C8771
I[2020-09-26|02:53:13.811] Added good transaction                       module=mempool tx=F976D9FF63F23BD7E6DFC3421931004C4B5A95AC119A4C1C8E302EADACC67B08 res="&{CheckTx:log:\"[]\" gas_wanted:4700000 }" height=89 total=1
I[2020-09-26|02:53:13.922] Rejected bad transaction                     module=mempool tx=A812EF2A429CD1D8613ADAEF7427A6010302ECA96EF6699CF6BC9E02E3402F24 peerID= res="&{CheckTx:code:3 log:\"invalid sequence: invalid nonce; got 4, expected 5\" gas_used:28735 codespace:\"sdk\" }" err=null
I[2020-09-26|02:53:13.942] Rejected bad transaction                     module=mempool tx=AC5BE8A31E78A20AB8D33AA127170B2E4C45057B2C2F7B3D290D61EBC8612F06 peerID= res="&{CheckTx:code:3 log:\"invalid sequence: invalid nonce; got 4, expected 5\" gas_used:33611 codespace:\"sdk\" }" err=null

The error message indicate the nonce is wrong.

I don't need the specific order of each transaction where I don't set the nonce value. Can I use the internal nonce count to padding each transaction in the block? The nonce will be arranged properly in geth that I don't need to set for each transaction when the order is not important for my program.

@noot noot self-assigned this Sep 28, 2020
@noot noot mentioned this issue Sep 28, 2020
11 tasks
@noot noot closed this as completed in #550 Sep 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants