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

exploring gas of using oz #25

Closed
wants to merge 3 commits into from
Closed

exploring gas of using oz #25

wants to merge 3 commits into from

Conversation

wilsoncusack
Copy link
Contributor

No description provided.

.gas-snapshot Outdated Show resolved Hide resolved
}

Clones.cloneDeterministic(implementation, salt);
account.initialize{value: msg.value}(owners);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

msg.value kinda has unpredictable behavior here, in that if the account is already deployed, this will just sit on the factory. Maybe should just remove payable on this function

Copy link
Contributor

@xenoliss xenoliss Mar 11, 2024

Choose a reason for hiding this comment

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

What about returning the ETH if already existing? Or we could have a similar approach to Oz's one and simply revert if already deployed

@wilsoncusack
Copy link
Contributor Author

wilsoncusack commented Mar 11, 2024

before
Screenshot 2024-03-10 at 8 14 54 PM

after
Screenshot 2024-03-10 at 8 14 30 PM

Looks pretty good except 170k gas hit on upgrade 😬

@wilsoncusack
Copy link
Contributor Author

Alchemy recently used Solady UUPS with OZ Clone, we could do the same https://github.com/alchemyplatform/modular-account

@@ -209,6 +210,10 @@ contract CoinbaseSmartWallet is MultiOwnable, UUPSUpgradeable, Receiver, ERC1271
}
}

function upgradeToAndCall(address newImplementation, bytes memory data) public payable override {
ERC1967Utils.upgradeToAndCall(newImplementation, data);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not actually safe, but OZ is a little annoying to work with here. Doesn't have a clone1967

Copy link
Contributor

@xenoliss xenoliss Mar 11, 2024

Choose a reason for hiding this comment

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

For context, this override is unsafe (and not effective) but temporarily necessary to test gas.

OZ's Clones library deploys 1167 minimal proxies but our smart account implementation is a UUPSUpgradeable contract which, when calling upgradeToAndCall, uses the 1967 standard to check if the IMPLEMENTATION_SLOT is set to __self. This reverts as 1167 does not use IMPLEMENTATION_SLOT.

@wilsoncusack
Copy link
Contributor Author

wilsoncusack commented Mar 11, 2024

Interestingly if I had Solady UUPS back in the gas doesn't get much better, investigating.

here
Screenshot 2024-03-10 at 10 09 32 PM

main
Screenshot 2024-03-10 at 10 10 31 PM

only think I can think is bytecode size change allowing for more optimizations? But I can't really think how that would actually be the case.

@wilsoncusack
Copy link
Contributor Author

Not pursuing for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants