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
fd02c719
Commit
fd02c719
authored
Mar 23, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: more cleanup
parent
402b6caf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
5 deletions
+45
-5
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+1
-1
SystemConfig.sol
packages/contracts-bedrock/contracts/L1/SystemConfig.sol
+44
-4
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
fd02c719
...
@@ -418,7 +418,7 @@ SequencerFeeVault_Test:test_withdraw_succeeds() (gas: 163228)
...
@@ -418,7 +418,7 @@ SequencerFeeVault_Test:test_withdraw_succeeds() (gas: 163228)
SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11515)
SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11515)
StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936)
StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936)
StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072)
StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072)
SystemConfig_Initialize_TestFail:test_initialize_lowGasLimit_reverts() (gas: 147
668
)
SystemConfig_Initialize_TestFail:test_initialize_lowGasLimit_reverts() (gas: 147
845
)
SystemConfig_Setters_TestFail:test_setBatcherHash_notOwner_reverts() (gas: 10546)
SystemConfig_Setters_TestFail:test_setBatcherHash_notOwner_reverts() (gas: 10546)
SystemConfig_Setters_TestFail:test_setGasConfig_notOwner_reverts() (gas: 10599)
SystemConfig_Setters_TestFail:test_setGasConfig_notOwner_reverts() (gas: 10599)
SystemConfig_Setters_TestFail:test_setGasLimit_notOwner_reverts() (gas: 10615)
SystemConfig_Setters_TestFail:test_setGasLimit_notOwner_reverts() (gas: 10615)
...
...
packages/contracts-bedrock/contracts/L1/SystemConfig.sol
View file @
fd02c719
...
@@ -21,6 +21,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -21,6 +21,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
* @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
* block distrubution.
* block distrubution.
* @custom:value RESOURCE_CONFIG Represents an update to the resource config.
*/
*/
enum UpdateType {
enum UpdateType {
BATCHER,
BATCHER,
...
@@ -31,7 +32,25 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -31,7 +32,25 @@ contract SystemConfig is OwnableUpgradeable, Semver {
}
}
/**
/**
* @notice
* @notice Represents the configuration for the EIP-1559 based curve for
* the deposit gas market. These values should be set with care
* as it is possible to set them in a way that breaks the deposit
* gas market. The target resource limit is defined as
* maxResourceLimit / elasticityMultiplier.
* This struct was designed to fit within a single word. There is
* additional space for additions in the future.
*
* @custom:field maxResourceLimit Represents the maximum amount of deposit
* gas that can be purchased per block.
* @custom:field elasticityMultiplier Determines the target resource limit
* along with the resource limit.
* @custom:field baseFeeMaxChangeDenominator Determines max change on fee per block.
* @custom:field minimumBaseFee The min deposit base fee, it is clamped to this
* value.
* @custom:field systemTxMaxGas The amount of gas supplied to the system
* transaction.
* @custom:field maximumBaseFee The max deposit base fee, it is clamped to this
* value.
*/
*/
struct ResourceConfig {
struct ResourceConfig {
uint32 maxResourceLimit;
uint32 maxResourceLimit;
...
@@ -136,6 +155,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -136,6 +155,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
* @param _batcherHash Initial batcher hash.
* @param _batcherHash Initial batcher hash.
* @param _gasLimit Initial gas limit.
* @param _gasLimit Initial gas limit.
* @param _unsafeBlockSigner Initial unsafe block signer address.
* @param _unsafeBlockSigner Initial unsafe block signer address.
* @param _config Initial ResourceConfig.
*/
*/
function initialize(
function initialize(
address _owner,
address _owner,
...
@@ -227,7 +247,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -227,7 +247,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
/**
/**
* @notice Low level setter for the unsafe block signer address. This function exists to
* @notice Low level setter for the unsafe block signer address. This function exists to
* deduplicate code arou
,
nd storing the unsafeBlockSigner address in storage.
* deduplicate code around storing the unsafeBlockSigner address in storage.
*
*
* @param _unsafeBlockSigner New unsafeBlockSigner value.
* @param _unsafeBlockSigner New unsafeBlockSigner value.
*/
*/
...
@@ -247,6 +267,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -247,6 +267,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
/**
/**
* @notice An external setter for the resource config.
* @notice An external setter for the resource config.
* @param _config The new resource config values.
*/
*/
function setResourceConfig(ResourceConfig memory _config) external onlyOwner {
function setResourceConfig(ResourceConfig memory _config) external onlyOwner {
_setResourceConfig(_config);
_setResourceConfig(_config);
...
@@ -257,7 +278,14 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -257,7 +278,14 @@ 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.
* config is sane before storing it. Holds the following 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
*
* @param _config The new resource config
*/
*/
function _setResourceConfig(ResourceConfig memory _config) internal {
function _setResourceConfig(ResourceConfig memory _config) internal {
require(
require(
...
@@ -272,13 +300,25 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -272,13 +300,25 @@ contract SystemConfig is OwnableUpgradeable, Semver {
_config.maxResourceLimit + _config.systemTxMaxGas <= gasLimit,
_config.maxResourceLimit + _config.systemTxMaxGas <= gasLimit,
"SystemConfig: gas limit too low"
"SystemConfig: gas limit too low"
);
);
require(
_config.elasticityMultiplier > 0,
"SystemConfig: elasticity multiplier cannot be 0"
);
require(
((_config.maxResourceLimit / _config.elasticityMultiplier) *
_config.elasticityMultiplier) == _config.maxResourceLimit,
"SystemConfig: precision loss with max and elasticity"
);
_resourceConfig = _config;
_resourceConfig = _config;
}
}
/**
/**
* @notice Returns the minimum L2 gas limit that can be safely set for the system to
* @notice Returns the minimum L2 gas limit that can be safely set for the system to
* operate.
* 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) {
function minimumGasLimit() public view returns (uint64) {
return uint64(_resourceConfig.maxResourceLimit) + uint64(_resourceConfig.systemTxMaxGas);
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