Skip to content

Commit 4089d76

Browse files
committed
manually match salt syntax
1 parent 2049782 commit 4089d76

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mode = "3"
1111
auto_detect_remappings = false
1212
# remappings = []
1313

14-
solc_version = "0.8.21"
14+
solc_version = "0.8.24"
1515
# EVM version must be Paris not Shanghai to prevent PUSH0 incompatibility with other EVM chains
1616
# Extra 137 deployment size, extra 0.1% runtime gas costs from using older version
1717
evm_version = "paris"

remappings.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ds-test/=lib/forge-std/lib/ds-test/src/
22
forge-std/=lib/forge-std/src/
33
murky/=lib/murky/src/
4-
openzeppelin/=lib/openzeppelin-contracts/contracts/
4+
openzeppelin/=lib/openzeppelin-contracts/contracts/
5+
era-contracts=lib/era-contracts/

script/Deploy.s.sol

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import {console2} from "forge-std/console2.sol";
66
import {DelegateRegistry} from "../src/DelegateRegistry.sol";
77
import {Singlesig} from "../src/singlesig/Singlesig.sol";
88

9+
import {Create2Factory} from "era-contracts/system-contracts/contracts/Create2Factory.sol";
10+
import {ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT} from "era-contracts/system-contracts/contracts/Constants.sol";
11+
912
interface ImmutableCreate2Factory {
1013
function safeCreate2(bytes32 salt, bytes calldata initCode) external payable returns (address deploymentAddress);
1114
function findCreate2Address(bytes32 salt, bytes calldata initCode) external view returns (address deploymentAddress);
@@ -23,13 +26,14 @@ interface ZksyncCreate2Factory {
2326
}
2427

2528
contract Deploy is Script {
26-
ZksyncCreate2Factory immutable zksyncCreateFactory = ZksyncCreate2Factory(0x0000000000000000000000000000000000010000);
29+
// ZksyncCreate2Factory immutable zksyncCreateFactory = ZksyncCreate2Factory(0x0000000000000000000000000000000000010000);
30+
Create2Factory immutable zksyncCreateFactory = Create2Factory(0x0000000000000000000000000000000000010000);
2731
ZksyncCreate2Factory immutable zksyncContractDeployer = ZksyncCreate2Factory(0x0000000000000000000000000000000000008006);
2832

2933
ImmutableCreate2Factory immutable factory = ImmutableCreate2Factory(0x0000000000FFe8B47B3e2130213B802212439497);
3034
bytes initCode = type(DelegateRegistry).creationCode;
3135
// bytes32 singlesigSalt = 0x0000000000000000000000000000000000000000fbe49ecfc3decb1164228b89;
32-
bytes32 registrySalt = 0x10000000000000000000000000000000000000002bbc593dd77cb93fbb932d5f;
36+
bytes32 registrySalt = 0x00000000000000000000000000000000000000002bbc593dd77cb93fbb932d5f;
3337

3438
// bytes initCode = abi.encodePacked(type(Singlesig).creationCode, abi.encode(address(0x6Ed7D526b020780f694f3c10Dfb25E1b134D3215)));
3539
// bytes32 salt = 0x000000000000000000000000000000000000000016c7768a8c7a2824b846321d;
@@ -45,15 +49,23 @@ contract Deploy is Script {
4549
// bytes32[] memory hashes = existing.getOutgoingDelegationHashes(0x86362a4C99d900D72d787Ef1BddA38Fd318aa5E9);
4650
// console2.logBytes32(hashes[0]);
4751

52+
DelegateRegistry saltDeploy = new DelegateRegistry{salt: registrySalt}();
53+
console2.log(address(saltDeploy));
54+
4855
DelegateRegistry predeploy = new DelegateRegistry();
56+
57+
bytes32 bytecodeHash = keccak256(initCode);
58+
bytes32 zkBytecodeHash = ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getRawCodeHash(address(predeploy));
59+
60+
console2.logBytes32(bytecodeHash);
61+
console2.logBytes32(zkBytecodeHash);
4962
console2.log(address(predeploy));
5063
console2.log(msg.sender);
51-
console2.logBytes32(keccak256(initCode));
5264
console2.logBytes32(registrySalt);
53-
address registryAddress = zksyncContractDeployer.getNewAddressCreate2(address(zksyncCreateFactory), keccak256(initCode), registrySalt, "");
65+
address registryAddress = zksyncContractDeployer.getNewAddressCreate2(address(zksyncCreateFactory), zkBytecodeHash, registrySalt, "");
5466
console2.log(registryAddress);
55-
bytes memory constructorInput = "";
56-
zksyncCreateFactory.create2(registrySalt, keccak256(initCode), constructorInput);
67+
68+
// zksyncCreateFactory.create2(registrySalt, zkBytecodeHash, "");
5769

5870
// address registryAddress = factory.safeCreate2(registrySalt, initCode);
5971
// DelegateRegistry registry = DelegateRegistry(registryAddress);

0 commit comments

Comments
 (0)