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 gas cost overflow for opCall opcode #2026

Merged
merged 5 commits into from
Nov 3, 2023

Conversation

Stefan-Ethernal
Copy link
Contributor

@Stefan-Ethernal Stefan-Ethernal commented Nov 2, 2023

Description

This PR introduces a fix to EVM in terms that it checks for overflows in case of opCall gas cost cannot fit uint64. In that case, the gas uint64 overflow error is returned and execution is halted.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

Manual tests

Please complete this section if you ran manual tests for this functionality, otherwise delete it

Documentation update

Please link the documentation update PR in this section if it's present, otherwise delete it

Additional comments

Please post additional comments in this section if you have them, otherwise delete it

@Stefan-Ethernal Stefan-Ethernal marked this pull request as ready for review November 2, 2023 11:43
helper/common/common.go Outdated Show resolved Hide resolved
helper/common/common.go Show resolved Hide resolved
Copy link
Contributor

@vcastellm vcastellm left a comment

Choose a reason for hiding this comment

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

LGTM have you been able to reproduce?

@Stefan-Ethernal
Copy link
Contributor Author

have you been able to reproduce?

Only through the unit test (https://github.com/0xPolygon/polygon-edge/pull/2026/files#diff-6f681b2f9f20cf2822bc04c36bd04e44b02b3048a32313ba05b8d90cd2dbacc3R708-R740), and compared that part with Geth implementation. IMO it is pretty much a corner use case (we would need to have a contract, that invokes other contract and providing nearly math.MaxUint64 for initial gas when calling another contract and EIP-150 hardfork needs to be disabled).

@Stefan-Ethernal Stefan-Ethernal merged commit 47f2d9b into develop Nov 3, 2023
9 of 10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2023
@Stefan-Ethernal Stefan-Ethernal deleted the EVM-870-gas-miscalculation branch November 3, 2023 15:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants