Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { ConfigType } from "interfaces/L2/IL1BlockInterop.sol";

interface IOptimismPortalInterop {
error CustomGasTokenNotSupported();
error AlreadyFinalized();
error BadTarget();
error Blacklisted();
Expand Down
1 change: 1 addition & 0 deletions packages/contracts-bedrock/interfaces/L1/ISystemConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.0;

import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";

/// @notice This interface corresponds to the Custom Gas Token version of the SystemConfig contract.
interface ISystemConfig {
enum UpdateType {
BATCHER,
Expand Down
1 change: 1 addition & 0 deletions packages/contracts-bedrock/interfaces/L2/IETHLiquidity.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.0;

interface IETHLiquidity {
error NotCustomGasToken();
error Unauthorized();

event LiquidityBurned(address indexed caller, uint256 value);
Expand Down
13 changes: 9 additions & 4 deletions packages/contracts-bedrock/interfaces/L2/IL1Block.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@
pragma solidity ^0.8.0;

interface IL1Block {
error NotDepositor();

event GasPayingTokenSet(address indexed token, uint8 indexed decimals, bytes32 name, bytes32 symbol);

function DEPOSITOR_ACCOUNT() external pure returns (address addr_);
function baseFeeScalar() external view returns (uint32);
function basefee() external view returns (uint256);
function batcherHash() external view returns (bytes32);
function blobBaseFee() external view returns (uint256);
function blobBaseFeeScalar() external view returns (uint32);
function gasPayingToken() external pure returns (address addr_, uint8 decimals_);
function gasPayingTokenName() external pure returns (string memory name_);
function gasPayingTokenSymbol() external pure returns (string memory symbol_);
function gasPayingToken() external view returns (address addr_, uint8 decimals_);
function gasPayingTokenName() external view returns (string memory name_);
function gasPayingTokenSymbol() external view returns (string memory symbol_);
function hash() external view returns (bytes32);
function isCustomGasToken() external pure returns (bool is_);
function isCustomGasToken() external view returns (bool);
function l1FeeOverhead() external view returns (uint256);
function l1FeeScalar() external view returns (uint256);
function number() external view returns (uint64);
function sequenceNumber() external view returns (uint64);
function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external;
function setL1BlockValues(
uint64 _number,
uint64 _timestamp,
Expand Down
11 changes: 7 additions & 4 deletions packages/contracts-bedrock/interfaces/L2/IL1BlockInterop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.0;

enum ConfigType {
SET_GAS_PAYING_TOKEN,
ADD_DEPENDENCY,
REMOVE_DEPENDENCY
}
Expand All @@ -16,6 +17,7 @@ interface IL1BlockInterop {

event DependencyAdded(uint256 indexed chainId);
event DependencyRemoved(uint256 indexed chainId);
event GasPayingTokenSet(address indexed token, uint8 indexed decimals, bytes32 name, bytes32 symbol);

function DEPOSITOR_ACCOUNT() external pure returns (address addr_);
function baseFeeScalar() external view returns (uint32);
Expand All @@ -25,18 +27,19 @@ interface IL1BlockInterop {
function blobBaseFeeScalar() external view returns (uint32);
function dependencySetSize() external view returns (uint8);
function depositsComplete() external;
function gasPayingToken() external pure returns (address addr_, uint8 decimals_);
function gasPayingTokenName() external pure returns (string memory name_);
function gasPayingTokenSymbol() external pure returns (string memory symbol_);
function gasPayingToken() external view returns (address addr_, uint8 decimals_);
function gasPayingTokenName() external view returns (string memory name_);
function gasPayingTokenSymbol() external view returns (string memory symbol_);
function hash() external view returns (bytes32);
function isCustomGasToken() external pure returns (bool is_);
function isCustomGasToken() external view returns (bool);
function isDeposit() external view returns (bool isDeposit_);
function isInDependencySet(uint256 _chainId) external view returns (bool);
function l1FeeOverhead() external view returns (uint256);
function l1FeeScalar() external view returns (uint256);
function number() external view returns (uint64);
function sequenceNumber() external view returns (uint64);
function setConfig(ConfigType _type, bytes memory _value) external;
function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external;
function setL1BlockValues(
uint64 _number,
uint64 _timestamp,
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts-bedrock/interfaces/L2/ISuperchainWETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ISemver } from "interfaces/universal/ISemver.sol";

interface ISuperchainWETH is IWETH98, IERC7802, ISemver {
error Unauthorized();
error NotCustomGasToken();
error InvalidCrossDomainSender();
error ZeroAddress();

Expand All @@ -15,7 +16,7 @@ interface ISuperchainWETH is IWETH98, IERC7802, ISemver {
event RelayETH(address indexed from, address indexed to, uint256 amount, uint256 source);

function balanceOf(address src) external view returns (uint256);
function withdraw(uint256 wad) external;
function withdraw(uint256 _amount) external;
function supportsInterface(bytes4 _interfaceId) external view returns (bool);
function sendETH(address _to, uint256 _chainId) external payable returns (bytes32 msgHash_);
function relayETH(address _from, address _to, uint256 _amount) external;
Expand Down
11 changes: 11 additions & 0 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ contract Deploy is Deployer {
);
vm.stopPrank();

if (cfg.useCustomGasToken()) {
// Reset the systemconfig then reinitialize it with the custom gas token
resetInitializedProxy("SystemConfig");
initializeSystemConfig();
}

if (cfg.useAltDA()) {
bytes32 typeHash = keccak256(bytes(cfg.daCommitmentType()));
bytes32 keccakHash = keccak256(bytes("KeccakCommitment"));
Expand Down Expand Up @@ -499,6 +505,11 @@ contract Deploy is Deployer {

bytes32 batcherHash = bytes32(uint256(uint160(cfg.batchSenderAddress())));

address customGasTokenAddress = Constants.ETHER;
if (cfg.useCustomGasToken()) {
customGasTokenAddress = cfg.customGasTokenAddress();
}

IProxyAdmin proxyAdmin = IProxyAdmin(payable(artifacts.mustGetAddress("ProxyAdmin")));
proxyAdmin.upgradeAndCall({
_proxy: payable(systemConfigProxy),
Expand Down
12 changes: 12 additions & 0 deletions packages/contracts-bedrock/scripts/deploy/DeployConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ contract DeployConfig is Script {
uint256 public daBondSize;
uint256 public daResolverRefundPercentage;

bool public useCustomGasToken;
address public customGasTokenAddress;

bool public useInterop;
bool public useSoulGasToken;
bool public isSoulBackedByNative;
Expand Down Expand Up @@ -170,6 +173,9 @@ contract DeployConfig is Script {
daBondSize = _readOr(_json, "$.daBondSize", 1000000000);
daResolverRefundPercentage = _readOr(_json, "$.daResolverRefundPercentage", 0);

useCustomGasToken = _readOr(_json, "$.useCustomGasToken", false);
customGasTokenAddress = _readOr(_json, "$.customGasTokenAddress", address(0));

useInterop = _readOr(_json, "$.useInterop", false);
useSoulGasToken = _readOr(_json, "$.useSoulGasToken", false);
isSoulBackedByNative = _readOr(_json, "$.isSoulBackedByNative", false);
Expand Down Expand Up @@ -240,6 +246,12 @@ contract DeployConfig is Script {
fundDevAccounts = _fundDevAccounts;
}

/// @notice Allow the `useCustomGasToken` config to be overridden in testing environments
function setUseCustomGasToken(address _token) public {
useCustomGasToken = true;
customGasTokenAddress = _token;
}

/// @notice Allow the `useUpgradedFork` config to be overridden in testing environments
/// @dev When true, the forked system WILL be upgraded in setUp().
/// When false, the forked system WILL NOT be upgraded in setUp().
Expand Down
13 changes: 13 additions & 0 deletions packages/contracts-bedrock/snapshots/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
GasBenchMark_L1BlockInterop_DepositsComplete:test_depositsComplete_benchmark() (gas: 7589)
GasBenchMark_L1BlockInterop_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5589)
GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchmark() (gas: 175722)
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5144)
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158553)
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7619)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 356487)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2954716)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 551627)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4063775)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 450267)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3496188)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 59798)
5 changes: 5 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/ETHLiquidity.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
"name": "LiquidityMinted",
"type": "event"
},
{
"inputs": [],
"name": "NotCustomGasToken",
"type": "error"
},
{
"inputs": [],
"name": "Unauthorized",
Expand Down
74 changes: 69 additions & 5 deletions packages/contracts-bedrock/snapshots/abi/L1Block.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"type": "uint8"
}
],
"stateMutability": "pure",
"stateMutability": "view",
"type": "function"
},
{
Expand All @@ -124,7 +124,7 @@
"type": "string"
}
],
"stateMutability": "pure",
"stateMutability": "view",
"type": "function"
},
{
Expand All @@ -137,7 +137,7 @@
"type": "string"
}
],
"stateMutability": "pure",
"stateMutability": "view",
"type": "function"
},
{
Expand Down Expand Up @@ -172,11 +172,11 @@
"outputs": [
{
"internalType": "bool",
"name": "is_",
"name": "",
"type": "bool"
}
],
"stateMutability": "pure",
"stateMutability": "view",
"type": "function"
},
{
Expand Down Expand Up @@ -231,6 +231,34 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "uint8",
"name": "_decimals",
"type": "uint8"
},
{
"internalType": "bytes32",
"name": "_name",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "_symbol",
"type": "bytes32"
}
],
"name": "setGasPayingToken",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -311,5 +339,41 @@
],
"stateMutability": "pure",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": true,
"internalType": "uint8",
"name": "decimals",
"type": "uint8"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "name",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "symbol",
"type": "bytes32"
}
],
"name": "GasPayingTokenSet",
"type": "event"
},
{
"inputs": [],
"name": "NotDepositor",
"type": "error"
}
]
Loading