-
Notifications
You must be signed in to change notification settings - Fork 933
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.0: Improve ProxyFactory
#468
Conversation
Pull Request Test Coverage Report for Build 3895212699
💛 - Coveralls |
10b24e5
to
7e18917
Compare
7e18917
to
7e2da4b
Compare
@@ -46,9 +46,9 @@ | |||
"devDependencies": { |
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 pinned some versions because of bugs/incompatibilities. Please see description for a more detailed explanation
I did not see this as critical as there is no attack vector in this case (afaik). When an inititalizer is passed this is critical as the initializer depends on the singleton logic. But yeah, it is more secure to always check and if someone wants to go the "unsecure" way they could create their own factory. So opting for the secure by default makes sense |
1845dd4
to
0474607
Compare
0474607
to
f9d7784
Compare
Given we have this check in place, should we keep the |
I would keep it for now. It uses very little gas and having an additional check doesn't hurt. |
f9d7784
to
6235738
Compare
/// @param _singleton Address of singleton contract. | ||
/// @param initializer Payload for message call sent to new proxy contract. | ||
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract. | ||
function calculateCreateChainSpecificProxyWithNonceAddress( |
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.
ahh I know why you added this and it is not a blocker, but I would not add any more methods that use the revert
approach to return data. It doesn't work well with all nodes (as they all return revert messages differently. If we want to we could refactor this into a custom error with a bytes param ... but that is not available at the solidity version we use afaik.
That being said I would remove both method to calculate the address completely (they provide no benefit). Also maybe we should remove the proxyRuntimeCode
as it provides little value (as on-chain information) and breaks zkSync support.
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 agree with reverting methods, they can really behave in an unexpected manner, see NomicFoundation/hardhat#3438
regarding proxyRuntimeCode
i'd like to hear Uxio's opinion (iirc methods were added because of him) but he's on vacation until Jan 16th
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.
This was used in the relay service which we deprecated, therefore I would optimistically remove the methods, worst case we add them back later :P
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.
Done, please check
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.
…into feat/improve-proxy-factory
6235738
to
1f8f495
Compare
4696b02
to
4cb2283
Compare
) public returns (GnosisSafeProxy proxy) { | ||
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it | ||
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce, getChainId())); | ||
proxy = deployProxy(_singleton, salt); | ||
if (initializer.length > 0) |
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 realized that we could move this to the deployProxy
method or use the createProxyWithNonce
method in this function (with the saltNonce
being keccak256(abi.encodePacked(saltNonce, callback))
(as it is for createProxyWithCallback). This would reduce code duplication.
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.
good call, please check it now. I had to import the runtime bytecode from solc artifacts to be used in tests though.
e8606e2
to
40d832f
Compare
40d832f
to
8abdcdd
Compare
This PR:
Regarding dependency version changes:
I had to regenerate the lock file because the current dependencies snapshot didn't work for me with the latest Node LTS release. Tests simply didn't run. After I did
rm -rf node modules && rm -rf yarn.lock && yarn
, tests that expected return data in reverts failed, allegedly because of a bug in ethers, see NomicFoundation/hardhat#3438As a result, I pinned hardhat and ethers dependencies. Furthermore, I also pinned solhint-related things because updated versions do not pass the lining check and require contract code reformatting.
Open questions:
Gas before changes:
After changes: