fix: entrypoint impl deterministic address

This commit is contained in:
moebius
2025-03-19 16:21:54 +01:00
parent f974d9a6a2
commit c0492071fe
2 changed files with 10 additions and 8 deletions

View File

@@ -106,15 +106,16 @@ abstract contract DeployProtocol is Script {
}
function _deployEntrypoint() private {
// Deploy implementation at any address
address _impl = address(new Entrypoint());
// Deploy Entrypoint implementation
address _impl =
CreateX.deployCreate2(DeployLib.salt(deployer, DeployLib.ENTRYPOINT_IMPL_SALT), type(Entrypoint).creationCode);
// Encode `initialize` call data
bytes memory _intializationData = abi.encodeCall(Entrypoint.initialize, (owner, postman));
// Deploy proxy and initialize
address _entrypoint = CreateX.deployCreate2(
DeployLib.salt(deployer, DeployLib.ENTRYPOINT_SALT),
DeployLib.salt(deployer, DeployLib.ENTRYPOINT_PROXY_SALT),
abi.encodePacked(type(ERC1967Proxy).creationCode, abi.encode(_impl, _intializationData))
);

View File

@@ -20,11 +20,12 @@ library DeployLib {
* @dev Predefined salt values for each contract type
* @notice These values ensure deterministic addresses across deployments
*/
bytes11 internal constant ENTRYPOINT_SALT = bytes11(keccak256('Entrypoint1'));
bytes11 internal constant SIMPLE_POOL_SALT = bytes11(keccak256(abi.encodePacked('PrivacyPoolSimple1')));
bytes11 internal constant COMPLEX_POOL_SALT = bytes11(keccak256(abi.encodePacked('PrivacyPoolComplex1')));
bytes11 internal constant WITHDRAWAL_VERIFIER_SALT = bytes11(keccak256(abi.encodePacked('WithdrawalVerifier1')));
bytes11 internal constant RAGEQUIT_VERIFIER_SALT = bytes11(keccak256(abi.encodePacked('RagequitVerifier1')));
bytes11 internal constant ENTRYPOINT_IMPL_SALT = bytes11(keccak256('EntrypointImplementation_1'));
bytes11 internal constant ENTRYPOINT_PROXY_SALT = bytes11(keccak256('EntrypointProxy_1'));
bytes11 internal constant SIMPLE_POOL_SALT = bytes11(keccak256(abi.encodePacked('PrivacyPoolSimple_1')));
bytes11 internal constant COMPLEX_POOL_SALT = bytes11(keccak256(abi.encodePacked('PrivacyPoolComplex_1')));
bytes11 internal constant WITHDRAWAL_VERIFIER_SALT = bytes11(keccak256(abi.encodePacked('WithdrawalVerifier_1')));
bytes11 internal constant RAGEQUIT_VERIFIER_SALT = bytes11(keccak256(abi.encodePacked('RagequitVerifier_1')));
/**
* @dev Creates a custom salt for deterministic deployments