erigon icon indicating copy to clipboard operation
erigon copied to clipboard

Transaction with wrong chainId is added to tx pool

Open yevh-berdnyk opened this issue 3 years ago • 14 comments

System information

Erigon version: 2022.99.99-dev-60f6da76

OS & Version: OSX

Commit hash : 59bcbb4f3337b78e25f3a1545d4fe6d6bc03a855

Expected behaviour

Transaction with wrong chainId is not in the tx pool

Actual behaviour

Transaction with wrong chainId is in the tx pool:

{
  'blockHash': None,
  'blockNumber': None,
  'from': '0x67b1d87101671b127f5f8714789c7192f7ad340e',
  'gas': '0x5208',
  'maxPriorityFeePerGas': '0x12a05f200',
  'maxFeePerGas': '0x148a89eee',
  'hash': '0xdfe5d63a5347aca96ed51d6cdb874669d9591a7a1e80beff63e847df1b5dec99',
  'input': '0x',
  'nonce': '0x5',
  'to': '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
  'transactionIndex': None,
  'value': '0x470de4df820000',
  'type': '0x2',
  'accessList': [],
  'chainId': '0x1570d',
  'v': '0x0',
  'r': '0x19c004a754ad6991d5065c6024d89c77d48a1a57982ad60320e643f953ca752e',
  's': '0x75ea7bb1d351c9af9af5c2f54a432cd9cefa2103f520fc4947827c1b07c223fc'
}

Steps to reproduce the behaviour

  • Sign and send transaction with a random chainId:
{
  'nonce': 5,
  'to': '0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B',
  'value': 20000000000000000,
  'gas': 21000,
  'chainId': 67570,
  'maxFeePerGas': 5513977582,
  'maxPriorityFeePerGas': 5000000000
}
  • Get transaction pool content (for example by web3.geth.txpool.content())

yevh-berdnyk avatar Jul 28 '22 17:07 yevh-berdnyk

Hi @enriavil1, I've just retested this issue and unfortunately it's still reproducible. However I've noticed that's only relevant to EIP1559 transactions, when we sign and send a tx with gasPrice it's not added to a tx pool. I have no permission to reopen an issue in this repo, could you please do that?

yevh-berdnyk avatar Jul 29 '22 11:07 yevh-berdnyk

So the EIP-1559 txn is not added into the tx pool at all if the txn has a gas price?

enriavil1 avatar Jul 29 '22 11:07 enriavil1

EIP-1559 transactions don't include a gas price. I meant legacy transactions (with a gas price) are not added to the tx pool but EIP-1559 (without a gas price) are added (queued) in the tx pool

yevh-berdnyk avatar Jul 29 '22 12:07 yevh-berdnyk

What does Erigon say when you send the legacy tx? It should be giving you an error code

enriavil1 avatar Jul 29 '22 13:07 enriavil1

It's -32000: 'INTERNAL_ERROR: rlp parse transaction: invalid chainID' for legacy txs. For EIP-1559 I'm also getting -32000 before checking the tx pool

yevh-berdnyk avatar Jul 29 '22 13:07 yevh-berdnyk

That should only be happening if you have a different chainId from the chain you are sending your transaction to. Is it the same transaction as the one from the beginning?

enriavil1 avatar Jul 29 '22 18:07 enriavil1

What do you mean - the same transaction? I send a transaction once, get error which is expected and after that I check a tx pool.

yevh-berdnyk avatar Aug 01 '22 09:08 yevh-berdnyk

I meant if you are still sending this one: { 'nonce': 5, 'to': '0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B', 'value': 20000000000000000, 'gas': 21000, 'chainId': 67570, 'maxFeePerGas': 5513977582, 'maxPriorityFeePerGas': 5000000000 } so I can try and recreate it like I did in the previous one

enriavil1 avatar Aug 01 '22 16:08 enriavil1

ChainId is randomly generated number so it changes each time when I run a test. But the result is always the same

yevh-berdnyk avatar Aug 02 '22 09:08 yevh-berdnyk

Okay I get it legacy Tx with wrong chainId are not added into the txpool, but EIP-1559 with wrong chainId are added into txpool.

enriavil1 avatar Aug 02 '22 09:08 enriavil1

@enriavil1 are you still working on it?

mandrigin avatar Aug 08 '22 13:08 mandrigin

@enriavil1 are you still working on it?

Yes, but currently have not found the issue. I don't mind giving it away to someone else, as I am also fixing other bugs.

enriavil1 avatar Aug 08 '22 13:08 enriavil1

@mandrigin I suspect the error is in erigon-lib

enriavil1 avatar Aug 08 '22 13:08 enriavil1

okay, I adding @revittm to do that one

mandrigin avatar Aug 08 '22 13:08 mandrigin

Just retested - not reproducible anymore. Closing the issue

yevh-berdnyk avatar Sep 05 '22 11:09 yevh-berdnyk

This happened recently to one of my polygon archival nodes, tx with id 250 was in the txpool

icculp avatar Oct 18 '23 16:10 icculp