From 8f37f9f0d0f7b8fce179935346615e4dd7a1e955 Mon Sep 17 00:00:00 2001 From: Alexander Filippov Date: Thu, 4 Jul 2024 12:10:40 +0300 Subject: [PATCH] Update scripts --- .../DeployAllowListOperatorManager.s.sol | 34 ++++++-- script/scripts/MigrateDecentralization.s.sol | 77 ++++--------------- script/scripts/NewZkBobPoolUSDCImpl.s.sol | 32 ++++++++ 3 files changed, 73 insertions(+), 70 deletions(-) create mode 100644 script/scripts/NewZkBobPoolUSDCImpl.s.sol diff --git a/script/scripts/DeployAllowListOperatorManager.s.sol b/script/scripts/DeployAllowListOperatorManager.s.sol index 80a1f3e..9817058 100644 --- a/script/scripts/DeployAllowListOperatorManager.s.sol +++ b/script/scripts/DeployAllowListOperatorManager.s.sol @@ -3,26 +3,46 @@ pragma solidity 0.8.15; import "forge-std/Script.sol"; -import "./Env.s.sol"; import {AllowListOperatorManager} from "../../src/zkbob/manager/AllowListOperatorManager.sol"; +// TODO: Update this values before the deployment +address constant operatorManagerOwner = 0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290; +address constant zkBobProxy1 = 0x7D2D146a7AD3F0Dc398AA718a9bFCa2Bc873a5FD; +address constant zkBobProxyFeeReceiver1 = 0x7D2D146a7AD3F0Dc398AA718a9bFCa2Bc873a5FD; +address constant zkBobProxy2 = 0xFec49782FE8e11De9Fb3Ba645a76FE914FFfe3cb; +address constant zkBobProxyFeeReceiver2 = 0xFec49782FE8e11De9Fb3Ba645a76FE914FFfe3cb; +address constant zkBobProver1 = 0x33a0b018340d6424870cfC686a4d02e1df792254; +address constant zkBobProverFeeReceiver1 = 0x33a0b018340d6424870cfC686a4d02e1df792254; +address constant zkBobProver2 = 0x63A88E69fa7adEf036fc6ED94394CC9295de2f99; +address constant zkBobProverFeeReceiver2 = 0x63A88E69fa7adEf036fc6ED94394CC9295de2f99; + +bool constant allowListEnabled = true; + contract DeployAllowListOperatorManager is Script { function run() external { vm.startBroadcast(); - address[] memory operators = new address[](2); - operators[0] = zkBobProxy; - operators[1] = zkBobProver; + address[] memory operators = new address[](4); + operators[0] = zkBobProxy1; + operators[1] = zkBobProver1; + operators[2] = zkBobProxy2; + operators[3] = zkBobProver2; - address[] memory feeReceivers = new address[](2); - feeReceivers[0] = zkBobProxyFeeReceiver; - feeReceivers[1] = zkBobProverFeeReceiver; + address[] memory feeReceivers = new address[](4); + feeReceivers[0] = zkBobProxyFeeReceiver1; + feeReceivers[1] = zkBobProverFeeReceiver1; + feeReceivers[2] = zkBobProxyFeeReceiver2; + feeReceivers[3] = zkBobProverFeeReceiver2; AllowListOperatorManager operatorManager = new AllowListOperatorManager(operators, feeReceivers, allowListEnabled); + operatorManager.transferOwnership(operatorManagerOwner); + vm.stopBroadcast(); + assert(address(operatorManager.owner()) == operatorManagerOwner); + console2.log("AllowListOperatorManager address:", address(operatorManager)); } } diff --git a/script/scripts/MigrateDecentralization.s.sol b/script/scripts/MigrateDecentralization.s.sol index 5ffe925..e511582 100644 --- a/script/scripts/MigrateDecentralization.s.sol +++ b/script/scripts/MigrateDecentralization.s.sol @@ -9,16 +9,15 @@ import "../../src/proxy/EIP1967Proxy.sol"; import "../../src/zkbob/utils/ZkBobAccounting.sol"; import "../../src/zkbob/manager/AllowListOperatorManager.sol"; +// TODO: update this parameters before running the script +address constant newZkBobPoolImpl = 0x0114Bf30d9f5A7f503D3DFC65534F2B5AC302c85; +address constant newOperatorManager = 0xFd5a6a67D768d5BF1A8c7724387CA8786Bd4DD91; + /** * @dev OP-USDC pool proxy address. */ address constant zkBobPool = 0x1CA8C2B9B20E18e86d5b9a72370fC6c91814c97C; -/** - * @dev This address will become an owner of the new ZkBobAccounting and AllowListOperatorManager contracts. - */ -address constant operatorManagerOwner = 0x14fc6a1a996A2EB889cF86e5c8cD17323bC85290; - /** * @dev This value should be sufficient for dedicated prover to update the tree * but not too big to support liveness. @@ -30,20 +29,6 @@ uint64 constant gracePeriod = 3 minutes; */ uint64 constant minTreeUpdateFee = 0.1 gwei; -/** - * @dev AllowListOperatorManager related parameters. - */ -bool constant allowListEnabled = true; -// TODO: Update this addresses before deployment -address constant zkBobProxy1 = 0x7D2D146a7AD3F0Dc398AA718a9bFCa2Bc873a5FD; -address constant zkBobProxyFeeReceiver1 = 0x7D2D146a7AD3F0Dc398AA718a9bFCa2Bc873a5FD; -address constant zkBobProxy2 = 0xFec49782FE8e11De9Fb3Ba645a76FE914FFfe3cb; -address constant zkBobProxyFeeReceiver2 = 0xFec49782FE8e11De9Fb3Ba645a76FE914FFfe3cb; -address constant zkBobProver1 = 0x33a0b018340d6424870cfC686a4d02e1df792254; -address constant zkBobProverFeeReceiver1 = 0x33a0b018340d6424870cfC686a4d02e1df792254; -address constant zkBobProver2 = 0x63A88E69fa7adEf036fc6ED94394CC9295de2f99; -address constant zkBobProverFeeReceiver2 = 0x63A88E69fa7adEf036fc6ED94394CC9295de2f99; - // Only for checks: address constant relayer = 0xb9CD01c0b417b4e9095f620aE2f849A84a9B1690; @@ -101,54 +86,20 @@ contract MigrateDecentralization is Script, UpgradeTest { vm.startBroadcast(); - // 1. Deploy new ZkBobPoolUSDC implementation - ZkBobPoolUSDC newImpl = new ZkBobPoolUSDC( - pool.pool_id(), - pool.token(), - pool.transfer_verifier(), - pool.tree_verifier(), - pool.batch_deposit_verifier(), - address(pool.direct_deposit_queue()) - ); - - // 2. Upgrade proxy to new implementation - EIP1967Proxy(payable(address(pool))).upgradeTo(address(newImpl)); + // 1. Upgrade proxy to new implementation + EIP1967Proxy(payable(address(pool))).upgradeTo(address(newZkBobPoolImpl)); - migrateDecentralization(address(pool), address(snapshot.tokenSeller)); + // 2. Set grace period + ZkBobPool(pool).setGracePeriod(gracePeriod); + // 3. Set min tree update fee + ZkBobPool(pool).setMinTreeUpdateFee(minTreeUpdateFee); + // 4. Set token seller + ZkBobPoolUSDC(pool).setTokenSeller(snapshot.tokenSeller); + // 5. Set operator manager + ZkBobPool(pool).setOperatorManager(AllowListOperatorManager(newOperatorManager)); vm.stopBroadcast(); postCheck(ZkBobPoolUSDC(address(pool)), snapshot); } - - function migrateDecentralization(address _pool, address _tokenSeller) internal { - // 3. Set grace period - ZkBobPool(_pool).setGracePeriod(gracePeriod); - // 4. Set min tree update fee - ZkBobPool(_pool).setMinTreeUpdateFee(minTreeUpdateFee); - // 5. Set token seller - ZkBobPoolUSDC(_pool).setTokenSeller(_tokenSeller); - - // 6. Deploy AllowListOperatorManager - address[] memory operators = new address[](4); - operators[0] = zkBobProxy1; - operators[1] = zkBobProver1; - operators[2] = zkBobProxy2; - operators[3] = zkBobProver2; - - address[] memory feeReceivers = new address[](4); - feeReceivers[0] = zkBobProxyFeeReceiver1; - feeReceivers[1] = zkBobProverFeeReceiver1; - feeReceivers[2] = zkBobProxyFeeReceiver2; - feeReceivers[3] = zkBobProverFeeReceiver2; - - AllowListOperatorManager operatorManager = - new AllowListOperatorManager(operators, feeReceivers, allowListEnabled); - - // 7. Set operator manager - ZkBobPool(_pool).setOperatorManager(operatorManager); - - // 8. Transfer operator manager ownership to the owner - operatorManager.transferOwnership(operatorManagerOwner); - } } diff --git a/script/scripts/NewZkBobPoolUSDCImpl.s.sol b/script/scripts/NewZkBobPoolUSDCImpl.s.sol new file mode 100644 index 0000000..50ae05e --- /dev/null +++ b/script/scripts/NewZkBobPoolUSDCImpl.s.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: CC0-1.0 + +pragma solidity 0.8.15; + +import "forge-std/Script.sol"; +import "../../src/zkbob/ZkBobPoolUSDC.sol"; + +/** + * @dev OP-USDC pool proxy address. + */ +address constant zkBobPool = 0x1CA8C2B9B20E18e86d5b9a72370fC6c91814c97C; + +contract DeployNewZkBobPoolUSDCImpl is Script { + function run() external { + ZkBobPoolUSDC pool = ZkBobPoolUSDC(payable(zkBobPool)); + + vm.startBroadcast(); + + ZkBobPoolUSDC newImpl = new ZkBobPoolUSDC( + pool.pool_id(), + pool.token(), + pool.transfer_verifier(), + pool.tree_verifier(), + pool.batch_deposit_verifier(), + address(pool.direct_deposit_queue()) + ); + + vm.stopBroadcast(); + + console2.log("ZkBobPoolUSDC implementation:", address(newImpl)); + } +}