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
ef3d55cf
Commit
ef3d55cf
authored
Aug 07, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
6558908a
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
239 additions
and
141 deletions
+239
-141
Deploy.s.sol
packages/contracts-bedrock/scripts/Deploy.s.sol
+29
-25
SystemConfig.sol
packages/contracts-bedrock/src/L1/SystemConfig.sol
+116
-68
CommonTest.t.sol
packages/contracts-bedrock/test/CommonTest.t.sol
+31
-11
SystemConfig.t.sol
packages/contracts-bedrock/test/SystemConfig.t.sol
+41
-26
SystemConfig.t.sol
...ages/contracts-bedrock/test/invariants/SystemConfig.t.sol
+22
-11
No files found.
packages/contracts-bedrock/scripts/Deploy.s.sol
View file @
ef3d55cf
...
...
@@ -385,32 +385,29 @@ contract Deploy is Deployer {
/// @notice Deploy the SystemConfig
function deploySystemConfig() broadcast() public returns (address) {
bytes32 batcherHash = bytes32(uint256(uint160(cfg.batchSenderAddress())));
SystemConfig config = new SystemConfig({
_owner: cfg.finalSystemOwner(),
_overhead: cfg.gasPriceOracleOverhead(),
_scalar: cfg.gasPriceOracleScalar(),
_batcherHash: batcherHash,
_gasLimit: uint64(cfg.l2GenesisBlockGasLimit()),
_unsafeBlockSigner: cfg.p2pSequencerAddress(),
_config: Constants.DEFAULT_RESOURCE_CONFIG()
});
SystemConfig config = new SystemConfig();
require(config.owner() ==
cfg.finalSystemOwner(
));
require(config.overhead() ==
cfg.gasPriceOracleOverhead()
);
require(config.scalar() ==
cfg.gasPriceOracleScalar()
);
require(config.unsafeBlockSigner() ==
cfg.p2pSequencerAddress(
));
require(config.batcherHash() == b
atcherHash
);
require(config.owner() ==
address(0
));
require(config.overhead() ==
0
);
require(config.scalar() ==
0
);
require(config.unsafeBlockSigner() ==
address(0
));
require(config.batcherHash() == b
ytes32(0)
);
ResourceMetering.ResourceConfig memory rconfig = Constants.DEFAULT_RESOURCE_CONFIG();
ResourceMetering.ResourceConfig memory resourceConfig = config.resourceConfig();
require(resourceConfig.maxResourceLimit == rconfig.maxResourceLimit);
require(resourceConfig.elasticityMultiplier == rconfig.elasticityMultiplier);
require(resourceConfig.baseFeeMaxChangeDenominator == rconfig.baseFeeMaxChangeDenominator);
require(resourceConfig.systemTxMaxGas == rconfig.systemTxMaxGas);
require(resourceConfig.minimumBaseFee == rconfig.minimumBaseFee);
require(resourceConfig.maximumBaseFee == rconfig.maximumBaseFee);
require(resourceConfig.maxResourceLimit == 0);
require(resourceConfig.elasticityMultiplier == 0);
require(resourceConfig.baseFeeMaxChangeDenominator == 0);
require(resourceConfig.systemTxMaxGas == 0);
require(resourceConfig.minimumBaseFee == 0);
require(resourceConfig.maximumBaseFee == 0);
require(config.l1ERC721Bridge() == address(0));
require(config.l1StandardBridge() == address(0));
require(config.l2OutputOracle() == address(0));
require(config.optimismPortal() == address(0));
require(config.l1CrossDomainMessenger() == address(0));
require(config.startBlock() == 0);
save("SystemConfig", address(config));
console.log("SystemConfig deployed at %s", address(config));
...
...
@@ -480,6 +477,7 @@ contract Deploy is Deployer {
/// @notice Initialize the SystemConfig
function initializeSystemConfig() broadcast() public {
/*
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
address systemConfigProxy = mustGetAddress("SystemConfigProxy");
address systemConfig = mustGetAddress("SystemConfig");
...
...
@@ -503,11 +501,10 @@ contract Deploy is Deployer {
mustGetAddress("L1ERC721BridgeProxy"),
mustGetAddress("L1StandardBridgeProxy"),
mustGetAddress("L2OutputOracleProxy"),
mustGetAddress("OptimismPortalProxy")
mustGetAddress("OptimismPortalProxy"),
0 // TODO: this needs to come from deploy config
)
)
// TODO: assert that addresses are correct
});
SystemConfig config = SystemConfig(systemConfigProxy);
...
...
@@ -529,6 +526,13 @@ contract Deploy is Deployer {
require(resourceConfig.minimumBaseFee == rconfig.minimumBaseFee);
require(resourceConfig.maximumBaseFee == rconfig.maximumBaseFee);
require(config.l1ERC721Bridge() == mustGetAddress("L1ERC721BridgeProxy"));
require(config.l1StandardBridge() == mustGetAddress("L1StandardBridgeProxy"));
require(config.l2OutputOracle() == mustGetAddress("L2OutputOracleProxy"));
require(config.optimismPortal() == mustGetAddress("OptimismPortalProxy"));
require(config.l1CrossDomainMessenger() == mustGetAddress("L1CrossDomainMessengerProxy"));
require(config.startBlock() == 0); // TODO
*/
}
/// @notice Initialize the L1StandardBridge
...
...
packages/contracts-bedrock/src/L1/SystemConfig.sol
View file @
ef3d55cf
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/test/CommonTest.t.sol
View file @
ef3d55cf
...
...
@@ -202,17 +202,37 @@ contract Portal_Initializer is L2OutputOracle_Initializer {
function setUp() public virtual override {
super.setUp();
ResourceMetering.ResourceConfig memory config = Constants.DEFAULT_RESOURCE_CONFIG();
systemConfig = new SystemConfig({
_owner: address(1),
_overhead: 0,
_scalar: 10000,
_batcherHash: bytes32(0),
_gasLimit: 30_000_000,
_unsafeBlockSigner: address(0),
_config: config
});
Proxy systemConfigProxy = new Proxy(multisig);
SystemConfig systemConfigImpl = new SystemConfig();
vm.prank(multisig);
systemConfigProxy.upgradeToAndCall(
address(systemConfigImpl),
hex""
/*
abi.encodeCall(
SystemConfig.initialize,
(
address(1), //_owner,
0, //_overhead,
10000, //_scalar,
bytes32(0), //_batcherHash,
30_000_000, //_gasLimit,
address(0), //_unsafeBlockSigner,
Constants.DEFAULT_RESOURCE_CONFIG(), //_config,
address(0x40), //_l1CrossDomainMessenger,
address(0x41), //_l1ERC721Bridge,
address(0x42), //_l1StandardBridge,
address(0x43), //_l2OutputOracle,
address(0x44), //_optimismPortal,
0 //_startBlock
)
)
*/
);
systemConfig = SystemConfig(address(systemConfigProxy));
opImpl = new OptimismPortal();
...
...
packages/contracts-bedrock/test/SystemConfig.t.sol
View file @
ef3d55cf
...
...
@@ -9,34 +9,40 @@ import { Constants } from "../src/libraries/Constants.sol";
// Target contract dependencies
import { ResourceMetering } from "../src/L1/ResourceMetering.sol";
import { Proxy } from "../src/universal/Proxy.sol";
// Target contract
import { SystemConfig } from "../src/L1/SystemConfig.sol";
contract SystemConfig_Init is CommonTest {
SystemConfig sysConf;
SystemConfig systemConfigImpl;
function setUp() public virtual override {
super.setUp();
ResourceMetering.ResourceConfig memory config = ResourceMetering.ResourceConfig({
maxResourceLimit: 20_000_000,
elasticityMultiplier: 10,
baseFeeMaxChangeDenominator: 8,
minimumBaseFee: 1 gwei,
systemTxMaxGas: 1_000_000,
maximumBaseFee: type(uint128).max
});
Proxy proxy = new Proxy(multisig);
systemConfigImpl = new SystemConfig();
vm.prank(multisig);
proxy.upgradeToAndCall(
address(systemConfigImpl),
abi.encodeCall(
SystemConfig.initialize,
(
alice, //_owner,
2100, //_overhead,
1000000, //_scalar,
bytes32(hex"abcd"), //_batcherHash,
30_000_000, //_gasLimit,
address(1), //_unsafeBlockSigner,
Constants.DEFAULT_RESOURCE_CONFIG(), //_config,
0 //_startBlock
)
)
);
sysConf = new SystemConfig({
_owner: alice,
_overhead: 2100,
_scalar: 1000000,
_batcherHash: bytes32(hex"abcd"),
_gasLimit: 30_000_000,
_unsafeBlockSigner: address(1),
_config: config
});
sysConf = SystemConfig(address(proxy));
}
}
...
...
@@ -54,16 +60,25 @@ contract SystemConfig_Initialize_TestFail is SystemConfig_Init {
maximumBaseFee: type(uint128).max
});
vm.store(address(sysConf), bytes32(0), bytes32(0));
vm.expectRevert("SystemConfig: gas limit too low");
new SystemConfig({
_owner: alice,
_overhead: 0,
_scalar: 0,
_batcherHash: bytes32(hex""),
_gasLimit: minimumGasLimit - 1,
_unsafeBlockSigner: address(1),
_config: cfg
});
vm.prank(multisig);
Proxy(payable(address(sysConf))).upgradeToAndCall(
address(systemConfigImpl),
abi.encodeCall(
SystemConfig.initialize,
(
alice, //_owner,
2100, //_overhead,
1000000, //_scalar,
bytes32(hex"abcd"), //_batcherHash,
minimumGasLimit - 1, //_gasLimit,
address(1), //_unsafeBlockSigner,
cfg, //_config,
0 //_startBlock
)
)
);
}
}
...
...
packages/contracts-bedrock/test/invariants/SystemConfig.t.sol
View file @
ef3d55cf
...
...
@@ -3,24 +3,35 @@ pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { SystemConfig } from "../../src/L1/SystemConfig.sol";
import { Proxy } from "../../src/universal/Proxy.sol";
import { ResourceMetering } from "../../src/L1/ResourceMetering.sol";
import { Constants } from "../../src/libraries/Constants.sol";
contract SystemConfig_GasLimitLowerBound_Invariant is Test {
SystemConfig public config;
function setUp() public {
ResourceMetering.ResourceConfig memory cfg = Constants.DEFAULT_RESOURCE_CONFIG();
function setUp() external {
Proxy proxy = new Proxy(msg.sender);
SystemConfig configImpl = new SystemConfig();
config = new SystemConfig({
_owner: address(0xbeef),
_overhead: 2100,
_scalar: 1000000,
_batcherHash: bytes32(hex"abcd"),
_gasLimit: 30_000_000,
_unsafeBlockSigner: address(1),
_config: cfg
});
proxy.upgradeToAndCall(
address(configImpl),
abi.encodeCall(
configImpl.initialize,
(
address(0xbeef), // owner
2100, // overhead
1000000, // scalar
bytes32(hex"abcd"), // batcher hash
30_000_000, // gas limit
address(1), // unsafe block signer
Constants.DEFAULT_RESOURCE_CONFIG(), // resource config
0 //_startBlock
)
)
);
config = SystemConfig(address(proxy));
// Set the target contract to the `config`
targetContract(address(config));
...
...
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