Skip to content

Commit

Permalink
add new event & fields to L1 system config required for the Ecotone u…
Browse files Browse the repository at this point in the history
…pgrade
  • Loading branch information
anikaraghu authored and Roberto Bayardo committed Dec 21, 2023
1 parent 79e62bf commit cf07d83
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions packages/contracts-bedrock/src/L1/SystemConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 FEE_SCALARS_ECOTONE Represents an update to fee scalars on L2 after ecotone.
/// block distrubution.
enum UpdateType {
BATCHER,
GAS_CONFIG,
GAS_LIMIT,
UNSAFE_BLOCK_SIGNER
UNSAFE_BLOCK_SIGNER,
FEE_SCALARS_ECOTONE
}

/// @notice Version identifier, used for upgrades.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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 });
_setFeeScalarsEcotone({ _basefeeScalar: uint32(_scalar), _blobBasefeeScalar: 0 });
_setGasLimit(_gasLimit);
_setUnsafeBlockSigner(_unsafeBlockSigner);
_setResourceConfig(_config);
Expand Down Expand Up @@ -197,6 +206,24 @@ contract SystemConfig is OwnableUpgradeable, ISemver {
emit ConfigUpdate(VERSION, UpdateType.GAS_CONFIG, data);
}

/// @notice Updates fee scalars. Can only be called by the owner. Introduced in Ecotone.
/// @param _basefeeScalar New basefeeScalar value.
/// @param _blobBasefeeScalar New blobBasefeeScalar value.
function setFeeScalarsEcotone(uint32 _basefeeScalar, uint32 _blobBasefeeScalar) external onlyOwner {
_setFeeScalarsEcotone(_basefeeScalar, _blobBasefeeScalar);
}

/// @notice Internal function for updating the fee scalars.
/// @param _basefeeScalar New basefeeScalar value.
/// @param _blobBasefeeScalar New blobBasefeeScalar value.
function _setFeeScalarsEcotone(uint32 _basefeeScalar, uint32 _blobBasefeeScalar) internal {
basefeeScalar = _basefeeScalar;
blobBasefeeScalar = _blobBasefeeScalar;

bytes memory data = abi.encodePacked(_basefeeScalar, _blobBasefeeScalar);
emit ConfigUpdate(VERSION, UpdateType.FEE_SCALARS_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 {
Expand Down

0 comments on commit cf07d83

Please sign in to comment.