mirror of
https://github.com/0xbow-io/privacy-pools-core.git
synced 2026-01-10 09:58:00 -05:00
fix: entrypoint impl deterministic address (#48)
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
"package.json": "sort-package-json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xbow/privacy-pools-core-sdk": "0.1.13",
|
||||
"@0xbow/privacy-pools-core-sdk": "0.1.15",
|
||||
"@openzeppelin/contracts": "5.1.0",
|
||||
"@openzeppelin/contracts-upgradeable": "5.0.2",
|
||||
"@openzeppelin/foundry-upgrades": "0.3.6",
|
||||
|
||||
@@ -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))
|
||||
);
|
||||
|
||||
@@ -146,8 +147,10 @@ abstract contract DeployProtocol is Script {
|
||||
|
||||
function _deployComplexPool(PoolConfig memory _config) private {
|
||||
// Deploy pool with Create2
|
||||
bytes11 _tokenSalt = bytes11(keccak256(abi.encodePacked(DeployLib.COMPLEX_POOL_SALT, _config.symbol)));
|
||||
|
||||
address _pool = CreateX.deployCreate2(
|
||||
DeployLib.salt(deployer, DeployLib.COMPLEX_POOL_SALT),
|
||||
DeployLib.salt(deployer, _tokenSalt),
|
||||
abi.encodePacked(
|
||||
type(PrivacyPoolComplex).creationCode,
|
||||
abi.encode(address(entrypoint), withdrawalVerifier, ragequitVerifier, address(_config.asset))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -160,7 +160,7 @@ contract IntegrationBase is Test {
|
||||
address _impl = address(new Entrypoint());
|
||||
bytes memory _intializationData = abi.encodeCall(Entrypoint.initialize, (_OWNER, _POSTMAN));
|
||||
address _entrypointAddr = _CREATEX.deployCreate2(
|
||||
DeployLib.salt(_OWNER, DeployLib.ENTRYPOINT_SALT),
|
||||
DeployLib.salt(_OWNER, DeployLib.ENTRYPOINT_PROXY_SALT),
|
||||
abi.encodePacked(type(ERC1967Proxy).creationCode, abi.encode(_impl, _intializationData))
|
||||
);
|
||||
_entrypoint = Entrypoint(payable(_entrypointAddr));
|
||||
|
||||
@@ -168,11 +168,13 @@ contract IntegrationDeploy is Test {
|
||||
function _deployEntrypoint() private returns (address) {
|
||||
address _owner = makeAddr('OWNER');
|
||||
address _postman = makeAddr('POSTMAN');
|
||||
address _impl = address(new Entrypoint());
|
||||
bytes memory _intializationData = abi.encodeCall(Entrypoint.initialize, (_owner, _postman));
|
||||
|
||||
address _impl =
|
||||
_CREATEX.deployCreate2(DeployLib.salt(_DEPLOYER, DeployLib.ENTRYPOINT_IMPL_SALT), type(Entrypoint).creationCode);
|
||||
|
||||
return _CREATEX.deployCreate2(
|
||||
DeployLib.salt(_DEPLOYER, DeployLib.ENTRYPOINT_SALT),
|
||||
DeployLib.salt(_DEPLOYER, DeployLib.ENTRYPOINT_PROXY_SALT),
|
||||
abi.encodePacked(type(ERC1967Proxy).creationCode, abi.encode(_impl, _intializationData))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@0xbow/privacy-pools-core-sdk@0.1.13":
|
||||
version "0.1.13"
|
||||
resolved "https://registry.yarnpkg.com/@0xbow/privacy-pools-core-sdk/-/privacy-pools-core-sdk-0.1.13.tgz#0727f6300261882fc6218b92f7b7fe8f5804a0db"
|
||||
integrity sha512-mU0CiBEWqSE26txwLqtcL2Vh0iIDXoh+ihb17h6+ot0K2S4DVldHCQvFOM6B4ARLTxkSTqbrUsv88Nr/Q9KOQg==
|
||||
"@0xbow/privacy-pools-core-sdk@0.1.15":
|
||||
version "0.1.15"
|
||||
resolved "https://registry.yarnpkg.com/@0xbow/privacy-pools-core-sdk/-/privacy-pools-core-sdk-0.1.15.tgz#9617dfaff34ec950cd5975f935dbe98c54df46d6"
|
||||
integrity sha512-IDd4ItsUJNY2an+eZvGyggUTqgdCXei4mprk2LzP/Vdo7DgG0IJzepQU3upNl469mj6w5HkCLJMI/dI+vpudbQ==
|
||||
dependencies:
|
||||
"@types/snarkjs" "0.7.9"
|
||||
"@zk-kit/lean-imt" "2.2.2"
|
||||
|
||||
Reference in New Issue
Block a user