-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Add test for RLP when encoding a payload with length >= 2**64 #6343
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
Changes from all commits
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 | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -205,6 +205,16 @@ describe('RLP', function () { | |||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('reverts out of gas when encoding payload with length >= 2**64', async function () { | ||||||||||||||||||||||||||||||||||||||
| const data = ethers.concat([ | ||||||||||||||||||||||||||||||||||||||
| this.mock.interface.getFunction('$encode(bytes)').selector, | ||||||||||||||||||||||||||||||||||||||
| ethers.AbiCoder.defaultAbiCoder().encode(['uint256'], ['0x20']), // offset to bytes | ||||||||||||||||||||||||||||||||||||||
| ethers.toBeHex(MAX_UINT64, 32), // forged length | ||||||||||||||||||||||||||||||||||||||
| ethers.AbiCoder.defaultAbiCoder().encode(['uint256'], [56]), // long-form path (length > 55) | ||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||
| await expect(this.mock.runner.sendTransaction({ to: this.mock.target, data })).to.be.revertedWithoutReason(); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+208
to
+216
Contributor
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. Value mismatch: The test description and PR title reference "length >= 2**64", but - ethers.toBeHex(MAX_UINT64, 32), // forged length
+ ethers.toBeHex(MAX_UINT64 + 1n, 32), // forged length >= 2**64If 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it('RLP encoder predict create addresses', async function () { | ||||||||||||||||||||||||||||||||||||||
| for (const [from, nonce] of product( | ||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
Technically, this would be a valid input that would correspond to a buffer of size 264, and not 264-1.
Would still not properly test the function, because it OOG in the calldata to memory copy BEFORE the any of the
encode(bytes)internal logic is reached.