Skip to content

Commit

Permalink
manually match salt syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfoobar committed Jan 16, 2025
1 parent 2049782 commit 4089d76
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -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/
openzeppelin/=lib/openzeppelin-contracts/contracts/
era-contracts=lib/era-contracts/
24 changes: 18 additions & 6 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 4089d76

Please sign in to comment.