Skip to content

Commit

Permalink
E2E deployment to 0x0000000059A24EB229eED07Ac44229DB56C5d797
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfoobar committed Jan 16, 2025
1 parent c4ad335 commit c90f811
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ simulate-deploy:
forge script -vvv script/Deploy.s.sol --sig "run()" --rpc-url ${RPC_URL} --private-key ${PK} --broadcast --verify --delay 30 --etherscan-api-key ${ETHERSCAN_API_KEY}

verify:
forge verify-contract 0x00000000000000447e69651d841bD8D104Bed493 src/DelegateRegistry.sol:DelegateRegistry --chain 81457 --etherscan-api-key ${ETHERSCAN_API_KEY} --retries 5 --delay 30 --watch
forge verify-contract 0x0000000059A24EB229eED07Ac44229DB56C5d797 src/DelegateRegistry.sol:DelegateRegistry --chain 11124 --etherscan-api-key ${ETHERSCAN_API_KEY} --retries 5 --delay 30 --watch --zksync
# forge verify-contract 0x0000000059A24EB229eED07Ac44229DB56C5d797 src/DelegateRegistry.sol:DelegateRegistry --retries 5 --delay 30 --watch --zksync --verifier-url https://api-sepolia.abscan.org/api --etherscan-api-key IEYKU3EEM5XCD76N7Y7HF9HG7M9ARZ2H4A

cast-deploy-singlesig:
cast send --rpc-url ${RPC_URL} --private-key ${PK} 0x0000000000ffe8b47b3e2130213b802212439497 0x64e03087000000000000000000000000000000000000000016c7768a8c7a2824b846321d00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000bf0608060405234801561001057600080fd5b50604051610bd0380380610bd083398101604081905261002f9161007d565b600080546001600160a01b0319166001600160a01b03831690811782556040519091907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506100ad565b60006020828403121561008f57600080fd5b81516001600160a01b03811681146100a657600080fd5b9392505050565b610b14806100bc6000396000f3fe6080604052600436106100915760003560e01c8063b61d27f611610063578063e30c39781161004b578063e30c397814610214578063f23a6e6114610241578063f2fde38b1461028757005b8063b61d27f6146101ac578063bc197c81146101cc57005b806301ffc9a71461009a578063150b7a02146100cf57806379ba5097146101455780638da5cb5b1461015a57005b3661009857005b005b3480156100a657600080fd5b506100ba6100b5366004610703565b6102a7565b60405190151581526020015b60405180910390f35b3480156100db57600080fd5b506101146100ea3660046107be565b7f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016100c6565b34801561015157600080fd5b5061009861038c565b34801561016657600080fd5b506000546101879073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100c6565b3480156101b857600080fd5b506100ba6101c736600461085c565b6104cb565b3480156101d857600080fd5b506101146101e736600461098a565b7fbc197c810000000000000000000000000000000000000000000000000000000098975050505050505050565b34801561022057600080fd5b506001546101879073ffffffffffffffffffffffffffffffffffffffff1681565b34801561024d57600080fd5b5061011461025c366004610a45565b7ff23a6e61000000000000000000000000000000000000000000000000000000009695505050505050565b34801561029357600080fd5b506100986102a2366004610abd565b6105e6565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316148061033a57507f150b7a02000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b8061038657507f4e2312e0000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60015473ffffffffffffffffffffffffffffffffffffffff163314610438576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e6572000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6001546000805460405173ffffffffffffffffffffffffffffffffffffffff93841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600154600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909216919091179055565b6000805473ffffffffffffffffffffffffffffffffffffffff163314610573576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6f776e6572000000000000000000000000000000000000000000000000000000606482015260840161042f565b8373ffffffffffffffffffffffffffffffffffffffff1683836040516105999190610ad8565b60006040518083038185875af1925050503d80600081146105d6576040519150601f19603f3d011682016040523d82523d6000602084013e6105db565b606091505b509095945050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461068d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6f776e6572000000000000000000000000000000000000000000000000000000606482015260840161042f565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83811691821790925560008054604051929316917f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227009190a350565b60006020828403121561071557600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461074557600080fd5b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461077057600080fd5b919050565b60008083601f84011261078757600080fd5b50813567ffffffffffffffff81111561079f57600080fd5b6020830191508360208285010111156107b757600080fd5b9250929050565b6000806000806000608086880312156107d657600080fd5b6107df8661074c565b94506107ed6020870161074c565b935060408601359250606086013567ffffffffffffffff81111561081057600080fd5b61081c88828901610775565b969995985093965092949392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060006060848603121561087157600080fd5b61087a8461074c565b925060208401359150604084013567ffffffffffffffff8082111561089e57600080fd5b818601915086601f8301126108b257600080fd5b8135818111156108c4576108c461082d565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561090a5761090a61082d565b8160405282815289602084870101111561092357600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60008083601f84011261095757600080fd5b50813567ffffffffffffffff81111561096f57600080fd5b6020830191508360208260051b85010111156107b757600080fd5b60008060008060008060008060a0898b0312156109a657600080fd5b6109af8961074c565b97506109bd60208a0161074c565b9650604089013567ffffffffffffffff808211156109da57600080fd5b6109e68c838d01610945565b909850965060608b01359150808211156109ff57600080fd5b610a0b8c838d01610945565b909650945060808b0135915080821115610a2457600080fd5b50610a318b828c01610775565b999c989b5096995094979396929594505050565b60008060008060008060a08789031215610a5e57600080fd5b610a678761074c565b9550610a756020880161074c565b94506040870135935060608701359250608087013567ffffffffffffffff811115610a9f57600080fd5b610aab89828a01610775565b979a9699509497509295939492505050565b600060208284031215610acf57600080fd5b6107458261074c565b6000825160005b81811015610af95760208186018101518583015201610adf565b50600092019182525091905056fea164736f6c6343000815000a0000000000000000000000006ed7d526b020780f694f3c10dfb25e1b134d321500000000000000000000000000000000
Expand Down
57 changes: 26 additions & 31 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ interface ZksyncCreate2Factory {
contract Deploy is Script {
address immutable firstOwner = 0x6Ed7D526b020780f694f3c10Dfb25E1b134D3215;

// ZksyncCreate2Factory immutable zksyncCreateFactory = ZksyncCreate2Factory(0x0000000000000000000000000000000000010000);
Create2Factory immutable zksyncCreateFactory = Create2Factory(0x0000000000000000000000000000000000010000);
ZksyncCreate2Factory immutable zksyncContractDeployer = ZksyncCreate2Factory(0x0000000000000000000000000000000000008006);

Expand All @@ -38,55 +37,51 @@ contract Deploy is Script {
// bytes32 registrySalt = 0x00000000000000000000000000000000000000002bbc593dd77cb93fbb932d5f;

bytes32 zkSinglesigSalt = 0x000000000000000000000000000000000000000091430a7ea982667861000090;
// bytes32 registrySalt = bytes32(0);
bytes32 registrySalt = 0x0000000000000000000000000000000000000000dc73d3e78582b023010000a0;
bytes32 zkRegistrySalt = 0x000000000000000000000000000000000000000077151a04325c7971a80c00a0;

// bytes initCode = abi.encodePacked(type(Singlesig).creationCode, abi.encode(address(0x6Ed7D526b020780f694f3c10Dfb25E1b134D3215)));
// bytes32 salt = 0x000000000000000000000000000000000000000016c7768a8c7a2824b846321d;

function run() external {
vm.startBroadcast();

Singlesig predeploySinglesig = new Singlesig{salt: zkSinglesigSalt}(firstOwner);
bytes32 singlesigZKBytecodeHash = ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getRawCodeHash(address(predeploySinglesig));
bytes32 constructorHash = keccak256(abi.encode(firstOwner));
console2.log(address(predeploySinglesig));
console2.logBytes(abi.encode(firstOwner));
console2.logBytes32(singlesigZKBytecodeHash);
console2.logBytes32(constructorHash);
bytes memory preimage = bytes.concat(CREATE2_PREFIX, bytes32(uint256(uint160(address(zksyncCreateFactory)))), zkSinglesigSalt, singlesigZKBytecodeHash, constructorHash);
console2.logBytes(preimage);
// Singlesig predeploySinglesig = new Singlesig{salt: zkSinglesigSalt}(firstOwner);
// bytes32 singlesigZKBytecodeHash = ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getRawCodeHash(address(predeploySinglesig));
// bytes32 constructorHash = keccak256(abi.encode(firstOwner));
// console2.log(address(predeploySinglesig));
// console2.logBytes(abi.encode(firstOwner));
// console2.logBytes32(singlesigZKBytecodeHash);
// console2.logBytes32(constructorHash);
// bytes memory preimage = bytes.concat(CREATE2_PREFIX, bytes32(uint256(uint160(address(zksyncCreateFactory)))), zkSinglesigSalt, singlesigZKBytecodeHash, constructorHash);
// console2.logBytes(preimage);

// address singlesigAddress = factory.safeCreate2(singlesigSalt, initCode);
// Singlesig singlesig = Singlesig(payable(singlesigAddress));
// console2.log(address(singlesig));
// --------

// DelegateRegistry existing = DelegateRegistry(0x6b176c958fb89Ddca0fc8214150DA4c4D0a32fbe);
// bytes32[] memory hashes = existing.getOutgoingDelegationHashes(0x86362a4C99d900D72d787Ef1BddA38Fd318aa5E9);
// console2.logBytes32(hashes[0]);

// DelegateRegistry saltDeploy = new DelegateRegistry{salt: registrySalt}();
// console2.logBytes32(keccak256(""));
// console2.log(address(saltDeploy));
DelegateRegistry saltDeploy = new DelegateRegistry{salt: zkRegistrySalt}();
console2.logBytes32(keccak256(""));
console2.log(address(saltDeploy));

// DelegateRegistry predeploy = new DelegateRegistry();

// bytes32 bytecodeHash = keccak256(initCode);
// bytes32 zkBytecodeHash = ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getRawCodeHash(address(predeploy));
bytes32 zkBytecodeHash = ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getRawCodeHash(address(saltDeploy));

// console2.logBytes32(bytecodeHash);
// console2.logBytes32(zkBytecodeHash);
// console2.log(address(predeploy));
// console2.log(msg.sender);
// console2.logBytes32(registrySalt);
// bytes memory preimage = bytes.concat(CREATE2_PREFIX, bytes32(uint256(uint160(address(zksyncCreateFactory)))), registrySalt, zkBytecodeHash, keccak256(""));
// console2.logBytes(preimage);
// address localRegistryAddress = address(uint160(uint256(keccak256(
// bytes.concat(CREATE2_PREFIX, bytes32(uint256(uint160(address(zksyncCreateFactory)))), registrySalt, zkBytecodeHash, keccak256(""))
// ))));
// console2.log(localRegistryAddress);
// address registryAddress = zksyncContractDeployer.getNewAddressCreate2(address(zksyncCreateFactory), zkBytecodeHash, registrySalt, "");
// console2.log(registryAddress);
console2.logBytes32(zkBytecodeHash);
console2.log(msg.sender);
console2.logBytes32(zkRegistrySalt);
bytes memory preimage = bytes.concat(CREATE2_PREFIX, bytes32(uint256(uint160(address(zksyncCreateFactory)))), zkRegistrySalt, zkBytecodeHash, keccak256(""));
console2.logBytes(preimage);
address localRegistryAddress = address(uint160(uint256(keccak256(
bytes.concat(CREATE2_PREFIX, bytes32(uint256(uint160(address(zksyncCreateFactory)))), zkRegistrySalt, zkBytecodeHash, keccak256(""))
))));
console2.log(localRegistryAddress);
address registryAddress = zksyncContractDeployer.getNewAddressCreate2(address(zksyncCreateFactory), zkBytecodeHash, zkRegistrySalt, "");
console2.log(registryAddress);

// zksyncCreateFactory.create2(registrySalt, zkBytecodeHash, "");

Expand Down
2 changes: 1 addition & 1 deletion src/DelegateRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ contract DelegateRegistry is IDelegateRegistry {
function sweep() external {
assembly ("memory-safe") {
// This hardcoded address is a CREATE2 factory counterfactual smart contract wallet that will always accept native token transfers
let result := call(gas(), 0x000000dE1E80ea5a234FB5488fee2584251BC7e8, selfbalance(), 0, 0, 0, 0)
let result := call(gas(), 0x000000aA2a733BB7bB003b0339859907d5D87320, selfbalance(), 0, 0, 0, 0)
}
}

Expand Down

0 comments on commit c90f811

Please sign in to comment.