Skip to content

Commit

Permalink
eip-1559 sysconfig contract changes
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-bayardo committed Oct 17, 2024
1 parent 15ae54a commit ffa6ccd
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 19 deletions.
18 changes: 9 additions & 9 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchm
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099)
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531)
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369242)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967382)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564356)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076571)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467019)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512723)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72621)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369350)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967490)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564464)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076679)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 466998)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512702)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72664)
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68357)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68921)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68422)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68986)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155610)
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
"sourceCodeHash": "0x39489a85bc3a5c8560f82d41b31bf7fe22f5b648f4ed538f61695a73092ea9eb"
},
"src/L1/SystemConfig.sol": {
"initCodeHash": "0xbe40fde9ebea4cd0820dc7f1b1a5c8c1f5ace448baacdafb3068d16d55218180",
"sourceCodeHash": "0x7c0366afeb116516d2de0d29456efea82ccdf643b1fcea215e3585d109c314a7"
"initCodeHash": "0x429058f75d97fa7a7d0166b59830909bc722324feefc40f2b41419d6335d3f37",
"sourceCodeHash": "0x5ca776041a4ddc0d28ec55db7012d669481cd4601b0e71dbd3493a67b8a7e5a5"
},
"src/L1/SystemConfigInterop.sol": {
"initCodeHash": "0x9fe11f6086be055e9abfc6d38037ba2af5a9644b4a4b3fd66a6cbdb55f17c1e1",
"sourceCodeHash": "0x53de72f7057d459da79207f560b3bf1d057e901ec38f515ea7d29d7e323063e1"
"initCodeHash": "0x277a61dcabed81a15739a8e9ed50615252bcc687cebea852e00191d0a1fbe11f",
"sourceCodeHash": "0x38361a4f70a19e1b7819e933932a0c9fd2bcebaaebcbc7942f5c00dfaa2c28df"
},
"src/L2/BaseFeeVault.sol": {
"initCodeHash": "0xbf49824cf37e201181484a8a423fcad8f504dc925921a2b28e83398197858dec",
Expand Down
44 changes: 44 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/SystemConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,32 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eip1559Denominator",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eip1559Elasticity",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasLimit",
Expand Down Expand Up @@ -586,6 +612,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint32",
"name": "_denominator",
"type": "uint32"
},
{
"internalType": "uint32",
"name": "_elasticity",
"type": "uint32"
}
],
"name": "setEIP1559Params",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
44 changes: 44 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/SystemConfigInterop.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,32 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eip1559Denominator",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eip1559Elasticity",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasLimit",
Expand Down Expand Up @@ -747,6 +773,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint32",
"name": "_denominator",
"type": "uint32"
},
{
"internalType": "uint32",
"name": "_elasticity",
"type": "uint32"
}
],
"name": "setEIP1559Params",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,19 @@
"offset": 0,
"slot": "105",
"type": "struct IResourceMetering.ResourceConfig"
},
{
"bytes": "4",
"label": "eip1559Denominator",
"offset": 0,
"slot": "106",
"type": "uint32"
},
{
"bytes": "4",
"label": "eip1559Elasticity",
"offset": 4,
"slot": "106",
"type": "uint32"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,19 @@
"offset": 0,
"slot": "105",
"type": "struct IResourceMetering.ResourceConfig"
},
{
"bytes": "4",
"label": "eip1559Denominator",
"offset": 0,
"slot": "106",
"type": "uint32"
},
{
"bytes": "4",
"label": "eip1559Elasticity",
"offset": 4,
"slot": "106",
"type": "uint32"
}
]
32 changes: 29 additions & 3 deletions packages/contracts-bedrock/src/L1/SystemConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
BATCHER,
FEE_SCALARS,
GAS_LIMIT,
UNSAFE_BLOCK_SIGNER
UNSAFE_BLOCK_SIGNER,
EIP_1559_PARAMS
}

/// @notice Struct representing the addresses of L1 system contracts. These should be the
Expand Down Expand Up @@ -123,16 +124,22 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
/// Set as internal with a getter so that the struct is returned instead of a tuple.
IResourceMetering.ResourceConfig internal _resourceConfig;

/// @notice The EIP-1559 base fee max change denominator.
uint32 public eip1559Denominator;

/// @notice The EIP-1559 elasticity multiplier.
uint32 public eip1559Elasticity;

/// @notice Emitted when configuration is updated.
/// @param version SystemConfig version.
/// @param updateType Type of update.
/// @param data Encoded update data.
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);

/// @notice Semantic version.
/// @custom:semver 2.3.0-beta.4
/// @custom:semver 2.3.0-beta.5
function version() public pure virtual returns (string memory) {
return "2.3.0-beta.4";
return "2.3.0-beta.5";
}

/// @notice Constructs the SystemConfig contract. Cannot set
Expand Down Expand Up @@ -420,6 +427,25 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
emit ConfigUpdate(VERSION, UpdateType.GAS_LIMIT, data);
}

/// @notice Updates the EIP-1559 parameters of the chain. Can only be called by the owner.
/// @param _denominator EIP-1559 base fee max change denominator.
/// @param _elasticity EIP-1559 elasticity multiplier.
function setEIP1559Params(uint32 _denominator, uint32 _elasticity) external onlyOwner {
_setEIP1559Params(_denominator, _elasticity);
}

/// @notice Internal function for updating the EIP-1559 parameters.
function _setEIP1559Params(uint32 _denominator, uint32 _elasticity) internal {
// require the parameters have sane values:
require(_denominator >= 1, "SystemConfig: denominator must be >= 1");
require(_elasticity >= 1, "SystemConfig: elasticity must be >= 1");
eip1559Denominator = _denominator;
eip1559Elasticity = _elasticity;

bytes memory data = abi.encode(uint256(_denominator) << 32 | uint64(_elasticity));
emit ConfigUpdate(VERSION, UpdateType.EIP_1559_PARAMS, data);
}

/// @notice Sets the start block in a backwards compatible way. Proxies
/// that were initialized before the startBlock existed in storage
/// can have their start block set by a user provided override.
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/src/L1/SystemConfigInterop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ contract SystemConfigInterop is SystemConfig {
Storage.setAddress(DEPENDENCY_MANAGER_SLOT, _dependencyManager);
}

/// @custom:semver +interop-beta.2
/// @custom:semver +interop-beta.3
function version() public pure override returns (string memory) {
return string.concat(super.version(), "+interop-beta.2");
return string.concat(super.version(), "+interop-beta.3");
}

/// @notice Internal setter for the gas paying token address, includes validation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ interface ISystemConfig {
BATCHER,
FEE_SCALARS,
GAS_LIMIT,
UNSAFE_BLOCK_SIGNER
UNSAFE_BLOCK_SIGNER,
EIP_1559_PARAMS
}

struct Addresses {
Expand Down Expand Up @@ -42,6 +43,8 @@ interface ISystemConfig {
function blobbasefeeScalar() external view returns (uint32);
function disputeGameFactory() external view returns (address addr_);
function gasLimit() external view returns (uint64);
function eip1559Denominator() external view returns (uint32);
function eip1559Elasticity() external view returns (uint32);
function gasPayingToken() external view returns (address addr_, uint8 decimals_);
function gasPayingTokenName() external view returns (string memory name_);
function gasPayingTokenSymbol() external view returns (string memory symbol_);
Expand Down Expand Up @@ -75,6 +78,7 @@ interface ISystemConfig {
function setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobbasefeeScalar) external;
function setGasLimit(uint64 _gasLimit) external;
function setUnsafeBlockSigner(address _unsafeBlockSigner) external;
function setEIP1559Params(uint32 _denominator, uint32 _elasticity) external;
function startBlock() external view returns (uint256 startBlock_);
function transferOwnership(address newOwner) external; // nosemgrep
function unsafeBlockSigner() external view returns (address addr_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ interface ISystemConfigInterop {
function blobbasefeeScalar() external view returns (uint32);
function disputeGameFactory() external view returns (address addr_);
function gasLimit() external view returns (uint64);
function eip1559Denominator() external view returns (uint32);
function eip1559Elasticity() external view returns (uint32);
function gasPayingToken() external view returns (address addr_, uint8 decimals_);
function gasPayingTokenName() external view returns (string memory name_);
function gasPayingTokenSymbol() external view returns (string memory symbol_);
Expand All @@ -46,6 +48,7 @@ interface ISystemConfigInterop {
function setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobbasefeeScalar) external;
function setGasLimit(uint64 _gasLimit) external;
function setUnsafeBlockSigner(address _unsafeBlockSigner) external;
function setEIP1559Params(uint32 _denominator, uint32 _elasticity) external;
function startBlock() external view returns (uint256 startBlock_);
function transferOwnership(address newOwner) external; // nosemgrep
function unsafeBlockSigner() external view returns (address addr_);
Expand Down
6 changes: 6 additions & 0 deletions packages/contracts-bedrock/test/L1/SystemConfig.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,12 @@ contract SystemConfig_Setters_TestFail is SystemConfig_Init {
vm.expectRevert("SystemConfig: gas limit too high");
systemConfig.setGasLimit(maximumGasLimit + 1);
}

/// @dev Tests that `setGasLimit` reverts if the caller is not the owner.
function test_setEIP1559Params_notOwner_reverts() external {
vm.expectRevert("Ownable: caller is not the owner");
systemConfig.setEIP1559Params(1, 1);
}
}

contract SystemConfig_Setters_Test is SystemConfig_Init {
Expand Down
10 changes: 10 additions & 0 deletions packages/contracts-bedrock/test/universal/Specs.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ contract Specification_Test is CommonTest {
_addSpec({ _name: "SystemConfig", _sel: _getSel("VERSION()") });
_addSpec({ _name: "SystemConfig", _sel: _getSel("batcherHash()") });
_addSpec({ _name: "SystemConfig", _sel: _getSel("gasLimit()") });
_addSpec({ _name: "SystemConfig", _sel: _getSel("eip1559Denominator()") });
_addSpec({ _name: "SystemConfig", _sel: _getSel("eip1559Elasticity()") });
_addSpec({ _name: "SystemConfig", _sel: ISystemConfig.initialize.selector });
_addSpec({ _name: "SystemConfig", _sel: ISystemConfig.minimumGasLimit.selector });
_addSpec({ _name: "SystemConfig", _sel: _getSel("overhead()") });
Expand All @@ -440,6 +442,7 @@ contract Specification_Test is CommonTest {
_addSpec({ _name: "SystemConfig", _sel: ISystemConfig.setBatcherHash.selector, _auth: Role.SYSTEMCONFIGOWNER });
_addSpec({ _name: "SystemConfig", _sel: ISystemConfig.setGasConfig.selector, _auth: Role.SYSTEMCONFIGOWNER });
_addSpec({ _name: "SystemConfig", _sel: ISystemConfig.setGasLimit.selector, _auth: Role.SYSTEMCONFIGOWNER });
_addSpec({ _name: "SystemConfig", _sel: ISystemConfig.setEIP1559Params.selector, _auth: Role.SYSTEMCONFIGOWNER });
_addSpec({
_name: "SystemConfig",
_sel: ISystemConfig.setUnsafeBlockSigner.selector,
Expand Down Expand Up @@ -482,6 +485,8 @@ contract Specification_Test is CommonTest {
_addSpec({ _name: "SystemConfigInterop", _sel: _getSel("VERSION()") });
_addSpec({ _name: "SystemConfigInterop", _sel: _getSel("batcherHash()") });
_addSpec({ _name: "SystemConfigInterop", _sel: _getSel("gasLimit()") });
_addSpec({ _name: "SystemConfigInterop", _sel: _getSel("eip1559Denominator()") });
_addSpec({ _name: "SystemConfigInterop", _sel: _getSel("eip1559Elasticity()") });
_addSpec({ _name: "SystemConfigInterop", _sel: ISystemConfig.initialize.selector });
_addSpec({ _name: "SystemConfigInterop", _sel: ISystemConfig.minimumGasLimit.selector });
_addSpec({ _name: "SystemConfigInterop", _sel: _getSel("overhead()") });
Expand All @@ -504,6 +509,11 @@ contract Specification_Test is CommonTest {
_sel: ISystemConfig.setGasLimit.selector,
_auth: Role.SYSTEMCONFIGOWNER
});
_addSpec({
_name: "SystemConfigInterop",
_sel: ISystemConfig.setEIP1559Params.selector,
_auth: Role.SYSTEMCONFIGOWNER
});
_addSpec({
_name: "SystemConfigInterop",
_sel: ISystemConfig.setUnsafeBlockSigner.selector,
Expand Down

0 comments on commit ffa6ccd

Please sign in to comment.