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
402b6caf
Commit
402b6caf
authored
Mar 23, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: fixup
parent
2f284658
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
158 additions
and
90 deletions
+158
-90
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+73
-72
SystemConfig.sol
packages/contracts-bedrock/contracts/L1/SystemConfig.sol
+20
-9
FuzzOptimismPortal.sol
...ontracts-bedrock/contracts/echidna/FuzzOptimismPortal.sol
+1
-1
CommonTest.t.sol
packages/contracts-bedrock/contracts/test/CommonTest.t.sol
+1
-1
SystemConfig.t.sol
packages/contracts-bedrock/contracts/test/SystemConfig.t.sol
+62
-6
SystemConfig.t.sol
...acts-bedrock/contracts/test/invariants/SystemConfig.t.sol
+1
-1
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
402b6caf
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/contracts/L1/SystemConfig.sol
View file @
402b6caf
...
...
@@ -239,14 +239,14 @@ contract SystemConfig is OwnableUpgradeable, Semver {
}
/**
* @notice
* @notice
A getter for the resource config.
*/
function resourceConfig() external view returns (ResourceConfig memory) {
return _resourceConfig;
}
/**
* @notice
* @notice
An external setter for the resource config.
*/
function setResourceConfig(ResourceConfig memory _config) external onlyOwner {
_setResourceConfig(_config);
...
...
@@ -256,20 +256,31 @@ contract SystemConfig is OwnableUpgradeable, Semver {
}
/**
* @notice
* @notice An internal setter for the resource config. Ensures that the
* config is sane before storing it.
*/
function _setResourceConfig(ResourceConfig memory _config) internal {
require(_config.minimumBaseFee <= _config.maximumBaseFee);
require(_config.baseFeeMaxChangeDenominator > 0);
require(_config.maxResourceLimit + _config.systemTxMaxGas <= gasLimit);
require(
_config.minimumBaseFee <= _config.maximumBaseFee,
"SystemConfig: min base fee must be less than max base"
);
require(
_config.baseFeeMaxChangeDenominator > 0,
"SystemConfig: denominator cannot be 0"
);
require(
_config.maxResourceLimit + _config.systemTxMaxGas <= gasLimit,
"SystemConfig: gas limit too low"
);
_resourceConfig = _config;
}
/**
* @notice
* @notice Returns the minimum L2 gas limit that can be safely set for the system to
* operate.
*/
function minimumGasLimit() public view returns (uint
256
) {
return
_resourceConfig.maxResourceLimit + _resourceConfig.systemTxMaxGas
;
function minimumGasLimit() public view returns (uint
64
) {
return
uint64(_resourceConfig.maxResourceLimit) + uint64(_resourceConfig.systemTxMaxGas)
;
}
}
packages/contracts-bedrock/contracts/echidna/FuzzOptimismPortal.sol
View file @
402b6caf
...
...
@@ -11,7 +11,7 @@ contract EchidnaFuzzOptimismPortal {
constructor() {
SystemConfig config = new SystemConfig({
_owner: address(
0
),
_owner: address(
1
),
_overhead: 0,
_scalar: 10000,
_batcherHash: bytes32(0),
...
...
packages/contracts-bedrock/contracts/test/CommonTest.t.sol
View file @
402b6caf
...
...
@@ -172,7 +172,7 @@ contract Portal_Initializer is L2OutputOracle_Initializer {
super.setUp();
systemConfig = new SystemConfig({
_owner: address(
0
),
_owner: address(
1
),
_overhead: 0,
_scalar: 10000,
_batcherHash: bytes32(0),
...
...
packages/contracts-bedrock/contracts/test/SystemConfig.t.sol
View file @
402b6caf
...
...
@@ -14,24 +14,23 @@ contract SystemConfig_Init is CommonTest {
_overhead: 2100,
_scalar: 1000000,
_batcherHash: bytes32(hex"abcd"),
_gasLimit:
9
_000_000,
_gasLimit:
30
_000_000,
_unsafeBlockSigner: address(1)
});
}
}
contract SystemConfig_Initialize_TestFail is
CommonTes
t {
contract SystemConfig_Initialize_TestFail is
SystemConfig_Ini
t {
function test_initialize_lowGasLimit_reverts() external {
vm.expectRevert("SystemConfig: gas limit too low"
);
uint64 minimumGasLimit = sysConf.minimumGasLimit(
);
// The minimum gas limit defined in SystemConfig:
uint64 MINIMUM_GAS_LIMIT = 8_000_000;
vm.expectRevert("SystemConfig: gas limit too low");
new SystemConfig({
_owner: alice,
_overhead: 0,
_scalar: 0,
_batcherHash: bytes32(hex""),
_gasLimit:
MINIMUM_GAS_LIMIT
- 1,
_gasLimit:
minimumGasLimit
- 1,
_unsafeBlockSigner: address(1)
});
}
...
...
@@ -57,6 +56,63 @@ contract SystemConfig_Setters_TestFail is SystemConfig_Init {
vm.expectRevert("Ownable: caller is not the owner");
sysConf.setUnsafeBlockSigner(address(0x20));
}
function test_setResourceConfig_notOwner_reverts() external {
vm.expectRevert("Ownable: caller is not the owner");
SystemConfig.ResourceConfig memory config = SystemConfig.ResourceConfig({
maxResourceLimit: 20_000_000,
elasticityMultiplier: 10,
baseFeeMaxChangeDenominator: 8,
minimumBaseFee: 1 gwei,
systemTxMaxGas: 1_000_000,
maximumBaseFee: type(uint128).max
});
sysConf.setResourceConfig(config);
}
function test_setResourceConfig_badMinMax_reverts() external {
SystemConfig.ResourceConfig memory config = SystemConfig.ResourceConfig({
maxResourceLimit: 20_000_000,
elasticityMultiplier: 10,
baseFeeMaxChangeDenominator: 8,
systemTxMaxGas: 1_000_000,
minimumBaseFee: 2 gwei,
maximumBaseFee: 1 gwei
});
vm.prank(sysConf.owner());
vm.expectRevert("SystemConfig: min base fee must be less than max base");
sysConf.setResourceConfig(config);
}
function test_setResourceConfig_zeroDenominator_reverts() external {
SystemConfig.ResourceConfig memory config = SystemConfig.ResourceConfig({
maxResourceLimit: 20_000_000,
elasticityMultiplier: 10,
baseFeeMaxChangeDenominator: 0,
systemTxMaxGas: 1_000_000,
minimumBaseFee: 1 gwei,
maximumBaseFee: 2 gwei
});
vm.prank(sysConf.owner());
vm.expectRevert("SystemConfig: denominator cannot be 0");
sysConf.setResourceConfig(config);
}
function test_setResourceConfig_lowGasLimit_reverts() external {
uint64 gasLimit = sysConf.gasLimit();
SystemConfig.ResourceConfig memory config = SystemConfig.ResourceConfig({
maxResourceLimit: uint32(gasLimit),
elasticityMultiplier: 10,
baseFeeMaxChangeDenominator: 8,
systemTxMaxGas: uint32(gasLimit),
minimumBaseFee: 1 gwei,
maximumBaseFee: 2 gwei
});
vm.prank(sysConf.owner());
vm.expectRevert("SystemConfig: gas limit too low");
sysConf.setResourceConfig(config);
}
}
contract SystemConfig_Setters_Test is SystemConfig_Init {
...
...
packages/contracts-bedrock/contracts/test/invariants/SystemConfig.t.sol
View file @
402b6caf
...
...
@@ -12,7 +12,7 @@ contract SystemConfig_GasLimitLowerBound_Invariant is Test {
_overhead: 2100,
_scalar: 1000000,
_batcherHash: bytes32(hex"abcd"),
_gasLimit:
8
_000_000,
_gasLimit:
30
_000_000,
_unsafeBlockSigner: address(1)
});
...
...
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