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

Feature: Enhance 1.4.1 contract checks for support proxy contract #683

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

mmv08
Copy link
Member

@mmv08 mmv08 commented Oct 13, 2023

This PR:

@mmv08 mmv08 requested review from a team, rmeissner, Uxio0 and akshay-ap and removed request for a team October 13, 2023 11:26
@github-actions
Copy link

github-actions bot commented Oct 13, 2023

Pull Request Test Coverage Report for Build 6610678646

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 95.2%

Totals Coverage Status
Change from base Build 6589591326: 0.02%
Covered Lines: 368
Relevant Lines: 377

💛 - Coveralls

Copy link
Collaborator

@nlordell nlordell left a comment

Choose a reason for hiding this comment

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

Code looks good to me, as for the rationale, is it just we don't want to accidentally run this migration on a proxy contract that isn't the standard Safe proxy contract (and overwrite some important storage that the proxy contract uses for other things)?

@mmv08
Copy link
Member Author

mmv08 commented Oct 20, 2023

Code looks good to me, as for the rationale, is it just we don't want to accidentally run this migration on a proxy contract that isn't the standard Safe proxy contract (and overwrite some important storage that the proxy contract uses for other things)?

Yes and no. A correct proxy implementation should use something other than this storage slot because things may break. In this case, it's more about running a migration transaction without migrating anything. For version 1.5.0, though, it gets more critical because the guard interface changes there to add a module transaction check. The contract also implements migration methods for such cases (upgrade singleton together with a guard), so it was needed to avoid an issue where the singleton stays the same, but the guard updates. See #652 (comment)

@@ -49,9 +60,7 @@ contract Safe130To141Migration is SafeStorage {
* @notice Migrate to Safe 1.4.1 Singleton (L1) at `SAFE_141_SINGLETON`
* @dev This function should only be called via a delegatecall to perform the upgrade.
*/
function migrate() public {
require(address(this) != MIGRATION_SINGLETON, "Migration should only be called via delegatecall");
Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAIU, this can be removed because isContract(singleton) implies that this was called through a DELEGATECALL (since this contract doesn't set storage itself).

If that is the case, shouldn't address public immutable MIGRATION_SINGLETON be removed as it is no longer used?

Copy link
Collaborator

@nlordell nlordell Oct 23, 2023

Choose a reason for hiding this comment

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

Also, on a general note, is it OK to have this kind of check be "implicit" or should it be more explicit (at the cost of a small amount of additional gas)?

Copy link
Member Author

Choose a reason for hiding this comment

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

If that is the case, shouldn't address public immutable MIGRATION_SINGLETON be removed as it is no longer used?

Good catch, thanks. I will remove it

Also, on a general note, is it OK to have this kind of check be "implicit" or should it be more explicit (at the cost of a small amount of additional gas)?

I think it's OK to have an implicit check if it's explicitly mentioned somewhere. I will try to improve the documentation.

@mmv08 mmv08 force-pushed the feature/1.4.1-migration-enhancements branch from 6f6e70c to bd26f51 Compare October 23, 2023 08:29
@mmv08 mmv08 requested a review from nlordell October 23, 2023 08:29
Copy link
Collaborator

@nlordell nlordell left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM.

@mmv08 mmv08 merged commit 357f55e into main Oct 31, 2023
17 checks passed
@mmv08 mmv08 deleted the feature/1.4.1-migration-enhancements branch October 31, 2023 10:51
Saw-mon-and-Natalie pushed a commit to Saw-mon-and-Natalie/safe-contracts that referenced this pull request Nov 1, 2023
…ration-enhancements

Feature: Enhance 1.4.1 contract checks for support proxy contract
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.

Update 1.4.1 migration contract with storage slot 0 checks and proper documentation
2 participants