-
Notifications
You must be signed in to change notification settings - Fork 13
Plugin design #203
Comments
Safe plugin designIssues with the current design1. Cannot deploy account and send the first userOp in a single step. There are a few things going on here.On deployment, the plugin appears to be treated as an unstated-entity. Here is a test that verifies this by trying to deploy a Safe account and send a user op via the ecdsa plugin in a single step:
The relevant lines are:
According the ERC, unstaked entities CAN be used if:
So because the userOp is creating a new account, we break the above rule. The rule does state another way around this is to use a staked factory contract. This could be one option for overcoming the issue. Although it’s probably too cost-prohibitive as the minimum stake value is meant to be equivalent to ~$1000 in native tokens. If the account is already deployed, then we can access state no problem. Note: when we say account here, we mean the Safe account. We are also assuming the plugin has already been deployed. The canonical Safe 4337 module gets around this problem because it does not rely on module state during deployment via initCode. It instead uses the state on the Safe account itself and just calls the required functions from the module. Here is a test showing this:
The relevant solidity line of code where the module calls into the Safe when validating signatures:
Here is a test showing that deploying a Safe account and enabling a module with state will fail in doing so in a single userOp:
The relevant lines are:
Here is a test showing that you can use state in the plugin/module if it is used when an account isn’t being deployed (initCode is empty):
This is basically the same code as the above example but the Safe is deployed outside of 4337 via the Safe proxy factory. This flow is pretty similar to how are current plugins work (deploy account via regular transaction, then send userOp with no initCode), but with a modified Safe 4337 module. You might see the following comment in some of the plugin tests: // Note: initCode is not used because we need to create both the saf
// proxy and the plugin, and 4337 currently only allows one contract
// creation in this step. Since we need an extra step anyway, it's simpler
// to do the whole create outside of 4337. I wasn’t sure exactly what rules were broken here so wrote some tests to verify this behaviour:
2. Cannot easily use multiple 4337-compatible modules with the current designThis is because the 4337 plugins are also fallback handlers - also an issue with canonical Safe 4447 module. This limitation can be overcome by a routing fallback handler. See https://ethereum.stackexchange.com/questions/157043/is-there-a-recommended-pattern-to-add-multiple-4337-compatible-modules-to-a-safe Inconsistencies between WAX plugins
Design requirementsIdeal functional requirements for designThere are many requirements for the design of the Safe modules. The following section summarises the key functional requirements in order for the safe account with plugins to behave like regular erc 4337 accounts.
WAX Safe plugin design vs official safe 4337 plugin designThe canonical Safe 4337 module is an audited 4337-compatible Safe module that can be used with any Safe using V1.4.1 or newer. The key differences bewteen this module and out plugins are:
Next steps/Questions
ERC rules referenceChecks the account must do:Under section on specification https://eips.ethereum.org/EIPS/eip-4337#specification
Rules relevant for signature aggregation:Under section on specification https://eips.ethereum.org/EIPS/eip-4337#specification
Storage access rules under simulation:Under section on simulation rationale https://eips.ethereum.org/EIPS/eip-4337#specification-1
When un-staked entities can be usedUnder section un-staked entities https://eips.ethereum.org/EIPS/eip-4337#un-staked-entities
Behaviour and rules for first-time account creationUnder section on first-time account creation https://eips.ethereum.org/EIPS/eip-4337#first-time-account-creation
|
Follow up issue that captures next steps/questions #208 Here is the branch where the aforementioned testing was done https://github.com/getwax/wax/tree/safe-plugin-design-spike |
There are a few issues with are current Safe plugin design. There are also some small inconsistencies between different plugins. And our design also differs from the canonical Safe 4337 plugin.
The purpose of this issue to is to:
The text was updated successfully, but these errors were encountered: