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

MixBytes: add user op max cost setter #58

Merged
merged 5 commits into from
Jan 30, 2024
Merged

Conversation

fedealconada
Copy link
Contributor

As per MixBytes recommendation, adds a userOpMaxCost setter.
Also adds some polishes.

@fedealconada fedealconada requested a review from rrecuero January 29, 2024 12:02
@fedealconada fedealconada changed the base branch from main to increase-test-coverage-3 January 29, 2024 12:03
Copy link

Slither report

THIS CHECKLIST IS NOT COMPLETE. Use --show-ignored-findings to show all the results.
Summary

@fedealconada fedealconada changed the title add user op max cost setter MixBytes: add user op max cost setter Jan 29, 2024

uint256 public constant RATE_LIMIT_PERIOD = 1 minutes;
uint256 public constant RATE_LIMIT_THRESHOLD_TOTAL = 50;

uint256 public userOpMaxCost;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would set the initial value here because sponsor paymaster is already initialized so the initializer is not going to be called

Copy link
Contributor Author

@fedealconada fedealconada Jan 30, 2024

Choose a reason for hiding this comment

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

we can't do that when using UUPS...
https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#avoid-initial-values-in-field-declarations

but it's true that the initialize won't be called again, i think we have 2 options here:

  • create a new initialise fn: e.g initializeV2 which only initializes this variable
  • or just make sure that we call the setUserOpMaxCost and the migration.

thoughts?

Copy link
Contributor Author

@fedealconada fedealconada Jan 30, 2024

Choose a reason for hiding this comment

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

also, this is interesting. when upgrading a contract:

  • you cannot change the order in which the contract state variables are declared
  • you cannot change the type of a variable
  • you cannot change the type of a variable
  • you cannot introduce a new variable before existing ones
  • you cannot remove an existing variable

If you need to introduce a new variable, make sure you always do so at the end:

we may need to re-visit our last changes on the contracts and maybe revert the changes (if there are) and re-deploy? or maybe not? they've been working fine...

we should ideally also make sure that all tests run locally but also on mainnet fork (on the deployed contracts)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I have been taking care to follow this. It is what we did at Babylon. Always add at the end

you cannot change the order in which the contract state variables are declared
you cannot change the type of a variable
you cannot introduce a new variable before existing ones
you cannot remove an existing variable

Copy link
Contributor

@rrecuero rrecuero left a comment

Choose a reason for hiding this comment

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

One comment about initialization. Otherwise, lgtm

@fedealconada fedealconada changed the base branch from increase-test-coverage-3 to main January 30, 2024 10:49
Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (7d5918c) 93.82% compared to head (ebd6fb8) 94.34%.
Report is 1 commits behind head on main.

❗ Current head ebd6fb8 differs from pull request most recent head d5134ef. Consider uploading reports for the commit d5134ef to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #58      +/-   ##
==========================================
+ Coverage   93.82%   94.34%   +0.52%     
==========================================
  Files           8        8              
  Lines         437      442       +5     
  Branches      121      122       +1     
==========================================
+ Hits          410      417       +7     
  Misses          2        2              
+ Partials       25       23       -2     
Files Coverage Δ
src/paymasters/SponsorPaymaster.sol 92.85% <100.00%> (+1.68%) ⬆️
src/wallet/KintoWalletFactory.sol 96.36% <100.00%> (+1.91%) ⬆️
src/wallet/KintoWallet.sol 91.96% <83.33%> (+0.14%) ⬆️

@fedealconada fedealconada merged commit 7239d0a into main Jan 30, 2024
3 of 6 checks passed
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.

2 participants