-
Notifications
You must be signed in to change notification settings - Fork 11
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 encoding for branch and extension for inlined data. #391
base: main
Are you sure you want to change the base?
Conversation
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.
One change request. The fix itself: 👍
@@ -649,7 +649,9 @@ private void EncodeBranch(scoped in Key key, scoped in ComputeContext ctx, scope | |||
// Write length of length in front of the payload, resetting the stream properly | |||
var end = stream.Position; | |||
var actualLength = end - initialShift; | |||
var lengthOfLength = Rlp.LengthOfLength(actualLength) + 1; | |||
var lengthOfLength = Rlp.LengthOfLength(actualLength); | |||
if (actualLength >= 56) //to match StartSequence |
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.
Should we have it extracted as a const under Rlp
maybe? Then both Rlp.LengthOfLength
and this place could refer to it properly?
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.
Added constant in Rlp
@@ -692,7 +694,10 @@ private void EncodeExtension(scoped in Key key, scoped in ComputeContext ctx, sc | |||
RlpStream stream = new(pooled.Span.Slice(slice, totalLength)); | |||
stream.StartSequence(contentLength); | |||
stream.Encode(span); | |||
stream.Encode(keccakOrRlp.Keccak); | |||
if (keccakOrRlp.DataType == KeccakOrRlp.Type.Rlp) |
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.
Clearly, after following the test, this check was missing.
Fix RLP encoding for small inlined data:
Keccak
orRlp
-contentLength
already takes that into account