From b46269c891158887bf0a7be47c1370decea30ac8 Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Sat, 10 Feb 2024 11:35:25 +0800 Subject: [PATCH] feat(protocol): fix signal service multi-hop proof verification bugs (#15680) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Keszey Dániel Co-authored-by: Brecht Devos --- .../contracts/common/AuthorizableContract.sol | 42 ----- .../contracts/signal/HopRelayRegistry.sol | 101 ++++++++++ .../contracts/signal/IHopRelayRegistry.sol | 35 ++++ .../contracts/signal/SignalService.sol | 85 +++++---- .../protocol/genesis/GenerateGenesis.g.sol | 7 - .../AuthorizeRemoteTaikoProtocols.s.sol | 46 ----- packages/protocol/script/DeployOnL1.s.sol | 4 +- packages/protocol/test/L1/TaikoL1TestBase.sol | 29 ++- packages/protocol/test/L2/TaikoL2.t.sol | 2 +- packages/protocol/test/TaikoTest.sol | 1 + .../AutomataDcapV3AttestationTest.t.sol | 2 +- .../common/AttestationBase.t.sol | 2 +- packages/protocol/test/bridge/Bridge.t.sol | 13 +- .../test/common/AuthorizableContract.t.sol | 70 ------- .../protocol/test/signal/SignalService.t.sol | 178 ++++++++++++++++-- .../test/tokenvault/ERC1155Vault.t.sol | 4 +- .../protocol/test/tokenvault/ERC20Vault.t.sol | 2 +- .../test/tokenvault/ERC721Vault.t.sol | 4 +- .../protocol/test/verifiers/SgxVerifier.t.sol | 2 +- .../utils/generate_genesis/taikoL2.ts | 6 - 20 files changed, 371 insertions(+), 264 deletions(-) delete mode 100644 packages/protocol/contracts/common/AuthorizableContract.sol create mode 100644 packages/protocol/contracts/signal/HopRelayRegistry.sol create mode 100644 packages/protocol/contracts/signal/IHopRelayRegistry.sol delete mode 100644 packages/protocol/script/AuthorizeRemoteTaikoProtocols.s.sol delete mode 100644 packages/protocol/test/common/AuthorizableContract.t.sol diff --git a/packages/protocol/contracts/common/AuthorizableContract.sol b/packages/protocol/contracts/common/AuthorizableContract.sol deleted file mode 100644 index 3ccb0fb4d0..0000000000 --- a/packages/protocol/contracts/common/AuthorizableContract.sol +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: MIT -// _____ _ _ _ _ -// |_ _|_ _(_) |_____ | | __ _| |__ ___ -// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< -// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ -// -// Email: security@taiko.xyz -// Website: https://taiko.xyz -// GitHub: https://github.com/taikoxyz -// Discord: https://discord.gg/taikoxyz -// Twitter: https://twitter.com/taikoxyz -// Blog: https://mirror.xyz/labs.taiko.eth -// Youtube: https://www.youtube.com/@taikoxyz - -pragma solidity 0.8.24; - -import "../common/EssentialContract.sol"; - -/// @title AuthorizableContract -abstract contract AuthorizableContract is EssentialContract { - mapping(address => bytes32 label) public authorizedAddresses; - uint256[49] private __gap; - - event Authorized(address indexed addr, bytes32 oldLabel, bytes32 newLabel); - - error INVALID_ADDRESS(); - error INVALID_LABEL(); - - function authorize(address addr, bytes32 label) external onlyOwner { - if (addr == address(0)) revert INVALID_ADDRESS(); - - bytes32 oldLabel = authorizedAddresses[addr]; - if (oldLabel == label) revert INVALID_LABEL(); - authorizedAddresses[addr] = label; - - emit Authorized(addr, oldLabel, label); - } - - function isAuthorizedAs(address addr, bytes32 label) public view returns (bool) { - return label != 0 && authorizedAddresses[addr] == label; - } -} diff --git a/packages/protocol/contracts/signal/HopRelayRegistry.sol b/packages/protocol/contracts/signal/HopRelayRegistry.sol new file mode 100644 index 0000000000..95f5feaf2f --- /dev/null +++ b/packages/protocol/contracts/signal/HopRelayRegistry.sol @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity 0.8.24; + +import "../common/EssentialContract.sol"; +import "./IHopRelayRegistry.sol"; + +/// @title HopRelayRegistry +contract HopRelayRegistry is EssentialContract, IHopRelayRegistry { + mapping(uint64 => mapping(uint64 => mapping(address => bool))) internal registry; + uint256[49] private __gap; + + event RelayRegistered( + uint64 indexed srcChainId, + uint64 indexed hopChainId, + address indexed hopRelay, + bool registered + ); + + error MHG_INVALID_PARAMS(); + error MHG_INVALID_STATE(); + + function init() external initializer { + __Essential_init(); + } + + /// @dev Register a trusted hop relay. + /// @param srcChainId The source chain ID where state roots correspond to. + /// @param hopChainId The hop relay's local chain ID. + /// @param hopRelay The address of the relay. + function registerRelay( + uint64 srcChainId, + uint64 hopChainId, + address hopRelay + ) + external + onlyOwner + { + _registerRelay(srcChainId, hopChainId, hopRelay, true); + } + + /// @dev Deregister a trusted hop relay. + /// @param srcChainId The source chain ID where state roots correspond to. + /// @param hopChainId The hop relay's local chain ID. + /// @param hopRelay The address of the relay. + function deregisterRelay( + uint64 srcChainId, + uint64 hopChainId, + address hopRelay + ) + external + onlyOwner + { + _registerRelay(srcChainId, hopChainId, hopRelay, false); + } + + /// @inheritdoc IHopRelayRegistry + function isRelayRegistered( + uint64 srcChainId, + uint64 hopChainId, + address hopRelay + ) + public + view + returns (bool) + { + return registry[srcChainId][hopChainId][hopRelay]; + } + + function _registerRelay( + uint64 srcChainId, + uint64 hopChainId, + address hopRelay, + bool registered + ) + private + { + if ( + srcChainId == 0 || hopChainId == 0 || srcChainId == hopChainId || hopRelay == address(0) + ) { + revert MHG_INVALID_PARAMS(); + } + if (registry[srcChainId][hopChainId][hopRelay] == registered) { + revert MHG_INVALID_STATE(); + } + registry[srcChainId][hopChainId][hopRelay] = registered; + emit RelayRegistered(srcChainId, hopChainId, hopRelay, registered); + } +} diff --git a/packages/protocol/contracts/signal/IHopRelayRegistry.sol b/packages/protocol/contracts/signal/IHopRelayRegistry.sol new file mode 100644 index 0000000000..659ffa10eb --- /dev/null +++ b/packages/protocol/contracts/signal/IHopRelayRegistry.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ +// +// Email: security@taiko.xyz +// Website: https://taiko.xyz +// GitHub: https://github.com/taikoxyz +// Discord: https://discord.gg/taikoxyz +// Twitter: https://twitter.com/taikoxyz +// Blog: https://mirror.xyz/labs.taiko.eth +// Youtube: https://www.youtube.com/@taikoxyz + +pragma solidity 0.8.24; + +/// @title IHopRelayRegistry +/// @notice A registry of hop relays for multi-hop bridging. +// A hop relay is a contract that relays a corresponding chain's state roots to its loal signal +// service. +interface IHopRelayRegistry { + /// @dev Returns if a relay is trusted. + /// @param srcChainId The source chain ID where state roots correspond to. + /// @param hopChainId The hop relay's local chain ID. + /// @param hopRelay The address of the relay. + /// @return trusted True if the relay is a trusted one. + function isRelayRegistered( + uint64 srcChainId, + uint64 hopChainId, + address hopRelay + ) + external + view + returns (bool trusted); +} diff --git a/packages/protocol/contracts/signal/SignalService.sol b/packages/protocol/contracts/signal/SignalService.sol index b9dc173ccf..6258fceeb5 100644 --- a/packages/protocol/contracts/signal/SignalService.sol +++ b/packages/protocol/contracts/signal/SignalService.sol @@ -15,10 +15,11 @@ pragma solidity 0.8.24; import "lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol"; -import "../common/AuthorizableContract.sol"; +import "../common/EssentialContract.sol"; import "../common/ICrossChainSync.sol"; import "../thirdparty/optimism/trie/SecureMerkleTrie.sol"; import "../thirdparty/optimism/rlp/RLPReader.sol"; +import "./IHopRelayRegistry.sol"; import "./ISignalService.sol"; /// @title SignalService @@ -31,38 +32,40 @@ import "./ISignalService.sol"; /// Use the respective chain IDs as labels for authorization. /// Note: SignalService should not authorize Bridges or other Bridgable /// applications. -contract SignalService is AuthorizableContract, ISignalService { +contract SignalService is EssentialContract, ISignalService { using SafeCast for uint256; // merkleProof represents ABI-encoded tuple of (key, value, and proof) // returned from the eth_getProof() API. struct Hop { + uint64 chainId; address relay; bytes32 stateRoot; bytes merkleProof; } struct Proof { - address crossChainSync; uint64 height; bytes merkleProof; + // Ensure that hops are ordered such that those closer to the signal's source chain come + // before others. Hop[] hops; } - error SS_INVALID_FUNC_PARAMS(); - error SS_INVALID_PROOF_PARAMS(); - error SS_CROSS_CHAIN_SYNC_UNAUTHORIZED(uint256 chaindId); - error SS_CROSS_CHAIN_SYNC_ZERO_STATE_ROOT(); - error SS_HOP_RELAYER_UNAUTHORIZED(); + uint256[50] private __gap; + + error SS_INVALID_PARAMS(); + error SS_INVALID_PROOF(); error SS_INVALID_APP(); - error SS_INVALID_APP_PROOF(); - error SS_INVALID_HOP_PROOF(); + error SS_INVALID_RELAY(); error SS_INVALID_SIGNAL(); + error SS_INVALID_STATE_ROOT(); + error SS_MULTIHOP_DISABLED(); error SS_UNSUPPORTED(); /// @dev Initializer to be called after being deployed behind a proxy. - function init() external initializer { - __OwnerUUPSUpgradable_init(); + function init(address _addressManager) external initializer { + __Essential_init(_addressManager); } /// @inheritdoc ISignalService @@ -100,49 +103,50 @@ contract SignalService is AuthorizableContract, ISignalService { returns (bool) { if (app == address(0) || signal == 0 || srcChainId == 0 || srcChainId == block.chainid) { - revert SS_INVALID_FUNC_PARAMS(); + revert SS_INVALID_PARAMS(); } Proof memory p = abi.decode(proof, (Proof)); - if (p.crossChainSync == address(0) || p.merkleProof.length == 0) { - revert SS_INVALID_PROOF_PARAMS(); + if (!isMultiHopEnabled() && p.hops.length > 0) { + revert SS_MULTIHOP_DISABLED(); } - for (uint256 i; i < p.hops.length; ++i) { - if (p.hops[i].stateRoot == 0 || p.hops[i].merkleProof.length == 0) { - revert SS_INVALID_PROOF_PARAMS(); - } - } + uint64 _srcChainId = srcChainId; + address _srcApp = app; + bytes32 _srcSignal = signal; - // p.crossChainSync is either a TaikoL1 contract or a TaikoL2 contract - if (!isAuthorizedAs(p.crossChainSync, bytes32(block.chainid))) { - revert SS_CROSS_CHAIN_SYNC_UNAUTHORIZED(block.chainid); + // Verify hop proofs + IHopRelayRegistry hrr; + if (p.hops.length > 0) { + hrr = IHopRelayRegistry(resolve("hop_relay_registry", false)); } - bytes32 stateRoot = ICrossChainSync(p.crossChainSync).getSyncedSnippet(p.height).stateRoot; - if (stateRoot == 0) revert SS_CROSS_CHAIN_SYNC_ZERO_STATE_ROOT(); - // If a signal is sent from chainA -> chainB -> chainC (this chain), we verify the proofs in // the following order: - // 1. using chainC's latest parent's stateRoot to verify that chainB's TaikoL1/TaikoL2 contract has + // 1. using chainC's latest parent's stateRoot to verify that chainB's TaikoL1/TaikoL2 + // contract has // sent a given hop stateRoot on chainB using its own signal service. // 2. using the verified hop stateRoot to verify that the source app on chainA has sent a // signal using its own signal service. // We always verify the proofs in the reversed order (top to bottom). for (uint256 i; i < p.hops.length; ++i) { Hop memory hop = p.hops[i]; - if (hop.stateRoot == stateRoot) revert SS_INVALID_HOP_PROOF(); - bytes32 label = authorizedAddresses[hop.relay]; - if (label == 0) revert SS_HOP_RELAYER_UNAUTHORIZED(); + if (!hrr.isRelayRegistered(_srcChainId, hop.chainId, hop.relay)) { + revert SS_INVALID_RELAY(); + } - uint64 hopChainId = uint256(label).toUint64(); + verifyMerkleProof(hop.stateRoot, _srcChainId, _srcApp, _srcSignal, hop.merkleProof); - verifyMerkleProof(stateRoot, hopChainId, hop.relay, hop.stateRoot, hop.merkleProof); - stateRoot = hop.stateRoot; + _srcChainId = hop.chainId; + _srcApp = hop.relay; + _srcSignal = hop.stateRoot; } - verifyMerkleProof(stateRoot, srcChainId, app, signal, p.merkleProof); + ICrossChainSync ccs = ICrossChainSync(resolve("taiko", false)); + bytes32 stateRoot = ccs.getSyncedSnippet(p.height).stateRoot; + + verifyMerkleProof(stateRoot, _srcChainId, _srcApp, _srcSignal, p.merkleProof); return true; } @@ -157,7 +161,20 @@ contract SignalService is AuthorizableContract, ISignalService { view virtual { + if (stateRoot == 0) revert SS_INVALID_STATE_ROOT(); + if (merkleProof.length == 0) revert SS_INVALID_PROOF(); + + bool verified; + // TODO(dani): implement this please + + if (!verified) revert SS_INVALID_PROOF(); + } + + /// @notice Checks if multi-hop is enabled. + /// @return Returns true if multi-hop bridging is enabled. + function isMultiHopEnabled() public view virtual returns (bool) { + return false; } /// @notice Get the storage slot of the signal. diff --git a/packages/protocol/genesis/GenerateGenesis.g.sol b/packages/protocol/genesis/GenerateGenesis.g.sol index 1820abbb77..ae2bcb0721 100644 --- a/packages/protocol/genesis/GenerateGenesis.g.sol +++ b/packages/protocol/genesis/GenerateGenesis.g.sol @@ -282,13 +282,6 @@ contract TestGenerateGenesis is Test, AddressResolver { signalServiceProxy.sendSignal(keccak256(abi.encodePacked(block.prevrandao))); - assertEq( - true, - signalServiceProxy.isAuthorizedAs( - getPredeployedContractAddress("TaikoL2"), bytes32((block.chainid)) - ) - ); - vm.startPrank(ownerSecurityCouncil); SignalService signalService = diff --git a/packages/protocol/script/AuthorizeRemoteTaikoProtocols.s.sol b/packages/protocol/script/AuthorizeRemoteTaikoProtocols.s.sol deleted file mode 100644 index dccf825a54..0000000000 --- a/packages/protocol/script/AuthorizeRemoteTaikoProtocols.s.sol +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: MIT -// _____ _ _ _ _ -// |_ _|_ _(_) |_____ | | __ _| |__ ___ -// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< -// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ -// -// Email: security@taiko.xyz -// Website: https://taiko.xyz -// GitHub: https://github.com/taikoxyz -// Discord: https://discord.gg/taikoxyz -// Twitter: https://twitter.com/taikoxyz -// Blog: https://mirror.xyz/labs.taiko.eth -// Youtube: https://www.youtube.com/@taikoxyz - -pragma solidity 0.8.24; - -import "forge-std/Script.sol"; -import "forge-std/console2.sol"; -import "../contracts/signal/SignalService.sol"; - -contract AuthorizeRemoteTaikoProtocols is Script { - uint256 public privateKey = vm.envUint("PRIVATE_KEY"); - address public signalServiceAddress = vm.envAddress("SIGNAL_SERVICE_ADDRESS"); - uint256[] public remoteChainIDs = vm.envUint("REMOTE_CHAIN_IDS", ","); - address[] public remoteTaikoProtocols = vm.envAddress("REMOTE_TAIKO_PROTOCOLS", ","); - - function run() external { - require( - remoteChainIDs.length == remoteTaikoProtocols.length, - "invalid remote taiko protocol addresses length" - ); - - vm.startBroadcast(privateKey); - - SignalService signalService = SignalService(payable(signalServiceAddress)); - for (uint256 i; i < remoteChainIDs.length; ++i) { - console2.log(remoteTaikoProtocols[i], "--->", remoteChainIDs[i]); - if (!signalService.isAuthorizedAs(remoteTaikoProtocols[i], bytes32(remoteChainIDs[i]))) - { - signalService.authorize(remoteTaikoProtocols[i], bytes32(remoteChainIDs[i])); - } - } - - vm.stopBroadcast(); - } -} diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/DeployOnL1.s.sol index 7692539034..48328bfd22 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/DeployOnL1.s.sol @@ -102,8 +102,6 @@ contract DeployOnL1 is DeployCapability { console2.log("------------------------------------------"); if (signalService.owner() == address(this)) { - signalService.authorize(taikoL1Addr, bytes32(block.chainid)); - signalService.authorize(vm.envAddress("TAIKO_L2_ADDRESS"), bytes32(uint256(l2ChainId))); signalService.transferOwnership(timelock); } else { console2.log("------------------------------------------"); @@ -221,7 +219,7 @@ contract DeployOnL1 is DeployCapability { deployProxy({ name: "signal_service", impl: address(new SignalService()), - data: abi.encodeCall(SignalService.init, ()), + data: abi.encodeCall(SignalService.init, (sharedAddressManager)), registerTo: sharedAddressManager, owner: address(0) }); diff --git a/packages/protocol/test/L1/TaikoL1TestBase.sol b/packages/protocol/test/L1/TaikoL1TestBase.sol index 6350071286..14e2c39562 100644 --- a/packages/protocol/test/L1/TaikoL1TestBase.sol +++ b/packages/protocol/test/L1/TaikoL1TestBase.sol @@ -43,7 +43,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "address_manager", impl: address(new AddressManager()), - data: bytes.concat(AddressManager.init.selector) + data: abi.encodeCall(AddressManager.init, ()) }) ); @@ -51,7 +51,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "signal_service", impl: address(new SignalService()), - data: bytes.concat(SignalService.init.selector) + data: abi.encodeCall(SignalService.init, address(addressManager)) }) ); @@ -59,7 +59,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "tier_pse_zkevm", impl: address(new PseZkVerifier()), - data: bytes.concat(PseZkVerifier.init.selector, abi.encode(address(addressManager))) + data: abi.encodeCall(PseZkVerifier.init, address(addressManager)) }) ); @@ -67,7 +67,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "tier_sgx", impl: address(new SgxVerifier()), - data: bytes.concat(SgxVerifier.init.selector, abi.encode(address(addressManager))) + data: abi.encodeCall(SgxVerifier.init, address(addressManager)) }) ); @@ -79,7 +79,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "tier_sgx_and_pse_zkevm", impl: address(new SgxAndZkVerifier()), - data: bytes.concat(SgxAndZkVerifier.init.selector, abi.encode(address(addressManager))) + data: abi.encodeCall(SgxAndZkVerifier.init, address(addressManager)) }) ); @@ -87,7 +87,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "guardian_verifier", impl: address(new GuardianVerifier()), - data: bytes.concat(GuardianVerifier.init.selector, abi.encode(address(addressManager))) + data: abi.encodeCall(GuardianVerifier.init, address(addressManager)) }) ); @@ -95,7 +95,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "guardian_prover", impl: address(new GuardianProver()), - data: bytes.concat(GuardianProver.init.selector, abi.encode(address(addressManager))) + data: abi.encodeCall(GuardianProver.init, address(addressManager)) }) ); @@ -105,7 +105,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "tier_provider", impl: address(new TaikoA6TierProvider()), - data: bytes.concat(TaikoA6TierProvider.init.selector) + data: abi.encodeCall(TaikoA6TierProvider.init, ()) }) ); @@ -114,7 +114,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "bridge", impl: address(new Bridge()), - data: bytes.concat(Bridge.init.selector, abi.encode(addressManager)), + data: abi.encodeCall(Bridge.init, address(addressManager)), registerTo: address(addressManager), owner: address(0) }) @@ -125,7 +125,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "assignment_hook", impl: address(new AssignmentHook()), - data: bytes.concat(AssignmentHook.init.selector, abi.encode(address(addressManager))) + data: abi.encodeCall(AssignmentHook.init, address(addressManager)) }) ); @@ -148,14 +148,7 @@ abstract contract TaikoL1TestBase is TaikoTest { deployProxy({ name: "taiko_token", impl: address(new TaikoToken()), - data: bytes.concat( - TaikoToken.init.selector, - abi.encode( - "Taiko Token", // - "TTKOk", - address(this) - ) - ), + data: abi.encodeCall(TaikoToken.init, ("Taiko Token", "TTKOk", address(this))), registerTo: address(addressManager), owner: address(0) }) diff --git a/packages/protocol/test/L2/TaikoL2.t.sol b/packages/protocol/test/L2/TaikoL2.t.sol index 2392dc1367..acaf017baa 100644 --- a/packages/protocol/test/L2/TaikoL2.t.sol +++ b/packages/protocol/test/L2/TaikoL2.t.sol @@ -31,7 +31,7 @@ contract TestTaikoL2 is TaikoTest { deployProxy({ name: "signal_service", impl: address(new SignalService()), - data: abi.encodeCall(SignalService.init, ()), + data: abi.encodeCall(SignalService.init, (addressManager)), registerTo: addressManager, owner: address(0) }); diff --git a/packages/protocol/test/TaikoTest.sol b/packages/protocol/test/TaikoTest.sol index d1067d3049..12b1eda9b7 100644 --- a/packages/protocol/test/TaikoTest.sol +++ b/packages/protocol/test/TaikoTest.sol @@ -10,6 +10,7 @@ import "../contracts/thirdparty/LibFixedPointMath.sol"; import "../contracts/bridge/Bridge.sol"; import "../contracts/signal/SignalService.sol"; +import "../contracts/signal/HopRelayRegistry.sol"; import "../contracts/tokenvault/BridgedERC20.sol"; import "../contracts/tokenvault/BridgedERC721.sol"; import "../contracts/tokenvault/BridgedERC1155.sol"; diff --git a/packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol b/packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol index d67d438c44..8cd18b8c8c 100644 --- a/packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol +++ b/packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol @@ -14,7 +14,7 @@ contract AutomataDcapV3AttestationTest is Test, AttestationBase { function setUp() public { // Call the AttestationBase init setup - super.intialSetup(); + super.initialSetup(); } function testAttestation() public { diff --git a/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol b/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol index 68c1a3cac9..daa1d88625 100644 --- a/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol +++ b/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol @@ -37,7 +37,7 @@ contract AttestationBase is Test, DcapTestUtils, V3QuoteParseUtils { bytes sampleQuote = hex"03000200000000000a000f00939a7233f79c4ca9940a0db3957f060712ce6af1e4a81e0ecdac427b99bb0295000000000b0b100fffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000e700000000000000ae9bd17e36f8bf636cb03fc2a63873ee8d0887fdd596ca6144f82cfa0ee3262000000000000000000000000000000000000000000000000000000000000000001d3d2b8e78a9081c4d7865026f984b265197696dfe4a0598a2d0ef0764f700f500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c2d4564358139c90c17b744fe837f4ddc503eedf0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ca1000006399514fd6f9487da072276f760326510efe4277b9a7d9bf6c4d44c54e277a9fae1f09b711bf62c2d40596626184709b8b58f692b5bd3351dfa59dda19794f33c7277e139f5f2982256989fb65198701d836f8d6f15256ff05d4891bcadae813757a7c09fd1ce02297783baf66b9d97662b5fc38053c34970280bea0eb6e1a7e0b0b100fffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000001500000000000000e70000000000000096b347a64e5a045e27369c26e6dcda51fd7c850e9b3a3a79e718f43261dee1e400000000000000000000000000000000000000000000000000000000000000008c4f5775d796503e96137f77c68a829a0056ac8ded70140b081b094490c57bff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035b9ea12f4cf90ec68e8f4b0cbeb15ab6c70e858f1ed8b00c6f3b8471bf1146600000000000000000000000000000000000000000000000000000000000000005ec0f952f3ef6572b1dfa26bbd07e36d47bff6cfa731c726bd977f93beda6edf836944a8ddd88f3809ab8746a1875cf13089e481d8c36275d1fb71f5837c58f12000000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f0500620e00002d2d2d2d2d424547494e2043455254494649434154452d2d2d2d2d0a4d494945387a4343424a6d674177494241674956414c7a2b6a596a7863582b664a6f6d415562434a71676966496f6c364d416f4743437147534d343942414d430a4d484178496a416742674e5642414d4d47556c756447567349464e4857434251513073675547786864475a76636d306751304578476a415942674e5642416f4d0a45556c756447567349454e76636e4276636d4630615739754d5251774567594456515148444174545957353059534244624746795954454c4d416b47413155450a4341774351304578437a414a42674e5642415954416c56544d4234584454497a4d4467794f4445784d544d774e566f5844544d774d4467794f4445784d544d770a4e566f77634445694d434147413155454177775a535735305a5777675530645949464244537942445a584a3061575a70593246305a5445614d426747413155450a43677752535735305a577767513239796347397959585270623234784644415342674e564241634d43314e68626e526849454e7359584a684d517377435159440a5651514944414a445154454c4d416b474131554542684d4356564d775754415442676371686b6a4f5051494242676771686b6a4f50514d4242774e43414151790a734153725336726b656a31344866314a537075504f314e445556797a5842437670316834324631305555304146555767315934386f6542673774764e355832490a54474542357a48426a7a6a76396b755779556a556f344944446a434341776f77487759445652306a42426777466f41556c5739647a62306234656c4153636e550a3944504f4156634c336c5177617759445652306642475177596a42676f46366758495a616148523063484d364c79396863476b7564484a316333526c5a484e6c0a636e5a705932567a4c6d6c75644756734c6d4e766253397a5a3367765932567964476c6d61574e6864476c76626939324e4339775932746a636d772f593245390a6347786864475a76636d306d5a57356a62325270626d63395a4756794d42304741315564446751574242525456365a6c7a31764a6b5953666b4a6a384e69667a0a716761775744414f42674e56485138424166384542414d434273417744415944565230544151482f4241497741444343416a734743537147534962345451454e0a41515343416977776767496f4d42344743697147534962345451454e4151454545503547726745637a6f704e626f4d3073493062744145776767466c42676f710a686b69472b453042445145434d4949425654415142677371686b69472b4530424451454341514942437a415142677371686b69472b45304244514543416749420a437a415142677371686b69472b4530424451454341774942417a415142677371686b69472b4530424451454342414942417a415242677371686b69472b4530420a4451454342514943415038774551594c4b6f5a496876684e41513042416759434167442f4d42414743797147534962345451454e41514948416745414d4241470a43797147534962345451454e41514949416745414d42414743797147534962345451454e4151494a416745414d42414743797147534962345451454e4151494b0a416745414d42414743797147534962345451454e4151494c416745414d42414743797147534962345451454e4151494d416745414d42414743797147534962340a5451454e4151494e416745414d42414743797147534962345451454e4151494f416745414d42414743797147534962345451454e41514950416745414d4241470a43797147534962345451454e41514951416745414d42414743797147534962345451454e415149524167454e4d42384743797147534962345451454e415149530a4242414c43774d442f2f38414141414141414141414141414d42414743697147534962345451454e41514d45416741414d42514743697147534962345451454e0a4151514542674267616741414144415042676f71686b69472b45304244514546436745424d42344743697147534962345451454e415159454545574a7a4f76790a5a45384b336b6a2f48685845612f73775241594b4b6f5a496876684e41513042427a41324d42414743797147534962345451454e415163424151482f4d4241470a43797147534962345451454e415163434151482f4d42414743797147534962345451454e415163444151482f4d416f4743437147534d343942414d43413067410a4d45554349427133767832444e616d5142466d55644d652b6d5059454375383458676f4643674977534a5634634a61544169454134337037747277423830732b0a32697761686d4464416e434d774a56504c69534575774451463856456753773d0a2d2d2d2d2d454e442043455254494649434154452d2d2d2d2d0a2d2d2d2d2d424547494e2043455254494649434154452d2d2d2d2d0a4d4949436c6a4343416a32674177494241674956414a567658633239472b487051456e4a3150517a7a674658433935554d416f4743437147534d343942414d430a4d476778476a415942674e5642414d4d45556c756447567349464e48574342536232393049454e424d526f77474159445651514b4442464a626e526c624342440a62334a7762334a6864476c76626a45554d424947413155454277774c553246756447456751327868636d4578437a414a42674e564241674d416b4e424d5173770a435159445651514745774a56557a4165467730784f4441314d6a45784d4455774d5442614677307a4d7a41314d6a45784d4455774d5442614d484178496a41670a42674e5642414d4d47556c756447567349464e4857434251513073675547786864475a76636d306751304578476a415942674e5642416f4d45556c75644756730a49454e76636e4276636d4630615739754d5251774567594456515148444174545957353059534244624746795954454c4d416b474131554543417743513045780a437a414a42674e5642415954416c56544d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741454e53422f377432316c58534f0a3243757a7078773734654a423732457944476757357258437478327456544c7136684b6b367a2b5569525a436e71523770734f766771466553786c6d546c4a6c0a65546d693257597a33714f42757a43427544416642674e5648534d4547444157674251695a517a575770303069664f44744a5653763141624f536347724442530a42674e5648523845537a424a4d45656752614244686b466f64485277637a6f764c324e6c636e52705a6d6c6a5958526c63793530636e567a6447566b633256790a646d6c6a5a584d75615735305a577775593239744c306c756447567355306459556d397664454e424c6d526c636a416442674e5648513445466751556c5739640a7a62306234656c4153636e553944504f4156634c336c517744675944565230504151482f42415144416745474d42494741315564457745422f7751494d4159420a4166384341514177436759494b6f5a497a6a30454177494452774177524149675873566b6930772b6936565947573355462f32327561586530594a446a3155650a6e412b546a44316169356343494359623153416d4435786b66545670766f34556f79695359787244574c6d5552344349394e4b7966504e2b0a2d2d2d2d2d454e442043455254494649434154452d2d2d2d2d0a2d2d2d2d2d424547494e2043455254494649434154452d2d2d2d2d0a4d4949436a7a4343416a53674177494241674955496d554d316c71644e496e7a6737535655723951477a6b6e42717777436759494b6f5a497a6a3045417749770a614445614d4267474131554541777752535735305a5777675530645949464a766233516751304578476a415942674e5642416f4d45556c756447567349454e760a636e4276636d4630615739754d5251774567594456515148444174545957353059534244624746795954454c4d416b47413155454341774351304578437a414a0a42674e5642415954416c56544d423458445445344d4455794d5445774e4455784d466f58445451354d54497a4d54497a4e546b314f566f77614445614d4267470a4131554541777752535735305a5777675530645949464a766233516751304578476a415942674e5642416f4d45556c756447567349454e76636e4276636d46300a615739754d5251774567594456515148444174545957353059534244624746795954454c4d416b47413155454341774351304578437a414a42674e56424159540a416c56544d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414543366e45774d4449595a4f6a2f69505773437a61454b69370a314f694f534c52466857476a626e42564a66566e6b59347533496a6b4459594c304d784f346d717379596a6c42616c54565978465032734a424b357a6c4b4f420a757a43427544416642674e5648534d4547444157674251695a517a575770303069664f44744a5653763141624f5363477244425342674e5648523845537a424a0a4d45656752614244686b466f64485277637a6f764c324e6c636e52705a6d6c6a5958526c63793530636e567a6447566b63325679646d6c6a5a584d75615735300a5a577775593239744c306c756447567355306459556d397664454e424c6d526c636a416442674e564851344546675155496d554d316c71644e496e7a673753560a55723951477a6b6e4271777744675944565230504151482f42415144416745474d42494741315564457745422f7751494d4159424166384341514577436759490a4b6f5a497a6a3045417749445351417752674968414f572f35516b522b533943695344634e6f6f774c7550524c735747662f59693747535839344267775477670a41694541344a306c72486f4d732b586f356f2f7358364f39515778485241765a55474f6452513763767152586171493d0a2d2d2d2d2d454e442043455254494649434154452d2d2d2d2d0a00"; - function intialSetup() public { + function initialSetup() public { // pinned September 23rd, 2023, 0221 UTC // comment this line out if you are replacing sampleQuote with your own // this line is needed to bypass expiry reverts for stale quotes diff --git a/packages/protocol/test/bridge/Bridge.t.sol b/packages/protocol/test/bridge/Bridge.t.sol index c935866d92..c7dd95a499 100644 --- a/packages/protocol/test/bridge/Bridge.t.sol +++ b/packages/protocol/test/bridge/Bridge.t.sol @@ -91,7 +91,7 @@ contract BridgeTest is TaikoTest { deployProxy({ name: "signal_service", impl: address(new SkipProofCheckSignal()), - data: abi.encodeCall(SignalService.init, ()), + data: abi.encodeCall(SignalService.init, (address(addressManager))), registerTo: address(addressManager), owner: address(0) }) @@ -101,7 +101,7 @@ contract BridgeTest is TaikoTest { deployProxy({ name: "signal_service", impl: address(new SignalService()), - data: abi.encodeCall(SignalService.init, ()) + data: abi.encodeCall(SignalService.init, (address(addressManager))) }) ); @@ -549,9 +549,6 @@ contract BridgeTest is TaikoTest { // proofs via rpc // in foundry function test_Bridge_process_message() public { - /* DISCALIMER: From now on we do not need to have real - proofs because we can bypass with overriding skipProofCheck() - in a mockBirdge AND proof system already 'battle tested'.*/ // This predefined successful process message call fails now // since we modified the iBridge.Message struct and cut out // depositValue @@ -572,9 +569,6 @@ contract BridgeTest is TaikoTest { // proofs via rpc // in foundry function test_Bridge_retry_message_and_end_up_in_failed_status() public { - /* DISCALIMER: From now on we do not need to have real - proofs because we can bypass with overriding skipProofCheck() - in a mockBirdge AND proof system already 'battle tested'.*/ vm.startPrank(Alice); (IBridge.Message memory message, bytes memory proof) = setUpPredefinedSuccessfulProcessMessageCall(); @@ -632,9 +626,6 @@ contract BridgeTest is TaikoTest { destChainBridge.retryMessage(message, true); } - /* DISCALIMER: From now on we do not need to have real - proofs because we can bypass with overriding skipProofCheck() - in a mockBirdge AND proof system already 'battle tested'.*/ function setUpPredefinedSuccessfulProcessMessageCall() internal returns (IBridge.Message memory, bytes memory) diff --git a/packages/protocol/test/common/AuthorizableContract.t.sol b/packages/protocol/test/common/AuthorizableContract.t.sol deleted file mode 100644 index 2458d46bb9..0000000000 --- a/packages/protocol/test/common/AuthorizableContract.t.sol +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.24; - -import "../L1/TaikoL1TestBase.sol"; - -/// @author Kirk Baird -contract TestAuthorizableContract is TaikoL1TestBase { - function deployTaikoL1() internal override returns (TaikoL1) { - return - TaikoL1(payable(deployProxy({ name: "taiko", impl: address(new TaikoL1()), data: "" }))); - } - - function setUp() public override { - // Call the TaikoL1TestBase setUp() - super.setUp(); - } - - function test_authorize() external { - bytes32 bobLabel = keccak256("Bob"); - //logs - vm.expectEmit(address(ss)); - emit AuthorizableContract.Authorized(Bob, 0, bobLabel); - // call authorize - ss.authorize(Bob, bobLabel); - - // validation - assertEq(ss.authorizedAddresses(Bob), bobLabel, "wrong Label"); - assertEq(ss.isAuthorizedAs(Bob, bobLabel), true, "should return true"); - - //stop prank - vm.stopPrank(); - } - - function test_authorize_invalid_address() external { - bytes32 bobLabel = keccak256("Bob"); - - vm.expectRevert(AuthorizableContract.INVALID_ADDRESS.selector); - // call authorize - ss.authorize(address(0), bobLabel); - } - - function test_authorize_invalid_label() external { - bytes32 bobLabel = keccak256("Bob"); - - //logs - vm.expectEmit(address(ss)); - emit AuthorizableContract.Authorized(Bob, 0, bobLabel); - - // call authorize - ss.authorize(Bob, bobLabel); - - // call authorize - vm.expectRevert(AuthorizableContract.INVALID_LABEL.selector); - ss.authorize(Bob, bobLabel); - } - - function test_isAuthorizedAs() external { - bytes32 bobLabel = keccak256("Bob"); - - //logs - vm.expectEmit(address(ss)); - emit AuthorizableContract.Authorized(Bob, 0, bobLabel); - - // call authorize - ss.authorize(Bob, bobLabel); - - assertEq(ss.isAuthorizedAs(Bob, bobLabel), true, "should return true"); - assertEq(ss.isAuthorizedAs(Alice, 0), false, "should return false"); - } -} diff --git a/packages/protocol/test/signal/SignalService.t.sol b/packages/protocol/test/signal/SignalService.t.sol index 3b74007be5..e21c939dbe 100644 --- a/packages/protocol/test/signal/SignalService.t.sol +++ b/packages/protocol/test/signal/SignalService.t.sol @@ -3,10 +3,42 @@ pragma solidity 0.8.24; import "../TaikoTest.sol"; +contract SignalServiceForTest is SignalService { + bool private _skipVerifyMerkleProof; + bool private _multiHopEnabled; + + function setSkipMerkleProofCheck(bool skip) external { + _skipVerifyMerkleProof = skip; + } + + function setMultiHopEnabled(bool enabled) external { + _multiHopEnabled = enabled; + } + + function verifyMerkleProof( + bytes32, /*stateRoot*/ + uint64, /*srcChainId*/ + address, /*srcApp*/ + bytes32, /*srcSignal*/ + bytes memory /*merkleProof*/ + ) + public + view + override + { + if (!_skipVerifyMerkleProof) revert("verifyMerkleProof failed"); + } + + function isMultiHopEnabled() public view override returns (bool) { + return _multiHopEnabled; + } +} + contract TestSignalService is TaikoTest { AddressManager addressManager; - SignalService relayer; + SignalServiceForTest signalService; SignalService destSignalService; + HopRelayRegistry hopRelayRegistry; DummyCrossChainSync crossChainSync; uint64 public destChainId = 7; @@ -25,67 +57,177 @@ contract TestSignalService is TaikoTest { }) ); - relayer = SignalService( + signalService = SignalServiceForTest( deployProxy({ name: "signal_service", - impl: address(new SignalService()), - data: abi.encodeCall(SignalService.init, ()) + impl: address(new SignalServiceForTest()), + data: abi.encodeCall(SignalService.init, (address(addressManager))) + }) + ); + + hopRelayRegistry = HopRelayRegistry( + deployProxy({ + name: "hop_relay_registry", + impl: address(new HopRelayRegistry()), + data: abi.encodeCall(HopRelayRegistry.init, ()), + registerTo: address(addressManager), + owner: address(0) }) ); destSignalService = SignalService( deployProxy({ name: "signal_service", - impl: address(new SignalService()), - data: abi.encodeCall(SignalService.init, ()) + impl: address(new SignalServiceForTest()), + data: abi.encodeCall(SignalService.init, (address(addressManager))) }) ); crossChainSync = DummyCrossChainSync( deployProxy({ - name: "dummy_cross_chain_sync", + name: "taiko", // must be named so impl: address(new DummyCrossChainSync()), data: "" }) ); - register(address(addressManager), "signal_service", address(destSignalService), destChainId); - - register(address(addressManager), "taiko", address(crossChainSync), destChainId); - vm.stopPrank(); } function test_SignalService_sendSignal_revert() public { vm.expectRevert(SignalService.SS_INVALID_SIGNAL.selector); - relayer.sendSignal(0); + signalService.sendSignal(0); } function test_SignalService_isSignalSent_revert() public { bytes32 signal = bytes32(uint256(1)); vm.expectRevert(SignalService.SS_INVALID_APP.selector); - relayer.isSignalSent(address(0), signal); + signalService.isSignalSent(address(0), signal); signal = bytes32(uint256(0)); vm.expectRevert(SignalService.SS_INVALID_SIGNAL.selector); - relayer.isSignalSent(Alice, signal); + signalService.isSignalSent(Alice, signal); } function test_SignalService_sendSignal_isSignalSent() public { vm.startPrank(Alice); bytes32 signal = bytes32(uint256(1)); - relayer.sendSignal(signal); + signalService.sendSignal(signal); - assertTrue(relayer.isSignalSent(Alice, signal)); + assertTrue(signalService.isSignalSent(Alice, signal)); } function test_SignalService_getSignalSlot() public { vm.startPrank(Alice); for (uint8 i = 1; i < 100; ++i) { bytes32 signal = bytes32(block.prevrandao + i); - relayer.sendSignal(signal); + signalService.sendSignal(signal); - assertTrue(relayer.isSignalSent(Alice, signal)); + assertTrue(signalService.isSignalSent(Alice, signal)); } } + + function test_SignalService_proveSignalReceived_L1_L2() public { + signalService.setSkipMerkleProofCheck(true); + signalService.setMultiHopEnabled(false); + + bytes32 stateRoot = randBytes32(); + crossChainSync.setSyncedData("", stateRoot); + + uint64 thisChainId = uint64(block.chainid); + + uint64 srcChainId = thisChainId + 1; + address app = randAddress(); + bytes32 signal = randBytes32(); + + SignalService.Proof memory p; + p.height = 10; + // p.merkleProof = "doesn't matter"; + + vm.expectRevert(); // cannot resolve "taiko" + signalService.proveSignalReceived(srcChainId, app, signal, abi.encode(p)); + + vm.startPrank(Alice); + register(address(addressManager), "taiko", address(crossChainSync), thisChainId); + assertEq(signalService.proveSignalReceived(srcChainId, app, signal, abi.encode(p)), true); + + signalService.setSkipMerkleProofCheck(false); + + vm.expectRevert(); // cannot decode the proof + signalService.proveSignalReceived(srcChainId, app, signal, abi.encode(p)); + } + + function test_SignalService_proveSignalReceived_multi_hop_L2_L2() public { + signalService.setSkipMerkleProofCheck(true); + signalService.setMultiHopEnabled(false); + + bytes32 stateRoot = randBytes32(); + crossChainSync.setSyncedData("", stateRoot); + + uint64 thisChainId = uint64(block.chainid); + + uint64 srcChainId = thisChainId + 1; + + uint64 hop1ChainId = thisChainId + 2; + address hop1Relay = randAddress(); + bytes32 hop1StateRoot = randBytes32(); + + uint64 hop2ChainId = thisChainId + 3; + address hop2Relay = randAddress(); + bytes32 hop2StateRoot = randBytes32(); + + address app = randAddress(); + bytes32 signal = randBytes32(); + + SignalService.Proof memory p; + p.height = 10; + p.hops = new SignalService.Hop[](2); + + p.hops[0] = SignalService.Hop({ + chainId: hop1ChainId, + relay: hop1Relay, + stateRoot: hop1StateRoot, + merkleProof: "dummy proof1" + }); + + p.hops[1] = SignalService.Hop({ + chainId: hop2ChainId, + relay: hop2Relay, + stateRoot: hop2StateRoot, + merkleProof: "dummy proof2" + }); + + vm.startPrank(Alice); + register(address(addressManager), "taiko", address(crossChainSync), thisChainId); + + // Multiple is disabled, shall revert + vm.expectRevert(SignalService.SS_MULTIHOP_DISABLED.selector); + signalService.proveSignalReceived(srcChainId, app, signal, abi.encode(p)); + + // Enable multi-hop + vm.startPrank(Alice); + signalService.setMultiHopEnabled(true); + + // Neither relay is registered + vm.expectRevert(SignalService.SS_INVALID_RELAY.selector); + signalService.proveSignalReceived(srcChainId, app, signal, abi.encode(p)); + + // Register both relays + vm.startPrank(Alice); + hopRelayRegistry.registerRelay(srcChainId, hop1ChainId, hop1Relay); + hopRelayRegistry.registerRelay(hop1ChainId, hop2ChainId, hop2Relay); + vm.stopPrank(); + + signalService.proveSignalReceived(srcChainId, app, signal, abi.encode(p)); + + // Deregister the first relay and register it again with incorrect chainIds + vm.startPrank(Alice); + hopRelayRegistry.deregisterRelay(srcChainId, hop1ChainId, hop1Relay); + hopRelayRegistry.registerRelay(999, 888, hop1Relay); + vm.stopPrank(); + + // Still revert + vm.expectRevert(SignalService.SS_INVALID_RELAY.selector); + signalService.proveSignalReceived(srcChainId, app, signal, abi.encode(p)); + } } diff --git a/packages/protocol/test/tokenvault/ERC1155Vault.t.sol b/packages/protocol/test/tokenvault/ERC1155Vault.t.sol index 6d0dc4a335..b0c136f2cd 100644 --- a/packages/protocol/test/tokenvault/ERC1155Vault.t.sol +++ b/packages/protocol/test/tokenvault/ERC1155Vault.t.sol @@ -143,7 +143,7 @@ contract ERC1155VaultTest is TaikoTest { deployProxy({ name: "signal_service", impl: address(new SignalService()), - data: abi.encodeCall(SignalService.init, ()) + data: abi.encodeCall(SignalService.init, (address(addressManager))) }) ); @@ -170,7 +170,7 @@ contract ERC1155VaultTest is TaikoTest { deployProxy({ name: "signal_service", impl: address(new SkipProofCheckSignal()), - data: abi.encodeCall(SignalService.init, ()) + data: abi.encodeCall(SignalService.init, (address(addressManager))) }) ); diff --git a/packages/protocol/test/tokenvault/ERC20Vault.t.sol b/packages/protocol/test/tokenvault/ERC20Vault.t.sol index 864c66aee7..350a210ae2 100644 --- a/packages/protocol/test/tokenvault/ERC20Vault.t.sol +++ b/packages/protocol/test/tokenvault/ERC20Vault.t.sol @@ -141,7 +141,7 @@ contract TestERC20Vault is TaikoTest { deployProxy({ name: "signal_service", impl: address(new SignalService()), - data: abi.encodeCall(SignalService.init, ()), + data: abi.encodeCall(SignalService.init, (address(addressManager))), registerTo: address(0), owner: address(0) }) diff --git a/packages/protocol/test/tokenvault/ERC721Vault.t.sol b/packages/protocol/test/tokenvault/ERC721Vault.t.sol index 7e96f4aabb..17724d17a0 100644 --- a/packages/protocol/test/tokenvault/ERC721Vault.t.sol +++ b/packages/protocol/test/tokenvault/ERC721Vault.t.sol @@ -159,7 +159,7 @@ contract ERC721VaultTest is TaikoTest { deployProxy({ name: "signal_service", impl: address(new SignalService()), - data: abi.encodeCall(SignalService.init, ()) + data: abi.encodeCall(SignalService.init, (address(addressManager))) }) ); @@ -186,7 +186,7 @@ contract ERC721VaultTest is TaikoTest { deployProxy({ name: "signal_service", impl: address(new SkipProofCheckSignal()), - data: abi.encodeCall(SignalService.init, ()) + data: abi.encodeCall(SignalService.init, (address(addressManager))) }) ); diff --git a/packages/protocol/test/verifiers/SgxVerifier.t.sol b/packages/protocol/test/verifiers/SgxVerifier.t.sol index 8382a3f320..6d125bbcd0 100644 --- a/packages/protocol/test/verifiers/SgxVerifier.t.sol +++ b/packages/protocol/test/verifiers/SgxVerifier.t.sol @@ -23,7 +23,7 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { super.setUp(); // Call the AttestationBase init setup - super.intialSetup(); + super.initialSetup(); registerAddress("automata_dcap_attestation", address(attestation)); } diff --git a/packages/protocol/utils/generate_genesis/taikoL2.ts b/packages/protocol/utils/generate_genesis/taikoL2.ts index af929ea210..b025b69d92 100644 --- a/packages/protocol/utils/generate_genesis/taikoL2.ts +++ b/packages/protocol/utils/generate_genesis/taikoL2.ts @@ -464,12 +464,6 @@ async function generateContractConfigs( _paused: 1, // _FALSE // Ownable2Upgradeable _owner: ownerSecurityCouncil, - authorizedAddresses: { - [addressMap.TaikoL2]: ethers.utils.hexZeroPad( - ethers.utils.hexlify(chainId), - 32, - ), - }, }, slots: { [IMPLEMENTATION_SLOT]: addressMap.SignalServiceImpl,