Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/utils/RLP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +210 to +213
Copy link
Collaborator

@Amxx Amxx Feb 11, 2026

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.

Suggested change
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)
this.mock.interface.getFunction('$encode(bytes)').selector,
ethers.toBeHex('0x20, 32), // offset to bytes
ethers.toBeHex(MAX_UINT64 + 1n, 32), // forged length

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.

]);
await expect(this.mock.runner.sendTransaction({ to: this.mock.target, data })).to.be.revertedWithoutReason();
});
Comment on lines +208 to +216
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Value mismatch: MAX_UINT64 is 2^64 - 1, not >= 2^64.

The test description and PR title reference "length >= 2**64", but MAX_UINT64 equals 2^64 - 1, which is strictly less than 2^64. If the intent is to test the boundary condition at >= 2^64, consider using MAX_UINT64 + 1n:

-      ethers.toBeHex(MAX_UINT64, 32), // forged length
+      ethers.toBeHex(MAX_UINT64 + 1n, 32), // forged length >= 2**64

If MAX_UINT64 is the intended value (testing the max 64-bit length), then the test description should be updated to reflect "length close to 2^64" or "length == 2^64 - 1".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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();
});
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 + 1n, 32), // forged length >= 2**64
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();
});
🤖 Prompt for AI Agents
In `@test/utils/RLP.test.js` around lines 208 - 216, The test's description
("length >= 2**64") doesn't match the value used (MAX_UINT64 == 2**64 - 1) in
the RLP.test.js case; either update the forged length to test the >= 2**64
boundary by using MAX_UINT64 + 1 (so the encoded length is >= 2**64) in the data
construction that uses MAX_UINT64, or keep the current numeric value and change
the it(...) title/description to accurately state "length == 2**64 - 1" or
"length close to 2**64"; locate the test by the it(...) string and the usage of
MAX_UINT64 in the data variable to apply the fix.


it('RLP encoder predict create addresses', async function () {
for (const [from, nonce] of product(
[
Expand Down
Loading