Fix eth_sendRawTransaction 500 error when handling malformed RLP payloads #3652
Labels
bug
Something isn't working
Team Promoted
Issues to be triaged and discussed by committers, maintainers, to be worked on the following sprint
Milestone
Issue Description
The
eth_sendRawTransaction
endpoint returns a 500 error instead of a proper 400 client error when receiving transactions with malformed RLP payloads. The error occurs during transaction parsing inPrecheck.parseTxIfNeeded
when ethers.js encounters unexpected data after what should be a complete RLP transaction.Steps to Reproduce
eth_sendRawTransaction
endpointCurrent Behavior
unexpected junk after rlp payload (argument="data", value=<transaction-hex>, code=INVALID_ARGUMENT, version=6.13.5)
Expected Behavior
INVALID_ARGUMENTS
Root Cause
The error occurs in
Precheck.parseTxIfNeeded
when callingTransaction.from(transaction)
from ethers.js. The specific error (INVALID_ARGUMENT) isn't handled in the error mapping logic, so it's treated as an unknown internal error (500).Proposed Solution
parseRawTxAndPrecheck
orgenericErrorHandler
to detect ethers.js "unexpected junk after rlp payload" errors, or more generic to check for INVALID_ARGUMENTS codepredefined.INVALID_ARGUMENTS
JsonRpcErrorThe text was updated successfully, but these errors were encountered: