-
Notifications
You must be signed in to change notification settings - Fork 37
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: add factory stake script #326
Conversation
Summary by OctaneNew Contracts
Updated ContractsNo contracts were updated in this PR. 🔗 Commit Hash: 62c24e9 |
OverviewOctane AI analysis has finished. No vulnerabilities were found. Cheers! 🎉🎉🎉 🔗 Commit Hash: 62c24e9 |
Contract sizes: | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
| AccountFactory | 6,661 | 7,135 | 17,915 | 42,017 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| AllowlistModule | 10,262 | 10,289 | 14,314 | 38,863 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| ExecutionInstallDelegate | 5,947 | 5,993 | 18,629 | 43,159 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| ModularAccount | 23,273 | 23,672 | 1,303 | 25,480 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| NativeTokenLimitModule | 5,093 | 5,120 | 19,483 | 44,032 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| PaymasterGuardModule | 2,097 | 2,124 | 22,479 | 47,028 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| SemiModularAccount7702 | 23,741 | 24,133 | 835 | 25,019 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| SemiModularAccountBytecode | 24,223 | 24,622 | 353 | 24,530 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| SemiModularAccountStorageOnly | 24,756 | 25,155 | -180 | 23,997 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| SingleSignerValidationModule | 3,976 | 4,003 | 20,600 | 45,149 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| TimeRangeModule | 2,504 | 2,531 | 22,072 | 46,621 |
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
|-------------------------------+------------------+-------------------+--------------------+---------------------|
| WebAuthnValidationModule | 9,462 | 9,489 | 15,114 | 39,663 | Code coverage: |
Motivation
We need to stake the factory after deployment.
Solution
Add a factory staking script and a corresponding test.
Unfortunately, this revealed an issue with how foundry treats
setEnv
while running multiple tests: each cheatcode affects global state, so there's a race condition between tests that use the same env var. This results in tests passing when running just invidual tests (via--mt
or--mc
), but failing when running all tests at once.To solve this, I adjusted all instances of
vm.setEnv("ENTRYPOINT", ...)
to use the canonical v0.7.0 entrypoint address, and defined a new env var forACCOUNT_FACTORY_TO_STAKE
. In the majority of cases this will be the same asACCOUNT_FACTORY
, but it was too cumbersome to cause the deployment target of the factory deploy script's test and the setup scenario in the staking script test to line up.The script also checks whether or not the stake amount needs to be topped up, if it was previously insufficient. It does not do this style of check for the unstakeDelay or the
bool staked
- it assumes that the provided unstake delay will be equal to or greater than the current value. This is reasonable because if we ever have to lower the stake time, we would need to go through the unstake and restake process anyways, which would require new scripts.