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
624 changes: 624 additions & 0 deletions op-e2e/system/gastoken/gastoken_test.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.0;
import { IStandardBridge } from "interfaces/universal/IStandardBridge.sol";
import { ICrossDomainMessenger } from "interfaces/universal/ICrossDomainMessenger.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";

interface IL1StandardBridge is IStandardBridge {
event ERC20DepositInitiated(
Expand Down Expand Up @@ -63,7 +64,8 @@ interface IL1StandardBridge is IStandardBridge {
payable;
function initialize(
ICrossDomainMessenger _messenger,
ISuperchainConfig _superchainConfig
ISuperchainConfig _superchainConfig,
ISystemConfig _systemConfig
)
external;
function l2TokenBridge() external view returns (address);
Expand Down
15 changes: 15 additions & 0 deletions packages/contracts-bedrock/interfaces/L1/IOptimismPortal2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";

interface IOptimismPortal2 {
error CustomGasTokenNotSupported();
error AlreadyFinalized();
error BadTarget();
error Blacklisted();
Expand All @@ -23,10 +24,13 @@ interface IOptimismPortal2 {
error InvalidMerkleProof();
error InvalidProof();
error LargeCalldata();
error NoValue();
error NonReentrant();
error OnlyCustomGasToken();
error OutOfGas();
error ProposalNotValidated();
error SmallGasLimit();
error TransferFailed();
error Unauthorized();
error UnexpectedList();
error UnexpectedString();
Expand All @@ -43,8 +47,18 @@ interface IOptimismPortal2 {

receive() external payable;

function balance() external view returns (uint256);
function blacklistDisputeGame(IDisputeGame _disputeGame) external;
function checkWithdrawal(bytes32 _withdrawalHash, address _proofSubmitter) external view;
function depositERC20Transaction(
address _to,
uint256 _mint,
uint256 _value,
uint64 _gasLimit,
bool _isCreation,
bytes memory _data
)
external;
function depositTransaction(
address _to,
uint256 _value,
Expand Down Expand Up @@ -96,6 +110,7 @@ interface IOptimismPortal2 {
returns (IDisputeGame disputeGameProxy, uint64 timestamp); // nosemgrep
function respectedGameType() external view returns (GameType);
function respectedGameTypeUpdatedAt() external view returns (uint64);
function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external;
function setRespectedGameType(GameType _gameType) external;
function superchainConfig() external view returns (ISuperchainConfig);
function systemConfig() external view returns (ISystemConfig);
Expand Down
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 All @@ -24,10 +25,13 @@ interface IOptimismPortalInterop {
error InvalidMerkleProof();
error InvalidProof();
error LargeCalldata();
error NoValue();
error NonReentrant();
error OnlyCustomGasToken();
error OutOfGas();
error ProposalNotValidated();
error SmallGasLimit();
error TransferFailed();
error Unauthorized();
error UnexpectedList();
error UnexpectedString();
Expand All @@ -44,8 +48,18 @@ interface IOptimismPortalInterop {

receive() external payable;

function balance() external view returns (uint256);
function blacklistDisputeGame(IDisputeGame _disputeGame) external;
function checkWithdrawal(bytes32 _withdrawalHash, address _proofSubmitter) external view;
function depositERC20Transaction(
address _to,
uint256 _mint,
uint256 _value,
uint64 _gasLimit,
bool _isCreation,
bytes memory _data
)
external;
function depositTransaction(
address _to,
uint256 _value,
Expand Down Expand Up @@ -98,6 +112,7 @@ interface IOptimismPortalInterop {
function respectedGameType() external view returns (GameType);
function respectedGameTypeUpdatedAt() external view returns (uint64);
function setConfig(ConfigType _type, bytes memory _value) external;
function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external;
function setRespectedGameType(GameType _gameType) external;
function superchainConfig() external view returns (ISuperchainConfig);
function systemConfig() external view returns (ISystemConfig);
Expand Down
8 changes: 8 additions & 0 deletions packages/contracts-bedrock/interfaces/L1/ISystemConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ 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 {
error CustomGasTokenNotSupported();

enum UpdateType {
BATCHER,
FEE_SCALARS,
Expand All @@ -19,6 +22,7 @@ interface ISystemConfig {
address disputeGameFactory;
address optimismPortal;
address optimismMintableERC20Factory;
address gasPayingToken;
}

event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
Expand All @@ -44,6 +48,9 @@ interface ISystemConfig {
function eip1559Denominator() external view returns (uint32);
function eip1559Elasticity() external view returns (uint32);
function getAddresses() external view returns (Addresses memory);
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 initialize(
address _owner,
uint32 _basefeeScalar,
Expand All @@ -56,6 +63,7 @@ interface ISystemConfig {
Addresses memory _addresses
)
external;
function isCustomGasToken() external view returns (bool);
function l1CrossDomainMessenger() external view returns (address addr_);
function l1ERC721Bridge() external view returns (address addr_);
function l1StandardBridge() external view returns (address addr_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";

interface ISystemConfigInterop {
error CustomGasTokenNotSupported();

event ConfigUpdate(uint256 indexed version, ISystemConfig.UpdateType indexed updateType, bytes data);
event Initialized(uint8 version);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
Expand All @@ -27,6 +29,10 @@ interface ISystemConfigInterop {
function gasLimit() external view returns (uint64);
function eip1559Denominator() external view returns (uint32);
function eip1559Elasticity() external view returns (uint32);
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 isCustomGasToken() external view returns (bool);
function l1CrossDomainMessenger() external view returns (address addr_);
function l1ERC721Bridge() external view returns (address addr_);
function l1StandardBridge() external view returns (address addr_);
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
16 changes: 15 additions & 1 deletion 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 @@ -305,6 +311,8 @@ contract Deploy is Deployer {
artifacts.save("MipsSingleton", address(dio.mipsSingleton()));
artifacts.save("OPContractsManager", address(dio.opcm()));
artifacts.save("DelayedWETHImpl", address(dio.delayedWETHImpl()));
// added for CGT
artifacts.save("SystemConfigImpl", address(dio.systemConfigImpl()));

// Get a contract set from the implementation addresses which were just deployed.
Types.ContractSet memory impls = Types.ContractSet({
Expand Down Expand Up @@ -499,6 +507,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 All @@ -520,7 +533,8 @@ contract Deploy is Deployer {
l1StandardBridge: artifacts.mustGetAddress("L1StandardBridgeProxy"),
disputeGameFactory: artifacts.mustGetAddress("DisputeGameFactoryProxy"),
optimismPortal: artifacts.mustGetAddress("OptimismPortalProxy"),
optimismMintableERC20Factory: artifacts.mustGetAddress("OptimismMintableERC20FactoryProxy")
optimismMintableERC20Factory: artifacts.mustGetAddress("OptimismMintableERC20FactoryProxy"),
gasPayingToken: customGasTokenAddress
})
)
)
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
2 changes: 2 additions & 0 deletions packages/contracts-bedrock/scripts/deploy/DeployOPChain.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ contract DeployOPChain is Script {
systemConfig.optimismMintableERC20Factory() == address(_doo.optimismMintableERC20FactoryProxy()),
"SYSCON-210"
);
(address gasPayingToken,) = systemConfig.gasPayingToken();
require(gasPayingToken == Constants.ETHER, "SYSCON-220");
}

function assertValidL1CrossDomainMessenger(DeployOPChainInput _doi, DeployOPChainOutput _doo) internal {
Expand Down
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
Loading