ethereum / execution-apis

Collection of APIs provided by Ethereum execution layer clients

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make `eth_sendRawTransaction` idempotent

lightclient opened this issue · comments

From @MicahZoltu in NethermindEth/nethermind#4148:

Describe the bug

If you eth_sendRawTransaction for a transaction that is already in the mempool you receive an error of AlreadyKnown. Instead, you should receive the transaction hash.

This is especially impactful when combined with other bugs like when you call eth_sendRawTransaction and get back a FeeTooLow error (no transaction hash) and then when you send it again you get AlreadyKnown error. This means you never can receive the transaction hash for the transaction in question (unless you calculate it yourself) so you can't actually query it.

If the transaction is already in the mempool, a more appropriate response would be to return the transaction hash which would make eth_sendRawTransaction semi-idempotent (you could call it multiple times and get the same answer each time).

To Reproduce

Steps to reproduce the behavior:

Via JSON-RPC call eth_sendRawTransaction with some transaction.
Call eth_sandRawTransaction again with the same transaction details.
Notice that you receive AlreadyKnown error.

Expected behavior

You get the transaction hash back.

Additional context

I'm not sure what Geth does here, but even if it returns AlreadyKnown I think this is incorrect behavior since you could just return the transaction hash which would always be a correct response in this case.