-
Notifications
You must be signed in to change notification settings - Fork 973
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
Add Safe to L2 Setup Contract #759
Conversation
This PR introduces a setup contract that can be called from the `Safe` setup function in order to automatically promote a Safe at setup time if the code is executing on an L2. Namely, this allows the Safe Proxy factory to use a single singleton and initializer for all chains, but end up with different `singleton`s depending on the chain ID.
Pull Request Test Coverage Report for Build 9780086819Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test run
b2514b0
to
6041507
Compare
7c9f3a3
to
ff81fbd
Compare
@@ -71,7 +71,7 @@ jobs: | |||
solidity: ["0.7.6", "0.8.24"] | |||
include: | |||
- solidity: "0.8.24" | |||
settings: '{"viaIR":true,"optimizer":{"enabled":true,"runs":1000000}}' | |||
settings: '{"viaIR":false,"optimizer":{"enabled":true,"runs":1000000}}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set this to false because hardhat fails to infer the revert reason in some tests.
@@ -67,7 +68,7 @@ | |||
"eslint-config-prettier": "^9.1.0", | |||
"eslint-plugin-no-only-tests": "^3.1.0", | |||
"eslint-plugin-prettier": "^5.1.3", | |||
"hardhat": "^2.22.3", | |||
"hardhat": "^2.22.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hardhat really wanted me to update to the latest version
test/libraries/SafeToL2Setup.spec.ts
Outdated
const { safeToL2SetupLib } = await setupTests(); | ||
const randomAddress = ethers.hexlify(ethers.randomBytes(20)); | ||
|
||
await expect(safeToL2SetupLib.setupToL2(randomAddress)).to.be.rejectedWith("GS900"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should document this new error code somewhere.
Yes
…On Tue, 2 Jul 2024 at 7:36 PM Nicholas Rodrigues Lordello < ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In test/libraries/SafeToL2Setup.spec.ts
<#759 (comment)>
:
> + ethers.ZeroAddress,
+ 0,
+ ethers.ZeroAddress,
+ ]);
+ const safeAddress = await proxyFactory.createProxyWithNonce.staticCall(safeSingleton.target, setupData, 0);
+
+ await expect(proxyFactory.createProxyWithNonce(safeSingleton.target, setupData, 0))
+ .to.emit(safeToL2SetupLib.attach(safeAddress), "ChangedSingleton")
+ .withArgs(safeL2SingletonAddress);
+ });
+
+ it("can be used only via DELEGATECALL opcode", async () => {
+ const { safeToL2SetupLib } = await setupTests();
+ const randomAddress = ethers.hexlify(ethers.randomBytes(20));
+
+ await expect(safeToL2SetupLib.setupToL2(randomAddress)).to.be.rejectedWith("GS900");
We should document this new error code somewhere.
—
Reply to this email directly, view it on GitHub
<#759 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BJI7R6NXRKJJDZHB3YDXLH3ZKLCGLAVCNFSM6AAAAABHLCGTV2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCNJUGIYTEMJTGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, only some small nits.
Co-authored-by: Nicholas Rodrigues Lordello <[email protected]>
expect(sameHexString(value, "0".repeat(64))).to.be.true; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯 - generally, well documented and not too difficult to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Approved (can't approve in GH because I opened the PR).
Only open question would be, should we add this to the deployment scripts? Although this can be done in a separate PR. Also left some "take-it-or-leave-it" ubernits.
Co-authored-by: Nicholas Rodrigues Lordello <[email protected]>
…-contracts into experiment/auto-l2-safe
This PR introduces a setup contract that can be called from the
Safe
setup function in order to automatically promote a Safe at setup time if the code is executing on an L2. Namely, this allows the Safe Proxy factory to use a single singleton and initializer for all chains, but end up with differentsingleton
s depending on the chain ID.The expected use of this contract is to use the standard proxy factory:
On L1 (i.e. Ethereum Mainnet where
chainId == 1
), you would end up with a Safe wheresafe.singleton == l1Singleton
and on any other chains, you would end up withsafe.singleton == l2Singleton
. This would happen before the first transaction.