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

feat: Factory Deployment Script #318

Merged
merged 6 commits into from
Dec 10, 2024
Merged

Conversation

Zer0dot
Copy link
Contributor

@Zer0dot Zer0dot commented Dec 7, 2024

Motivation

We need scripts to predict the factory address and to deploy it.

Solution

Implement the aforementioned scripts, as well as some minor refactors to reduce resulting code duplication.

TODO

  • Create the factory address prediction script.
  • Test the deployment

@Zer0dot Zer0dot force-pushed the zer0dot/deploy-factory branch from 43d5021 to db63642 Compare December 9, 2024 23:35
Base automatically changed from zer0dot/deploy-scripts-predict to adam/deploy-scripts December 10, 2024 00:57
@Zer0dot Zer0dot force-pushed the zer0dot/deploy-factory branch from e3fa152 to 065b98c Compare December 10, 2024 01:01
@Zer0dot
Copy link
Contributor Author

Zer0dot commented Dec 10, 2024

Note that the factory address prediction reads addresses from the env for dependencies, rather than using the predicted addresses in the same script, as those may differ from the predicted addresses.

@Zer0dot Zer0dot marked this pull request as ready for review December 10, 2024 01:40
Copy link
Contributor

@adamegyed adamegyed left a comment

Choose a reason for hiding this comment

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

Looks good, had a couple small comments

Comment on lines 44 to 45
expectedFactoryAddr = vm.envOr("FACTORY", address(0));
factorySalt = vm.envOr("FACTORY_SALT", uint256(0));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the current var used in the .env.example file is ACCOUNT_FACTORY and ACCOUNT_FACTORY_SALT. I'm fine with using either that or the one here, but could you make it consistent across the locations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do! Good catch, in my infinite wisdom I didn't check .env.example :)

} else {
console.log("Using user-defined EntryPoint at: %x", address(entryPoint));
}
IEntryPoint entryPoint = _getEntryPoint(); //IEntryPoint(payable(vm.envOr("ENTRYPOINT", address(0))));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: delete comment

}

function _getSemiModularAccountBytecodeImpl() internal view returns (SemiModularAccountBytecode) {
return SemiModularAccountBytecode(payable(vm.envOr("SEMI_MODULAR_ACCOUNT_BYTECODE_IMPL", address(0))));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's a different format already set up in .env.example without the _IMPL ending, could you make that consistent here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, will do!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops-- actually the one in .env.example has _IMPL, I'd say we're good to keep it, it ensures the developer knows we're looking for an implementation, not an actual account.

Comment on lines 30 to 34
entryPoint = IEntryPoint(address(6));
modularAccountImpl = ModularAccount(payable(address(1)));
semiModularAccountBytecodeImpl = SemiModularAccountBytecode(payable(address(2)));
singleSignerValidationModule = address(3);
webAuthnValidationModule = address(4);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not deploy real copies of them? The EP can use the deploy script in OptimizedTest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, could go either way, I just didn't really want to test anything related to deploying anything else-- but it's a small change, I'll address this!

semiModularAccountBytecodeImpl = SemiModularAccountBytecode(payable(address(2)));
singleSignerValidationModule = address(3);
webAuthnValidationModule = address(4);
factoryOwner = address(5);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: prefer makeAddr over incrementing numbers due to appearing as precompiles in the test traces.

@Zer0dot Zer0dot merged commit 62ba7f7 into adam/deploy-scripts Dec 10, 2024
4 checks passed
@Zer0dot Zer0dot deleted the zer0dot/deploy-factory branch December 10, 2024 23:28
Zer0dot added a commit that referenced this pull request Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants