Skip to content
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

Fix rlp validate to handle lists ending at the start of another list #8143

Conversation

Matilda-Clerke
Copy link
Contributor

PR description

RLP.validate attempts to traverse the supplied RLP, but when the end of a list is at the start of a new list it fails to correctly leave the previous list. In particular, this was noticed to occur when validating RLP representing an access list transaction in which both the access list entry and its list of storage keys ended on the start of the next access list entry.

and handle empty lists in AbstractRLPInput

Signed-off-by: Matilda Clerke <[email protected]>
Copy link
Contributor

@pinges pinges left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -168,6 +168,14 @@ public void calculateSize_overflowMaxRLPStringLength() {
.hasMessageContaining("RLP item exceeds max supported size of 2147483647: 2147483648");
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this testing the case where you have multiple lists end? If not, could you please add another test that does test that!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is. This is testing the exact transaction that I have been investigating

@Matilda-Clerke Matilda-Clerke enabled auto-merge (squash) January 21, 2025 05:05
@@ -168,6 +168,14 @@ public void calculateSize_overflowMaxRLPStringLength() {
.hasMessageContaining("RLP item exceeds max supported size of 2147483647: 2147483648");
}

@Test
public void testValidateWithEmptyListIncluded() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Sounds like the issue is more specific than just an empty list? Would be nice to make the test name and RLP example precisely highlight the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I wrote the test back when I still thought the empty list was the problem

Signed-off-by: Matilda Clerke <[email protected]>
Signed-off-by: Matilda Clerke <[email protected]>
@Matilda-Clerke Matilda-Clerke merged commit 5933a2a into hyperledger:main Jan 21, 2025
43 checks passed
// ["0x02"]
// ]
Bytes validRlp = Bytes.fromHexString("c4c101c102");
RLP.validate(validRlp);
Copy link
Contributor

@siladu siladu Jan 21, 2025

Choose a reason for hiding this comment

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

Suggested change
RLP.validate(validRlp);
assertThatCode(() -> RLP.validate(bytes)).doesNotThrowAnyException();

@ahamlat
Copy link
Contributor

ahamlat commented Jan 21, 2025

This looks a pretty critical part of the code, that is running fine for years. Would you mind testing a sync from scratch to see if your change doesn't have any regression ?

@Matilda-Clerke
Copy link
Contributor Author

Fair point @ahamlat I'll be running full syncs for Matilda-Clerke:7582-avoid-unnecessary-rlp-encoding-during-sync with this change included

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants