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 overflow exception on decoding due to negative long field #4167

Merged
merged 2 commits into from
Jun 20, 2022

Conversation

asdacap
Copy link
Contributor

@asdacap asdacap commented Jun 16, 2022

  • Fix overflow error when storing negative long field (like 0xffffffffffffffff which is -1 when interpreted as signed number)

Changes:

  • Decode to long directly

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Testing

  • Added unit test, confirm exception.
  • Fix, confirm no excepion.

Further comments (optional)

  • Ideally, the field itself should be changed to ulong, but that seems like a lot of potential issue.

@LukaszRozmej
Copy link
Member

I think this might not fix root cause, that we have corrupted receipt encoded. Can we add log values when this happens?

@asdacap
Copy link
Contributor Author

asdacap commented Jun 17, 2022

Not sure if receipt is involved in this case, but nothing really "corrupted" happened here... A header with "0xffffffffffffffff" as gas used was inserted, no issue with encoding so nothing happen. I assume the hash is valid, so it goes to processing, which then determined that the gas used is wrong, so it reject the block, which get recorded by invalid chain tracker, which then get back the header to get it's parent to know the last valid hash. Unlike encoding, the decoding failed, which is what this PR fix.

@LukaszRozmej LukaszRozmej merged commit 5614f91 into master Jun 20, 2022
@LukaszRozmej LukaszRozmej deleted the fix-header-decoding branch June 20, 2022 12:40
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.

None yet

3 participants