-
Notifications
You must be signed in to change notification settings - Fork 14
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: when decoding addresses restrict to 20 bytes #56
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry @SamMayWork - I think I need to understand this better.
Maybe I need to work through this from base principals.
decodeABIUnsignedInt
should be processing exactly 20 bytes.The ABI specification states that
address
is processed identically touint256
.So on the face of it, your change seems to sidestep a bug in
decodeABIUnsignedInt
by introducing a new function... but I don't understand why.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.
Sorry, skipping working here before writing comment.
address
should be processed identically touint160
So I think the point here is that
uintXXX
processing is not correctly trimming before processing.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 is a fair point - address is just a
unit256
under the hood, so this fixed the problem seen on the BSC chain here, but if someone padded a normalunit256
with non-zero bytes, we'd actually hit the same issue.Taking the fixed code and moving it into the baseline
unit256
function...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.
Then just as important. A
uint256
should not panic the VM, includingffffffffffffffffffffffffab0974bbed8afc5212e951c8498873319d02d025
(which to my knowledge is a perfectly validuint256
)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.
So I'm expecting to see @SamMayWork :
ffffffffffffffffffffffffab0974bbed8afc5212e951c8498873319d02d025
as auint160
resulting in0xab0974bbed8afc5212e951c8498873319d02d025
as a numberffffffffffffffffffffffffab0974bbed8afc5212e951c8498873319d02d025
as auint8
resulting in0x25
as a numberffffffffffffffffffffffffab0974bbed8afc5212e951c8498873319d02d025
as auint256
processing0xffffffffffffffffffffffffab0974bbed8afc5212e951c8498873319d02d025
as a numberffffffffffffffffffffffffab0974bbed8afc5212e951c8498873319d02d025
as anaddress
processing0xab0974bbed8afc5212e951c8498873319d02d025
with the semantic thatuint160
andaddress
are equivalent at this layer of codeThere 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 be resolved by 711fd0f