Commit ef3d55cf authored by Mark Tyneway's avatar Mark Tyneway

wip

parent 6558908a
...@@ -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() == batcherHash); require(config.batcherHash() == bytes32(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
......
...@@ -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();
......
...@@ -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
)
)
);
} }
} }
......
...@@ -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));
......
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