-
Notifications
You must be signed in to change notification settings - Fork 36
Conversation
00766fe
to
e586592
Compare
Note: f114898 in this commit I remove one invalid test. If we use Geth's The majority of the invalid RLP errors come from rather interesting We also don't have this specific check from Geth which I have added as well. I also had to edit some tests which now throw with a different error message. I'm not super happy with the error messages and we should probably make them more explicit. Am also not entirely convinced that we have now covered all cases, especially because comparing the RLP implementation in Go and in JS is prone to off-by-one errors; in JS we use |
Maybe it is an idea to convert this file to JS tests? |
a9d6cbf
to
838d21c
Compare
i think part of the issue with the linting was your master branch was pointed to an older commit. rebased on master and tidied up looking good! |
that's a good idea, one step further would be to see if any of the cases there are not covered in |
return statement in else block can be placed outside if statement (https://eslint.org/docs/rules/no-else-return)
I'll check with ethereum/tests team to see if these RLP tests are managed since the last change was 2+ years ago :) But nevertheless it would be great to see if we have now covered all cases, since fuzzing this thing seems to be rather complicated. |
Thanks for the rebase @ryanio 😄 I added the test cases from Geth (not all, since some were duplicate or some threw in Go because of type errors, which I have converted). |
I'd like at least 2 approvals before merging here, since this is a rather big change. |
Two things to do;
|
@@ -201,9 +198,6 @@ function _decode(input: Buffer): Decoded { | |||
} | |||
|
|||
innerRemainder = safeSlice(input, llength, totalLength) | |||
if (innerRemainder.length === 0) { | |||
throw new Error('invalid rlp, List has a invalid length') |
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.
This one can also be removed but is a bit more complex. We only have innerRemainder.length === 0
in case that llength
and totalLength
are equal (any other combination would throw safeSlice
. However, we have totalLength = llength + length
and therefore we have that length
should be 0, but a few lines above there is a check whether length < 56
; if that is the case then it throws. So, this condition can also not be reached.
Coverage increased to more than 95% :) Now it is really ready for review, will not push any changes anymore. |
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.
lgtm, nice! great PR. we can wait for one more approval before merging
Thanks for the review and changes, let's indeed wait for one more approval 😄 |
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.
Left a couple of comments but looks good otherwise!
Co-authored-by: acolytec3 <[email protected]>
Co-authored-by: acolytec3 <[email protected]>
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.
LGTM!
There are some cases where we successfully decode invalid RLPs - we should throw in these cases. In this PR, (rather old) tests from
ethereum/tests
are added, as well some tests from Geth.This also updates the tests, as they are using deprecated methods like
equal
which should bestrictEqual
.