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

1.4.1 Feature: Backport migration contracts to 1.4.1 #795

Merged
merged 4 commits into from
Jul 23, 2024

Conversation

mmv08
Copy link
Member

@mmv08 mmv08 commented Jul 22, 2024

This PR implements #781.

It migrates the migration contracts from:

I had to refactor tests quite a bit because a lot has changed since the release of 1.4.1 like we added typechain types, migrated to ethers v6, etc

akshay-ap and others added 4 commits July 22, 2024 10:12
Fixes: #787

This PR adds a general migration contract that takes address of the
Safe, SafeL2 and fallback handler contracts during deployment. The
contract allows Safe to update the Singleton at `address(0)`.

- Uses error strings rather than error types because Solidity version
0.7.6 doesn't support it.

As of now tests cover below migration paths:
- 1.3.0 to 1.5.0
- 1.3.0 to 1.4.1
- 14.1 to 1.5.0

See `SafeMigration.spec.ts` to see how tests are organised. Do share if
you any thoughts to better run same tests on different migration paths.

The migration contract stores address of the Safe singletons and
fallback handler rather than using code hash and requiring the user to
provide singleton address as described in the issue. The reason being as
follows:

Checking codehash of the target singleton means user has to provide the
address of the target singleton. Also, checking code hash has higher gas
costs.

The only argument for using code hash for upgrades is that it also
allows unofficial singletons to be used for migration using official
migration contract. But, users/projects can also deploy their own
version of migration contract by providing singleton addresses in the
constructor and have similar security guarantees as the official
migration contract.

- Create a general migration contract which is not tightly bound to any
specific Safe version
- Update tests
- Remove other migration contract as this PR supersedes it

Unlike `Safe150Migration.sol`, this new contract does not check if
slot(0) of the contract stores an address having some non-empty code. I
think this check is not need because this contract is not intended to be
used in general by other proxy contracts and checking slot(0) value is
only a partially correct way. Would like to know thought of others.

---------

Co-authored-by: Nicholas Rodrigues Lordello <n@lordello.net>
Co-authored-by: Shebin John <admin@remedcu.com>
Co-authored-by: Mikhail <16622558+mmv08@users.noreply.github.com>
* Add contract to migrate a Safe from not L2 to L2
* Related to safe-global/safe-transaction-service#1703
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10039158260

Details

  • 49 of 49 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 94.066%

Totals Coverage Status
Change from base Build 10039117783: -0.1%
Covered Lines: 364
Relevant Lines: 379

💛 - Coveralls

@nlordell
Copy link
Collaborator

Nit: can we rename the branch to release/v1.4.1? This would allow us to potentially follow up with new v1.4.1-2, v1.4.1-3 etc. releases for other tooling updates that may be needed. It becomes kind of like a "LTS version" branch.

/**
* @notice Address of this contract
*/
address public immutable MIGRATION_SINGLETON;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These lints are annoying - can we fix the linter settings?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's fixed by upgrading the linter to the latest version, I would ignore it (like human ignore) and not add anything to keep the diff to a minimum.

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.

LGTM, assume that the SafeL2Setup contract will come in a follwo up?

@mmv08
Copy link
Member Author

mmv08 commented Jul 22, 2024

LGTM, assume that the SafeL2Setup contract will come in a follwo up?

oops, I absolutely missed it - but I think a follow up PR is better anyway

@mmv08 mmv08 changed the base branch from release/v1.4.1-1 to release/v1.4.1 July 23, 2024 12:20
@mmv08 mmv08 changed the base branch from release/v1.4.1 to release/v1.4.1-2 July 23, 2024 12:32
@mmv08 mmv08 merged commit ab1e24e into release/v1.4.1-2 Jul 23, 2024
11 checks passed
@mmv08 mmv08 deleted the migration-contract-141 branch July 23, 2024 12:33
@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2024
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.

5 participants