Skip to content

Commit

Permalink
Merge pull request #10264 from ethereum-optimism/feat/custom-gas-toke…
Browse files Browse the repository at this point in the history
…n-final-spec-nits

custom-gas-token: cleanup, final spec nits
  • Loading branch information
tynes authored Apr 23, 2024
2 parents 7ec7956 + ca78c04 commit 02085fe
Show file tree
Hide file tree
Showing 33 changed files with 981 additions and 348 deletions.
169 changes: 126 additions & 43 deletions op-bindings/bindings/crossdomainmessenger.go

Large diffs are not rendered by default.

118 changes: 95 additions & 23 deletions op-bindings/bindings/l1crossdomainmessenger.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-bindings/bindings/l1crossdomainmessenger_more.go

Large diffs are not rendered by default.

118 changes: 95 additions & 23 deletions op-bindings/bindings/l1standardbridge.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-bindings/bindings/l1standardbridge_more.go

Large diffs are not rendered by default.

118 changes: 95 additions & 23 deletions op-bindings/bindings/l2crossdomainmessenger.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-bindings/bindings/l2crossdomainmessenger_more.go

Large diffs are not rendered by default.

118 changes: 95 additions & 23 deletions op-bindings/bindings/l2standardbridge.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-bindings/bindings/l2standardbridge_more.go

Large diffs are not rendered by default.

