Commit b37c865f authored by Roberto Bayardo's avatar Roberto Bayardo Committed by GitHub

add new UpdateType & fields to L1 system config required for the Ecotone upgrade (#8723)

* add new event & fields to L1 system config required for the Ecotone upgrade

* Testsand linting

---------
Co-authored-by: default avataranikaraghu <anika.raghuvanshi@coinbase.com>
parent 0fbd62c8
This diff is collapsed.
This diff is collapsed.
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 352278) GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 352300)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2950440) GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2950462)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 540648) GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 540670)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4052841) GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4052863)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 442007) GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 441857)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3487756) GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3487778)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 55367) GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 55367)
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 86629) GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 86629)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68450) GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68300)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68899) GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68921)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 153501) GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 153501)
\ No newline at end of file
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
"sourceCodeHash": "0xfe22a85a76e6dca67a24202742374a23135354f3ce135f58ad8c06adf56a1d1c" "sourceCodeHash": "0xfe22a85a76e6dca67a24202742374a23135354f3ce135f58ad8c06adf56a1d1c"
}, },
"src/L1/SystemConfig.sol": { "src/L1/SystemConfig.sol": {
"initCodeHash": "0x7662ba203d662cf433b3e44b85fdd6f4d5b39d77eb88156200d15b6bc8f15bc4", "initCodeHash": "0x6362c8b56b6fa5efdb5121f8f697b33e31caeba5d0565749c1cd5656aa43d540",
"sourceCodeHash": "0x04ce779f3bf7463af5e633f76f2c712e73a8ade75c9ef3624ae59a761d279156" "sourceCodeHash": "0x88a5843cf763b01401e9eaaa4edcb8c3e60933580fa3fbc0f7e40959498e9783"
}, },
"src/L2/BaseFeeVault.sol": { "src/L2/BaseFeeVault.sol": {
"initCodeHash": "0x2744d34573be83206d1b75d049d18a7bb37f9058e68c0803e5008c46b0dc2474", "initCodeHash": "0x2744d34573be83206d1b75d049d18a7bb37f9058e68c0803e5008c46b0dc2474",
......
...@@ -98,6 +98,19 @@ ...@@ -98,6 +98,19 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "basefeeScalar",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "batcherHash", "name": "batcherHash",
...@@ -111,6 +124,19 @@ ...@@ -111,6 +124,19 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "blobBasefeeScalar",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "gasLimit", "name": "gasLimit",
...@@ -334,6 +360,24 @@ ...@@ -334,6 +360,24 @@
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "uint32",
"name": "_basefeeScalar",
"type": "uint32"
},
{
"internalType": "uint32",
"name": "_blobBasefeeScalar",
"type": "uint32"
}
],
"name": "setGasConfigEcotone",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
......
...@@ -62,6 +62,20 @@ ...@@ -62,6 +62,20 @@
"slot": "104", "slot": "104",
"type": "uint64" "type": "uint64"
}, },
{
"bytes": "4",
"label": "basefeeScalar",
"offset": 8,
"slot": "104",
"type": "uint32"
},
{
"bytes": "4",
"label": "blobBasefeeScalar",
"offset": 12,
"slot": "104",
"type": "uint32"
},
{ {
"bytes": "32", "bytes": "32",
"label": "_resourceConfig", "label": "_resourceConfig",
......
...@@ -17,12 +17,14 @@ contract SystemConfig is OwnableUpgradeable, ISemver { ...@@ -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_CONFIG Represents an update to txn fee config on L2.
/// @custom:value GAS_LIMIT Represents an update to gas limit 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 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. /// block distrubution.
enum UpdateType { enum UpdateType {
BATCHER, BATCHER,
GAS_CONFIG, GAS_CONFIG,
GAS_LIMIT, GAS_LIMIT,
UNSAFE_BLOCK_SIGNER UNSAFE_BLOCK_SIGNER,
GAS_CONFIG_ECOTONE
} }
/// @notice Version identifier, used for upgrades. /// @notice Version identifier, used for upgrades.
...@@ -52,6 +54,12 @@ contract SystemConfig is OwnableUpgradeable, ISemver { ...@@ -52,6 +54,12 @@ contract SystemConfig is OwnableUpgradeable, ISemver {
/// @notice L2 block gas limit. /// @notice L2 block gas limit.
uint64 public gasLimit; 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. /// @notice The configuration for the deposit fee market.
/// Used by the OptimismPortal to meter the cost of buying L2 gas on L1. /// 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. /// 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 { ...@@ -64,8 +72,8 @@ contract SystemConfig is OwnableUpgradeable, ISemver {
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data); event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
/// @notice Semantic version. /// @notice Semantic version.
/// @custom:semver 1.11.0 /// @custom:semver 1.12.0
string public constant version = "1.11.0"; string public constant version = "1.12.0";
/// @notice Constructs the SystemConfig contract. Cannot set /// @notice Constructs the SystemConfig contract. Cannot set
/// the owner to `address(0)` due to the Ownable contract's /// the owner to `address(0)` due to the Ownable contract's
...@@ -124,6 +132,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver { ...@@ -124,6 +132,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver {
// These are set in ascending order of their UpdateTypes. // These are set in ascending order of their UpdateTypes.
_setBatcherHash(_batcherHash); _setBatcherHash(_batcherHash);
_setGasConfig({ _overhead: _overhead, _scalar: _scalar }); _setGasConfig({ _overhead: _overhead, _scalar: _scalar });
_setGasConfigEcotone({ _basefeeScalar: uint32(_scalar), _blobBasefeeScalar: 0 });
_setGasLimit(_gasLimit); _setGasLimit(_gasLimit);
_setUnsafeBlockSigner(_unsafeBlockSigner); _setUnsafeBlockSigner(_unsafeBlockSigner);
_setResourceConfig(_config); _setResourceConfig(_config);
...@@ -197,6 +206,24 @@ contract SystemConfig is OwnableUpgradeable, ISemver { ...@@ -197,6 +206,24 @@ contract SystemConfig is OwnableUpgradeable, ISemver {
emit ConfigUpdate(VERSION, UpdateType.GAS_CONFIG, data); 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. /// @notice Updates the L2 gas limit. Can only be called by the owner.
/// @param _gasLimit New gas limit. /// @param _gasLimit New gas limit.
function setGasLimit(uint64 _gasLimit) external onlyOwner { function setGasLimit(uint64 _gasLimit) external onlyOwner {
......
...@@ -51,6 +51,8 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init { ...@@ -51,6 +51,8 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init {
assertEq(systemConfig.batcherHash(), batcherHash); assertEq(systemConfig.batcherHash(), batcherHash);
assertEq(systemConfig.gasLimit(), gasLimit); assertEq(systemConfig.gasLimit(), gasLimit);
assertEq(systemConfig.unsafeBlockSigner(), unsafeBlockSigner); assertEq(systemConfig.unsafeBlockSigner(), unsafeBlockSigner);
assertEq(systemConfig.basefeeScalar(), scalar);
assertEq(systemConfig.blobBasefeeScalar(), 0);
// Depends on `initialize` being called with defaults // Depends on `initialize` being called with defaults
ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG();
ResourceMetering.ResourceConfig memory actual = systemConfig.resourceConfig(); ResourceMetering.ResourceConfig memory actual = systemConfig.resourceConfig();
...@@ -109,6 +111,12 @@ contract SystemConfig_Setters_TestFail is SystemConfig_Init { ...@@ -109,6 +111,12 @@ contract SystemConfig_Setters_TestFail is SystemConfig_Init {
systemConfig.setGasConfig(0, 0); systemConfig.setGasConfig(0, 0);
} }
/// @dev Tests that `setGasConfigEcotone` reverts if the caller is not the owner.
function test_setGasConfigEcotone_notOwner_reverts() external {
vm.expectRevert("Ownable: caller is not the owner");
systemConfig.setGasConfigEcotone(0, 0);
}
/// @dev Tests that `setGasLimit` reverts if the caller is not the owner. /// @dev Tests that `setGasLimit` reverts if the caller is not the owner.
function test_setGasLimit_notOwner_reverts() external { function test_setGasLimit_notOwner_reverts() external {
vm.expectRevert("Ownable: caller is not the owner"); vm.expectRevert("Ownable: caller is not the owner");
...@@ -216,6 +224,19 @@ contract SystemConfig_Setters_Test is SystemConfig_Init { ...@@ -216,6 +224,19 @@ contract SystemConfig_Setters_Test is SystemConfig_Init {
assertEq(systemConfig.scalar(), newScalar); assertEq(systemConfig.scalar(), newScalar);
} }
/// @dev Tests that `setGasConfigEcotone` updates the gas limit successfully.
function testFuzz_setGasConfigEcotone_succeeds(uint32 basefeeScalar, uint32 blobBasefeeScalar) external {
vm.expectEmit(address(systemConfig));
emit ConfigUpdate(
0, SystemConfig.UpdateType.GAS_CONFIG_ECOTONE, abi.encodePacked(basefeeScalar, blobBasefeeScalar)
);
vm.prank(systemConfig.owner());
systemConfig.setGasConfigEcotone(basefeeScalar, blobBasefeeScalar);
assertEq(systemConfig.basefeeScalar(), basefeeScalar);
assertEq(systemConfig.blobBasefeeScalar(), blobBasefeeScalar);
}
/// @dev Tests that `setGasLimit` updates the gas limit successfully. /// @dev Tests that `setGasLimit` updates the gas limit successfully.
function testFuzz_setGasLimit_succeeds(uint64 newGasLimit) external { function testFuzz_setGasLimit_succeeds(uint64 newGasLimit) external {
uint64 minimumGasLimit = systemConfig.minimumGasLimit(); uint64 minimumGasLimit = systemConfig.minimumGasLimit();
......
...@@ -258,6 +258,8 @@ contract Specification_Test is CommonTest { ...@@ -258,6 +258,8 @@ contract Specification_Test is CommonTest {
_addSpec({ _name: "SystemConfig", _sel: _getSel("VERSION()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("VERSION()") });
_addSpec({ _name: "SystemConfig", _sel: _getSel("batcherHash()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("batcherHash()") });
_addSpec({ _name: "SystemConfig", _sel: _getSel("gasLimit()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("gasLimit()") });
_addSpec({ _name: "SystemConfig", _sel: _getSel("basefeeScalar()") });
_addSpec({ _name: "SystemConfig", _sel: _getSel("blobBasefeeScalar()") });
_addSpec({ _name: "SystemConfig", _sel: SystemConfig.initialize.selector }); _addSpec({ _name: "SystemConfig", _sel: SystemConfig.initialize.selector });
_addSpec({ _name: "SystemConfig", _sel: SystemConfig.minimumGasLimit.selector }); _addSpec({ _name: "SystemConfig", _sel: SystemConfig.minimumGasLimit.selector });
_addSpec({ _name: "SystemConfig", _sel: _getSel("overhead()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("overhead()") });
...@@ -267,6 +269,11 @@ contract Specification_Test is CommonTest { ...@@ -267,6 +269,11 @@ contract Specification_Test is CommonTest {
_addSpec({ _name: "SystemConfig", _sel: _getSel("scalar()") }); _addSpec({ _name: "SystemConfig", _sel: _getSel("scalar()") });
_addSpec({ _name: "SystemConfig", _sel: SystemConfig.setBatcherHash.selector, _auth: Role.SYSTEMCONFIGOWNER }); _addSpec({ _name: "SystemConfig", _sel: SystemConfig.setBatcherHash.selector, _auth: Role.SYSTEMCONFIGOWNER });
_addSpec({ _name: "SystemConfig", _sel: SystemConfig.setGasConfig.selector, _auth: Role.SYSTEMCONFIGOWNER }); _addSpec({ _name: "SystemConfig", _sel: SystemConfig.setGasConfig.selector, _auth: Role.SYSTEMCONFIGOWNER });
_addSpec({
_name: "SystemConfig",
_sel: SystemConfig.setGasConfigEcotone.selector,
_auth: Role.SYSTEMCONFIGOWNER
});
_addSpec({ _name: "SystemConfig", _sel: SystemConfig.setGasLimit.selector, _auth: Role.SYSTEMCONFIGOWNER }); _addSpec({ _name: "SystemConfig", _sel: SystemConfig.setGasLimit.selector, _auth: Role.SYSTEMCONFIGOWNER });
_addSpec({ _name: "SystemConfig", _sel: SystemConfig.setResourceConfig.selector, _auth: Role.SYSTEMCONFIGOWNER }); _addSpec({ _name: "SystemConfig", _sel: SystemConfig.setResourceConfig.selector, _auth: Role.SYSTEMCONFIGOWNER });
_addSpec({ _addSpec({
......
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