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) {
}
func TestCustomGasToken_Standard(t *testing.T) {
t.Skip("Custom gas token not supported")
testCustomGasToken(t, config.AllocTypeStandard)
}
......
......@@ -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();
......
......@@ -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();
......
......@@ -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.
interface ISystemConfig {
error CustomGasTokenNotSupported();
enum UpdateType {
BATCHER,
FEE_SCALARS,
......
......@@ -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);
......
......@@ -91,6 +91,8 @@ anvil-fork:
# Use anvil-fork in a separate terminal before running this command.
# Helpful for debugging.
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_TEST=true \
forge test {{ARGS}}
......
......@@ -4,10 +4,10 @@ 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: 369280)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967442)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564429)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076577)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467041)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512790)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369309)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967471)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564458)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076606)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467070)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512819)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72667)
\ No newline at end of file
......@@ -846,6 +846,11 @@
"name": "ContentLengthMismatch",
"type": "error"
},
{
"inputs": [],
"name": "CustomGasTokenNotSupported",
"type": "error"
},
{
"inputs": [],
"name": "EmptyItem",
......
......@@ -864,6 +864,11 @@
"name": "ContentLengthMismatch",
"type": "error"
},
{
"inputs": [],
"name": "CustomGasTokenNotSupported",
"type": "error"
},
{
"inputs": [],
"name": "EmptyItem",
......
......@@ -800,5 +800,10 @@
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"inputs": [],
"name": "CustomGasTokenNotSupported",
"type": "error"
}
]
\ No newline at end of file
......@@ -961,5 +961,10 @@
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"inputs": [],
"name": "CustomGasTokenNotSupported",
"type": "error"
}
]
\ No newline at end of file
......@@ -20,12 +20,12 @@
"sourceCodeHash": "0xe5179a20ae40d4e4773c52df98bac67e73e04044bec9e8750073b4e2f14fe81b"
},
"src/L1/OptimismPortal2.sol": {
"initCodeHash": "0xfd14fd690752519064d6de6c3e15d69ec9146bc8714e56ac286305773dbb1533",
"sourceCodeHash": "0x3dbd4601c67a43c42f403f6b28e6e2d8bf4f3d2cf2f2d8f7460026e0c6c66def"
"initCodeHash": "0x7e533474310583593c2d57d30fcd1ec11e1568dbaaf37a2dd28c5cc574068bac",
"sourceCodeHash": "0xe67f0c01c9c9ba67d279304f9db84eebeb2e93d9f2728fea95c7a194f0ae338a"
},
"src/L1/OptimismPortalInterop.sol": {
"initCodeHash": "0xc7a9282ef32425b65a647039908ea2b8d6ef231ba1b87c345c7b9f3f73acc240",
"sourceCodeHash": "0x85e9f10ba1884b1a45737fd35ae4c2f9a9054f81a6aba08941ab7a95e74543da"
"initCodeHash": "0x917b3b31a149b5aab96539208f4810d207875f6f2563a45c50ed13a7940066c0",
"sourceCodeHash": "0xae2fbe02c0f8685692babeed0252ae8a624dc6d3bfb082fc3807d7b84869004b"
},
"src/L1/ProtocolVersions.sol": {
"initCodeHash": "0x0000ec89712d8b4609873f1ba76afffd4205bf9110818995c90134dbec12e91e",
......@@ -36,12 +36,12 @@
"sourceCodeHash": "0xafa784ea78818a382ff3a61e2d84be58c7978110c06b9273db68c0213ead02d3"
},
"src/L1/SystemConfig.sol": {
"initCodeHash": "0xe1baf5d3415baf65a45031c37e4bd794ecb7f779b227f6cbed06d945aa2097fc",
"sourceCodeHash": "0x52b7d8825b4962e720513906ac993d36964cf03c45364c9f03d88507a0caac57"
"initCodeHash": "0xbb18eef17cdc1d0d307b0241e818820063e3ce3c7021ea3bb3a85ff6e79659e1",
"sourceCodeHash": "0x5d6a9ef41fed54479f742345368e693ec1fcabdb60118081c03fe9da3a5d27ed"
},
"src/L1/SystemConfigInterop.sol": {
"initCodeHash": "0x91ed371ee2f6d4a9ed1483971df8a6888cc8b5aca5212b180e395476f21cb268",
"sourceCodeHash": "0x6a51dc1b2bfadd9781c729f8db70972926f364b0e605536fb075bfddd0d4c433"
"initCodeHash": "0x0d61e2a95122417e9bf074a8fc0bce6f2b03268985d09580a83099dc9016c72d",
"sourceCodeHash": "0x673ec83b89680b44945af89229b286f26df07a5938d497df5def47872d331cf3"
},
"src/L2/BaseFeeVault.sol": {
"initCodeHash": "0xc403d4c555d8e69a2699e01d192ae7327136701fa02da10a6d75a584b3c364c9",
......
......@@ -46,6 +46,9 @@ import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol"
import { IDisputeGame } from "interfaces/dispute/IDisputeGame.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
/// @title OptimismPortal2
/// @notice The OptimismPortal is a low-level contract responsible for passing messages between L1
......@@ -57,7 +60,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
/// @notice Represents a proven withdrawal.
/// @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 {
IDisputeGame disputeGameProxy;
uint64 timestamp;
......@@ -183,9 +186,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
}
/// @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) {
return "3.11.0-beta.9";
return "3.11.0-beta.10";
}
/// @notice Constructs the OptimismPortal contract.
......@@ -235,6 +238,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
if (token == Constants.ETHER) {
return address(this).balance;
} else {
// Temporary revert till we support custom gas tokens
if (true) revert CustomGasTokenNotSupported();
return _balance;
}
}
......@@ -423,6 +429,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
// to accomplish this, `callWithMinGas` will revert.
success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, _tx.value, _tx.data);
} 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
// to call approve from a withdrawal and drain the balance of the portal.
if (_tx.target == token) revert BadTarget();
......@@ -492,6 +501,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
public
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
(address token,) = gasPayingToken();
if (token == Constants.ETHER) revert OnlyCustomGasToken();
......@@ -541,6 +553,10 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
metered(_gasLimit)
{
(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();
_depositTransaction({
......@@ -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
/// L2 native asset. Only the SystemConfig contract can call this function.
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();
// 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 {
OptimismPortal2(_proofMaturityDelaySeconds, _disputeGameFinalityDelaySeconds)
{ }
/// @custom:semver +interop-beta.6
/// @custom:semver +interop-beta.7
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.
......
......@@ -15,6 +15,9 @@ import { ISemver } from "interfaces/universal/ISemver.sol";
import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.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
/// @title SystemConfig
/// @notice The SystemConfig contract is used to manage configuration of an Optimism network.
......@@ -137,9 +140,9 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
/// @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) {
return "2.3.0-beta.9";
return "2.3.0-beta.10";
}
/// @notice Constructs the SystemConfig contract.
......@@ -294,6 +297,9 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
/// @param _token Address of the gas paying token.
function _setGasPayingToken(address _token) internal virtual {
if (_token != address(0) && _token != Constants.ETHER && !isCustomGasToken()) {
// Temporary revert till we support custom gas tokens
if (true) revert CustomGasTokenNotSupported();
require(
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
import { IResourceMetering } from "interfaces/L1/IResourceMetering.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
/// @title SystemConfigInterop
/// @notice The SystemConfig contract is used to manage configuration of an Optimism network.
......@@ -68,9 +71,9 @@ contract SystemConfigInterop is SystemConfig {
Storage.setAddress(DEPENDENCY_MANAGER_SLOT, _dependencyManager);
}
/// @custom:semver +interop-beta.8
/// @custom:semver +interop-beta.9
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.
......@@ -82,6 +85,9 @@ contract SystemConfigInterop is SystemConfig {
/// @param _token Address of the gas paying token.
function _setGasPayingToken(address _token) internal override {
if (_token != address(0) && _token != Constants.ETHER && !isCustomGasToken()) {
// Temporary revert till we support custom gas tokens
if (true) revert CustomGasTokenNotSupported();
require(
ERC20(_token).decimals() == GAS_PAYING_TOKEN_DECIMALS, "SystemConfig: bad decimals of gas paying token"
);
......
......@@ -698,8 +698,26 @@ contract L1CrossDomainMessenger_Test is CommonTest {
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.
function test_sendMessage_customGasTokenButNoValue_succeeds() external {
vm.skip(true, "Custom gas token not supported");
// Mock the gasPayingToken function to return a custom gas token
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
......
......@@ -309,6 +309,23 @@ contract OptimismPortal2_Test is CommonTest {
assertEq(address(optimismPortal2).balance, balanceBefore + _mint);
}
/// @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,
uint8 _decimals,
bytes32 _name,
bytes32 _symbol
)
external
{
skipIfForkTest("Custom gas token is still supported on forked tests");
vm.expectRevert(IOptimismPortal2.CustomGasTokenNotSupported.selector);
optimismPortal2.setGasPayingToken({ _token: _token, _decimals: _decimals, _name: _name, _symbol: _symbol });
}
/// @dev Tests that the gas paying token can be set.
function testFuzz_setGasPayingToken_succeeds(
address _token,
......@@ -318,6 +335,8 @@ contract OptimismPortal2_Test is CommonTest {
)
external
{
vm.skip(true, "Custom gas token not supported");
// TODO(opcm upgrades): remove skip once upgrade path is implemented
skipIfForkTest("OptimismPortal2_Test: gas paying token functionality DNE on op mainnet");
......@@ -349,6 +368,8 @@ contract OptimismPortal2_Test is CommonTest {
)
external
{
vm.skip(true, "Custom gas token not supported");
// TODO(opcm upgrades): remove skip once upgrade path is implemented
skipIfForkTest("OptimismPortal2_Test: gas paying token functionality DNE on op mainnet");
......@@ -394,6 +415,8 @@ contract OptimismPortal2_Test is CommonTest {
/// @dev Tests that the gas paying token cannot be set by a non-system config.
function test_setGasPayingToken_notSystemConfig_fails(address _caller) external {
vm.skip(true, "Custom gas token not supported");
// TODO(opcm upgrades): remove skip once upgrade path is implemented
skipIfForkTest("OptimismPortal2_Test: gas paying token functionality DNE on op mainnet");
......@@ -403,8 +426,21 @@ contract OptimismPortal2_Test is CommonTest {
optimismPortal2.setGasPayingToken({ _token: address(0), _decimals: 0, _name: "", _symbol: "" });
}
/// @dev Temporary test that checks that correct calls to depositERC20Transaction 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_depositERC20Transaction_customGasToken_reverts() external {
skipIfForkTest("Custom gas token is still supported on forked tests");
vm.expectRevert(IOptimismPortal2.CustomGasTokenNotSupported.selector);
optimismPortal2.depositERC20Transaction(address(0), 0, 0, 0, false, "");
}
/// @dev Tests that `depositERC20Transaction` reverts when the gas paying token is ether.
function test_depositERC20Transaction_noCustomGasToken_reverts() external {
vm.skip(true, "Custom gas token not supported");
// TODO(opcm upgrades): remove skip once upgrade path is implemented
skipIfForkTest("OptimismPortal2_Test: gas paying token functionality DNE on op mainnet");
......@@ -417,6 +453,8 @@ contract OptimismPortal2_Test is CommonTest {
}
function test_depositERC20Transaction_balanceOverflow_reverts() external {
vm.skip(true, "Custom gas token not supported");
// TODO(opcm upgrades): remove skip once upgrade path is implemented
skipIfForkTest("OptimismPortal2_Test: gas paying token functionality DNE on op mainnet");
vm.mockCall(address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(42), 18));
......@@ -966,8 +1004,80 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
assert(bob.balance == bobBalanceBefore + 100);
}
/// @dev Tests that `finalizeWithdrawalTransaction` reverts when using a custom gas token.
/// @dev Should be removed when/if Custom Gas Token functionality is allowed again.
function test_finalizeWithdrawalTransaction_customGasToken_reverts() external {
Types.WithdrawalTransaction memory _defaultTx_noData = Types.WithdrawalTransaction({
nonce: 0,
sender: alice,
target: bob,
value: 100,
gasLimit: 100_000,
data: hex""
});
// Get withdrawal proof data we can use for testing.
(
bytes32 _stateRoot_noData,
bytes32 _storageRoot_noData,
bytes32 _outputRoot_noData,
bytes32 _withdrawalHash_noData,
bytes[] memory _withdrawalProof_noData
) = ffi.getProveWithdrawalTransactionInputs(_defaultTx_noData);
// Setup a dummy output root proof for reuse.
Types.OutputRootProof memory _outputRootProof_noData = Types.OutputRootProof({
version: bytes32(uint256(0)),
stateRoot: _stateRoot_noData,
messagePasserStorageRoot: _storageRoot_noData,
latestBlockhash: bytes32(uint256(0))
});
uint256 _proposedBlockNumber_noData = 0xFF;
IFaultDisputeGame game_noData = IFaultDisputeGame(
payable(
address(
disputeGameFactory.create(
optimismPortal2.respectedGameType(),
Claim.wrap(_outputRoot_noData),
abi.encode(_proposedBlockNumber_noData)
)
)
)
);
uint256 _proposedGameIndex_noData = disputeGameFactory.gameCount() - 1;
// Warp beyond the chess clocks and finalize the game.
vm.warp(block.timestamp + game_noData.maxClockDuration().raw() + 1 seconds);
// Fund the portal so that we can withdraw ETH.
vm.store(address(optimismPortal2), bytes32(uint256(61)), bytes32(uint256(0xFFFFFFFF)));
deal(address(L1Token), address(optimismPortal2), 0xFFFFFFFF);
// modify the gas token to be non ether
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(L1Token), 18)
);
vm.expectEmit(address(optimismPortal2));
emit WithdrawalProven(_withdrawalHash_noData, alice, bob);
vm.expectEmit(address(optimismPortal2));
emit WithdrawalProvenExtension1(_withdrawalHash_noData, address(this));
optimismPortal2.proveWithdrawalTransaction({
_tx: _defaultTx_noData,
_disputeGameIndex: _proposedGameIndex_noData,
_outputRootProof: _outputRootProof_noData,
_withdrawalProof: _withdrawalProof_noData
});
// Warp and resolve the dispute game.
game_noData.resolveClaim(0, 0);
game_noData.resolve();
vm.warp(block.timestamp + optimismPortal2.proofMaturityDelaySeconds() + 1 seconds);
vm.expectRevert(IOptimismPortal2.CustomGasTokenNotSupported.selector);
optimismPortal2.finalizeWithdrawalTransaction(_defaultTx_noData);
}
/// @dev Tests that `finalizeWithdrawalTransaction` succeeds when _tx.data is empty and with a custom gas token.
function test_finalizeWithdrawalTransaction_noTxDataNonEtherGasToken_succeeds() external {
vm.skip(true, "Custom gas token not supported");
Types.WithdrawalTransaction memory _defaultTx_noData = Types.WithdrawalTransaction({
nonce: 0,
sender: alice,
......@@ -1130,6 +1240,8 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
/// @dev Tests that `finalizeWithdrawalTransaction` succeeds.
function test_finalizeWithdrawalTransaction_provenWithdrawalHashNonEtherTargetToken_reverts() external {
vm.skip(true, "Custom gas token not supported");
vm.mockCall(
address(systemConfig),
abi.encodeCall(systemConfig.gasPayingToken, ()),
......@@ -1844,6 +1956,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
)
external
{
vm.skip(true, "Custom gas token not supported");
// Ensure that msg.sender == tx.origin
vm.startPrank(address(this), address(this));
......@@ -1869,6 +1983,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
)
external
{
vm.skip(true, "Custom gas token not supported");
// Ensure that msg.sender != tx.origin
vm.startPrank(address(this), address(1));
......@@ -1885,6 +2001,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `depositERC20Transaction` reverts when not enough of the token is approved.
function test_depositERC20Transaction_notEnoughAmount_reverts() external {
vm.skip(true, "Custom gas token not supported");
// Mock the gas paying token to be the ERC20 token
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
......@@ -1896,6 +2014,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `depositERC20Transaction` reverts when token balance does not update correctly after transfer.
function test_depositERC20Transaction_incorrectTokenBalance_reverts() external {
vm.skip(true, "Custom gas token not supported");
// Mint the token to the contract and approve the token for the portal
token.mint(address(this), 100);
token.approve(address(optimismPortal2), 100);
......@@ -1919,6 +2039,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `depositERC20Transaction` reverts when creating a contract with a non-zero target.
function test_depositERC20Transaction_isCreationNotZeroTarget_reverts() external {
vm.skip(true, "Custom gas token not supported");
// Mock the gas paying token to be the ERC20 token
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
......@@ -1934,6 +2056,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `depositERC20Transaction` reverts when the gas limit is too low.
function test_depositERC20Transaction_gasLimitTooLow_reverts() external {
vm.skip(true, "Custom gas token not supported");
// Mock the gas paying token to be the ERC20 token
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
......@@ -1946,6 +2070,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `depositERC20Transaction` reverts when the data is too large.
function test_depositERC20Transaction_dataTooLarge_reverts() external {
vm.skip(true, "Custom gas token not supported");
bytes memory data = new bytes(120_001);
data[120_000] = 0x01;
......@@ -1962,6 +2088,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `balance()` returns the correct balance when the gas paying token is not ether.
function testFuzz_balance_nonEther_succeeds(uint256 _amount) external {
vm.skip(true, "Custom gas token not supported");
// Mint the token to the contract and approve the token for the portal
token.mint(address(this), _amount);
token.approve(address(optimismPortal2), _amount);
......@@ -1980,6 +2108,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `finalizeWithdrawalTransaction` succeeds.
function test_finalizeWithdrawalTransaction_provenWithdrawalHashWithNonEther_succeeds() external {
vm.skip(true, "Custom gas token not supported");
// Mint the token to the contract and approve the token for the portal
token.mint(address(this), _defaultTx.value);
token.approve(address(optimismPortal2), _defaultTx.value);
......@@ -2078,6 +2208,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
)
external
{
vm.skip(true, "Custom gas token not supported");
// Ensure that msg.sender == tx.origin
vm.startPrank(address(this), address(this));
......@@ -2101,6 +2233,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
)
external
{
vm.skip(true, "Custom gas token not supported");
// Ensure that msg.sender != tx.origin
vm.startPrank(address(this), address(1));
......@@ -2116,6 +2250,8 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `depositTransaction` fails when a custom gas token is used and msg.value is non-zero.
function test_depositTransaction_customGasTokenWithValue_reverts() external {
vm.skip(true, "Custom gas token not supported");
// Mock the gas paying token to be the ERC20 token
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
......
......@@ -325,6 +325,8 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init {
ERC20 token;
function setUp() public override {
vm.skip(true, "Custom gas token not supported");
token = new ERC20("Silly", "SIL");
super.enableCustomGasToken(address(token));
......
......@@ -26,8 +26,18 @@ contract SystemConfigInterop_Test is CommonTest {
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.
function test_initialize_decimalsIsNot18_reverts(uint8 decimals) external {
vm.skip(true, "Custom gas token not supported");
vm.assume(decimals != 18);
address _token = address(L1Token);
......@@ -39,6 +49,40 @@ contract SystemConfigInterop_Test is CommonTest {
_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.
function testFuzz_setGasPayingToken_succeeds(
address _token,
......@@ -47,6 +91,8 @@ contract SystemConfigInterop_Test is CommonTest {
)
public
{
vm.skip(true, "Custom gas token not supported");
assumeNotForgeAddress(_token);
vm.assume(_token != address(0));
vm.assume(_token != Constants.ETHER);
......
......@@ -3,7 +3,8 @@ pragma solidity 0.8.15;
// Testing utilities
import { CommonTest } from "test/setup/CommonTest.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
error CustomGasTokenNotSupported();
contract DeployVariations_Test is CommonTest {
function setUp() public override {
......@@ -14,8 +15,7 @@ contract DeployVariations_Test is CommonTest {
// Enable features which should be possible to enable or disable regardless of other options.
function enableAddOns(bool _enableCGT, bool _enableAltDa) public {
if (_enableCGT) {
ERC20 token = new ERC20("Silly", "SIL");
super.enableCustomGasToken(address(token));
revert CustomGasTokenNotSupported();
}
if (_enableAltDa) {
super.enableAltDA();
......@@ -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.
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);
super.setUp();
......@@ -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.
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);
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