169 changes: 126 additions & 43 deletions op-bindings/bindings/standardbridge.go

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369293)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967500)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 561908)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4074056)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467029)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512778)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369128)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967335)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 561731)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4073879)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 466921)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512670)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72672)
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92974)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68325)
Expand Down
20 changes: 10 additions & 10 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
"sourceCodeHash": "0xc59b8574531162e016d7342aeb6e79d05574e90dbea6c0e5ede35b65010ad894"
},
"src/L1/L1CrossDomainMessenger.sol": {
"initCodeHash": "0xb2e15eaa5af5e84097416ccd85233fe3af8d2f0a5de44d8cf9b42d98d7297a03",
"sourceCodeHash": "0x91a48b1e5b84241e52465b936d721e37387b9410dcedb4d846db79289e80d837"
"initCodeHash": "0x5c85913a45901e45998af2409d3636d9a96cd0a9d012dfca8ddf56b425b95a42",
"sourceCodeHash": "0x52e8993798b3a9c9022c31beec90a8f133cc19369330170bc2a45c690c857bc5"
},
"src/L1/L1ERC721Bridge.sol": {
"initCodeHash": "0xec73b46e68ea29298707f7b9709e7948afe303907b6c4e8b161e2ded2c85ee9c",
"sourceCodeHash": "0xd57acdbd001941e75cf4326ba7c1bdad809912f10b1e44ffaebe073917cdd296"
},
"src/L1/L1StandardBridge.sol": {
"initCodeHash": "0x2db8c1208d5a779876ff9685dae8236fe5e7b6bbe6bcce2207ca7c7c24b54fba",
"sourceCodeHash": "0xadd45eccc0113d978ddf85b27d1ee800789812586fb3a3d22f52082debaf9325"
"initCodeHash": "0x0036830ffeea9d74cc106bc9354d69db730e97b8cfcae5ae8cc64ba42b7aed27",
"sourceCodeHash": "0xb6e0f79eaf164e0993be78a4f9b4499112dd7cd452f1ccee9340f3030e322310"
},
"src/L1/L2OutputOracle.sol": {
"initCodeHash": "0x14c3a582ca46ef2a6abad5590323f4de26ff4de54415c927c62e131ccbf8d9ba",
Expand All @@ -49,7 +49,7 @@
},
"src/L1/SystemConfig.sol": {
"initCodeHash": "0x57f660e03393c5da321cc26cdf497c883982d4be93bcdb81955cce66e8a52168",
"sourceCodeHash": "0xf99c51d92bdb634907dc06bb4e9c6cbc5d3e6c235d28f2ee0997ccd0ea0246b7"
"sourceCodeHash": "0xb1e33b915cb85b39ab70035a28afca60ef085ab12f1d6b281ee271465fe01c43"
},
"src/L2/BaseFeeVault.sol": {
"initCodeHash": "0x2744d34573be83206d1b75d049d18a7bb37f9058e68c0803e5008c46b0dc2474",
Expand All @@ -61,23 +61,23 @@
},
"src/L2/L1Block.sol": {
"initCodeHash": "0x2364c817a3d767d0001236bca67e31fc6bd2a1e420a34153d933b5cc2b7f9b3f",
"sourceCodeHash": "0x66ce68c3bc698319e4829c7d1b145143aff271952c53c222f6f0f18e49254046"
"sourceCodeHash": "0x472088e594a08291de987d86902744d48bee6707b9427648cfe8645bba16fda2"
},
"src/L2/L1FeeVault.sol": {
"initCodeHash": "0x2744d34573be83206d1b75d049d18a7bb37f9058e68c0803e5008c46b0dc2474",
"sourceCodeHash": "0x3a94f273937d8908fb37dd2c495a6a0b9c3941fe68ccea51723f84eb343ba225"
},
"src/L2/L2CrossDomainMessenger.sol": {
"initCodeHash": "0x5af579fbebc8ef1a0437064e97714670305697f164fc8bed2b7beddec18a53f3",
"sourceCodeHash": "0x2cef6c7d184ad1f1ec207827a259d09c241ad8f14f887f42c3d92c2f0d478f6e"
"initCodeHash": "0x6fca9d0d1c87fea38db1c2d266bb5acd4a7a014abaaa5ff95e31bb5589ef42f3",
"sourceCodeHash": "0xd829462f5e35db4e593334bdc53941293213b3fad8d399ed8b20bc031fd3aab8"
},
"src/L2/L2ERC721Bridge.sol": {
"initCodeHash": "0xcafa012b2d8f1bb05c11cbbff9749c0fe6f995c9afb1d26d2d71f03384e34a22",
"sourceCodeHash": "0xa7646a588275046f92525ef121e5a0fe149e7752ea51fe62f7e0686a21153542"
},
"src/L2/L2StandardBridge.sol": {
"initCodeHash": "0x0c3541144b66cced2be908417bcd18f4b2f0d68b31a8788a420e7f3eebede737",
"sourceCodeHash": "0x02581ef6db3531c87e683f3c46060a9189f1c905e458821dcf5d328c09f48012"
"initCodeHash": "0x73f9c70c264947f6d963b8be6901f84cc4fb1b191e0fed6836d401df556ef145",
"sourceCodeHash": "0x78b0cbd013d8547be1a1741ed5b5a0462c3b5fa67f978b962843d990cd74e1be"
},
"src/L2/L2ToL1MessagePasser.sol": {
"initCodeHash": "0x08bbede75cd6dfd076903b8f04d24f82fa7881576c135825098778632e37eebc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,32 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasPayingTokenName",
"outputs": [
{
"internalType": "string",
"name": "name_",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasPayingTokenSymbol",
"outputs": [
{
"internalType": "string",
"name": "symbol_",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -228,7 +254,7 @@
"type": "bool"
}
],
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
Expand Down
28 changes: 27 additions & 1 deletion packages/contracts-bedrock/snapshots/abi/L1StandardBridge.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,32 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasPayingTokenName",
"outputs": [
{
"internalType": "string",
"name": "name_",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasPayingTokenSymbol",
"outputs": [
{
"internalType": "string",
"name": "symbol_",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -465,7 +491,7 @@
"type": "bool"
}
],
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,32 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasPayingTokenName",
"outputs": [
{
"internalType": "string",
"name": "name_",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasPayingTokenSymbol",
"outputs": [
{
"internalType": "string",
"name": "symbol_",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand All @@ -205,7 +231,7 @@
"type": "bool"
}
],
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
Expand Down
28 changes: 27 additions & 1 deletion packages/contracts-bedrock/snapshots/abi/L2StandardBridge.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,32 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasPayingTokenName",
"outputs": [
{
"internalType": "string",
"name": "name_",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasPayingTokenSymbol",
"outputs": [
{
"internalType": "string",
"name": "symbol_",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand All @@ -315,7 +341,7 @@
"type": "bool"
}
],
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
Expand Down
240 changes: 120 additions & 120 deletions packages/contracts-bedrock/snapshots/state-diff/Kontrol-Deploy.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions packages/contracts-bedrock/src/L1/L1CrossDomainMessenger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver {
(_addr, _decimals) = systemConfig.gasPayingToken();
}

/// @inheritdoc CrossDomainMessenger
function gasPayingTokenName() public view override returns (string memory name_) {
name_ = systemConfig.gasPayingTokenName();
}

/// @inheritdoc CrossDomainMessenger
function gasPayingTokenSymbol() public view override returns (string memory symbol_) {
symbol_ = systemConfig.gasPayingTokenSymbol();
}

/// @notice Getter function for the OptimismPortal contract on this chain.
/// Public getter is legacy and will be removed in the future. Use `portal()` instead.
/// @return Contract of the OptimismPortal on this chain.
Expand Down
10 changes: 10 additions & 0 deletions packages/contracts-bedrock/src/L1/L1StandardBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ contract L1StandardBridge is StandardBridge, ISemver {
(addr_, decimals_) = systemConfig.gasPayingToken();
}

/// @inheritdoc StandardBridge
function gasPayingTokenName() public view override returns (string memory name_) {
name_ = systemConfig.gasPayingTokenName();
}

/// @inheritdoc StandardBridge
function gasPayingTokenSymbol() public view override returns (string memory symbol_) {
symbol_ = systemConfig.gasPayingTokenSymbol();
}

/// @custom:legacy
/// @notice Deposits some amount of ETH into the sender's account on L2.
/// @param _minGasLimit Minimum gas limit for the deposit message on L2.
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/src/L1/SystemConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { ResourceMetering } from "src/L1/ResourceMetering.sol";
import { Storage } from "src/libraries/Storage.sol";
import { Constants } from "src/libraries/Constants.sol";
import { OptimismPortal } from "src/L1/OptimismPortal.sol";
import { GasPayingToken } from "src/libraries/GasPayingToken.sol";
import { GasPayingToken, IGasToken } from "src/libraries/GasPayingToken.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

/// @title SystemConfig
/// @notice The SystemConfig contract is used to manage configuration of an Optimism network.
/// All configuration is stored on L1 and picked up by L2 as part of the derviation of
/// the L2 chain.
contract SystemConfig is OwnableUpgradeable, ISemver {
contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
/// @notice Enum representing different types of updates.
/// @custom:value BATCHER Represents an update to the batcher hash.
/// @custom:value GAS_CONFIG Represents an update to txn fee config on L2.
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/src/L2/L1Block.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.15;
import { ISemver } from "src/universal/ISemver.sol";
import { Constants } from "src/libraries/Constants.sol";
import { Storage } from "src/libraries/Storage.sol";
import { GasPayingToken } from "src/libraries/GasPayingToken.sol";
import { GasPayingToken, IGasToken } from "src/libraries/GasPayingToken.sol";

/// @custom:proxied
/// @custom:predeploy 0x4200000000000000000000000000000000000015
Expand All @@ -13,7 +13,7 @@ import { GasPayingToken } from "src/libraries/GasPayingToken.sol";
/// Values within this contract are updated once per epoch (every L1 block) and can only be
/// set by the "depositor" account, a special system address. Depositor account transactions
/// are created by the protocol whenever we move to a new epoch.
contract L1Block is ISemver {
contract L1Block is ISemver, IGasToken {
/// @notice Error returns when a non-depositor account tries to set L1 block values.
error NotDepositor();

Expand Down
10 changes: 10 additions & 0 deletions packages/contracts-bedrock/src/L2/L2CrossDomainMessenger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ contract L2CrossDomainMessenger is CrossDomainMessenger, ISemver {
(addr_, decimals_) = L1Block(Predeploys.L1_BLOCK_ATTRIBUTES).gasPayingToken();
}

/// @inheritdoc CrossDomainMessenger
function gasPayingTokenName() public view override returns (string memory name_) {
name_ = L1Block(Predeploys.L1_BLOCK_ATTRIBUTES).gasPayingTokenName();
}

/// @inheritdoc CrossDomainMessenger
function gasPayingTokenSymbol() public view override returns (string memory symbol_) {
symbol_ = L1Block(Predeploys.L1_BLOCK_ATTRIBUTES).gasPayingTokenSymbol();
}

/// @inheritdoc CrossDomainMessenger
function _isOtherMessenger() internal view override returns (bool) {
return AddressAliasHelper.undoL1ToL2Alias(msg.sender) == address(otherMessenger);
Expand Down
10 changes: 10 additions & 0 deletions packages/contracts-bedrock/src/L2/L2StandardBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ contract L2StandardBridge is StandardBridge, ISemver {
(addr_, decimals_) = L1Block(Predeploys.L1_BLOCK_ATTRIBUTES).gasPayingToken();
}

/// @inheritdoc StandardBridge
function gasPayingTokenName() public view override returns (string memory name_) {
name_ = L1Block(Predeploys.L1_BLOCK_ATTRIBUTES).gasPayingTokenName();
}

/// @inheritdoc StandardBridge
function gasPayingTokenSymbol() public view override returns (string memory symbol_) {
symbol_ = L1Block(Predeploys.L1_BLOCK_ATTRIBUTES).gasPayingTokenSymbol();
}

/// @custom:legacy
/// @notice Initiates a withdrawal from L2 to L1.
/// This function only works with OptimismMintableERC20 tokens or ether. Use the
Expand Down
14 changes: 14 additions & 0 deletions packages/contracts-bedrock/src/libraries/GasPayingToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import { Storage } from "src/libraries/Storage.sol";
import { Constants } from "src/libraries/Constants.sol";
import { LibString } from "@solady/utils/LibString.sol";

/// @title IGasToken
/// @notice Implemented by contracts that are aware of the custom gas token used
/// by the L2 network.
interface IGasToken {
/// @notice Getter for the ERC20 token address that is used to pay for gas and its decimals.
function gasPayingToken() external view returns (address, uint8);
/// @notice Returns the gas token name.
function gasPayingTokenName() external view returns (string memory);
/// @notice Returns the gas token symbol.
function gasPayingTokenSymbol() external view returns (string memory);
/// @notice Returns true if the network uses a custom gas token.
function isCustomGasToken() external view returns (bool);
}

/// @title GasPayingToken
/// @notice Handles reading and writing the custom gas token to storage.
/// To be used in any place where gas token information is read or
Expand Down
Loading

0 comments on commit 02085fe

Please sign in to comment.