Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: superchain bridge rename #86

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/scripts/Artifacts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ contract L2Genesis is Deployer {
setETHLiquidity(); // 25
setOptimismSuperchainERC20Factory(); // 26
setOptimismSuperchainERC20Beacon(); // 27
setSuperchainERC20Bridge(); // 28
setSuperchainTokenBridge(); // 28
}
}

Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"sourceCodeHash": "0xfea53344596d735eff3be945ed1300dc75a6f8b7b2c02c0043af5b0036f5f239"
},
"src/L2/OptimismSuperchainERC20.sol": {
"initCodeHash": "0x28372d06b45a3235a2c5273e3d6e41fe9572dd58ad8a20161b917d0e45a9718e",
"initCodeHash": "0xadeaebb33c1d758d88d7aadd0ad654c9a1f2d59824c5dad19e1d9cf05ea3e516",
"sourceCodeHash": "0x5a40eabbdc33bd96ff0a7bc2be6699a7b6233610bf67f3da899f0efb367bb486"
},
"src/L2/OptimismSuperchainERC20Beacon.sol": {
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@
},
{
"inputs": [],
"name": "OnlySuperchainERC20Bridge",
"name": "OnlySuperchainTokenBridge",
"type": "error"
},
{
Expand Down
20 changes: 10 additions & 10 deletions packages/contracts-bedrock/src/L2/SuperchainERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
_;
}

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/src/libraries/Predeploys.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down Expand Up @@ -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");
}

Expand All @@ -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) {
Expand Down
24 changes: 12 additions & 12 deletions packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading