From 50d784afdc9e4a066b833501015d39ac86d36c69 Mon Sep 17 00:00:00 2001 From: agusduha Date: Mon, 7 Oct 2024 15:15:54 -0300 Subject: [PATCH] fix: superchain bridge rename --- packages/contracts-bedrock/.gas-snapshot | 14 +++---- packages/contracts-bedrock/lib/forge-std | 2 +- .../contracts-bedrock/scripts/Artifacts.s.sol | 4 +- .../contracts-bedrock/scripts/L2Genesis.s.sol | 6 +-- .../scripts/checks/semver-natspec/main.go | 4 +- packages/contracts-bedrock/semver-lock.json | 8 ++-- .../abi/OptimismSuperchainERC20.json | 2 +- ...Bridge.json => SuperchainTokenBridge.json} | 0 ...Bridge.json => SuperchainTokenBridge.json} | 0 .../src/L2/SuperchainERC20.sol | 20 +++++----- ...20Bridge.sol => SuperchainTokenBridge.sol} | 8 ++-- .../IOptimismSuperchainERC20Factory.sol | 2 +- .../src/L2/interfaces/ISuperchainERC20.sol | 2 +- ...0Bridge.sol => ISuperchainTokenBridge.sol} | 6 +-- .../src/libraries/Predeploys.sol | 8 ++-- .../test/L2/SuperchainERC20.t.sol | 24 +++++------ ...idge.t.sol => SuperchainTokenBridge.t.sol} | 40 +++++++++---------- .../mocks/SuperchainERC20Implementation.sol | 2 +- .../contracts-bedrock/test/setup/Setup.sol | 6 +-- 19 files changed, 79 insertions(+), 79 deletions(-) rename packages/contracts-bedrock/snapshots/abi/{SuperchainERC20Bridge.json => SuperchainTokenBridge.json} (100%) rename packages/contracts-bedrock/snapshots/storageLayout/{SuperchainERC20Bridge.json => SuperchainTokenBridge.json} (100%) rename packages/contracts-bedrock/src/L2/{SuperchainERC20Bridge.sol => SuperchainTokenBridge.sol} (96%) rename packages/contracts-bedrock/src/L2/interfaces/{ISuperchainERC20Bridge.sol => ISuperchainTokenBridge.sol} (85%) rename packages/contracts-bedrock/test/L2/{SuperchainERC20Bridge.t.sol => SuperchainTokenBridge.t.sol} (87%) diff --git a/packages/contracts-bedrock/.gas-snapshot b/packages/contracts-bedrock/.gas-snapshot index 4c8038a0ac68..da67af9f81fc 100644 --- a/packages/contracts-bedrock/.gas-snapshot +++ b/packages/contracts-bedrock/.gas-snapshot @@ -4,14 +4,14 @@ GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchm GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099) GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531) GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597) -GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369242) -GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967382) -GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564356) -GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076571) +GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369245) +GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967385) +GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564368) +GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076583) GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467019) -GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512701) +GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512723) GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72618) GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973) -GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68312) -GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68943) +GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68357) +GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68921) GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155610) \ No newline at end of file diff --git a/packages/contracts-bedrock/lib/forge-std b/packages/contracts-bedrock/lib/forge-std index 2d8b7b876a5b..8f24d6b04c92 160000 --- a/packages/contracts-bedrock/lib/forge-std +++ b/packages/contracts-bedrock/lib/forge-std @@ -1 +1 @@ -Subproject commit 2d8b7b876a5b328d6a73e13c4740ed7a0d72d5f4 +Subproject commit 8f24d6b04c92975e0795b5868aa0d783251cdeaa diff --git a/packages/contracts-bedrock/scripts/Artifacts.s.sol b/packages/contracts-bedrock/scripts/Artifacts.s.sol index fc7e3d8a1503..8408e09c8184 100644 --- a/packages/contracts-bedrock/scripts/Artifacts.s.sol +++ b/packages/contracts-bedrock/scripts/Artifacts.s.sol @@ -158,8 +158,8 @@ abstract contract Artifacts { return payable(Predeploys.OPTIMISM_SUPERCHAIN_ERC20_FACTORY); } else if (digest == keccak256(bytes("OptimismSuperchainERC20Beacon"))) { return payable(Predeploys.OPTIMISM_SUPERCHAIN_ERC20_BEACON); - } else if (digest == keccak256(bytes("SuperchainERC20Bridge"))) { - return payable(Predeploys.SUPERCHAIN_ERC20_BRIDGE); + } else if (digest == keccak256(bytes("SuperchainTokenBridge"))) { + return payable(Predeploys.SUPERCHAIN_TOKEN_BRIDGE); } return payable(address(0)); } diff --git a/packages/contracts-bedrock/scripts/L2Genesis.s.sol b/packages/contracts-bedrock/scripts/L2Genesis.s.sol index 71e7239241da..83b521409d3c 100644 --- a/packages/contracts-bedrock/scripts/L2Genesis.s.sol +++ b/packages/contracts-bedrock/scripts/L2Genesis.s.sol @@ -281,7 +281,7 @@ contract L2Genesis is Deployer { setETHLiquidity(); // 25 setOptimismSuperchainERC20Factory(); // 26 setOptimismSuperchainERC20Beacon(); // 27 - setSuperchainERC20Bridge(); // 28 + setSuperchainTokenBridge(); // 28 } } @@ -558,8 +558,8 @@ contract L2Genesis is Deployer { /// @notice This predeploy is following the safety invariant #1. /// This contract has no initializer. - function setSuperchainERC20Bridge() internal { - _setImplementationCode(Predeploys.SUPERCHAIN_ERC20_BRIDGE); + function setSuperchainTokenBridge() internal { + _setImplementationCode(Predeploys.SUPERCHAIN_TOKEN_BRIDGE); } /// @notice Sets all the preinstalls. diff --git a/packages/contracts-bedrock/scripts/checks/semver-natspec/main.go b/packages/contracts-bedrock/scripts/checks/semver-natspec/main.go index cc65480d2c00..ea341864e604 100644 --- a/packages/contracts-bedrock/scripts/checks/semver-natspec/main.go +++ b/packages/contracts-bedrock/scripts/checks/semver-natspec/main.go @@ -130,13 +130,13 @@ func run() error { } // Skip mock contracts - if strings.Contains(contractName, "_MockContract") { + if strings.Contains(contractName, "_mock") { return } contractPath := contractFiles[contractName] if contractPath == "" { - fail("%s: Source file not found (For test mock contracts, suffix the name with '_MockContract' to ignore this warning)", contractName) + fail("%s: Source file not found (For test mock contracts, suffix the name with '_mock' to ignore this warning)", contractName) return } diff --git a/packages/contracts-bedrock/semver-lock.json b/packages/contracts-bedrock/semver-lock.json index a9031d13d060..c0a5da89e474 100644 --- a/packages/contracts-bedrock/semver-lock.json +++ b/packages/contracts-bedrock/semver-lock.json @@ -116,7 +116,7 @@ "sourceCodeHash": "0xfea53344596d735eff3be945ed1300dc75a6f8b7b2c02c0043af5b0036f5f239" }, "src/L2/OptimismSuperchainERC20.sol": { - "initCodeHash": "0x28372d06b45a3235a2c5273e3d6e41fe9572dd58ad8a20161b917d0e45a9718e", + "initCodeHash": "0xadeaebb33c1d758d88d7aadd0ad654c9a1f2d59824c5dad19e1d9cf05ea3e516", "sourceCodeHash": "0x5a40eabbdc33bd96ff0a7bc2be6699a7b6233610bf67f3da899f0efb367bb486" }, "src/L2/OptimismSuperchainERC20Beacon.sol": { @@ -133,11 +133,11 @@ }, "src/L2/SuperchainERC20.sol": { "initCodeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", - "sourceCodeHash": "0x4d251314bae2904986d3df791e916fc619bc65d09ccd80bc2032cfdd12b8c0a3" + "sourceCodeHash": "0x19f598d3b3e77963f9af395b0102dd9acea0e76f7a0ed6eb937d94d3c054137e" }, - "src/L2/SuperchainERC20Bridge.sol": { + "src/L2/SuperchainTokenBridge.sol": { "initCodeHash": "0xfeba60d8e17a0c62cc56c7319da323e154ccc6c379e7b72c48c9d0ce1e5b9474", - "sourceCodeHash": "0xf576ba9150a9ec0f1b624b821453eec9a79a8baadb735e3b7b7a7cae7f8e9f91" + "sourceCodeHash": "0xbfd1a6959cf5ae96c3e0aaf9aa638633e6cb8a7a183484e91ec29d619d687a42" }, "src/L2/SuperchainWETH.sol": { "initCodeHash": "0x5db03c5c4cd6ea9e4b3e74e28f50d04fd3e130af5109b34fa208808fa9ba7742", diff --git a/packages/contracts-bedrock/snapshots/abi/OptimismSuperchainERC20.json b/packages/contracts-bedrock/snapshots/abi/OptimismSuperchainERC20.json index 5c0d8bcb8074..d2e66cf3a057 100644 --- a/packages/contracts-bedrock/snapshots/abi/OptimismSuperchainERC20.json +++ b/packages/contracts-bedrock/snapshots/abi/OptimismSuperchainERC20.json @@ -577,7 +577,7 @@ }, { "inputs": [], - "name": "OnlySuperchainERC20Bridge", + "name": "OnlySuperchainTokenBridge", "type": "error" }, { diff --git a/packages/contracts-bedrock/snapshots/abi/SuperchainERC20Bridge.json b/packages/contracts-bedrock/snapshots/abi/SuperchainTokenBridge.json similarity index 100% rename from packages/contracts-bedrock/snapshots/abi/SuperchainERC20Bridge.json rename to packages/contracts-bedrock/snapshots/abi/SuperchainTokenBridge.json diff --git a/packages/contracts-bedrock/snapshots/storageLayout/SuperchainERC20Bridge.json b/packages/contracts-bedrock/snapshots/storageLayout/SuperchainTokenBridge.json similarity index 100% rename from packages/contracts-bedrock/snapshots/storageLayout/SuperchainERC20Bridge.json rename to packages/contracts-bedrock/snapshots/storageLayout/SuperchainTokenBridge.json diff --git a/packages/contracts-bedrock/src/L2/SuperchainERC20.sol b/packages/contracts-bedrock/src/L2/SuperchainERC20.sol index e2fb81bdc084..e55f4e9a2012 100644 --- a/packages/contracts-bedrock/src/L2/SuperchainERC20.sol +++ b/packages/contracts-bedrock/src/L2/SuperchainERC20.sol @@ -8,15 +8,15 @@ import { ERC20 } from "@solady/tokens/ERC20.sol"; /// @title SuperchainERC20 /// @notice SuperchainERC20 is a standard extension of the base ERC20 token contract that unifies ERC20 token -/// bridging to make it fungible across the Superchain. This construction allows the SuperchainERC20Bridge to +/// bridging to make it fungible across the Superchain. This construction allows the SuperchainTokenBridge to /// burn and mint tokens. abstract contract SuperchainERC20 is ERC20, ICrosschainERC20, ISemver { - /// @notice Thrown when attempting to mint or burn tokens and the function caller is not the SuperchainERC20Bridge. - error OnlySuperchainERC20Bridge(); + /// @notice Thrown when attempting to mint or burn tokens and the function caller is not the SuperchainTokenBridge. + error OnlySuperchainTokenBridge(); - /// @notice A modifier that only allows the SuperchainERC20Bridge to call - modifier onlySuperchainERC20Bridge() { - if (msg.sender != Predeploys.SUPERCHAIN_ERC20_BRIDGE) revert OnlySuperchainERC20Bridge(); + /// @notice A modifier that only allows the SuperchainTokenBridge to call + modifier onlySuperchainTokenBridge() { + if (msg.sender != Predeploys.SUPERCHAIN_TOKEN_BRIDGE) revert OnlySuperchainTokenBridge(); _; } @@ -26,19 +26,19 @@ abstract contract SuperchainERC20 is ERC20, ICrosschainERC20, ISemver { return "1.0.0-beta.1"; } - /// @notice Allows the SuperchainERC20Bridge to mint tokens. + /// @notice Allows the SuperchainTokenBridge to mint tokens. /// @param _to Address to mint tokens to. /// @param _amount Amount of tokens to mint. - function __crosschainMint(address _to, uint256 _amount) external virtual onlySuperchainERC20Bridge { + function __crosschainMint(address _to, uint256 _amount) external virtual onlySuperchainTokenBridge { _mint(_to, _amount); emit CrosschainMinted(_to, _amount); } - /// @notice Allows the SuperchainERC20Bridge to burn tokens. + /// @notice Allows the SuperchainTokenBridge to burn tokens. /// @param _from Address to burn tokens from. /// @param _amount Amount of tokens to burn. - function __crosschainBurn(address _from, uint256 _amount) external virtual onlySuperchainERC20Bridge { + function __crosschainBurn(address _from, uint256 _amount) external virtual onlySuperchainTokenBridge { _burn(_from, _amount); emit CrosschainBurnt(_from, _amount); diff --git a/packages/contracts-bedrock/src/L2/SuperchainERC20Bridge.sol b/packages/contracts-bedrock/src/L2/SuperchainTokenBridge.sol similarity index 96% rename from packages/contracts-bedrock/src/L2/SuperchainERC20Bridge.sol rename to packages/contracts-bedrock/src/L2/SuperchainTokenBridge.sol index dc6cd86b04bd..37d5e5ae36b6 100644 --- a/packages/contracts-bedrock/src/L2/SuperchainERC20Bridge.sol +++ b/packages/contracts-bedrock/src/L2/SuperchainTokenBridge.sol @@ -10,11 +10,11 @@ import { IL2ToL2CrossDomainMessenger } from "src/L2/interfaces/IL2ToL2CrossDomai /// @custom:proxied true /// @custom:predeploy 0x4200000000000000000000000000000000000028 -/// @title SuperchainERC20Bridge -/// @notice The SuperchainERC20Bridge allows for the bridging of ERC20 tokens to make them fungible across the +/// @title SuperchainTokenBridge +/// @notice The SuperchainTokenBridge allows for the bridging of ERC20 tokens to make them fungible across the /// Superchain. It builds on top of the L2ToL2CrossDomainMessenger for both replay protection and domain /// binding. -contract SuperchainERC20Bridge { +contract SuperchainTokenBridge { /// @notice Thrown when attempting to perform an operation and the account is the zero address. error ZeroAddress(); @@ -23,7 +23,7 @@ contract SuperchainERC20Bridge { error CallerNotL2ToL2CrossDomainMessenger(); /// @notice Thrown when attempting to relay a message and the cross domain message sender is not the - /// SuperchainERC20Bridge. + /// SuperchainTokenBridge. error InvalidCrossDomainSender(); /// @notice Emitted when tokens are sent from one chain to another. diff --git a/packages/contracts-bedrock/src/L2/interfaces/IOptimismSuperchainERC20Factory.sol b/packages/contracts-bedrock/src/L2/interfaces/IOptimismSuperchainERC20Factory.sol index d501bc51b28d..2f5c4db34a7f 100644 --- a/packages/contracts-bedrock/src/L2/interfaces/IOptimismSuperchainERC20Factory.sol +++ b/packages/contracts-bedrock/src/L2/interfaces/IOptimismSuperchainERC20Factory.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import { IOptimismERC20Factory } from "./IOptimismERC20Factory.sol"; +import { IOptimismERC20Factory } from "src/L2/interfaces/IOptimismERC20Factory.sol"; import { ISemver } from "src/universal/interfaces/ISemver.sol"; /// @title IOptimismSuperchainERC20Factory diff --git a/packages/contracts-bedrock/src/L2/interfaces/ISuperchainERC20.sol b/packages/contracts-bedrock/src/L2/interfaces/ISuperchainERC20.sol index c10b32eaa5af..ceca21546919 100644 --- a/packages/contracts-bedrock/src/L2/interfaces/ISuperchainERC20.sol +++ b/packages/contracts-bedrock/src/L2/interfaces/ISuperchainERC20.sol @@ -9,7 +9,7 @@ import { ISemver } from "src/universal/interfaces/ISemver.sol"; /// @title ISuperchainERC20 /// @notice This interface is available on the SuperchainERC20 contract. interface ISuperchainERC20 is ICrosschainERC20, IERC20Solady, ISemver { - error OnlySuperchainERC20Bridge(); + error OnlySuperchainTokenBridge(); function __constructor__() external; } diff --git a/packages/contracts-bedrock/src/L2/interfaces/ISuperchainERC20Bridge.sol b/packages/contracts-bedrock/src/L2/interfaces/ISuperchainTokenBridge.sol similarity index 85% rename from packages/contracts-bedrock/src/L2/interfaces/ISuperchainERC20Bridge.sol rename to packages/contracts-bedrock/src/L2/interfaces/ISuperchainTokenBridge.sol index e4c7cc127598..a99d188d1c55 100644 --- a/packages/contracts-bedrock/src/L2/interfaces/ISuperchainERC20Bridge.sol +++ b/packages/contracts-bedrock/src/L2/interfaces/ISuperchainTokenBridge.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.0; import { ISemver } from "src/universal/interfaces/ISemver.sol"; -/// @title ISuperchainERC20Bridge -/// @notice Interface for the SuperchainERC20Bridge contract. -interface ISuperchainERC20Bridge is ISemver { +/// @title ISuperchainTokenBridge +/// @notice Interface for the SuperchainTokenBridge contract. +interface ISuperchainTokenBridge is ISemver { error ZeroAddress(); error CallerNotL2ToL2CrossDomainMessenger(); error InvalidCrossDomainSender(); diff --git a/packages/contracts-bedrock/src/libraries/Predeploys.sol b/packages/contracts-bedrock/src/libraries/Predeploys.sol index 5bc1d75a1f06..30cad3b1f854 100644 --- a/packages/contracts-bedrock/src/libraries/Predeploys.sol +++ b/packages/contracts-bedrock/src/libraries/Predeploys.sol @@ -105,8 +105,8 @@ library Predeploys { /// @notice Arbitrary address of the OptimismSuperchainERC20 implementation contract. address internal constant OPTIMISM_SUPERCHAIN_ERC20 = 0xB9415c6cA93bdC545D4c5177512FCC22EFa38F28; - /// @notice Address of the SuperchainERC20Bridge predeploy. - address internal constant SUPERCHAIN_ERC20_BRIDGE = 0x4200000000000000000000000000000000000028; + /// @notice Address of the SuperchainTokenBridge predeploy. + address internal constant SUPERCHAIN_TOKEN_BRIDGE = 0x4200000000000000000000000000000000000028; /// @notice Returns the name of the predeploy at the given address. function getName(address _addr) internal pure returns (string memory out_) { @@ -138,7 +138,7 @@ library Predeploys { if (_addr == ETH_LIQUIDITY) return "ETHLiquidity"; if (_addr == OPTIMISM_SUPERCHAIN_ERC20_FACTORY) return "OptimismSuperchainERC20Factory"; if (_addr == OPTIMISM_SUPERCHAIN_ERC20_BEACON) return "OptimismSuperchainERC20Beacon"; - if (_addr == SUPERCHAIN_ERC20_BRIDGE) return "SuperchainERC20Bridge"; + if (_addr == SUPERCHAIN_TOKEN_BRIDGE) return "SuperchainTokenBridge"; revert("Predeploys: unnamed predeploy"); } @@ -159,7 +159,7 @@ library Predeploys { || (_useInterop && _addr == SUPERCHAIN_WETH) || (_useInterop && _addr == ETH_LIQUIDITY) || (_useInterop && _addr == OPTIMISM_SUPERCHAIN_ERC20_FACTORY) || (_useInterop && _addr == OPTIMISM_SUPERCHAIN_ERC20_BEACON) - || (_useInterop && _addr == SUPERCHAIN_ERC20_BRIDGE); + || (_useInterop && _addr == SUPERCHAIN_TOKEN_BRIDGE); } function isPredeployNamespace(address _addr) internal pure returns (bool) { diff --git a/packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol b/packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol index 976f5799200a..3f360bebe14d 100644 --- a/packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol +++ b/packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol @@ -19,20 +19,20 @@ import { BeaconProxy } from "@openzeppelin/contracts-v5/proxy/beacon/BeaconProxy import { SuperchainERC20 } from "src/L2/SuperchainERC20.sol"; import { ICrosschainERC20 } from "src/L2/interfaces/ICrosschainERC20.sol"; import { ISuperchainERC20 } from "src/L2/interfaces/ISuperchainERC20.sol"; -import { SuperchainERC20Implementation_MockContract } from "test/mocks/SuperchainERC20Implementation.sol"; +import { SuperchainERC20Implementation_mock } from "test/mocks/SuperchainERC20Implementation.sol"; /// @title SuperchainERC20Test /// @notice Contract for testing the SuperchainERC20 contract. contract SuperchainERC20Test is Test { address internal constant ZERO_ADDRESS = address(0); - address internal constant SUPERCHAIN_ERC20_BRIDGE = Predeploys.SUPERCHAIN_ERC20_BRIDGE; + address internal constant SUPERCHAIN_TOKEN_BRIDGE = Predeploys.SUPERCHAIN_TOKEN_BRIDGE; address internal constant MESSENGER = Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER; SuperchainERC20 public superchainERC20; /// @notice Sets up the test suite. function setUp() public { - superchainERC20 = new SuperchainERC20Implementation_MockContract(); + superchainERC20 = new SuperchainERC20Implementation_mock(); } /// @notice Helper function to setup a mock and expect a call to it. @@ -44,10 +44,10 @@ contract SuperchainERC20Test is Test { /// @notice Tests the `mint` function reverts when the caller is not the bridge. function testFuzz___crosschainMint_callerNotBridge_reverts(address _caller, address _to, uint256 _amount) public { // Ensure the caller is not the bridge - vm.assume(_caller != SUPERCHAIN_ERC20_BRIDGE); + vm.assume(_caller != SUPERCHAIN_TOKEN_BRIDGE); - // Expect the revert with `OnlySuperchainERC20Bridge` selector - vm.expectRevert(ISuperchainERC20.OnlySuperchainERC20Bridge.selector); + // Expect the revert with `OnlySuperchainTokenBridge` selector + vm.expectRevert(ISuperchainERC20.OnlySuperchainTokenBridge.selector); // Call the `mint` function with the non-bridge caller vm.prank(_caller); @@ -72,7 +72,7 @@ contract SuperchainERC20Test is Test { emit ICrosschainERC20.CrosschainMinted(_to, _amount); // Call the `mint` function with the bridge caller - vm.prank(SUPERCHAIN_ERC20_BRIDGE); + vm.prank(SUPERCHAIN_TOKEN_BRIDGE); superchainERC20.__crosschainMint(_to, _amount); // Check the total supply and balance of `_to` after the mint were updated correctly @@ -89,10 +89,10 @@ contract SuperchainERC20Test is Test { public { // Ensure the caller is not the bridge - vm.assume(_caller != SUPERCHAIN_ERC20_BRIDGE); + vm.assume(_caller != SUPERCHAIN_TOKEN_BRIDGE); - // Expect the revert with `OnlySuperchainERC20Bridge` selector - vm.expectRevert(ISuperchainERC20.OnlySuperchainERC20Bridge.selector); + // Expect the revert with `OnlySuperchainTokenBridge` selector + vm.expectRevert(ISuperchainERC20.OnlySuperchainTokenBridge.selector); // Call the `burn` function with the non-bridge caller vm.prank(_caller); @@ -105,7 +105,7 @@ contract SuperchainERC20Test is Test { vm.assume(_from != ZERO_ADDRESS); // Mint some tokens to `_from` so then they can be burned - vm.prank(SUPERCHAIN_ERC20_BRIDGE); + vm.prank(SUPERCHAIN_TOKEN_BRIDGE); superchainERC20.__crosschainMint(_from, _amount); // Get the total supply and balance of `_from` before the burn to compare later on the assertions @@ -121,7 +121,7 @@ contract SuperchainERC20Test is Test { emit ICrosschainERC20.CrosschainBurnt(_from, _amount); // Call the `burn` function with the bridge caller - vm.prank(SUPERCHAIN_ERC20_BRIDGE); + vm.prank(SUPERCHAIN_TOKEN_BRIDGE); superchainERC20.__crosschainBurn(_from, _amount); // Check the total supply and balance of `_from` after the burn were updated correctly diff --git a/packages/contracts-bedrock/test/L2/SuperchainERC20Bridge.t.sol b/packages/contracts-bedrock/test/L2/SuperchainTokenBridge.t.sol similarity index 87% rename from packages/contracts-bedrock/test/L2/SuperchainERC20Bridge.t.sol rename to packages/contracts-bedrock/test/L2/SuperchainTokenBridge.t.sol index dd77b80316b9..37f8e4b7e567 100644 --- a/packages/contracts-bedrock/test/L2/SuperchainERC20Bridge.t.sol +++ b/packages/contracts-bedrock/test/L2/SuperchainTokenBridge.t.sol @@ -9,14 +9,14 @@ import { Predeploys } from "src/libraries/Predeploys.sol"; import { IL2ToL2CrossDomainMessenger } from "src/L2/interfaces/IL2ToL2CrossDomainMessenger.sol"; // Target contract -import { ISuperchainERC20Bridge } from "src/L2/interfaces/ISuperchainERC20Bridge.sol"; +import { ISuperchainTokenBridge } from "src/L2/interfaces/ISuperchainTokenBridge.sol"; import { ISuperchainERC20 } from "src/L2/interfaces/ISuperchainERC20.sol"; import { IOptimismSuperchainERC20Factory } from "src/L2/interfaces/IOptimismSuperchainERC20Factory.sol"; import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol"; -/// @title SuperchainERC20BridgeTest -/// @notice Contract for testing the SuperchainERC20Bridge contract. -contract SuperchainERC20BridgeTest is Bridge_Initializer { +/// @title SuperchainTokenBridgeTest +/// @notice Contract for testing the SuperchainTokenBridge contract. +contract SuperchainTokenBridgeTest is Bridge_Initializer { address internal constant ZERO_ADDRESS = address(0); string internal constant NAME = "SuperchainERC20"; string internal constant SYMBOL = "OSE"; @@ -53,11 +53,11 @@ contract SuperchainERC20BridgeTest is Bridge_Initializer { /// @notice Tests the `sendERC20` function reverts when the address `_to` is zero. function testFuzz_sendERC20_zeroAddressTo_reverts(address _sender, uint256 _amount, uint256 _chainId) public { // Expect the revert with `ZeroAddress` selector - vm.expectRevert(ISuperchainERC20Bridge.ZeroAddress.selector); + vm.expectRevert(ISuperchainTokenBridge.ZeroAddress.selector); // Call the `sendERC20` function with the zero address as `_to` vm.prank(_sender); - superchainERC20Bridge.sendERC20(address(superchainERC20), ZERO_ADDRESS, _amount, _chainId); + superchainTokenBridge.sendERC20(address(superchainERC20), ZERO_ADDRESS, _amount, _chainId); } /// @notice Tests the `sendERC20` function burns the sender tokens, sends the message, and emits the `SendERC20` @@ -76,7 +76,7 @@ contract SuperchainERC20BridgeTest is Bridge_Initializer { vm.assume(_to != ZERO_ADDRESS); // Mint some tokens to the sender so then they can be sent - vm.prank(Predeploys.SUPERCHAIN_ERC20_BRIDGE); + vm.prank(Predeploys.SUPERCHAIN_TOKEN_BRIDGE); superchainERC20.__crosschainMint(_sender, _amount); // Get the total supply and balance of `_sender` before the send to compare later on the assertions @@ -88,23 +88,23 @@ contract SuperchainERC20BridgeTest is Bridge_Initializer { emit Transfer(_sender, ZERO_ADDRESS, _amount); // Look for the emit of the `SendERC20` event - vm.expectEmit(address(superchainERC20Bridge)); + vm.expectEmit(address(superchainTokenBridge)); emit SendERC20(address(superchainERC20), _sender, _to, _amount, _chainId); // Mock the call over the `sendMessage` function and expect it to be called properly bytes memory _message = - abi.encodeCall(superchainERC20Bridge.relayERC20, (address(superchainERC20), _sender, _to, _amount)); + abi.encodeCall(superchainTokenBridge.relayERC20, (address(superchainERC20), _sender, _to, _amount)); _mockAndExpect( Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, abi.encodeWithSelector( - IL2ToL2CrossDomainMessenger.sendMessage.selector, _chainId, address(superchainERC20Bridge), _message + IL2ToL2CrossDomainMessenger.sendMessage.selector, _chainId, address(superchainTokenBridge), _message ), abi.encode(_msgHash) ); // Call the `sendERC20` function vm.prank(_sender); - bytes32 _returnedMsgHash = superchainERC20Bridge.sendERC20(address(superchainERC20), _to, _amount, _chainId); + bytes32 _returnedMsgHash = superchainTokenBridge.sendERC20(address(superchainERC20), _to, _amount, _chainId); // Check the message hash was generated correctly assertEq(_msgHash, _returnedMsgHash); @@ -127,15 +127,15 @@ contract SuperchainERC20BridgeTest is Bridge_Initializer { vm.assume(_caller != Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER); // Expect the revert with `CallerNotL2ToL2CrossDomainMessenger` selector - vm.expectRevert(ISuperchainERC20Bridge.CallerNotL2ToL2CrossDomainMessenger.selector); + vm.expectRevert(ISuperchainTokenBridge.CallerNotL2ToL2CrossDomainMessenger.selector); // Call the `relayERC20` function with the non-messenger caller vm.prank(_caller); - superchainERC20Bridge.relayERC20(_token, _caller, _to, _amount); + superchainTokenBridge.relayERC20(_token, _caller, _to, _amount); } /// @notice Tests the `relayERC20` function reverts when the `crossDomainMessageSender` that sent the message is not - /// the same SuperchainERC20Bridge. + /// the same SuperchainTokenBridge. function testFuzz_relayERC20_notCrossDomainSender_reverts( address _token, address _crossDomainMessageSender, @@ -144,7 +144,7 @@ contract SuperchainERC20BridgeTest is Bridge_Initializer { ) public { - vm.assume(_crossDomainMessageSender != address(superchainERC20Bridge)); + vm.assume(_crossDomainMessageSender != address(superchainTokenBridge)); // Mock the call over the `crossDomainMessageSender` function setting a wrong sender vm.mockCall( @@ -154,11 +154,11 @@ contract SuperchainERC20BridgeTest is Bridge_Initializer { ); // Expect the revert with `InvalidCrossDomainSender` selector - vm.expectRevert(ISuperchainERC20Bridge.InvalidCrossDomainSender.selector); + vm.expectRevert(ISuperchainTokenBridge.InvalidCrossDomainSender.selector); // Call the `relayERC20` function with the sender caller vm.prank(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER); - superchainERC20Bridge.relayERC20(_token, _crossDomainMessageSender, _to, _amount); + superchainTokenBridge.relayERC20(_token, _crossDomainMessageSender, _to, _amount); } /// @notice Tests the `relayERC20` mints the proper amount and emits the `RelayERC20` event. @@ -169,7 +169,7 @@ contract SuperchainERC20BridgeTest is Bridge_Initializer { _mockAndExpect( Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, abi.encodeWithSelector(IL2ToL2CrossDomainMessenger.crossDomainMessageSender.selector), - abi.encode(address(superchainERC20Bridge)) + abi.encode(address(superchainTokenBridge)) ); // Mock the call over the `crossDomainMessageSource` function setting the source chain ID as value @@ -188,12 +188,12 @@ contract SuperchainERC20BridgeTest is Bridge_Initializer { emit Transfer(ZERO_ADDRESS, _to, _amount); // Look for the emit of the `RelayERC20` event - vm.expectEmit(address(superchainERC20Bridge)); + vm.expectEmit(address(superchainTokenBridge)); emit RelayERC20(address(superchainERC20), _from, _to, _amount, _source); // Call the `relayERC20` function with the messenger caller vm.prank(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER); - superchainERC20Bridge.relayERC20(address(superchainERC20), _from, _to, _amount); + superchainTokenBridge.relayERC20(address(superchainERC20), _from, _to, _amount); // Check the total supply and balance of `_to` after the relay were updated correctly assertEq(IERC20(address(superchainERC20)).totalSupply(), _totalSupplyBefore + _amount); diff --git a/packages/contracts-bedrock/test/mocks/SuperchainERC20Implementation.sol b/packages/contracts-bedrock/test/mocks/SuperchainERC20Implementation.sol index 4f3dec45896c..5b84b075fa6d 100644 --- a/packages/contracts-bedrock/test/mocks/SuperchainERC20Implementation.sol +++ b/packages/contracts-bedrock/test/mocks/SuperchainERC20Implementation.sol @@ -5,7 +5,7 @@ import { SuperchainERC20 } from "src/L2/SuperchainERC20.sol"; /// @title SuperchainERC20Implementation Mock contract /// @notice Mock contract just to create tests over an implementation of the SuperchainERC20 abstract contract. -contract SuperchainERC20Implementation_MockContract is SuperchainERC20 { +contract SuperchainERC20Implementation_mock is SuperchainERC20 { /// @notice Semantic version. /// @custom:semver 1.0.0-beta.1 string public constant override version = "1.0.0-beta.1"; diff --git a/packages/contracts-bedrock/test/setup/Setup.sol b/packages/contracts-bedrock/test/setup/Setup.sol index 2af8b6d04e40..3f63da993b81 100644 --- a/packages/contracts-bedrock/test/setup/Setup.sol +++ b/packages/contracts-bedrock/test/setup/Setup.sol @@ -49,7 +49,7 @@ import { IETHLiquidity } from "src/L2/interfaces/IETHLiquidity.sol"; import { IWETH } from "src/universal/interfaces/IWETH.sol"; import { IGovernanceToken } from "src/governance/interfaces/IGovernanceToken.sol"; import { ILegacyMessagePasser } from "src/legacy/interfaces/ILegacyMessagePasser.sol"; -import { ISuperchainERC20Bridge } from "src/L2/interfaces/ISuperchainERC20Bridge.sol"; +import { ISuperchainTokenBridge } from "src/L2/interfaces/ISuperchainTokenBridge.sol"; /// @title Setup /// @dev This contact is responsible for setting up the contracts in state. It currently @@ -107,7 +107,7 @@ contract Setup { IWETH weth = IWETH(payable(Predeploys.WETH)); ISuperchainWETHERC20 superchainWeth = ISuperchainWETHERC20(payable(Predeploys.SUPERCHAIN_WETH)); IETHLiquidity ethLiquidity = IETHLiquidity(Predeploys.ETH_LIQUIDITY); - ISuperchainERC20Bridge superchainERC20Bridge = ISuperchainERC20Bridge(Predeploys.SUPERCHAIN_ERC20_BRIDGE); + ISuperchainTokenBridge superchainTokenBridge = ISuperchainTokenBridge(Predeploys.SUPERCHAIN_TOKEN_BRIDGE); IOptimismSuperchainERC20Factory l2OptimismSuperchainERC20Factory = IOptimismSuperchainERC20Factory(Predeploys.OPTIMISM_SUPERCHAIN_ERC20_FACTORY); @@ -231,7 +231,7 @@ contract Setup { labelPredeploy(Predeploys.ETH_LIQUIDITY); labelPredeploy(Predeploys.OPTIMISM_SUPERCHAIN_ERC20_FACTORY); labelPredeploy(Predeploys.OPTIMISM_SUPERCHAIN_ERC20_BEACON); - labelPredeploy(Predeploys.SUPERCHAIN_ERC20_BRIDGE); + labelPredeploy(Predeploys.SUPERCHAIN_TOKEN_BRIDGE); // L2 Preinstalls labelPreinstall(Preinstalls.MultiCall3);