Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP4844 L1 Smart Contract Updates #8715

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went back and forth around keeping the old GAS_CONFIG naming vs this FEE_SCALARS one - if using the Fee Scalar naming instead, we could techincally omit the "ecotone" suffix throughout - open to thoughts

}

/// @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: _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.encode(_basefeeScalar, _blobBasefeeScalar);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do encodePacked

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