From 20310dbbdad53a51e9a0ef984274bd46f27f5235 Mon Sep 17 00:00:00 2001 From: anikaraghu Date: Wed, 20 Dec 2023 15:48:13 -0800 Subject: [PATCH] add new event & fields to L1 system config required for the Ecotone upgrade --- .../contracts-bedrock/src/L1/SystemConfig.sol | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/contracts-bedrock/src/L1/SystemConfig.sol b/packages/contracts-bedrock/src/L1/SystemConfig.sol index 7fbb43eb70353..6ddc39265f681 100644 --- a/packages/contracts-bedrock/src/L1/SystemConfig.sol +++ b/packages/contracts-bedrock/src/L1/SystemConfig.sol @@ -17,12 +17,14 @@ contract SystemConfig is OwnableUpgradeable, ISemver { /// @custom:value GAS_CONFIG Represents an update to txn fee config on L2. /// @custom:value GAS_LIMIT Represents an update to gas limit on L2. /// @custom:value UNSAFE_BLOCK_SIGNER Represents an update to the signer key for unsafe + /// @custom:value GAS_CONFIG_ECOTONE Represents an update to txn fee config on L2 after Ecotone upgrade. /// block distrubution. enum UpdateType { BATCHER, GAS_CONFIG, GAS_LIMIT, - UNSAFE_BLOCK_SIGNER + UNSAFE_BLOCK_SIGNER, + GAS_CONFIG_ECOTONE } /// @notice Version identifier, used for upgrades. @@ -52,6 +54,12 @@ contract SystemConfig is OwnableUpgradeable, ISemver { /// @notice L2 block gas limit. uint64 public gasLimit; + /// @notice The scalar value applied to the L1 base fee portion of the blob-capable L1 cost func + uint32 public basefeeScalar; + + /// @notice The scalar value applied to the L1 blob base fee portion of the blob-capable L1 cost func + uint32 public blobBasefeeScalar; + /// @notice The configuration for the deposit fee market. /// Used by the OptimismPortal to meter the cost of buying L2 gas on L1. /// Set as internal with a getter so that the struct is returned instead of a tuple. @@ -64,8 +72,8 @@ contract SystemConfig is OwnableUpgradeable, ISemver { event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data); /// @notice Semantic version. - /// @custom:semver 1.11.0 - string public constant version = "1.11.0"; + /// @custom:semver 1.12.0 + string public constant version = "1.12.0"; /// @notice Constructs the SystemConfig contract. Cannot set /// the owner to `address(0)` due to the Ownable contract's @@ -124,6 +132,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver { // These are set in ascending order of their UpdateTypes. _setBatcherHash(_batcherHash); _setGasConfig({ _overhead: _overhead, _scalar: _scalar }); + _setGasConfigEcotone({ _basefeeScalar: uint32(_scalar), _blobBasefeeScalar: 0 }); _setGasLimit(_gasLimit); _setUnsafeBlockSigner(_unsafeBlockSigner); _setResourceConfig(_config); @@ -197,6 +206,24 @@ contract SystemConfig is OwnableUpgradeable, ISemver { emit ConfigUpdate(VERSION, UpdateType.GAS_CONFIG, data); } + /// @notice Updates gas config as of the Ecotone upgrade. Can only be called by the owner. + /// @param _basefeeScalar New basefeeScalar value. + /// @param _blobBasefeeScalar New blobBasefeeScalar value. + function setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobBasefeeScalar) external onlyOwner { + _setGasConfigEcotone(_basefeeScalar, _blobBasefeeScalar); + } + + /// @notice Internal function for updating the fee scalars as of the Ecotone upgrade. + /// @param _basefeeScalar New basefeeScalar value. + /// @param _blobBasefeeScalar New blobBasefeeScalar value. + function _setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobBasefeeScalar) internal { + basefeeScalar = _basefeeScalar; + blobBasefeeScalar = _blobBasefeeScalar; + + bytes memory data = abi.encodePacked(_basefeeScalar, _blobBasefeeScalar); + emit ConfigUpdate(VERSION, UpdateType.GAS_CONFIG_ECOTONE, data); + } + /// @notice Updates the L2 gas limit. Can only be called by the owner. /// @param _gasLimit New gas limit. function setGasLimit(uint64 _gasLimit) external onlyOwner {