Commit f58973a9 authored by Mark Tyneway's avatar Mark Tyneway

systemconfig: updates

parent bc0e517b
......@@ -25,6 +25,8 @@ contract SystemConfig is OwnableUpgradeable, Semver {
UNSAFE_BLOCK_SIGNER
}
/// @notice Struct representing the addresses of L1 system contracts. These should be the
/// proxies and will differ for each OP Stack chain.
struct Addresses {
address l1CrossDomainMessenger;
address l1ERC721Bridge;
......@@ -42,22 +44,22 @@ contract SystemConfig is OwnableUpgradeable, Semver {
/// proof to fetch this value.
bytes32 public constant UNSAFE_BLOCK_SIGNER_SLOT = keccak256("systemconfig.unsafeblocksigner");
/// @notice
/// @notice Storage slot that the L1CrossDomainMessenger address is stored at.
bytes32 public constant L1_CROSS_DOMAIN_MESSENGER_SLOT = keccak256("systemconfig.l1crossdomainmessenger");
/// @notice
/// @notice Storage slot that the L1ERC721Bridge address is stored at.
bytes32 public constant L1_ERC_721_BRIDGE_SLOT = keccak256("systemconfig.l1erc721bridge");
/// @notice
/// @notice Storage slot that the L1StandardBridge address is stored at.
bytes32 public constant L1_STANDARD_BRIDGE_SLOT = keccak256("systemconfig.l1standardbridge");
/// @notice
/// @notice Storage slot that the L2OutputOracle address is stored at.
bytes32 public constant L2_OUTPUT_ORACLE_SLOT = keccak256("systemconfig.l2outputoracle");
/// @notice
/// @notice Storage slot that the OptimismPortal address is stored at.
bytes32 public constant OPTIMISM_PORTAL_SLOT = keccak256("systemconfig.optimismportal");
/// @notice
/// @notice Storage slot that the batch inbox address is stored at.
bytes32 public constant BATCH_INBOX_SLOT = keccak256("systemconfig.batchinbox");
/// @notice Fixed L2 gas overhead. Used as part of the L2 fee calculation.
......@@ -85,8 +87,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
/// @param data Encoded update data.
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
/// @notice The block at which the op-node can start searching for
/// logs from.
/// @notice The block at which the op-node can start searching for logs from.
uint256 public startBlock;
/// @custom:semver 1.4.0
......
......@@ -18,6 +18,19 @@ contract SystemConfig_Init is CommonTest {
SystemConfig sysConf;
SystemConfig systemConfigImpl;
// Dummy addresses used to test getters
address constant batchInbox = address(0x18);
address constant l1CrossDomainMessenger = address(0x20);
address constant l1ERC721Bridge = address(0x21);
address constant l1StandardBridge = address(0x22);
address constant l2OutputOracle = address(0x23);
address constant optimismPortal = address(0x24);
uint256 constant overhead = 2100;
uint256 constant scalar = 1000000;
bytes32 constant batcherHash = bytes32(hex"abcd");
uint64 constant gasLimit = 30_000_000;
address constant unsafeBlockSigner = address(1);
function setUp() public virtual override {
super.setUp();
......@@ -30,21 +43,21 @@ contract SystemConfig_Init is CommonTest {
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
address(0), // _batchInbox
SystemConfig.Addresses({ // _addresses
l1CrossDomainMessenger: address(0),
l1ERC721Bridge: address(0),
l1StandardBridge: address(0),
l2OutputOracle: address(0),
optimismPortal: address(0)
alice, //_owner,
overhead, //_overhead,
scalar, //_scalar,
batcherHash, // _batcherHash
gasLimit, //_gasLimit,
unsafeBlockSigner, //_unsafeBlockSigner,
Constants.DEFAULT_RESOURCE_CONFIG(), //_config,
0, //_startBlock
batchInbox, // _batchInbox
SystemConfig.Addresses({ // _addresses
l1CrossDomainMessenger: l1CrossDomainMessenger,
l1ERC721Bridge: l1ERC721Bridge,
l1StandardBridge: l1StandardBridge,
l2OutputOracle: l2OutputOracle,
optimismPortal: optimismPortal
})
)
)
......@@ -54,6 +67,35 @@ contract SystemConfig_Init is CommonTest {
}
}
contract SystemConfig_Initialize_Test is SystemConfig_Init {
/// @dev Tests that initailization sets the correct values.
function test_initialize_values() external {
assertEq(sysConf.l1CrossDomainMessenger(), l1CrossDomainMessenger);
assertEq(sysConf.l1ERC721Bridge(), l1ERC721Bridge);
assertEq(sysConf.l1StandardBridge(), l1StandardBridge);
assertEq(sysConf.l2OutputOracle(), l2OutputOracle);
assertEq(sysConf.optimismPortal(), optimismPortal);
assertEq(sysConf.batchInbox(), batchInbox);
assertEq(sysConf.owner(), alice);
assertEq(sysConf.overhead(), overhead);
assertEq(sysConf.scalar(), scalar);
assertEq(sysConf.batcherHash(), batcherHash);
assertEq(sysConf.gasLimit(), gasLimit);
assertEq(sysConf.unsafeBlockSigner(), unsafeBlockSigner);
// Depends on start block being set to 0 in `initialize`
assertEq(sysConf.startBlock(), block.number);
// Depends on `initialize` being called with defaults
ResourceMetering.ResourceConfig memory cfg = Constants.DEFAULT_RESOURCE_CONFIG();
ResourceMetering.ResourceConfig memory actual = sysConf.resourceConfig();
assertEq(actual.maxResourceLimit, cfg.maxResourceLimit);
assertEq(actual.elasticityMultiplier, cfg.elasticityMultiplier);
assertEq(actual.baseFeeMaxChangeDenominator, cfg.baseFeeMaxChangeDenominator);
assertEq(actual.minimumBaseFee, cfg.minimumBaseFee);
assertEq(actual.systemTxMaxGas, cfg.systemTxMaxGas);
assertEq(actual.maximumBaseFee, cfg.maximumBaseFee);
}
}
contract SystemConfig_Initialize_TestFail is SystemConfig_Init {
/// @dev Tests that initialization reverts if the gas limit is too low.
function test_initialize_lowGasLimit_reverts() external {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment