From 4089d76c39f7ec13b3c73b997396a213f203a52c Mon Sep 17 00:00:00 2001 From: 0xfoobar <0xfoobar1@gmail.com> Date: Wed, 15 Jan 2025 20:00:50 -0500 Subject: [PATCH] manually match salt syntax --- foundry.toml | 2 +- remappings.txt | 3 ++- script/Deploy.s.sol | 24 ++++++++++++++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/foundry.toml b/foundry.toml index a0a7405..e8efd08 100644 --- a/foundry.toml +++ b/foundry.toml @@ -11,7 +11,7 @@ mode = "3" auto_detect_remappings = false # remappings = [] -solc_version = "0.8.21" +solc_version = "0.8.24" # EVM version must be Paris not Shanghai to prevent PUSH0 incompatibility with other EVM chains # Extra 137 deployment size, extra 0.1% runtime gas costs from using older version evm_version = "paris" diff --git a/remappings.txt b/remappings.txt index 16e2a3c..52a2ea2 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,4 +1,5 @@ ds-test/=lib/forge-std/lib/ds-test/src/ forge-std/=lib/forge-std/src/ murky/=lib/murky/src/ -openzeppelin/=lib/openzeppelin-contracts/contracts/ \ No newline at end of file +openzeppelin/=lib/openzeppelin-contracts/contracts/ +era-contracts=lib/era-contracts/ \ No newline at end of file diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol index 39ab4ad..93eca48 100644 --- a/script/Deploy.s.sol +++ b/script/Deploy.s.sol @@ -6,6 +6,9 @@ import {console2} from "forge-std/console2.sol"; import {DelegateRegistry} from "../src/DelegateRegistry.sol"; import {Singlesig} from "../src/singlesig/Singlesig.sol"; +import {Create2Factory} from "era-contracts/system-contracts/contracts/Create2Factory.sol"; +import {ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT} from "era-contracts/system-contracts/contracts/Constants.sol"; + interface ImmutableCreate2Factory { function safeCreate2(bytes32 salt, bytes calldata initCode) external payable returns (address deploymentAddress); function findCreate2Address(bytes32 salt, bytes calldata initCode) external view returns (address deploymentAddress); @@ -23,13 +26,14 @@ interface ZksyncCreate2Factory { } contract Deploy is Script { - ZksyncCreate2Factory immutable zksyncCreateFactory = ZksyncCreate2Factory(0x0000000000000000000000000000000000010000); + // ZksyncCreate2Factory immutable zksyncCreateFactory = ZksyncCreate2Factory(0x0000000000000000000000000000000000010000); + Create2Factory immutable zksyncCreateFactory = Create2Factory(0x0000000000000000000000000000000000010000); ZksyncCreate2Factory immutable zksyncContractDeployer = ZksyncCreate2Factory(0x0000000000000000000000000000000000008006); ImmutableCreate2Factory immutable factory = ImmutableCreate2Factory(0x0000000000FFe8B47B3e2130213B802212439497); bytes initCode = type(DelegateRegistry).creationCode; // bytes32 singlesigSalt = 0x0000000000000000000000000000000000000000fbe49ecfc3decb1164228b89; - bytes32 registrySalt = 0x10000000000000000000000000000000000000002bbc593dd77cb93fbb932d5f; + bytes32 registrySalt = 0x00000000000000000000000000000000000000002bbc593dd77cb93fbb932d5f; // bytes initCode = abi.encodePacked(type(Singlesig).creationCode, abi.encode(address(0x6Ed7D526b020780f694f3c10Dfb25E1b134D3215))); // bytes32 salt = 0x000000000000000000000000000000000000000016c7768a8c7a2824b846321d; @@ -45,15 +49,23 @@ contract Deploy is Script { // bytes32[] memory hashes = existing.getOutgoingDelegationHashes(0x86362a4C99d900D72d787Ef1BddA38Fd318aa5E9); // console2.logBytes32(hashes[0]); + DelegateRegistry saltDeploy = new DelegateRegistry{salt: registrySalt}(); + console2.log(address(saltDeploy)); + DelegateRegistry predeploy = new DelegateRegistry(); + + bytes32 bytecodeHash = keccak256(initCode); + bytes32 zkBytecodeHash = ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getRawCodeHash(address(predeploy)); + + console2.logBytes32(bytecodeHash); + console2.logBytes32(zkBytecodeHash); console2.log(address(predeploy)); console2.log(msg.sender); - console2.logBytes32(keccak256(initCode)); console2.logBytes32(registrySalt); - address registryAddress = zksyncContractDeployer.getNewAddressCreate2(address(zksyncCreateFactory), keccak256(initCode), registrySalt, ""); + address registryAddress = zksyncContractDeployer.getNewAddressCreate2(address(zksyncCreateFactory), zkBytecodeHash, registrySalt, ""); console2.log(registryAddress); - bytes memory constructorInput = ""; - zksyncCreateFactory.create2(registrySalt, keccak256(initCode), constructorInput); + + // zksyncCreateFactory.create2(registrySalt, zkBytecodeHash, ""); // address registryAddress = factory.safeCreate2(registrySalt, initCode); // DelegateRegistry registry = DelegateRegistry(registryAddress);