-
Notifications
You must be signed in to change notification settings - Fork 81
fix: eth_sendRawTransaction now handles malformed RLP data correctly #3765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b34292f
c59b247
a7ec395
fd5e791
e600d1f
5edc18b
4b26464
2e41c24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,19 @@ describe('@ethSendRawTransaction eth_sendRawTransaction spec', async function () | |
); | ||
}); | ||
|
||
it('should return a predefined INVALID_ARGUMENTS when transaction has invalid format', async function () { | ||
// signature has been truncated | ||
const invalidTx = | ||
'0xf8748201280585800e8dfc0085800e8dfc00832dc6c094aca85ef7e1fce27079bbf99b60fcf6fd19b99b248502540be40080c001a0210446cfb671c3174392410d52fa3cd58723d8417e40cc67c6225b8f7e3ff693a02674b392846c59f783ea96655d39560956dd987051972064a5d853cea0b6f6d711'; | ||
await RelayAssertions.assertRejection( | ||
predefined.INVALID_ARGUMENTS('invalid hex string'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm I wanna see the |
||
ethImpl.sendRawTransaction, | ||
false, | ||
ethImpl, | ||
[invalidTx, requestDetails], | ||
); | ||
}); | ||
|
||
it('should return a computed hash if unable to retrieve EthereumHash from record due to contract revert', async function () { | ||
const signed = await signTransaction(transaction); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,8 @@ describe('Precheck', async function () { | |
const txWithZeroValue = | ||
'0xf86380843b9aca00825208940000000000000000000000000000000000000000808025a04e557f2008ff383df9a21919860939f60f4c27b9c845b89021ae2a79be4f6790a002f86d6dcefd2ffec72bf4d427091e7375acb6707e49d99893173cbc03515fd6'; | ||
const parsedTxWithZeroValue = ethers.Transaction.from(txWithZeroValue); | ||
|
||
const invalidTx = | ||
'6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea26469706673582212209c06253b6069b4e1f720945c020dc1c7b3d74b850eba35ac8b6fb407eff7ca7364736f6c63430008120033'; | ||
const defaultGasPrice = 720_000_000_000; | ||
const defaultGasLimit = 1_000_000; | ||
const defaultChainId = Number('0x12a'); | ||
|
@@ -943,4 +944,16 @@ describe('Precheck', async function () { | |
expect(async () => await precheck.receiverAccount(parsedTx, requestDetails)).not.to.throw; | ||
}); | ||
}); | ||
|
||
describe('parseRawTransaction', async function () { | ||
it('should successfully parse a valid transaction string', function () { | ||
const parsedTx = Precheck.parseRawTransaction(parsedTxWithMatchingChainId); | ||
expect(parsedTx).to.be.instanceOf(Transaction); | ||
expect(parsedTx.chainId).to.equal(BigInt(298)); | ||
}); | ||
|
||
it('should throw INVALID_ARGUMENTS for invalid RLP', function () { | ||
expect(() => Precheck.parseRawTransaction(invalidTx)).to.throw('Error invoking RPC: invalid BytesLike value'); | ||
}); | ||
Comment on lines
+956
to
+957
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's test the unexpected junk after RLP payload issue. |
||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d suggest removing this overhead and simply returning INVALID_ARGUMENTS. At this point, the only operation that throws an error is the Transaction.from(), which functions as a parsing engine. If it fails, it indicates an issue with the transaction hash, which is the argument itself—so I believe there’s no need to use INTERNAL_ERROR here.