Commit b62e7740 authored by Michael Amadi's avatar Michael Amadi Committed by GitHub

temporarily disable custom gas token support (#13603)

* temp disable CGT

* temp disable CGT

* fix tests

* fix tests

* fix tests

* fix tests

* fix go tests

* update tests

* fix tests

* use skipIfForkTest function

* fixes

* fixes
parent 56e753b1
...@@ -44,6 +44,7 @@ func TestCustomGasToken_L2OO(t *testing.T) { ...@@ -44,6 +44,7 @@ func TestCustomGasToken_L2OO(t *testing.T) {
} }
func TestCustomGasToken_Standard(t *testing.T) { func TestCustomGasToken_Standard(t *testing.T) {
t.Skip("Custom gas token not supported")
testCustomGasToken(t, config.AllocTypeStandard) testCustomGasToken(t, config.AllocTypeStandard)
} }
......
...@@ -9,6 +9,7 @@ import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol"; ...@@ -9,6 +9,7 @@ import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol"; import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
interface IOptimismPortal2 { interface IOptimismPortal2 {
error CustomGasTokenNotSupported();
error AlreadyFinalized(); error AlreadyFinalized();
error BadTarget(); error BadTarget();
error Blacklisted(); error Blacklisted();
......
...@@ -10,6 +10,7 @@ import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol"; ...@@ -10,6 +10,7 @@ import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { ConfigType } from "interfaces/L2/IL1BlockInterop.sol"; import { ConfigType } from "interfaces/L2/IL1BlockInterop.sol";
interface IOptimismPortalInterop { interface IOptimismPortalInterop {
error CustomGasTokenNotSupported();
error AlreadyFinalized(); error AlreadyFinalized();
error BadTarget(); error BadTarget();
error Blacklisted(); error Blacklisted();
......
...@@ -5,6 +5,8 @@ import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol"; ...@@ -5,6 +5,8 @@ import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
/// @notice This interface corresponds to the Custom Gas Token version of the SystemConfig contract. /// @notice This interface corresponds to the Custom Gas Token version of the SystemConfig contract.
interface ISystemConfig { interface ISystemConfig {
error CustomGasTokenNotSupported();
enum UpdateType { enum UpdateType {
BATCHER, BATCHER,
FEE_SCALARS, FEE_SCALARS,
......
...@@ -5,6 +5,8 @@ import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol"; ...@@ -5,6 +5,8 @@ import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol"; import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
interface ISystemConfigInterop { interface ISystemConfigInterop {
error CustomGasTokenNotSupported();
event ConfigUpdate(uint256 indexed version, ISystemConfig.UpdateType indexed updateType, bytes data); event ConfigUpdate(uint256 indexed version, ISystemConfig.UpdateType indexed updateType, bytes data);
event Initialized(uint8 version); event Initialized(uint8 version);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
......
...@@ -91,6 +91,8 @@ anvil-fork: ...@@ -91,6 +91,8 @@ anvil-fork:
# Use anvil-fork in a separate terminal before running this command. # Use anvil-fork in a separate terminal before running this command.
# Helpful for debugging. # Helpful for debugging.
test-upgrade-against-anvil *ARGS: build-go-ffi test-upgrade-against-anvil *ARGS: build-go-ffi
#!/bin/bash
export FORK_BLOCK_NUMBER=$pinnedBlockNumber
FORK_RPC_URL=http://127.0.0.1:8545 \ FORK_RPC_URL=http://127.0.0.1:8545 \
FORK_TEST=true \ FORK_TEST=true \
forge test {{ARGS}} forge test {{ARGS}}
......
...@@ -4,10 +4,10 @@ GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchm ...@@ -4,10 +4,10 @@ GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchm
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099) GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099)
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531) GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531)
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597) GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369280) GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369309)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967442) GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967471)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564429) GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564458)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076577) GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076606)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467041) GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467070)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512790) GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512819)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72667) GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72667)
\ No newline at end of file
...@@ -846,6 +846,11 @@ ...@@ -846,6 +846,11 @@
"name": "ContentLengthMismatch", "name": "ContentLengthMismatch",
"type": "error" "type": "error"
}, },
{
"inputs": [],
"name": "CustomGasTokenNotSupported",
"type": "error"
},
{ {
"inputs": [], "inputs": [],
"name": "EmptyItem", "name": "EmptyItem",
......
...@@ -864,6 +864,11 @@ ...@@ -864,6 +864,11 @@
"name": "ContentLengthMismatch", "name": "ContentLengthMismatch",
"type": "error" "type": "error"
}, },
{
"inputs": [],
"name": "CustomGasTokenNotSupported",
"type": "error"
},
{ {
"inputs": [], "inputs": [],
"name": "EmptyItem", "name": "EmptyItem",
......
...@@ -800,5 +800,10 @@ ...@@ -800,5 +800,10 @@
], ],
"name": "OwnershipTransferred", "name": "OwnershipTransferred",
"type": "event" "type": "event"
},
{
"inputs": [],
"name": "CustomGasTokenNotSupported",
"type": "error"
} }
] ]
\ No newline at end of file
...@@ -961,5 +961,10 @@ ...@@ -961,5 +961,10 @@
], ],
"name": "OwnershipTransferred", "name": "OwnershipTransferred",
"type": "event" "type": "event"
},
{
"inputs": [],
"name": "CustomGasTokenNotSupported",
"type": "error"
} }
] ]
\ No newline at end of file
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
"sourceCodeHash": "0xe5179a20ae40d4e4773c52df98bac67e73e04044bec9e8750073b4e2f14fe81b" "sourceCodeHash": "0xe5179a20ae40d4e4773c52df98bac67e73e04044bec9e8750073b4e2f14fe81b"
}, },
"src/L1/OptimismPortal2.sol": { "src/L1/OptimismPortal2.sol": {
"initCodeHash": "0xfd14fd690752519064d6de6c3e15d69ec9146bc8714e56ac286305773dbb1533", "initCodeHash": "0x7e533474310583593c2d57d30fcd1ec11e1568dbaaf37a2dd28c5cc574068bac",
"sourceCodeHash": "0x3dbd4601c67a43c42f403f6b28e6e2d8bf4f3d2cf2f2d8f7460026e0c6c66def" "sourceCodeHash": "0xe67f0c01c9c9ba67d279304f9db84eebeb2e93d9f2728fea95c7a194f0ae338a"
}, },
"src/L1/OptimismPortalInterop.sol": { "src/L1/OptimismPortalInterop.sol": {
"initCodeHash": "0xc7a9282ef32425b65a647039908ea2b8d6ef231ba1b87c345c7b9f3f73acc240", "initCodeHash": "0x917b3b31a149b5aab96539208f4810d207875f6f2563a45c50ed13a7940066c0",
"sourceCodeHash": "0x85e9f10ba1884b1a45737fd35ae4c2f9a9054f81a6aba08941ab7a95e74543da" "sourceCodeHash": "0xae2fbe02c0f8685692babeed0252ae8a624dc6d3bfb082fc3807d7b84869004b"
}, },
"src/L1/ProtocolVersions.sol": { "src/L1/ProtocolVersions.sol": {
"initCodeHash": "0x0000ec89712d8b4609873f1ba76afffd4205bf9110818995c90134dbec12e91e", "initCodeHash": "0x0000ec89712d8b4609873f1ba76afffd4205bf9110818995c90134dbec12e91e",
...@@ -36,12 +36,12 @@ ...@@ -36,12 +36,12 @@
"sourceCodeHash": "0xafa784ea78818a382ff3a61e2d84be58c7978110c06b9273db68c0213ead02d3" "sourceCodeHash": "0xafa784ea78818a382ff3a61e2d84be58c7978110c06b9273db68c0213ead02d3"
}, },
"src/L1/SystemConfig.sol": { "src/L1/SystemConfig.sol": {
"initCodeHash": "0xe1baf5d3415baf65a45031c37e4bd794ecb7f779b227f6cbed06d945aa2097fc", "initCodeHash": "0xbb18eef17cdc1d0d307b0241e818820063e3ce3c7021ea3bb3a85ff6e79659e1",
"sourceCodeHash": "0x52b7d8825b4962e720513906ac993d36964cf03c45364c9f03d88507a0caac57" "sourceCodeHash": "0x5d6a9ef41fed54479f742345368e693ec1fcabdb60118081c03fe9da3a5d27ed"
}, },
"src/L1/SystemConfigInterop.sol": { "src/L1/SystemConfigInterop.sol": {
"initCodeHash": "0x91ed371ee2f6d4a9ed1483971df8a6888cc8b5aca5212b180e395476f21cb268", "initCodeHash": "0x0d61e2a95122417e9bf074a8fc0bce6f2b03268985d09580a83099dc9016c72d",
"sourceCodeHash": "0x6a51dc1b2bfadd9781c729f8db70972926f364b0e605536fb075bfddd0d4c433" "sourceCodeHash": "0x673ec83b89680b44945af89229b286f26df07a5938d497df5def47872d331cf3"
}, },
"src/L2/BaseFeeVault.sol": { "src/L2/BaseFeeVault.sol": {
"initCodeHash": "0xc403d4c555d8e69a2699e01d192ae7327136701fa02da10a6d75a584b3c364c9", "initCodeHash": "0xc403d4c555d8e69a2699e01d192ae7327136701fa02da10a6d75a584b3c364c9",
......
...@@ -46,6 +46,9 @@ import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol" ...@@ -46,6 +46,9 @@ import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol"
import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol"; import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
import { IL1Block } from "interfaces/L2/IL1Block.sol"; import { IL1Block } from "interfaces/L2/IL1Block.sol";
/// @notice This is temporary. Error thrown when a chain uses a custom gas token.
error CustomGasTokenNotSupported();
/// @custom:proxied true /// @custom:proxied true
/// @title OptimismPortal2 /// @title OptimismPortal2
/// @notice The OptimismPortal is a low-level contract responsible for passing messages between L1 /// @notice The OptimismPortal is a low-level contract responsible for passing messages between L1
...@@ -57,7 +60,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -57,7 +60,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
/// @notice Represents a proven withdrawal. /// @notice Represents a proven withdrawal.
/// @custom:field disputeGameProxy The address of the dispute game proxy that the withdrawal was proven against. /// @custom:field disputeGameProxy The address of the dispute game proxy that the withdrawal was proven against.
/// @custom:field timestamp Timestamp at whcih the withdrawal was proven. /// @custom:field timestamp Timestamp at which the withdrawal was proven.
struct ProvenWithdrawal { struct ProvenWithdrawal {
IDisputeGame disputeGameProxy; IDisputeGame disputeGameProxy;
uint64 timestamp; uint64 timestamp;
...@@ -183,9 +186,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -183,9 +186,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
} }
/// @notice Semantic version. /// @notice Semantic version.
/// @custom:semver 3.11.0-beta.9 /// @custom:semver 3.11.0-beta.10
function version() public pure virtual returns (string memory) { function version() public pure virtual returns (string memory) {
return "3.11.0-beta.9"; return "3.11.0-beta.10";
} }
/// @notice Constructs the OptimismPortal contract. /// @notice Constructs the OptimismPortal contract.
...@@ -235,6 +238,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -235,6 +238,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
if (token == Constants.ETHER) { if (token == Constants.ETHER) {
return address(this).balance; return address(this).balance;
} else { } else {
// Temporary revert till we support custom gas tokens
if (true) revert CustomGasTokenNotSupported();
return _balance; return _balance;
} }
} }
...@@ -423,6 +429,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -423,6 +429,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
// to accomplish this, `callWithMinGas` will revert. // to accomplish this, `callWithMinGas` will revert.
success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, _tx.value, _tx.data); success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, _tx.value, _tx.data);
} else { } else {
// Temporary revert till we support custom gas tokens
if (true) revert CustomGasTokenNotSupported();
// Cannot call the token contract directly from the portal. This would allow an attacker // Cannot call the token contract directly from the portal. This would allow an attacker
// to call approve from a withdrawal and drain the balance of the portal. // to call approve from a withdrawal and drain the balance of the portal.
if (_tx.target == token) revert BadTarget(); if (_tx.target == token) revert BadTarget();
...@@ -492,6 +501,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -492,6 +501,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
public public
metered(_gasLimit) metered(_gasLimit)
{ {
// Temporary revert till we support custom gas tokens
if (true) revert CustomGasTokenNotSupported();
// Can only be called if an ERC20 token is used for gas paying on L2 // Can only be called if an ERC20 token is used for gas paying on L2
(address token,) = gasPayingToken(); (address token,) = gasPayingToken();
if (token == Constants.ETHER) revert OnlyCustomGasToken(); if (token == Constants.ETHER) revert OnlyCustomGasToken();
...@@ -541,6 +553,10 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -541,6 +553,10 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
metered(_gasLimit) metered(_gasLimit)
{ {
(address token,) = gasPayingToken(); (address token,) = gasPayingToken();
// Temporary revert till we support custom gas tokens
if (token != Constants.ETHER) revert CustomGasTokenNotSupported();
if (token != Constants.ETHER && msg.value != 0) revert NoValue(); if (token != Constants.ETHER && msg.value != 0) revert NoValue();
_depositTransaction({ _depositTransaction({
...@@ -603,6 +619,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver { ...@@ -603,6 +619,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
/// @notice Sets the gas paying token for the L2 system. This token is used as the /// @notice Sets the gas paying token for the L2 system. This token is used as the
/// L2 native asset. Only the SystemConfig contract can call this function. /// L2 native asset. Only the SystemConfig contract can call this function.
function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external { function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external {
// Temporary revert till we support custom gas tokens
if (true) revert CustomGasTokenNotSupported();
if (msg.sender != address(systemConfig)) revert Unauthorized(); if (msg.sender != address(systemConfig)) revert Unauthorized();
// Set L2 deposit gas as used without paying burning gas. Ensures that deposits cannot use too much L2 gas. // Set L2 deposit gas as used without paying burning gas. Ensures that deposits cannot use too much L2 gas.
......
...@@ -25,9 +25,9 @@ contract OptimismPortalInterop is OptimismPortal2 { ...@@ -25,9 +25,9 @@ contract OptimismPortalInterop is OptimismPortal2 {
OptimismPortal2(_proofMaturityDelaySeconds, _disputeGameFinalityDelaySeconds) OptimismPortal2(_proofMaturityDelaySeconds, _disputeGameFinalityDelaySeconds)
{ } { }
/// @custom:semver +interop-beta.6 /// @custom:semver +interop-beta.7
function version() public pure override returns (string memory) { function version() public pure override returns (string memory) {
return string.concat(super.version(), "+interop-beta.6"); return string.concat(super.version(), "+interop-beta.7");
} }
/// @notice Sets static configuration options for the L2 system. /// @notice Sets static configuration options for the L2 system.
......
...@@ -15,6 +15,9 @@ import { ISemver } from "interfaces/universal/ISemver.sol"; ...@@ -15,6 +15,9 @@ import { ISemver } from "interfaces/universal/ISemver.sol";
import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.sol"; import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.sol";
import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol"; import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
/// @dev This is temporary. Error thrown when a chain uses a custom gas token.
error CustomGasTokenNotSupported();
/// @custom:proxied true /// @custom:proxied true
/// @title SystemConfig /// @title SystemConfig
/// @notice The SystemConfig contract is used to manage configuration of an Optimism network. /// @notice The SystemConfig contract is used to manage configuration of an Optimism network.
...@@ -137,9 +140,9 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken { ...@@ -137,9 +140,9 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data); event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
/// @notice Semantic version. /// @notice Semantic version.
/// @custom:semver 2.3.0-beta.9 /// @custom:semver 2.3.0-beta.10
function version() public pure virtual returns (string memory) { function version() public pure virtual returns (string memory) {
return "2.3.0-beta.9"; return "2.3.0-beta.10";
} }
/// @notice Constructs the SystemConfig contract. /// @notice Constructs the SystemConfig contract.
...@@ -294,6 +297,9 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken { ...@@ -294,6 +297,9 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
/// @param _token Address of the gas paying token. /// @param _token Address of the gas paying token.
function _setGasPayingToken(address _token) internal virtual { function _setGasPayingToken(address _token) internal virtual {
if (_token != address(0) && _token != Constants.ETHER && !isCustomGasToken()) { if (_token != address(0) && _token != Constants.ETHER && !isCustomGasToken()) {
// Temporary revert till we support custom gas tokens
if (true) revert CustomGasTokenNotSupported();
require( require(
ERC20(_token).decimals() == GAS_PAYING_TOKEN_DECIMALS, "SystemConfig: bad decimals of gas paying token" ERC20(_token).decimals() == GAS_PAYING_TOKEN_DECIMALS, "SystemConfig: bad decimals of gas paying token"
); );
......
...@@ -16,6 +16,9 @@ import { IOptimismPortalInterop as IOptimismPortal } from "interfaces/L1/IOptimi ...@@ -16,6 +16,9 @@ import { IOptimismPortalInterop as IOptimismPortal } from "interfaces/L1/IOptimi
import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol"; import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
import { ConfigType } from "interfaces/L2/IL1BlockInterop.sol"; import { ConfigType } from "interfaces/L2/IL1BlockInterop.sol";
/// @dev This is temporary. Error thrown when a chain uses a custom gas token.
error CustomGasTokenNotSupported();
/// @custom:proxied true /// @custom:proxied true
/// @title SystemConfigInterop /// @title SystemConfigInterop
/// @notice The SystemConfig contract is used to manage configuration of an Optimism network. /// @notice The SystemConfig contract is used to manage configuration of an Optimism network.
...@@ -68,9 +71,9 @@ contract SystemConfigInterop is SystemConfig { ...@@ -68,9 +71,9 @@ contract SystemConfigInterop is SystemConfig {
Storage.setAddress(DEPENDENCY_MANAGER_SLOT, _dependencyManager); Storage.setAddress(DEPENDENCY_MANAGER_SLOT, _dependencyManager);
} }
/// @custom:semver +interop-beta.8 /// @custom:semver +interop-beta.9
function version() public pure override returns (string memory) { function version() public pure override returns (string memory) {
return string.concat(super.version(), "+interop-beta.8"); return string.concat(super.version(), "+interop-beta.9");
} }
/// @notice Internal setter for the gas paying token address, includes validation. /// @notice Internal setter for the gas paying token address, includes validation.
...@@ -82,6 +85,9 @@ contract SystemConfigInterop is SystemConfig { ...@@ -82,6 +85,9 @@ contract SystemConfigInterop is SystemConfig {
/// @param _token Address of the gas paying token. /// @param _token Address of the gas paying token.
function _setGasPayingToken(address _token) internal override { function _setGasPayingToken(address _token) internal override {
if (_token != address(0) && _token != Constants.ETHER && !isCustomGasToken()) { if (_token != address(0) && _token != Constants.ETHER && !isCustomGasToken()) {
// Temporary revert till we support custom gas tokens
if (true) revert CustomGasTokenNotSupported();
require( require(
ERC20(_token).decimals() == GAS_PAYING_TOKEN_DECIMALS, "SystemConfig: bad decimals of gas paying token" ERC20(_token).decimals() == GAS_PAYING_TOKEN_DECIMALS, "SystemConfig: bad decimals of gas paying token"
); );
......
...@@ -698,8 +698,26 @@ contract L1CrossDomainMessenger_Test is CommonTest { ...@@ -698,8 +698,26 @@ contract L1CrossDomainMessenger_Test is CommonTest {
assertEq(l1CrossDomainMessenger.paused(), superchainConfig.paused()); assertEq(l1CrossDomainMessenger.paused(), superchainConfig.paused());
} }
/// @dev Temporary test that checks that correct calls to sendMessage when using a custom gas token revert with the
/// expected error.
/// @dev Should be removed when/if Custom Gas Token functionality is allowed again.
function test_sendMessage_customGasToken_reverts() external {
skipIfForkTest("Custom gas token is still supported on forked tests");
// Mock the gasPayingToken function to return a custom gas token
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
vm.prank(alice);
vm.expectRevert(IOptimismPortal2.CustomGasTokenNotSupported.selector);
l1CrossDomainMessenger.sendMessage(recipient, hex"ff", uint32(100));
}
/// @dev Tests that sendMessage succeeds with a custom gas token when the call value is zero. /// @dev Tests that sendMessage succeeds with a custom gas token when the call value is zero.
function test_sendMessage_customGasTokenButNoValue_succeeds() external { function test_sendMessage_customGasTokenButNoValue_succeeds() external {
vm.skip(true, "Custom gas token not supported");
// Mock the gasPayingToken function to return a custom gas token // Mock the gasPayingToken function to return a custom gas token
vm.mockCall( vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18)) address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
......
...@@ -325,6 +325,8 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init { ...@@ -325,6 +325,8 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init {
ERC20 token; ERC20 token;
function setUp() public override { function setUp() public override {
vm.skip(true, "Custom gas token not supported");
token = new ERC20("Silly", "SIL"); token = new ERC20("Silly", "SIL");
super.enableCustomGasToken(address(token)); super.enableCustomGasToken(address(token));
......
...@@ -26,8 +26,18 @@ contract SystemConfigInterop_Test is CommonTest { ...@@ -26,8 +26,18 @@ contract SystemConfigInterop_Test is CommonTest {
super.setUp(); super.setUp();
} }
/// @dev Temporary test that checks that correct calls to initialize when using a custom gas token revert with the
/// expected error.
/// @dev Should be removed when/if Custom Gas Token functionality is allowed again.
function test_initialize_customGasToken_reverts() external {
vm.expectRevert(ISystemConfig.CustomGasTokenNotSupported.selector);
_cleanStorageAndInit(address(L1Token));
}
/// @dev Tests that when the decimals is not 18, initialization reverts. /// @dev Tests that when the decimals is not 18, initialization reverts.
function test_initialize_decimalsIsNot18_reverts(uint8 decimals) external { function test_initialize_decimalsIsNot18_reverts(uint8 decimals) external {
vm.skip(true, "Custom gas token not supported");
vm.assume(decimals != 18); vm.assume(decimals != 18);
address _token = address(L1Token); address _token = address(L1Token);
...@@ -39,6 +49,40 @@ contract SystemConfigInterop_Test is CommonTest { ...@@ -39,6 +49,40 @@ contract SystemConfigInterop_Test is CommonTest {
_cleanStorageAndInit(_token); _cleanStorageAndInit(_token);
} }
/// @dev Temporary test that checks that correct calls to setGasPayingToken when using a custom gas token revert
/// with the expected error.
/// @dev Should be removed when/if Custom Gas Token functionality is allowed again.
function test_setGasPayingToken_customGasToken_reverts(
address _token,
string calldata _name,
string calldata _symbol
)
external
{
assumeNotForgeAddress(_token);
vm.assume(_token != address(0));
vm.assume(_token != Constants.ETHER);
// Using vm.assume() would cause too many test rejections.
string memory name = _name;
if (bytes(_name).length > 32) {
name = _name[:32];
}
// Using vm.assume() would cause too many test rejections.
string memory symbol = _symbol;
if (bytes(_symbol).length > 32) {
symbol = _symbol[:32];
}
vm.mockCall(_token, abi.encodeCall(ERC20.decimals, ()), abi.encode(18));
vm.mockCall(_token, abi.encodeCall(ERC20.name, ()), abi.encode(name));
vm.mockCall(_token, abi.encodeCall(ERC20.symbol, ()), abi.encode(symbol));
vm.expectRevert(ISystemConfig.CustomGasTokenNotSupported.selector);
_cleanStorageAndInit(_token);
}
/// @dev Tests that the gas paying token can be set. /// @dev Tests that the gas paying token can be set.
function testFuzz_setGasPayingToken_succeeds( function testFuzz_setGasPayingToken_succeeds(
address _token, address _token,
...@@ -47,6 +91,8 @@ contract SystemConfigInterop_Test is CommonTest { ...@@ -47,6 +91,8 @@ contract SystemConfigInterop_Test is CommonTest {
) )
public public
{ {
vm.skip(true, "Custom gas token not supported");
assumeNotForgeAddress(_token); assumeNotForgeAddress(_token);
vm.assume(_token != address(0)); vm.assume(_token != address(0));
vm.assume(_token != Constants.ETHER); vm.assume(_token != Constants.ETHER);
......
...@@ -3,7 +3,8 @@ pragma solidity 0.8.15; ...@@ -3,7 +3,8 @@ pragma solidity 0.8.15;
// Testing utilities // Testing utilities
import { CommonTest } from "test/setup/CommonTest.sol"; import { CommonTest } from "test/setup/CommonTest.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
error CustomGasTokenNotSupported();
contract DeployVariations_Test is CommonTest { contract DeployVariations_Test is CommonTest {
function setUp() public override { function setUp() public override {
...@@ -14,8 +15,7 @@ contract DeployVariations_Test is CommonTest { ...@@ -14,8 +15,7 @@ contract DeployVariations_Test is CommonTest {
// Enable features which should be possible to enable or disable regardless of other options. // Enable features which should be possible to enable or disable regardless of other options.
function enableAddOns(bool _enableCGT, bool _enableAltDa) public { function enableAddOns(bool _enableCGT, bool _enableAltDa) public {
if (_enableCGT) { if (_enableCGT) {
ERC20 token = new ERC20("Silly", "SIL"); revert CustomGasTokenNotSupported();
super.enableCustomGasToken(address(token));
} }
if (_enableAltDa) { if (_enableAltDa) {
super.enableAltDA(); super.enableAltDA();
...@@ -24,6 +24,9 @@ contract DeployVariations_Test is CommonTest { ...@@ -24,6 +24,9 @@ contract DeployVariations_Test is CommonTest {
/// @dev It should be possible to enable Fault Proofs with any mix of CGT and Alt-DA. /// @dev It should be possible to enable Fault Proofs with any mix of CGT and Alt-DA.
function testFuzz_enableFaultProofs_succeeds(bool _enableCGT, bool _enableAltDa) public virtual { function testFuzz_enableFaultProofs_succeeds(bool _enableCGT, bool _enableAltDa) public virtual {
// We don't support CGT yet, so we need to set it to false
_enableCGT = false;
enableAddOns(_enableCGT, _enableAltDa); enableAddOns(_enableCGT, _enableAltDa);
super.setUp(); super.setUp();
...@@ -31,6 +34,9 @@ contract DeployVariations_Test is CommonTest { ...@@ -31,6 +34,9 @@ contract DeployVariations_Test is CommonTest {
/// @dev It should be possible to enable Fault Proofs and Interop with any mix of CGT and Alt-DA. /// @dev It should be possible to enable Fault Proofs and Interop with any mix of CGT and Alt-DA.
function test_enableInteropAndFaultProofs_succeeds(bool _enableCGT, bool _enableAltDa) public virtual { function test_enableInteropAndFaultProofs_succeeds(bool _enableCGT, bool _enableAltDa) public virtual {
// We don't support CGT yet, so we need to set it to false
_enableCGT = false;
enableAddOns(_enableCGT, _enableAltDa); enableAddOns(_enableCGT, _enableAltDa);
super.enableInterop(); super.enableInterop();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment