Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
1f7dc086
Commit
1f7dc086
authored
Mar 23, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: various cleanup
parent
3daf529b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
20 deletions
+26
-20
SystemConfig.sol
packages/contracts-bedrock/contracts/L1/SystemConfig.sol
+26
-20
No files found.
packages/contracts-bedrock/contracts/L1/SystemConfig.sol
View file @
1f7dc086
...
@@ -46,7 +46,9 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -46,7 +46,9 @@ contract SystemConfig is OwnableUpgradeable, Semver {
* @custom:field minimumBaseFee The min deposit base fee, it is clamped to this
* @custom:field minimumBaseFee The min deposit base fee, it is clamped to this
* value.
* value.
* @custom:field systemTxMaxGas The amount of gas supplied to the system
* @custom:field systemTxMaxGas The amount of gas supplied to the system
* transaction.
* transaction. This should be set to the same number
* that the op-node sets as the gas limit for the
* system transaction.
* @custom:field maximumBaseFee The max deposit base fee, it is clamped to this
* @custom:field maximumBaseFee The max deposit base fee, it is clamped to this
* value.
* value.
*/
*/
...
@@ -101,7 +103,8 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -101,7 +103,8 @@ contract SystemConfig is OwnableUpgradeable, Semver {
/**
/**
* @notice The configuration for the deposit fee market. Used by the OptimismPortal
* @notice The configuration for the deposit fee market. Used by the OptimismPortal
* to meter the cost of buying L2 gas on L1.
* to meter the cost of buying L2 gas on L1. Set as internal and wrapped with a getter
* so that the struct is returned instead of a tuple.
*/
*/
ResourceConfig internal _resourceConfig;
ResourceConfig internal _resourceConfig;
...
@@ -176,6 +179,18 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -176,6 +179,18 @@ contract SystemConfig is OwnableUpgradeable, Semver {
_setResourceConfig(_config);
_setResourceConfig(_config);
require(_gasLimit >= minimumGasLimit(), "SystemConfig: gas limit too low");
require(_gasLimit >= minimumGasLimit(), "SystemConfig: gas limit too low");
}
}
/**
* @notice Returns the minimum L2 gas limit that can be safely set for the system to
* operate. The L2 gas limit must be larger than or equal to the amount of
* gas that is allocated for deposits per block plus the amount of gas that
* is allocated for the system transaction.
* This function is used to determine if changes to parameters are safe.
*
* @return uint64
*/
function minimumGasLimit() public view returns (uint64) {
return uint64(_resourceConfig.maxResourceLimit) + uint64(_resourceConfig.systemTxMaxGas);
}
/**
/**
* @notice High level getter for the unsafe block signer address. Unsafe blocks can be
* @notice High level getter for the unsafe block signer address. Unsafe blocks can be
...
@@ -261,6 +276,8 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -261,6 +276,8 @@ contract SystemConfig is OwnableUpgradeable, Semver {
/**
/**
* @notice A getter for the resource config. Ensures that the struct is
* @notice A getter for the resource config. Ensures that the struct is
* returned instead of a tuple.
* returned instead of a tuple.
*
* @return ResourceConfig
*/
*/
function resourceConfig() external view returns (ResourceConfig memory) {
function resourceConfig() external view returns (ResourceConfig memory) {
return _resourceConfig;
return _resourceConfig;
...
@@ -279,30 +296,30 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -279,30 +296,30 @@ contract SystemConfig is OwnableUpgradeable, Semver {
/**
/**
* @notice An internal setter for the resource config. Ensures that the
* @notice An internal setter for the resource config. Ensures that the
* config is sane before storing it. Holds the following invariants:
* config is sane before storing it by checking for invariants.
* - min base fee must be less than or equal to max base fee
* - base fee change denominator must be greater than 0
* - max resource limit plus system tx gas must be less than or
* equal to the L2 gas limit
* - elasticity multiplier must be greater than 0
* - no precision loss when computing target resource limit
*
*
* @param _config The new resource config
* @param _config The new resource config
*/
*/
function _setResourceConfig(ResourceConfig memory _config) internal {
function _setResourceConfig(ResourceConfig memory _config) internal {
// min base fee must be less than or equal to max base fee
require(
require(
_config.minimumBaseFee <= _config.maximumBaseFee,
_config.minimumBaseFee <= _config.maximumBaseFee,
"SystemConfig: min base fee must be less than max base"
"SystemConfig: min base fee must be less than max base"
);
);
// base fee change denominator must be greater than 0
require(_config.baseFeeMaxChangeDenominator > 0, "SystemConfig: denominator cannot be 0");
require(_config.baseFeeMaxChangeDenominator > 0, "SystemConfig: denominator cannot be 0");
// max resource limit plus system tx gas must be less than or
// equal to the L2 gas limit
require(
require(
_config.maxResourceLimit + _config.systemTxMaxGas <= gasLimit,
_config.maxResourceLimit + _config.systemTxMaxGas <= gasLimit,
"SystemConfig: gas limit too low"
"SystemConfig: gas limit too low"
);
);
// elasticity multiplier must be greater than 0
require(
require(
_config.elasticityMultiplier > 0,
_config.elasticityMultiplier > 0,
"SystemConfig: elasticity multiplier cannot be 0"
"SystemConfig: elasticity multiplier cannot be 0"
);
);
// no precision loss when computing target resource limit
require(
require(
((_config.maxResourceLimit / _config.elasticityMultiplier) *
((_config.maxResourceLimit / _config.elasticityMultiplier) *
_config.elasticityMultiplier) == _config.maxResourceLimit,
_config.elasticityMultiplier) == _config.maxResourceLimit,
...
@@ -311,15 +328,4 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -311,15 +328,4 @@ contract SystemConfig is OwnableUpgradeable, Semver {
_resourceConfig = _config;
_resourceConfig = _config;
}
}
/**
* @notice Returns the minimum L2 gas limit that can be safely set for the system to
* operate. The L2 gas limit must be larger than or equal to the amount of
* gas that is allocated for deposits per block plus the amount of gas that
* is allocated for the system transaction.
* This function is used to determine if changes to parameters are safe.
*/
function minimumGasLimit() public view returns (uint64) {
return uint64(_resourceConfig.maxResourceLimit) + uint64(_resourceConfig.systemTxMaxGas);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment