-
Notifications
You must be signed in to change notification settings - Fork 3
Add counterfactual deployment test case #115
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Ah, it looks like I accidentally deleted a line when adding a helper, it has now been resolved. |
const userOp: UserOperationStruct = { | ||
sender: precomputedSCWAddress, | ||
nonce: 0, | ||
initCode, |
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.
Checking my understanding: won't it be a waste of gas to include this initcode with every l1 userop ?
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 think so, yes. You want to include it only if the wallet isn't already deployed.
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 point! We'd pay slightly more gas due to the increased callData
size of including the initCode
if we included it with every UserOperation.
address( | ||
uint160( | ||
uint( | ||
keccak256( | ||
abi.encodePacked( | ||
bytes1(0xff), | ||
address(this), | ||
salt, | ||
keccak256( | ||
abi.encodePacked( | ||
type(SCBridgeWallet).creationCode, | ||
abi.encode(owner), | ||
abi.encode(intermediary), | ||
abi.encode(entrypoint) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
); |
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.
A beautiful pyramid calculation.
Really great - thanks @lalexgap. |
Co-authored-by: Colin Kennedy <[email protected]>
This adds a test case to test the
Entrypoint
contract deploying ourSCBridgeWallet
on demand using our contract factory. Instead of deploying theSCBridgeWallet
before submitting theUserOperation
, the test specifies theinitcode
which points to our factory. When theEntryPoint
receives theUserOperation
it checks the precomputed address and deploys theSCBridgeWallet
for us.TODO:
initCode
and update our deploy script to just prefund theSCBridgeWallet
addresses instead of deploying to them.