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
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 {
...
@@ -385,32 +385,29 @@ contract Deploy is Deployer {
/// @notice Deploy the SystemConfig
/// @notice Deploy the SystemConfig
function deploySystemConfig() broadcast() public returns (address) {
function deploySystemConfig() broadcast() public returns (address) {
bytes32 batcherHash = bytes32(uint256(uint160(cfg.batchSenderAddress())));
SystemConfig config = new SystemConfig();
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()
});
require(config.owner() ==
cfg.finalSystemOwner(
));
require(config.owner() ==
address(0
));
require(config.overhead() ==
cfg.gasPriceOracleOverhead()
);
require(config.overhead() ==
0
);
require(config.scalar() ==
cfg.gasPriceOracleScalar()
);
require(config.scalar() ==
0
);
require(config.unsafeBlockSigner() ==
cfg.p2pSequencerAddress(
));
require(config.unsafeBlockSigner() ==
address(0
));
require(config.batcherHash() == b
atcherHash
);
require(config.batcherHash() == b
ytes32(0)
);
ResourceMetering.ResourceConfig memory rconfig = Constants.DEFAULT_RESOURCE_CONFIG();
ResourceMetering.ResourceConfig memory rconfig = Constants.DEFAULT_RESOURCE_CONFIG();
ResourceMetering.ResourceConfig memory resourceConfig = config.resourceConfig();
ResourceMetering.ResourceConfig memory resourceConfig = config.resourceConfig();
require(resourceConfig.maxResourceLimit == rconfig.maxResourceLimit);
require(resourceConfig.maxResourceLimit == 0);
require(resourceConfig.elasticityMultiplier == rconfig.elasticityMultiplier);
require(resourceConfig.elasticityMultiplier == 0);
require(resourceConfig.baseFeeMaxChangeDenominator == rconfig.baseFeeMaxChangeDenominator);
require(resourceConfig.baseFeeMaxChangeDenominator == 0);
require(resourceConfig.systemTxMaxGas == rconfig.systemTxMaxGas);
require(resourceConfig.systemTxMaxGas == 0);
require(resourceConfig.minimumBaseFee == rconfig.minimumBaseFee);
require(resourceConfig.minimumBaseFee == 0);
require(resourceConfig.maximumBaseFee == rconfig.maximumBaseFee);
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));
save("SystemConfig", address(config));
console.log("SystemConfig deployed at %s", address(config));
console.log("SystemConfig deployed at %s", address(config));
...
@@ -480,6 +477,7 @@ contract Deploy is Deployer {
...
@@ -480,6 +477,7 @@ contract Deploy is Deployer {
/// @notice Initialize the SystemConfig
/// @notice Initialize the SystemConfig
function initializeSystemConfig() broadcast() public {
function initializeSystemConfig() broadcast() public {
/*
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
address systemConfigProxy = mustGetAddress("SystemConfigProxy");
address systemConfigProxy = mustGetAddress("SystemConfigProxy");
address systemConfig = mustGetAddress("SystemConfig");
address systemConfig = mustGetAddress("SystemConfig");
...
@@ -503,11 +501,10 @@ contract Deploy is Deployer {
...
@@ -503,11 +501,10 @@ contract Deploy is Deployer {
mustGetAddress("L1ERC721BridgeProxy"),
mustGetAddress("L1ERC721BridgeProxy"),
mustGetAddress("L1StandardBridgeProxy"),
mustGetAddress("L1StandardBridgeProxy"),
mustGetAddress("L2OutputOracleProxy"),
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);
SystemConfig config = SystemConfig(systemConfigProxy);
...
@@ -529,6 +526,13 @@ contract Deploy is Deployer {
...
@@ -529,6 +526,13 @@ contract Deploy is Deployer {
require(resourceConfig.minimumBaseFee == rconfig.minimumBaseFee);
require(resourceConfig.minimumBaseFee == rconfig.minimumBaseFee);
require(resourceConfig.maximumBaseFee == rconfig.maximumBaseFee);
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
/// @notice Initialize the L1StandardBridge
...
...
packages/contracts-bedrock/src/L1/SystemConfig.sol
View file @
ef3d55cf
...
@@ -25,6 +25,15 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -25,6 +25,15 @@ contract SystemConfig is OwnableUpgradeable, Semver {
UNSAFE_BLOCK_SIGNER
UNSAFE_BLOCK_SIGNER
}
}
struct Addresses {
address l1CrossDomainMessenger;
address l1ERC721Bridge;
address l1StandardBridge;
address l2OutputOracle;
address optimismPortal;
//address batchInbox;
}
/// @notice Version identifier, used for upgrades.
/// @notice Version identifier, used for upgrades.
uint256 public constant VERSION = 0;
uint256 public constant VERSION = 0;
...
@@ -34,12 +43,24 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -34,12 +43,24 @@ contract SystemConfig is OwnableUpgradeable, Semver {
/// proof to fetch this value.
/// proof to fetch this value.
bytes32 public constant UNSAFE_BLOCK_SIGNER_SLOT = keccak256("systemconfig.unsafeblocksigner");
bytes32 public constant UNSAFE_BLOCK_SIGNER_SLOT = keccak256("systemconfig.unsafeblocksigner");
/// @notice
bytes32 public constant L1_CROSS_DOMAIN_MESSENGER_SLOT = keccak256("systemconfig.l1crossdomainmessenger");
bytes32 public constant L1_CROSS_DOMAIN_MESSENGER_SLOT = keccak256("systemconfig.l1crossdomainmessenger");
/// @notice
bytes32 public constant L1_ERC_721_BRIDGE_SLOT = keccak256("systemconfig.l1erc721bridge");
bytes32 public constant L1_ERC_721_BRIDGE_SLOT = keccak256("systemconfig.l1erc721bridge");
/// @notice
bytes32 public constant L1_STANDARD_BRIDGE_SLOT = keccak256("systemconfig.l1standardbridge");
bytes32 public constant L1_STANDARD_BRIDGE_SLOT = keccak256("systemconfig.l1standardbridge");
/// @notice
bytes32 public constant L2_OUTPUT_ORACLE_SLOT = keccak256("systemconfig.l2outputoracle");
bytes32 public constant L2_OUTPUT_ORACLE_SLOT = keccak256("systemconfig.l2outputoracle");
/// @notice
bytes32 public constant OPTIMISM_PORTAL_SLOT = keccak256("systemconfig.optimismportal");
bytes32 public constant OPTIMISM_PORTAL_SLOT = keccak256("systemconfig.optimismportal");
/// @notice
bytes32 public constant BATCH_INBOX_SLOT = keccak256("systemconfig.batchinbox");
/// @notice Fixed L2 gas overhead. Used as part of the L2 fee calculation.
/// @notice Fixed L2 gas overhead. Used as part of the L2 fee calculation.
uint256 public overhead;
uint256 public overhead;
...
@@ -66,40 +87,28 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -66,40 +87,28 @@ contract SystemConfig is OwnableUpgradeable, Semver {
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
/// @notice The block at which the op-node can start searching for
/// @notice The block at which the op-node can start searching for
/// logs from
/// logs from
.
uint256 startBlock;
uint256
public
startBlock;
/// @custom:semver 1.
3.1
/// @custom:semver 1.
4.0
/// @notice Constructs the SystemConfig contract.
/// @notice Constructs the SystemConfig contract.
/// @param _owner Initial owner of the contract.
constructor() Semver(1, 4, 0) {
/// @param _overhead Initial overhead value.
/// @param _scalar Initial scalar value.
/// @param _batcherHash Initial batcher hash.
/// @param _gasLimit Initial gas limit.
/// @param _unsafeBlockSigner Initial unsafe block signer address.
/// @param _config Initial resource config.
constructor(
address _owner,
uint256 _overhead,
uint256 _scalar,
bytes32 _batcherHash,
uint64 _gasLimit,
address _unsafeBlockSigner,
ResourceMetering.ResourceConfig memory _config
) Semver(1, 3, 1) {
initialize({
initialize({
_owner: _owner,
_owner: address(0),
_overhead: _overhead,
_overhead: 0,
_scalar: _scalar,
_scalar: 0,
_batcherHash: _batcherHash,
_batcherHash: bytes32(0),
_gasLimit: _gasLimit,
_gasLimit: 0,
_unsafeBlockSigner: _unsafeBlockSigner,
_unsafeBlockSigner: address(0),
_config: _config,
_config: ResourceMetering.ResourceConfig({
_l1CrossDomainMessenger: address(0),
maxResourceLimit: 0,
_l1ERC721Bridge: address(0),
elasticityMultiplier: 0,
_l1StandardBridge: address(0),
baseFeeMaxChangeDenominator: 0,
_l2OutputOracle: address(0),
minimumBaseFee: 0,
_optimismPortal: address(0)
systemTxMaxGas: 0,
maximumBaseFee: 0
}),
_startBlock: 0
});
});
}
}
...
@@ -120,44 +129,54 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -120,44 +129,54 @@ contract SystemConfig is OwnableUpgradeable, Semver {
uint64 _gasLimit,
uint64 _gasLimit,
address _unsafeBlockSigner,
address _unsafeBlockSigner,
ResourceMetering.ResourceConfig memory _config,
ResourceMetering.ResourceConfig memory _config,
address _l1CrossDomainMessenger,
uint256 _startBlock
address _l1ERC721Bridge,
) public reinitializer(2) {
address _l1StandardBridge,
address _l2OutputOracle,
address _optimismPortal
) public initializer {
__Ownable_init();
__Ownable_init();
transferOwnership(_owner);
transferOwnership(_owner);
// TODO: this needs to be backwards compatible with
// The start block for the op-node to start searching for logs
// chains that already have it set.
// needs to be set in a backwards compatible way. Only allow setting
startBlock = block.number;
// the start block with an override if it has previously never been set.
// Could add an extra arg that is an override and do
if (_startBlock != 0) {
// something like:
require(startBlock == 0, "SystemConfig: cannot override an already set start block");
/*
startBlock = _startBlock;
if (_startBlock != 0) startBlock = _startBlock;
} else if (startBlock == 0) {
else startBlock = block.number;
startBlock = block.number;
*/
}
// And then in the next upgrade, remove the extra arg
// and move to something like:
/*
if (startBlock == 0) startBlock = block.number;
*/
overhead = _overhead;
overhead = _overhead;
scalar = _scalar;
scalar = _scalar;
batcherHash = _batcherHash;
batcherHash = _batcherHash;
gasLimit = _gasLimit;
gasLimit = _gasLimit;
_set
UnsafeBlockSigner(_unsafeBlockSigner
);
_set
Address(_unsafeBlockSigner, UNSAFE_BLOCK_SIGNER_SLOT
);
_setResourceConfig(_config);
require(_gasLimit >= minimumGasLimit(), "SystemConfig: gas limit too low");
}
/// @notice Sets all of the addresses. These are not set in the `initialize`
/// function because it results in stack too deep errors when that
/// many constructor arguments are used. It is more simple to use
/// another function.
/// @param _l1CrossDomainMessenger Address of the L1CrossDomainMessenger.
/// @param _l1ERC721Bridge Address of the L1ERC721Bridge.
/// @param _l1StandardBridge Address of the L1StandardBridge.
/// @param _l2OutputOracle Address of the L2OutputOracle.
/// @param _batchInbox Address of the BatchInbox.
function setAddresses(
address _l1CrossDomainMessenger,
address _l1ERC721Bridge,
address _l1StandardBridge,
address _l2OutputOracle,
address _optimismPortal,
address _batchInbox
) external onlyOwner {
_setAddress(_l1CrossDomainMessenger, L1_CROSS_DOMAIN_MESSENGER_SLOT);
_setAddress(_l1CrossDomainMessenger, L1_CROSS_DOMAIN_MESSENGER_SLOT);
_setAddress(_l1ERC721Bridge, L1_ERC_721_BRIDGE_SLOT);
_setAddress(_l1ERC721Bridge, L1_ERC_721_BRIDGE_SLOT);
_setAddress(_l1StandardBridge, L1_STANDARD_BRIDGE_SLOT);
_setAddress(_l1StandardBridge, L1_STANDARD_BRIDGE_SLOT);
_setAddress(_l2OutputOracle, L2_OUTPUT_ORACLE_SLOT);
_setAddress(_l2OutputOracle, L2_OUTPUT_ORACLE_SLOT);
_setAddress(_optimismPortal, OPTIMISM_PORTAL_SLOT);
_setAddress(_optimismPortal, OPTIMISM_PORTAL_SLOT);
_setAddress(_batchInbox, BATCH_INBOX_SLOT);
_setResourceConfig(_config);
require(_gasLimit >= minimumGasLimit(), "SystemConfig: gas limit too low");
}
}
/// @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
...
@@ -189,7 +208,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -189,7 +208,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
/// @param _slot The storage slot to store the address in.
/// @param _slot The storage slot to store the address in.
/// @dev WARNING! This function must be used cautiously, as it allows for overwriting values
/// @dev WARNING! This function must be used cautiously, as it allows for overwriting values
/// in arbitrary storage slots. Solc will add checks that the data passed as `_addr`
/// in arbitrary storage slots. Solc will add checks that the data passed as `_addr`
/// is 20 bytes or less.
/// is 20 bytes or less.
function _setAddress(address _addr, bytes32 _slot) internal {
function _setAddress(address _addr, bytes32 _slot) internal {
bytes32 slot = _slot;
bytes32 slot = _slot;
assembly {
assembly {
...
@@ -197,10 +216,50 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -197,10 +216,50 @@ contract SystemConfig is OwnableUpgradeable, Semver {
}
}
}
}
/// @notice
function _getAddress(bytes32 _slot) internal view returns (address) {
address addr;
bytes32 slot = _slot;
assembly {
addr := sload(slot)
}
return addr;
}
/// @notice Getter for the L1CrossDomainMessenger address.
function l1CrossDomainMessenger() external view returns (address) {
return _getAddress(L1_CROSS_DOMAIN_MESSENGER_SLOT);
}
/// @notice Getter for the L1ERC721Bridge address.
function l1ERC721Bridge() external view returns (address) {
return _getAddress(L1_ERC_721_BRIDGE_SLOT);
}
/// @notice Getter for the L1StandardBridge address.
function l1StandardBridge() external view returns (address) {
return _getAddress(L1_STANDARD_BRIDGE_SLOT);
}
/// @notice Getter for the L2OutputOracle address.
function l2OutputOracle() external view returns (address) {
return _getAddress(L2_OUTPUT_ORACLE_SLOT);
}
/// @notice Getter for the OptimismPortal address.
function optimismPortal() external view returns (address) {
return _getAddress(OPTIMISM_PORTAL_SLOT);
}
/// @notice Getter for the BatchInbox address.
function batchInbox() external view returns (address) {
return _getAddress(BATCH_INBOX_SLOT);
}
/// @notice Updates the unsafe block signer address.
/// @notice Updates the unsafe block signer address.
/// @param _unsafeBlockSigner New unsafe block signer address.
/// @param _unsafeBlockSigner New unsafe block signer address.
function setUnsafeBlockSigner(address _unsafeBlockSigner) external onlyOwner {
function setUnsafeBlockSigner(address _unsafeBlockSigner) external onlyOwner {
_set
UnsafeBlockSigner(_unsafeBlockSigner
);
_set
Address(_unsafeBlockSigner, UNSAFE_BLOCK_SIGNER_SLOT
);
bytes memory data = abi.encode(_unsafeBlockSigner);
bytes memory data = abi.encode(_unsafeBlockSigner);
emit ConfigUpdate(VERSION, UpdateType.UNSAFE_BLOCK_SIGNER, data);
emit ConfigUpdate(VERSION, UpdateType.UNSAFE_BLOCK_SIGNER, data);
...
@@ -236,17 +295,6 @@ contract SystemConfig is OwnableUpgradeable, Semver {
...
@@ -236,17 +295,6 @@ contract SystemConfig is OwnableUpgradeable, Semver {
emit ConfigUpdate(VERSION, UpdateType.GAS_LIMIT, data);
emit ConfigUpdate(VERSION, UpdateType.GAS_LIMIT, data);
}
}
/// @notice Low level setter for the unsafe block signer address.
/// This function exists to deduplicate code around storing the unsafeBlockSigner
/// address in storage.
/// @param _unsafeBlockSigner New unsafeBlockSigner value.
function _setUnsafeBlockSigner(address _unsafeBlockSigner) internal {
bytes32 slot = UNSAFE_BLOCK_SIGNER_SLOT;
assembly {
sstore(slot, _unsafeBlockSigner)
}
}
/// @notice A getter for the resource config.
/// @notice A getter for the resource config.
/// Ensures that the struct is returned instead of a tuple.
/// Ensures that the struct is returned instead of a tuple.
/// @return ResourceConfig
/// @return ResourceConfig
...
...
packages/contracts-bedrock/test/CommonTest.t.sol
View file @
ef3d55cf
...
@@ -202,17 +202,37 @@ contract Portal_Initializer is L2OutputOracle_Initializer {
...
@@ -202,17 +202,37 @@ contract Portal_Initializer is L2OutputOracle_Initializer {
function setUp() public virtual override {
function setUp() public virtual override {
super.setUp();
super.setUp();
ResourceMetering.ResourceConfig memory config = Constants.DEFAULT_RESOURCE_CONFIG();
Proxy systemConfigProxy = new Proxy(multisig);
systemConfig = new SystemConfig({
SystemConfig systemConfigImpl = new SystemConfig();
_owner: address(1),
_overhead: 0,
vm.prank(multisig);
_scalar: 10000,
systemConfigProxy.upgradeToAndCall(
_batcherHash: bytes32(0),
address(systemConfigImpl),
_gasLimit: 30_000_000,
hex""
_unsafeBlockSigner: address(0),
/*
_config: config
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();
opImpl = new OptimismPortal();
...
...
packages/contracts-bedrock/test/SystemConfig.t.sol
View file @
ef3d55cf
...
@@ -9,34 +9,40 @@ import { Constants } from "../src/libraries/Constants.sol";
...
@@ -9,34 +9,40 @@ import { Constants } from "../src/libraries/Constants.sol";
// Target contract dependencies
// Target contract dependencies
import { ResourceMetering } from "../src/L1/ResourceMetering.sol";
import { ResourceMetering } from "../src/L1/ResourceMetering.sol";
import { Proxy } from "../src/universal/Proxy.sol";
// Target contract
// Target contract
import { SystemConfig } from "../src/L1/SystemConfig.sol";
import { SystemConfig } from "../src/L1/SystemConfig.sol";
contract SystemConfig_Init is CommonTest {
contract SystemConfig_Init is CommonTest {
SystemConfig sysConf;
SystemConfig sysConf;
SystemConfig systemConfigImpl;
function setUp() public virtual override {
function setUp() public virtual override {
super.setUp();
super.setUp();
ResourceMetering.ResourceConfig memory config = ResourceMetering.ResourceConfig({
Proxy proxy = new Proxy(multisig);
maxResourceLimit: 20_000_000,
systemConfigImpl = new SystemConfig();
elasticityMultiplier: 10,
baseFeeMaxChangeDenominator: 8,
vm.prank(multisig);
minimumBaseFee: 1 gwei,
proxy.upgradeToAndCall(
systemTxMaxGas: 1_000_000,
address(systemConfigImpl),
maximumBaseFee: type(uint128).max
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({
sysConf = SystemConfig(address(proxy));
_owner: alice,
_overhead: 2100,
_scalar: 1000000,
_batcherHash: bytes32(hex"abcd"),
_gasLimit: 30_000_000,
_unsafeBlockSigner: address(1),
_config: config
});
}
}
}
}
...
@@ -54,16 +60,25 @@ contract SystemConfig_Initialize_TestFail is SystemConfig_Init {
...
@@ -54,16 +60,25 @@ contract SystemConfig_Initialize_TestFail is SystemConfig_Init {
maximumBaseFee: type(uint128).max
maximumBaseFee: type(uint128).max
});
});
vm.store(address(sysConf), bytes32(0), bytes32(0));
vm.expectRevert("SystemConfig: gas limit too low");
vm.expectRevert("SystemConfig: gas limit too low");
new SystemConfig({
vm.prank(multisig);
_owner: alice,
Proxy(payable(address(sysConf))).upgradeToAndCall(
_overhead: 0,
address(systemConfigImpl),
_scalar: 0,
abi.encodeCall(
_batcherHash: bytes32(hex""),
SystemConfig.initialize,
_gasLimit: minimumGasLimit - 1,
(
_unsafeBlockSigner: address(1),
alice, //_owner,
_config: cfg
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;
...
@@ -3,24 +3,35 @@ pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { Test } from "forge-std/Test.sol";
import { SystemConfig } from "../../src/L1/SystemConfig.sol";
import { SystemConfig } from "../../src/L1/SystemConfig.sol";
import { Proxy } from "../../src/universal/Proxy.sol";
import { ResourceMetering } from "../../src/L1/ResourceMetering.sol";
import { ResourceMetering } from "../../src/L1/ResourceMetering.sol";
import { Constants } from "../../src/libraries/Constants.sol";
import { Constants } from "../../src/libraries/Constants.sol";
contract SystemConfig_GasLimitLowerBound_Invariant is Test {
contract SystemConfig_GasLimitLowerBound_Invariant is Test {
SystemConfig public config;
SystemConfig public config;
function setUp() public {
function setUp() external {
ResourceMetering.ResourceConfig memory cfg = Constants.DEFAULT_RESOURCE_CONFIG();
Proxy proxy = new Proxy(msg.sender);
SystemConfig configImpl = new SystemConfig();
config = new SystemConfig({
proxy.upgradeToAndCall(
_owner: address(0xbeef),
address(configImpl),
_overhead: 2100,
abi.encodeCall(
_scalar: 1000000,
configImpl.initialize,
_batcherHash: bytes32(hex"abcd"),
(
_gasLimit: 30_000_000,
address(0xbeef), // owner
_unsafeBlockSigner: address(1),
2100, // overhead
_config: cfg
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`
// Set the target contract to the `config`
targetContract(address(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