diff --git a/packages/contracts/script/DeployRecoveryController.s.sol b/packages/contracts/script/DeployRecoveryController.s.sol index 83ee22c2..3e1cb19b 100644 --- a/packages/contracts/script/DeployRecoveryController.s.sol +++ b/packages/contracts/script/DeployRecoveryController.s.sol @@ -8,6 +8,7 @@ import "../test/helpers/SimpleWallet.sol"; import "../test/helpers/RecoveryController.sol"; import "../src/utils/Verifier.sol"; import "../src/utils/Groth16Verifier.sol"; +import "../src/utils/ECDSAOwnedDKIMRegistry.sol"; import "../src/EmailAuth.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {UserOverrideableDKIMRegistry} from "@zk-email/contracts/UserOverrideableDKIMRegistry.sol"; @@ -36,7 +37,7 @@ contract Deploy is Script { vm.startBroadcast(deployerPrivateKey); address initialOwner = vm.addr(deployerPrivateKey); - // Deploy Useroverridable and Forward DKIM registries + // Deploy Useroverrideable DKIM registry dkim = UserOverrideableDKIMRegistry(vm.envOr("DKIM", address(0))); uint setTimeDelay = vm.envOr("DKIM_DELAY", uint(0)); console.log("DKIM_DELAY: %s", setTimeDelay); @@ -58,7 +59,31 @@ contract Deploy is Script { "UseroverrideableDKIMRegistry proxy deployed at: %s", address(dkim) ); + vm.setEnv("DKIM", vm.toString(address(dkim))); } + + // Deploy ECDSAOwned DKIM registry + ECDSAOwnedDKIMRegistry ecdsaDkim = ECDSAOwnedDKIMRegistry( + vm.envOr("ECDSA_DKIM", address(0)) + ); + if (address(ecdsaDkim) == address(0)) { + ECDSAOwnedDKIMRegistry ecdsaDkimImpl = new ECDSAOwnedDKIMRegistry(); + console.log( + "ECDSAOwnedDKIMRegistry implementation deployed at: %s", + address(ecdsaDkimImpl) + ); + ERC1967Proxy ecdsaDkimProxy = new ERC1967Proxy( + address(ecdsaDkimImpl), + abi.encodeCall(ecdsaDkimImpl.initialize, (initialOwner, signer)) + ); + ecdsaDkim = ECDSAOwnedDKIMRegistry(address(ecdsaDkimProxy)); + console.log( + "ECDSAOwnedDKIMRegistry deployed at: %s", + address(ecdsaDkim) + ); + vm.setEnv("ECDSA_DKIM", vm.toString(address(ecdsaDkim))); + } + // Deploy Verifier verifier = Verifier(vm.envOr("VERIFIER", address(0))); if (address(verifier) == address(0)) { @@ -77,7 +102,7 @@ contract Deploy is Script { ); verifier = Verifier(address(verifierProxy)); console.log("Verifier deployed at: %s", address(verifier)); - // vm.setEnv("VERIFIER", vm.toString(address(verifier))); + vm.setEnv("VERIFIER", vm.toString(address(verifier))); } // Deploy EmailAuth Implementation @@ -88,7 +113,7 @@ contract Deploy is Script { "EmailAuth implementation deployed at: %s", address(emailAuthImpl) ); - // vm.setEnv("EMAIL_AUTH_IMPL", vm.toString(address(emailAuthImpl))); + vm.setEnv("EMAIL_AUTH_IMPL", vm.toString(address(emailAuthImpl))); } // Create RecoveryController as EmailAccountRecovery implementation @@ -113,10 +138,10 @@ contract Deploy is Script { "RecoveryController deployed at: %s", address(recoveryController) ); - // vm.setEnv( - // "RECOVERY_CONTROLLER", - // vm.toString(address(recoveryController)) - // ); + vm.setEnv( + "RECOVERY_CONTROLLER", + vm.toString(address(recoveryController)) + ); } // Deploy SimpleWallet Implementation @@ -139,7 +164,7 @@ contract Deploy is Script { ); simpleWallet = SimpleWallet(payable(address(simpleWalletProxy))); console.log("SimpleWallet deployed at: %s", address(simpleWallet)); - // vm.setEnv("SIMPLE_WALLET", vm.toString(address(simpleWallet))); + vm.setEnv("SIMPLE_WALLET", vm.toString(address(simpleWallet))); } vm.stopBroadcast(); } diff --git a/packages/contracts/script/DeployRecoveryControllerZKSync.s.sol b/packages/contracts/script/DeployRecoveryControllerZKSync.s.sol index a745aa08..7bddc8ae 100644 --- a/packages/contracts/script/DeployRecoveryControllerZKSync.s.sol +++ b/packages/contracts/script/DeployRecoveryControllerZKSync.s.sol @@ -43,7 +43,7 @@ contract Deploy is Script { vm.startBroadcast(deployerPrivateKey); address initialOwner = vm.addr(deployerPrivateKey); - // Deploy Useroverridable and Forward DKIM registries + // Deploy Useroverrideable registry dkim = UserOverrideableDKIMRegistry(vm.envOr("DKIM", address(0))); uint setTimeDelay = vm.envOr("DKIM_DELAY", uint(0)); if (address(dkim) == address(0)) { diff --git a/packages/contracts/test/script/UpgradesScript.t.sol b/packages/contracts/test/script/UpgradesScript.t.sol deleted file mode 100644 index f96152fc..00000000 --- a/packages/contracts/test/script/UpgradesScript.t.sol +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.12; - -import "forge-std/Test.sol"; -import "forge-std/console.sol"; - -import {Deploy} from "../../script/DeployRecoveryController.s.sol"; -import {Upgrades} from "../../script/Upgrades.s.sol"; -import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; -import {StructHelper} from "../helpers/StructHelper.sol"; - -contract UpgradesScriptTest is StructHelper { - uint256 internal constant IMPLEMENTATION_SLOT = - 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; - - function setUp() public override { - vm.setEnv( - "PRIVATE_KEY", - "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" - ); - vm.setEnv("SIGNER", "0x69bec2dd161d6bbcc91ec32aa44d9333ebc864c0"); - } - - function test_run() public { - skipIfZkSync(); - - Deploy deploy = new Deploy(); - deploy.run(); - // vm.setEnv("SOURCE_DKIM", vm.toString(vm.envAddress("ECDSA_DKIM"))); - // Deploy2 deploy2 = new Deploy2(); - // deploy2.run(); - address verifier = vm.envAddress("VERIFIER"); - address ecdsaDkimAddr = vm.envAddress("ECDSA_DKIM"); - address dkim = vm.envAddress("DKIM"); - address verifierImpl = _readAddressFromSlot( - verifier, - IMPLEMENTATION_SLOT - ); - address ecdsaDkimImpl = _readAddressFromSlot( - ecdsaDkimAddr, - IMPLEMENTATION_SLOT - ); - address dkimImpl = _readAddressFromSlot(dkim, IMPLEMENTATION_SLOT); - Upgrades upgrades = new Upgrades(); - upgrades.run(); - assertNotEq( - verifierImpl, - _readAddressFromSlot(verifier, IMPLEMENTATION_SLOT) - ); - assertNotEq( - ecdsaDkimImpl, - _readAddressFromSlot(ecdsaDkimAddr, IMPLEMENTATION_SLOT) - ); - assertNotEq(dkimImpl, _readAddressFromSlot(dkim, IMPLEMENTATION_SLOT)); - } - - function _readAddressFromSlot( - address contractAddress, - uint256 slot - ) private view returns (address) { - address value; - assembly { - // Create a pointer to the slot - let ptr := mload(0x40) - mstore(ptr, slot) - // Read the value from the slot - value := sload(add(ptr, contractAddress)) - } - return value; - } -}