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

feat(types): modify types to use native u128 where possible #790

Closed
wants to merge 1 commit into from

Conversation

dancoombs
Copy link
Collaborator

Proposed Changes

  • Modify types to use native u128 instead of ruint U128 for local (not onchain) versions of user operations.
  • Impacts gas limit and fee fields
  • Convert to U128/U256 when necessary
  • For EP v0.7 the only fallible conversion is for preVerificationGas which onchain can be a U256. It is assumed there are no use cases where PVG needs to be > u128. We we're already relying on a U256 -> u128 conversion for gas limit calculation anyway.
  • For EP v0.6 all the gas and fee fields can have a fallible conversion. It is also assumed there are no legitimate use cases where these values can be larger than u128. For gas/fee representations this would be larger than a block's gas limit or larger than the total amount of token supply for ETH.

@0xfourzerofour
Copy link
Collaborator

looks good but we need to fix the unit tests and linting

Copy link
Collaborator

@0xfourzerofour 0xfourzerofour left a comment

Choose a reason for hiding this comment

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

Looks good just a few nits

.pre_verification_gas
.uint_try_to()
.context("pre verification gas out of bounds")?;
let pvg: u128 = user_op.pre_verification_gas;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we do not need the explicit type definition if its defined at the UO struct

.pre_verification_gas
.uint_try_to()
.context("pre verification gas out of bounds")?;
let pvg: u128 = user_op.pre_verification_gas;
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

* (self.pre_verification_gas
+ U256::from(self.call_gas_limit)
Copy link
Collaborator

Choose a reason for hiding this comment

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

low chance of this happening but if someone inputs an arbitrarily large value for one of these fields we may have an overflow calling function so might be a good idea to saturate.

not sure if this is checked before this but worth the safety

@dancoombs dancoombs closed this Sep 17, 2024
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.

3 participants