From 8d6c287312b95de75fea5437c1a40dbe86b0594d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keszey=20D=C3=A1niel?= Date: Mon, 15 Jul 2024 10:31:39 +0200 Subject: [PATCH] fix deployment issues caused by taiko-mon updates --- .../contracts/L1/VerifierRegistry.sol | 4 +- .../L1/verifiers/MockSgxVerifier.sol | 4 +- .../protocol/scripts/DeployL1Locally.s.sol | 42 ++++++++----------- packages/protocol/test/L1/TaikoL1TestBase.sol | 22 +++++----- 4 files changed, 33 insertions(+), 39 deletions(-) diff --git a/packages/protocol/contracts/L1/VerifierRegistry.sol b/packages/protocol/contracts/L1/VerifierRegistry.sol index 318950bc5af5..c50145e98419 100644 --- a/packages/protocol/contracts/L1/VerifierRegistry.sol +++ b/packages/protocol/contracts/L1/VerifierRegistry.sol @@ -24,8 +24,8 @@ contract VerifierRegistry is EssentialContract { uint16 public verifierIdGenerator; - function init(address _addressManager) external initializer { - __Essential_init(_addressManager); + function init(address _owner, address _addressManager) external initializer { + __Essential_init(_owner, _addressManager); verifierIdGenerator = 1; } diff --git a/packages/protocol/contracts/L1/verifiers/MockSgxVerifier.sol b/packages/protocol/contracts/L1/verifiers/MockSgxVerifier.sol index 9b4e145253b5..381835dbdb6e 100644 --- a/packages/protocol/contracts/L1/verifiers/MockSgxVerifier.sol +++ b/packages/protocol/contracts/L1/verifiers/MockSgxVerifier.sol @@ -9,14 +9,14 @@ import "../../automata-attestation/lib/QuoteV3Auth/V3Struct.sol"; import "./libs/LibPublicInput.sol"; import "./IVerifier.sol"; -/// @title SgxVerifier +/// @title MockSgxVerifier /// @notice This contract is the implementation of verifying SGX signature proofs /// onchain. /// @dev Please see references below: /// - Reference #1: https://ethresear.ch/t/2fa-zk-rollups-using-sgx/14462 /// - Reference #2: https://github.com/gramineproject/gramine/discussions/1579 /// @custom:security-contact security@taiko.xyz -contract SgxVerifier is EssentialContract, IVerifier { +contract MockSgxVerifier is EssentialContract, IVerifier { /// @dev Each public-private key pair (Ethereum address) is generated within /// the SGX program when it boots up. The off-chain remote attestation /// ensures the validity of the program hash and has the capability of diff --git a/packages/protocol/scripts/DeployL1Locally.s.sol b/packages/protocol/scripts/DeployL1Locally.s.sol index fe8bbbdb78af..96b2a2ca2829 100644 --- a/packages/protocol/scripts/DeployL1Locally.s.sol +++ b/packages/protocol/scripts/DeployL1Locally.s.sol @@ -6,7 +6,7 @@ import "@openzeppelin/contracts/utils/Strings.sol"; import "../contracts/L1/TaikoL1.sol"; import "../contracts/L1/BasedOperator.sol"; import "../contracts/L1/VerifierRegistry.sol"; -import "../contracts/L1/TaikoToken.sol"; +import "../contracts/tko/TaikoToken.sol"; import "../contracts/L1/provers/GuardianProver.sol"; // import "../contracts/L1/tiers/DevnetTierProvider.sol"; // import "../contracts/L1/tiers/TierProviderV2.sol"; @@ -21,7 +21,7 @@ import "../contracts/L1/provers/GuardianProver.sol"; // import "../contracts/automata-attestation/AutomataDcapV3Attestation.sol"; // import "../contracts/automata-attestation/utils/SigVerifyLib.sol"; // import "../contracts/automata-attestation/lib/PEMCertChainLib.sol"; -import "../contracts/L1/verifiers/SgxVerifier.sol"; +//import "../contracts/L1/verifiers/SgxVerifier.sol"; import "../contracts/L1/verifiers/MockSgxVerifier.sol"; // Avoid proof verification for now! // import "../contracts/team/proving/ProverSet.sol"; // import "../test/common/erc20/FreeMintERC20.sol"; @@ -141,7 +141,7 @@ contract DeployL1OnAnvil is DeployCapability { sharedAddressManager = deployProxy({ name: "shared_address_manager", impl: address(new AddressManager()), - data: abi.encodeCall(AddressManager.init, ()) + data: abi.encodeCall(AddressManager.init, (owner)) }); } @@ -151,9 +151,8 @@ contract DeployL1OnAnvil is DeployCapability { taikoToken = deployProxy({ name: "taiko_token", impl: address(new TaikoToken()), - data: abi.encodeCall(TaikoToken.init, ("TAIKO", "TAIKO", MAINNET_CONTRACT_OWNER)), - registerTo: sharedAddressManager, - owner: MAINNET_CONTRACT_OWNER + data: abi.encodeCall(TaikoToken.init, (MAINNET_CONTRACT_OWNER, MAINNET_CONTRACT_OWNER)), + registerTo: sharedAddressManager }); } @@ -243,7 +242,7 @@ contract DeployL1OnAnvil is DeployCapability { rollupAddressManager = deployProxy({ name: "rollup_address_manager", impl: address(new AddressManager()), - data: abi.encodeCall(AddressManager.init, ()) + data: abi.encodeCall(AddressManager.init, (owner)) }); // --------------------------------------------------------------- @@ -259,53 +258,48 @@ contract DeployL1OnAnvil is DeployCapability { data: abi.encodeCall( TaikoL1.init, ( + owner, rollupAddressManager, vm.envBytes32("L2_GENESIS_HASH") ) ), - registerTo: rollupAddressManager, - owner: MAINNET_CONTRACT_OWNER + registerTo: rollupAddressManager }); /* Deploy BasedOperator */ deployProxy({ name: "operator", impl: address(new BasedOperator()), - data: abi.encodeCall(BasedOperator.init, (address(rollupAddressManager))), - registerTo: rollupAddressManager, - owner: MAINNET_CONTRACT_OWNER + data: abi.encodeCall(BasedOperator.init, (MAINNET_CONTRACT_OWNER, rollupAddressManager)), + registerTo: rollupAddressManager }); /* Deploy MockSGXVerifier 3 times for now, so that we can call verifyProof without modifications of the protocol code. Later obv. shall be replaced with real verifiers. */ address verifier1 = deployProxy({ name: "tier_sgx1", impl: address(new MockSgxVerifier()), - data: abi.encodeCall(MockSgxVerifier.init, (rollupAddressManager)), - registerTo: rollupAddressManager, - owner: MAINNET_CONTRACT_OWNER + data: abi.encodeCall(MockSgxVerifier.init, (MAINNET_CONTRACT_OWNER, rollupAddressManager)), + registerTo: rollupAddressManager }); address verifier2 = deployProxy({ name: "tier_sgx2", impl: address(new MockSgxVerifier()), - data: abi.encodeCall(MockSgxVerifier.init, (rollupAddressManager)), - registerTo: rollupAddressManager, - owner: MAINNET_CONTRACT_OWNER + data: abi.encodeCall(MockSgxVerifier.init, (MAINNET_CONTRACT_OWNER, rollupAddressManager)), + registerTo: rollupAddressManager }); address verifier3 = deployProxy({ name: "tier_sgx3", impl: address(new MockSgxVerifier()), - data: abi.encodeCall(MockSgxVerifier.init, (rollupAddressManager)), - registerTo: rollupAddressManager, - owner: MAINNET_CONTRACT_OWNER + data: abi.encodeCall(MockSgxVerifier.init, (MAINNET_CONTRACT_OWNER, rollupAddressManager)), + registerTo: rollupAddressManager }); /* Deploy VerifierRegistry */ address vieriferRegistry = deployProxy({ name: "verifier_registry", impl: address(new VerifierRegistry()), - data: abi.encodeCall(VerifierRegistry.init, (rollupAddressManager)), - registerTo: rollupAddressManager, - owner: MAINNET_CONTRACT_OWNER + data: abi.encodeCall(VerifierRegistry.init, (MAINNET_CONTRACT_OWNER, rollupAddressManager)), + registerTo: rollupAddressManager }); // Add those 3 to verifier registry diff --git a/packages/protocol/test/L1/TaikoL1TestBase.sol b/packages/protocol/test/L1/TaikoL1TestBase.sol index f928ffc7d86a..af0b7777b087 100644 --- a/packages/protocol/test/L1/TaikoL1TestBase.sol +++ b/packages/protocol/test/L1/TaikoL1TestBase.sol @@ -23,9 +23,9 @@ abstract contract TaikoL1TestBase is TaikoTest { uint256 internal logCount; // PseZkVerifier public pv; /* 3 proof verifiers - to fulfill the requirement in BasedOperator.sol */ - SgxVerifier public sv1; - SgxVerifier public sv2; - SgxVerifier public sv3; + MockSgxVerifier public sv1; + MockSgxVerifier public sv2; + MockSgxVerifier public sv3; VerifierRegistry public vr; // SgxAndZkVerifier public sgxZkVerifier; // GuardianVerifier public gv; @@ -69,7 +69,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "verifier_registry", impl: address(new VerifierRegistry()), - data: abi.encodeCall(VerifierRegistry.init, (address(addressManager))) + data: abi.encodeCall(VerifierRegistry.init, (Alice, address(addressManager))) }) ); @@ -94,36 +94,36 @@ abstract contract TaikoL1TestBase is TaikoTest { // }) // ); - address sgxImpl = address(new SgxVerifier()); + address sgxImpl = address(new MockSgxVerifier()); //Naming is like: 3, 1, 2, is because we need to have incremental order of addresses in // BasedOperator, so figured out this is actually the way - sv1 = SgxVerifier( + sv1 = MockSgxVerifier( deployProxy({ name: "sgx2", //Name does not matter now, since we check validity via // verifierRegistry impl: sgxImpl, - data: abi.encodeCall(SgxVerifier.init, (Alice, address(addressManager))) + data: abi.encodeCall(MockSgxVerifier.init, (Alice, address(addressManager))) }) ); console2.log(address(sv1)); - sv2 = SgxVerifier( + sv2 = MockSgxVerifier( deployProxy({ name: "sgx3", //Name does not matter now, since we check validity via // verifierRegistry impl: sgxImpl, - data: abi.encodeCall(SgxVerifier.init, (Alice, address(addressManager))) + data: abi.encodeCall(MockSgxVerifier.init, (Alice, address(addressManager))) }) ); - sv3 = SgxVerifier( + sv3 = MockSgxVerifier( deployProxy({ name: "sgx1", //Name does not matter now, since we check validity via // verifierRegistry impl: sgxImpl, - data: abi.encodeCall(SgxVerifier.init, (Alice, address(addressManager))) + data: abi.encodeCall(MockSgxVerifier.init, (Alice, address(addressManager))) }) );