Commit 70cb6d94 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: fix compile time

Reduces the compile time to about 80s on my machine. The compile time
was greatly increased as part of the migration to using the deploy
script to set up the tests. Can we have our cake and eat it to? This
commit seems to say yes.

The call to `broadcast` now needs to include `msg.sender` because the
contract doing all of the deployments is no longer the top level
contract. This assumes that the deploy contract is not nested deeper
than the 2nd callframe. The deployments would fail if that was not the
case.

The `cfg` now is behind a public getter on the deploy script, so the
majority of the commit is updating places where the deploy config is
referenced to change it into calls.
parent bbf2c5b7
...@@ -53,7 +53,7 @@ import { Types } from "scripts/Types.sol"; ...@@ -53,7 +53,7 @@ import { Types } from "scripts/Types.sol";
/// Then add a call to that function inside of `run`. Be sure to call the `save` function after each /// Then add a call to that function inside of `run`. Be sure to call the `save` function after each
/// deployment so that hardhat-deploy style artifacts can be generated using a call to `sync()`. /// deployment so that hardhat-deploy style artifacts can be generated using a call to `sync()`.
contract Deploy is Deployer { contract Deploy is Deployer {
DeployConfig cfg; DeployConfig public cfg;
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Modifiers // // Modifiers //
...@@ -61,7 +61,7 @@ contract Deploy is Deployer { ...@@ -61,7 +61,7 @@ contract Deploy is Deployer {
/// @notice Modifier that wraps a function in broadcasting. /// @notice Modifier that wraps a function in broadcasting.
modifier broadcast() { modifier broadcast() {
vm.startBroadcast(); vm.startBroadcast(msg.sender);
_; _;
vm.stopBroadcast(); vm.stopBroadcast();
} }
......
...@@ -409,7 +409,7 @@ abstract contract Deployer is Script { ...@@ -409,7 +409,7 @@ abstract contract Deployer is Script {
} }
/// @notice Returns the abi for a deployed contract. /// @notice Returns the abi for a deployed contract.
function getAbi(string memory _name) internal returns (string memory) { function getAbi(string memory _name) public returns (string memory) {
string[] memory cmd = new string[](3); string[] memory cmd = new string[](3);
cmd[0] = Executables.bash; cmd[0] = Executables.bash;
cmd[1] = "-c"; cmd[1] = "-c";
...@@ -459,7 +459,7 @@ abstract contract Deployer is Script { ...@@ -459,7 +459,7 @@ abstract contract Deployer is Script {
} }
/// @dev Returns the value of the internal `_initialized` storage slot for a given contract. /// @dev Returns the value of the internal `_initialized` storage slot for a given contract.
function loadInitializedSlot(string memory _contractName, bool _isProxy) internal returns (uint8 initialized_) { function loadInitializedSlot(string memory _contractName, bool _isProxy) public returns (uint8 initialized_) {
StorageSlot memory slot = getInitializedSlot(_contractName); StorageSlot memory slot = getInitializedSlot(_contractName);
if (_isProxy) { if (_isProxy) {
_contractName = string.concat(_contractName, "Proxy"); _contractName = string.concat(_contractName, "Proxy");
......
...@@ -201,7 +201,7 @@ contract GasBenchMark_L2OutputOracle is CommonTest { ...@@ -201,7 +201,7 @@ contract GasBenchMark_L2OutputOracle is CommonTest {
super.setUp(); super.setUp();
nextBlockNumber = l2OutputOracle.nextBlockNumber(); nextBlockNumber = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber); warpToProposeTime(nextBlockNumber);
address proposer = cfg.l2OutputOracleProposer(); address proposer = deploy.cfg().l2OutputOracleProposer();
vm.startPrank(proposer); vm.startPrank(proposer);
} }
......
...@@ -11,15 +11,15 @@ import { FeeVault } from "src/universal/FeeVault.sol"; ...@@ -11,15 +11,15 @@ import { FeeVault } from "src/universal/FeeVault.sol";
contract FeeVault_Test is Bridge_Initializer { contract FeeVault_Test is Bridge_Initializer {
/// @dev Tests that the constructor sets the correct values. /// @dev Tests that the constructor sets the correct values.
function test_constructor_l1FeeVault_succeeds() external { function test_constructor_l1FeeVault_succeeds() external {
assertEq(l1FeeVault.RECIPIENT(), cfg.l1FeeVaultRecipient()); assertEq(l1FeeVault.RECIPIENT(), deploy.cfg().l1FeeVaultRecipient());
assertEq(l1FeeVault.MIN_WITHDRAWAL_AMOUNT(), cfg.l1FeeVaultMinimumWithdrawalAmount()); assertEq(l1FeeVault.MIN_WITHDRAWAL_AMOUNT(), deploy.cfg().l1FeeVaultMinimumWithdrawalAmount());
assertEq(uint8(l1FeeVault.WITHDRAWAL_NETWORK()), uint8(FeeVault.WithdrawalNetwork.L1)); assertEq(uint8(l1FeeVault.WITHDRAWAL_NETWORK()), uint8(FeeVault.WithdrawalNetwork.L1));
} }
/// @dev Tests that the constructor sets the correct values. /// @dev Tests that the constructor sets the correct values.
function test_constructor_baseFeeVault_succeeds() external { function test_constructor_baseFeeVault_succeeds() external {
assertEq(baseFeeVault.RECIPIENT(), cfg.baseFeeVaultRecipient()); assertEq(baseFeeVault.RECIPIENT(), deploy.cfg().baseFeeVaultRecipient());
assertEq(baseFeeVault.MIN_WITHDRAWAL_AMOUNT(), cfg.baseFeeVaultMinimumWithdrawalAmount()); assertEq(baseFeeVault.MIN_WITHDRAWAL_AMOUNT(), deploy.cfg().baseFeeVaultMinimumWithdrawalAmount());
assertEq(uint8(baseFeeVault.WITHDRAWAL_NETWORK()), uint8(FeeVault.WithdrawalNetwork.L1)); assertEq(uint8(baseFeeVault.WITHDRAWAL_NETWORK()), uint8(FeeVault.WithdrawalNetwork.L1));
} }
} }
...@@ -40,7 +40,7 @@ contract Initializer_Test is Bridge_Initializer { ...@@ -40,7 +40,7 @@ contract Initializer_Test is Bridge_Initializer {
InitializeableContract({ InitializeableContract({
target: address(l1CrossDomainMessenger), target: address(l1CrossDomainMessenger),
initCalldata: abi.encodeCall(l1CrossDomainMessenger.initialize, ()), initCalldata: abi.encodeCall(l1CrossDomainMessenger.initialize, ()),
initializedSlotVal: loadInitializedSlot("L1CrossDomainMessenger", true) initializedSlotVal: deploy.loadInitializedSlot("L1CrossDomainMessenger", true)
}) })
); );
// L2OutputOracle // L2OutputOracle
...@@ -48,7 +48,7 @@ contract Initializer_Test is Bridge_Initializer { ...@@ -48,7 +48,7 @@ contract Initializer_Test is Bridge_Initializer {
InitializeableContract({ InitializeableContract({
target: address(l2OutputOracle), target: address(l2OutputOracle),
initCalldata: abi.encodeCall(l2OutputOracle.initialize, (0, 0)), initCalldata: abi.encodeCall(l2OutputOracle.initialize, (0, 0)),
initializedSlotVal: loadInitializedSlot("L2OutputOracle", true) initializedSlotVal: deploy.loadInitializedSlot("L2OutputOracle", true)
}) })
); );
// OptimismPortal // OptimismPortal
...@@ -56,7 +56,7 @@ contract Initializer_Test is Bridge_Initializer { ...@@ -56,7 +56,7 @@ contract Initializer_Test is Bridge_Initializer {
InitializeableContract({ InitializeableContract({
target: address(optimismPortal), target: address(optimismPortal),
initCalldata: abi.encodeCall(optimismPortal.initialize, (false)), initCalldata: abi.encodeCall(optimismPortal.initialize, (false)),
initializedSlotVal: loadInitializedSlot("OptimismPortal", true) initializedSlotVal: deploy.loadInitializedSlot("OptimismPortal", true)
}) })
); );
// SystemConfig // SystemConfig
...@@ -82,7 +82,7 @@ contract Initializer_Test is Bridge_Initializer { ...@@ -82,7 +82,7 @@ contract Initializer_Test is Bridge_Initializer {
}) })
) )
), ),
initializedSlotVal: loadInitializedSlot("SystemConfig", true) initializedSlotVal: deploy.loadInitializedSlot("SystemConfig", true)
}) })
); );
// ProtocolVersions // ProtocolVersions
...@@ -92,7 +92,7 @@ contract Initializer_Test is Bridge_Initializer { ...@@ -92,7 +92,7 @@ contract Initializer_Test is Bridge_Initializer {
initCalldata: abi.encodeCall( initCalldata: abi.encodeCall(
protocolVersions.initialize, (address(0), ProtocolVersion.wrap(1), ProtocolVersion.wrap(2)) protocolVersions.initialize, (address(0), ProtocolVersion.wrap(1), ProtocolVersion.wrap(2))
), ),
initializedSlotVal: loadInitializedSlot("ProtocolVersions", true) initializedSlotVal: deploy.loadInitializedSlot("ProtocolVersions", true)
}) })
); );
} }
...@@ -139,7 +139,7 @@ contract Initializer_Test is Bridge_Initializer { ...@@ -139,7 +139,7 @@ contract Initializer_Test is Bridge_Initializer {
for (uint256 i; i < contractNames.length; i++) { for (uint256 i; i < contractNames.length; i++) {
string memory contractName = contractNames[i]; string memory contractName = contractNames[i];
string memory contractAbi = getAbi(contractName); string memory contractAbi = deploy.getAbi(contractName);
// Query the contract's ABI for an `initialize()` function. // Query the contract's ABI for an `initialize()` function.
command[2] = string.concat( command[2] = string.concat(
......
...@@ -20,13 +20,13 @@ import { L2OutputOracle } from "src/L1/L2OutputOracle.sol"; ...@@ -20,13 +20,13 @@ import { L2OutputOracle } from "src/L1/L2OutputOracle.sol";
contract L2OutputOracle_constructor_Test is CommonTest { contract L2OutputOracle_constructor_Test is CommonTest {
/// @dev Tests that constructor sets the initial values correctly. /// @dev Tests that constructor sets the initial values correctly.
function test_constructor_succeeds() external { function test_constructor_succeeds() external {
address proposer = cfg.l2OutputOracleProposer(); address proposer = deploy.cfg().l2OutputOracleProposer();
address challenger = cfg.l2OutputOracleChallenger(); address challenger = deploy.cfg().l2OutputOracleChallenger();
uint256 submissionInterval = cfg.l2OutputOracleSubmissionInterval(); uint256 submissionInterval = deploy.cfg().l2OutputOracleSubmissionInterval();
uint256 startingBlockNumber = cfg.l2OutputOracleStartingBlockNumber(); uint256 startingBlockNumber = deploy.cfg().l2OutputOracleStartingBlockNumber();
uint256 startingTimestamp = cfg.l2OutputOracleStartingTimestamp(); uint256 startingTimestamp = deploy.cfg().l2OutputOracleStartingTimestamp();
uint256 l2BlockTime = cfg.l2BlockTime(); uint256 l2BlockTime = deploy.cfg().l2BlockTime();
uint256 finalizationPeriodSeconds = cfg.finalizationPeriodSeconds(); uint256 finalizationPeriodSeconds = deploy.cfg().finalizationPeriodSeconds();
assertEq(l2OutputOracle.PROPOSER(), proposer); assertEq(l2OutputOracle.PROPOSER(), proposer);
assertEq(l2OutputOracle.proposer(), proposer); assertEq(l2OutputOracle.proposer(), proposer);
...@@ -45,10 +45,10 @@ contract L2OutputOracle_constructor_Test is CommonTest { ...@@ -45,10 +45,10 @@ contract L2OutputOracle_constructor_Test is CommonTest {
/// @dev Tests that the constructor reverts if the l2BlockTime is invalid. /// @dev Tests that the constructor reverts if the l2BlockTime is invalid.
function test_constructor_l2BlockTimeZero_reverts() external { function test_constructor_l2BlockTimeZero_reverts() external {
address proposer = cfg.l2OutputOracleProposer(); address proposer = deploy.cfg().l2OutputOracleProposer();
address challenger = cfg.l2OutputOracleChallenger(); address challenger = deploy.cfg().l2OutputOracleChallenger();
uint256 submissionInterval = cfg.l2OutputOracleSubmissionInterval(); uint256 submissionInterval = deploy.cfg().l2OutputOracleSubmissionInterval();
uint256 startingBlockNumber = cfg.l2OutputOracleStartingBlockNumber(); uint256 startingBlockNumber = deploy.cfg().l2OutputOracleStartingBlockNumber();
vm.expectRevert("L2OutputOracle: L2 block time must be greater than 0"); vm.expectRevert("L2OutputOracle: L2 block time must be greater than 0");
new L2OutputOracle({ new L2OutputOracle({
_submissionInterval: submissionInterval, _submissionInterval: submissionInterval,
...@@ -63,10 +63,10 @@ contract L2OutputOracle_constructor_Test is CommonTest { ...@@ -63,10 +63,10 @@ contract L2OutputOracle_constructor_Test is CommonTest {
/// @dev Tests that the constructor reverts if the submissionInterval is zero. /// @dev Tests that the constructor reverts if the submissionInterval is zero.
function test_constructor_submissionInterval_reverts() external { function test_constructor_submissionInterval_reverts() external {
uint256 l2BlockTime = cfg.l2BlockTime(); uint256 l2BlockTime = deploy.cfg().l2BlockTime();
address proposer = cfg.l2OutputOracleProposer(); address proposer = deploy.cfg().l2OutputOracleProposer();
address challenger = cfg.l2OutputOracleChallenger(); address challenger = deploy.cfg().l2OutputOracleChallenger();
uint256 startingBlockNumber = cfg.l2OutputOracleStartingBlockNumber(); uint256 startingBlockNumber = deploy.cfg().l2OutputOracleStartingBlockNumber();
vm.expectRevert("L2OutputOracle: submission interval must be greater than 0"); vm.expectRevert("L2OutputOracle: submission interval must be greater than 0");
new L2OutputOracle({ new L2OutputOracle({
_submissionInterval: 0, _submissionInterval: 0,
...@@ -98,7 +98,7 @@ contract L2OutputOracle_getter_Test is CommonTest { ...@@ -98,7 +98,7 @@ contract L2OutputOracle_getter_Test is CommonTest {
// Roll to after the block number we'll propose // Roll to after the block number we'll propose
warpToProposeTime(proposedNumber); warpToProposeTime(proposedNumber);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
l2OutputOracle.proposeL2Output(proposedOutput1, proposedNumber, 0, 0); l2OutputOracle.proposeL2Output(proposedOutput1, proposedNumber, 0, 0);
assertEq(l2OutputOracle.latestBlockNumber(), proposedNumber); assertEq(l2OutputOracle.latestBlockNumber(), proposedNumber);
} }
...@@ -108,7 +108,7 @@ contract L2OutputOracle_getter_Test is CommonTest { ...@@ -108,7 +108,7 @@ contract L2OutputOracle_getter_Test is CommonTest {
uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber();
uint256 nextOutputIndex = l2OutputOracle.nextOutputIndex(); uint256 nextOutputIndex = l2OutputOracle.nextOutputIndex();
warpToProposeTime(nextBlockNumber); warpToProposeTime(nextBlockNumber);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
l2OutputOracle.proposeL2Output(proposedOutput1, nextBlockNumber, 0, 0); l2OutputOracle.proposeL2Output(proposedOutput1, nextBlockNumber, 0, 0);
Types.OutputProposal memory proposal = l2OutputOracle.getL2Output(nextOutputIndex); Types.OutputProposal memory proposal = l2OutputOracle.getL2Output(nextOutputIndex);
...@@ -126,7 +126,7 @@ contract L2OutputOracle_getter_Test is CommonTest { ...@@ -126,7 +126,7 @@ contract L2OutputOracle_getter_Test is CommonTest {
bytes32 output1 = keccak256(abi.encode(1)); bytes32 output1 = keccak256(abi.encode(1));
uint256 nextBlockNumber1 = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber1 = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber1); warpToProposeTime(nextBlockNumber1);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
l2OutputOracle.proposeL2Output(output1, nextBlockNumber1, 0, 0); l2OutputOracle.proposeL2Output(output1, nextBlockNumber1, 0, 0);
// Querying with exact same block as proposed returns the proposal. // Querying with exact same block as proposed returns the proposal.
...@@ -140,7 +140,7 @@ contract L2OutputOracle_getter_Test is CommonTest { ...@@ -140,7 +140,7 @@ contract L2OutputOracle_getter_Test is CommonTest {
bytes32 output1 = keccak256(abi.encode(1)); bytes32 output1 = keccak256(abi.encode(1));
uint256 nextBlockNumber1 = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber1 = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber1); warpToProposeTime(nextBlockNumber1);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
l2OutputOracle.proposeL2Output(output1, nextBlockNumber1, 0, 0); l2OutputOracle.proposeL2Output(output1, nextBlockNumber1, 0, 0);
// Querying with previous block returns the proposal too. // Querying with previous block returns the proposal too.
...@@ -153,25 +153,25 @@ contract L2OutputOracle_getter_Test is CommonTest { ...@@ -153,25 +153,25 @@ contract L2OutputOracle_getter_Test is CommonTest {
bytes32 output1 = keccak256(abi.encode(1)); bytes32 output1 = keccak256(abi.encode(1));
uint256 nextBlockNumber1 = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber1 = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber1); warpToProposeTime(nextBlockNumber1);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
l2OutputOracle.proposeL2Output(output1, nextBlockNumber1, 0, 0); l2OutputOracle.proposeL2Output(output1, nextBlockNumber1, 0, 0);
bytes32 output2 = keccak256(abi.encode(2)); bytes32 output2 = keccak256(abi.encode(2));
uint256 nextBlockNumber2 = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber2 = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber2); warpToProposeTime(nextBlockNumber2);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
l2OutputOracle.proposeL2Output(output2, nextBlockNumber2, 0, 0); l2OutputOracle.proposeL2Output(output2, nextBlockNumber2, 0, 0);
bytes32 output3 = keccak256(abi.encode(3)); bytes32 output3 = keccak256(abi.encode(3));
uint256 nextBlockNumber3 = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber3 = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber3); warpToProposeTime(nextBlockNumber3);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
l2OutputOracle.proposeL2Output(output3, nextBlockNumber3, 0, 0); l2OutputOracle.proposeL2Output(output3, nextBlockNumber3, 0, 0);
bytes32 output4 = keccak256(abi.encode(4)); bytes32 output4 = keccak256(abi.encode(4));
uint256 nextBlockNumber4 = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber4 = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber4); warpToProposeTime(nextBlockNumber4);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
l2OutputOracle.proposeL2Output(output4, nextBlockNumber4, 0, 0); l2OutputOracle.proposeL2Output(output4, nextBlockNumber4, 0, 0);
// Querying with a block number between the first and second proposal // Querying with a block number between the first and second proposal
...@@ -204,9 +204,9 @@ contract L2OutputOracle_getter_Test is CommonTest { ...@@ -204,9 +204,9 @@ contract L2OutputOracle_getter_Test is CommonTest {
/// @dev Tests that `computeL2Timestamp` returns the correct value. /// @dev Tests that `computeL2Timestamp` returns the correct value.
function test_computeL2Timestamp_succeeds() external { function test_computeL2Timestamp_succeeds() external {
uint256 startingBlockNumber = cfg.l2OutputOracleStartingBlockNumber(); uint256 startingBlockNumber = deploy.cfg().l2OutputOracleStartingBlockNumber();
uint256 startingTimestamp = cfg.l2OutputOracleStartingTimestamp(); uint256 startingTimestamp = deploy.cfg().l2OutputOracleStartingTimestamp();
uint256 l2BlockTime = cfg.l2BlockTime(); uint256 l2BlockTime = deploy.cfg().l2BlockTime();
// reverts if timestamp is too low // reverts if timestamp is too low
vm.expectRevert(stdError.arithmeticError); vm.expectRevert(stdError.arithmeticError);
...@@ -241,7 +241,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest { ...@@ -241,7 +241,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest {
uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber); warpToProposeTime(nextBlockNumber);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
l2OutputOracle.proposeL2Output(nonZeroHash, nextBlockNumber, prevL1BlockHash, prevL1BlockNumber); l2OutputOracle.proposeL2Output(nonZeroHash, nextBlockNumber, prevL1BlockHash, prevL1BlockNumber);
} }
...@@ -261,7 +261,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest { ...@@ -261,7 +261,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest {
bytes32 outputToPropose = bytes32(0); bytes32 outputToPropose = bytes32(0);
uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber); warpToProposeTime(nextBlockNumber);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
vm.expectRevert("L2OutputOracle: L2 output proposal cannot be the zero hash"); vm.expectRevert("L2OutputOracle: L2 output proposal cannot be the zero hash");
l2OutputOracle.proposeL2Output(outputToPropose, nextBlockNumber, 0, 0); l2OutputOracle.proposeL2Output(outputToPropose, nextBlockNumber, 0, 0);
} }
...@@ -271,7 +271,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest { ...@@ -271,7 +271,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest {
function test_proposeL2Output_unexpectedBlockNumber_reverts() external { function test_proposeL2Output_unexpectedBlockNumber_reverts() external {
uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber); warpToProposeTime(nextBlockNumber);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
vm.expectRevert("L2OutputOracle: block number must be equal to next expected block number"); vm.expectRevert("L2OutputOracle: block number must be equal to next expected block number");
l2OutputOracle.proposeL2Output(nonZeroHash, nextBlockNumber - 1, 0, 0); l2OutputOracle.proposeL2Output(nonZeroHash, nextBlockNumber - 1, 0, 0);
} }
...@@ -282,7 +282,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest { ...@@ -282,7 +282,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest {
uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber();
uint256 nextTimestamp = l2OutputOracle.computeL2Timestamp(nextBlockNumber); uint256 nextTimestamp = l2OutputOracle.computeL2Timestamp(nextBlockNumber);
vm.warp(nextTimestamp); vm.warp(nextTimestamp);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
vm.expectRevert("L2OutputOracle: cannot propose L2 output in the future"); vm.expectRevert("L2OutputOracle: cannot propose L2 output in the future");
l2OutputOracle.proposeL2Output(nonZeroHash, nextBlockNumber, 0, 0); l2OutputOracle.proposeL2Output(nonZeroHash, nextBlockNumber, 0, 0);
} }
...@@ -292,7 +292,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest { ...@@ -292,7 +292,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest {
function test_proposeL2Output_wrongFork_reverts() external { function test_proposeL2Output_wrongFork_reverts() external {
uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber); warpToProposeTime(nextBlockNumber);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
vm.expectRevert("L2OutputOracle: block hash does not match the hash at the expected height"); vm.expectRevert("L2OutputOracle: block hash does not match the hash at the expected height");
l2OutputOracle.proposeL2Output(nonZeroHash, nextBlockNumber, bytes32(uint256(0x01)), block.number); l2OutputOracle.proposeL2Output(nonZeroHash, nextBlockNumber, bytes32(uint256(0x01)), block.number);
} }
...@@ -309,7 +309,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest { ...@@ -309,7 +309,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest {
uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber(); uint256 nextBlockNumber = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber); warpToProposeTime(nextBlockNumber);
vm.prank(cfg.l2OutputOracleProposer()); vm.prank(deploy.cfg().l2OutputOracleProposer());
// This will fail when foundry no longer returns zerod block hashes // This will fail when foundry no longer returns zerod block hashes
vm.expectRevert("L2OutputOracle: block hash does not match the hash at the expected height"); vm.expectRevert("L2OutputOracle: block hash does not match the hash at the expected height");
...@@ -336,7 +336,7 @@ contract L2OutputOracle_deleteOutputs_Test is CommonTest { ...@@ -336,7 +336,7 @@ contract L2OutputOracle_deleteOutputs_Test is CommonTest {
// validate latestBlockNumber has been reduced // validate latestBlockNumber has been reduced
uint256 latestBlockNumberAfter = l2OutputOracle.latestBlockNumber(); uint256 latestBlockNumberAfter = l2OutputOracle.latestBlockNumber();
uint256 latestOutputIndexAfter = l2OutputOracle.latestOutputIndex(); uint256 latestOutputIndexAfter = l2OutputOracle.latestOutputIndex();
uint256 submissionInterval = cfg.l2OutputOracleSubmissionInterval(); uint256 submissionInterval = deploy.cfg().l2OutputOracleSubmissionInterval();
assertEq(latestBlockNumber - submissionInterval, latestBlockNumberAfter); assertEq(latestBlockNumber - submissionInterval, latestBlockNumberAfter);
// validate that the new latest output is as expected. // validate that the new latest output is as expected.
...@@ -365,7 +365,7 @@ contract L2OutputOracle_deleteOutputs_Test is CommonTest { ...@@ -365,7 +365,7 @@ contract L2OutputOracle_deleteOutputs_Test is CommonTest {
// validate latestBlockNumber has been reduced // validate latestBlockNumber has been reduced
uint256 latestBlockNumberAfter = l2OutputOracle.latestBlockNumber(); uint256 latestBlockNumberAfter = l2OutputOracle.latestBlockNumber();
uint256 latestOutputIndexAfter = l2OutputOracle.latestOutputIndex(); uint256 latestOutputIndexAfter = l2OutputOracle.latestOutputIndex();
uint256 submissionInterval = cfg.l2OutputOracleSubmissionInterval(); uint256 submissionInterval = deploy.cfg().l2OutputOracleSubmissionInterval();
assertEq(latestBlockNumber - submissionInterval * 3, latestBlockNumberAfter); assertEq(latestBlockNumber - submissionInterval * 3, latestBlockNumberAfter);
// validate that the new latest output is as expected. // validate that the new latest output is as expected.
...@@ -434,13 +434,13 @@ contract L2OutputOracle_deleteOutputs_Test is CommonTest { ...@@ -434,13 +434,13 @@ contract L2OutputOracle_deleteOutputs_Test is CommonTest {
contract L2OutputOracleUpgradeable_Test is CommonTest { contract L2OutputOracleUpgradeable_Test is CommonTest {
/// @dev Tests that the proxy is initialized with the correct values. /// @dev Tests that the proxy is initialized with the correct values.
function test_initValuesOnProxy_succeeds() external { function test_initValuesOnProxy_succeeds() external {
address proposer = cfg.l2OutputOracleProposer(); address proposer = deploy.cfg().l2OutputOracleProposer();
address challenger = cfg.l2OutputOracleChallenger(); address challenger = deploy.cfg().l2OutputOracleChallenger();
uint256 submissionInterval = cfg.l2OutputOracleSubmissionInterval(); uint256 submissionInterval = deploy.cfg().l2OutputOracleSubmissionInterval();
uint256 startingBlockNumber = cfg.l2OutputOracleStartingBlockNumber(); uint256 startingBlockNumber = deploy.cfg().l2OutputOracleStartingBlockNumber();
uint256 startingTimestamp = cfg.l2OutputOracleStartingTimestamp(); uint256 startingTimestamp = deploy.cfg().l2OutputOracleStartingTimestamp();
uint256 l2BlockTime = cfg.l2BlockTime(); uint256 l2BlockTime = deploy.cfg().l2BlockTime();
uint256 finalizationPeriodSeconds = cfg.finalizationPeriodSeconds(); uint256 finalizationPeriodSeconds = deploy.cfg().finalizationPeriodSeconds();
assertEq(l2OutputOracle.SUBMISSION_INTERVAL(), submissionInterval); assertEq(l2OutputOracle.SUBMISSION_INTERVAL(), submissionInterval);
assertEq(l2OutputOracle.submissionInterval(), submissionInterval); assertEq(l2OutputOracle.submissionInterval(), submissionInterval);
...@@ -458,18 +458,18 @@ contract L2OutputOracleUpgradeable_Test is CommonTest { ...@@ -458,18 +458,18 @@ contract L2OutputOracleUpgradeable_Test is CommonTest {
/// @dev Tests that the impl is created with the correct values. /// @dev Tests that the impl is created with the correct values.
function test_initValuesOnImpl_succeeds() external { function test_initValuesOnImpl_succeeds() external {
L2OutputOracle oracleImpl = L2OutputOracle(mustGetAddress("L2OutputOracle")); L2OutputOracle oracleImpl = L2OutputOracle(deploy.mustGetAddress("L2OutputOracle"));
assertEq(oracleImpl.SUBMISSION_INTERVAL(), cfg.l2OutputOracleSubmissionInterval()); assertEq(oracleImpl.SUBMISSION_INTERVAL(), deploy.cfg().l2OutputOracleSubmissionInterval());
assertEq(oracleImpl.submissionInterval(), cfg.l2OutputOracleSubmissionInterval()); assertEq(oracleImpl.submissionInterval(), deploy.cfg().l2OutputOracleSubmissionInterval());
assertEq(oracleImpl.L2_BLOCK_TIME(), cfg.l2BlockTime()); assertEq(oracleImpl.L2_BLOCK_TIME(), deploy.cfg().l2BlockTime());
assertEq(oracleImpl.l2BlockTime(), cfg.l2BlockTime()); assertEq(oracleImpl.l2BlockTime(), deploy.cfg().l2BlockTime());
assertEq(oracleImpl.FINALIZATION_PERIOD_SECONDS(), cfg.finalizationPeriodSeconds()); assertEq(oracleImpl.FINALIZATION_PERIOD_SECONDS(), deploy.cfg().finalizationPeriodSeconds());
assertEq(oracleImpl.finalizationPeriodSeconds(), cfg.finalizationPeriodSeconds()); assertEq(oracleImpl.finalizationPeriodSeconds(), deploy.cfg().finalizationPeriodSeconds());
assertEq(oracleImpl.PROPOSER(), cfg.l2OutputOracleProposer()); assertEq(oracleImpl.PROPOSER(), deploy.cfg().l2OutputOracleProposer());
assertEq(oracleImpl.proposer(), cfg.l2OutputOracleProposer()); assertEq(oracleImpl.proposer(), deploy.cfg().l2OutputOracleProposer());
assertEq(oracleImpl.CHALLENGER(), cfg.l2OutputOracleChallenger()); assertEq(oracleImpl.CHALLENGER(), deploy.cfg().l2OutputOracleChallenger());
assertEq(oracleImpl.challenger(), cfg.l2OutputOracleChallenger()); assertEq(oracleImpl.challenger(), deploy.cfg().l2OutputOracleChallenger());
assertEq(oracleImpl.startingBlockNumber(), 0); assertEq(oracleImpl.startingBlockNumber(), 0);
assertEq(oracleImpl.startingTimestamp(), 0); assertEq(oracleImpl.startingTimestamp(), 0);
...@@ -477,24 +477,24 @@ contract L2OutputOracleUpgradeable_Test is CommonTest { ...@@ -477,24 +477,24 @@ contract L2OutputOracleUpgradeable_Test is CommonTest {
/// @dev Tests that the proxy cannot be initialized twice. /// @dev Tests that the proxy cannot be initialized twice.
function test_initializeProxy_alreadyInitialized_reverts() external { function test_initializeProxy_alreadyInitialized_reverts() external {
uint256 startingBlockNumber = cfg.l2OutputOracleStartingBlockNumber(); uint256 startingBlockNumber = deploy.cfg().l2OutputOracleStartingBlockNumber();
uint256 startingTimestamp = cfg.l2OutputOracleStartingTimestamp(); uint256 startingTimestamp = deploy.cfg().l2OutputOracleStartingTimestamp();
vm.expectRevert("Initializable: contract is already initialized"); vm.expectRevert("Initializable: contract is already initialized");
l2OutputOracle.initialize({ _startingBlockNumber: startingBlockNumber, _startingTimestamp: startingTimestamp }); l2OutputOracle.initialize({ _startingBlockNumber: startingBlockNumber, _startingTimestamp: startingTimestamp });
} }
/// @dev Tests that the implementation contract cannot be initialized twice. /// @dev Tests that the implementation contract cannot be initialized twice.
function test_initializeImpl_alreadyInitialized_reverts() external { function test_initializeImpl_alreadyInitialized_reverts() external {
L2OutputOracle oracleImpl = L2OutputOracle(mustGetAddress("L2OutputOracle")); L2OutputOracle oracleImpl = L2OutputOracle(deploy.mustGetAddress("L2OutputOracle"));
uint256 startingBlockNumber = cfg.l2OutputOracleStartingBlockNumber(); uint256 startingBlockNumber = deploy.cfg().l2OutputOracleStartingBlockNumber();
uint256 startingTimestamp = cfg.l2OutputOracleStartingTimestamp(); uint256 startingTimestamp = deploy.cfg().l2OutputOracleStartingTimestamp();
vm.expectRevert("Initializable: contract is already initialized"); vm.expectRevert("Initializable: contract is already initialized");
oracleImpl.initialize({ _startingBlockNumber: startingBlockNumber, _startingTimestamp: startingTimestamp }); oracleImpl.initialize({ _startingBlockNumber: startingBlockNumber, _startingTimestamp: startingTimestamp });
} }
/// @dev Tests that the proxy can be successfully upgraded. /// @dev Tests that the proxy can be successfully upgraded.
function test_upgrading_succeeds() external { function test_upgrading_succeeds() external {
Proxy proxy = Proxy(mustGetAddress("L2OutputOracleProxy")); Proxy proxy = Proxy(deploy.mustGetAddress("L2OutputOracleProxy"));
// Check an unused slot before upgrading. // Check an unused slot before upgrading.
bytes32 slot21Before = vm.load(address(l2OutputOracle), bytes32(uint256(21))); bytes32 slot21Before = vm.load(address(l2OutputOracle), bytes32(uint256(21)));
assertEq(bytes32(0), slot21Before); assertEq(bytes32(0), slot21Before);
......
...@@ -33,7 +33,7 @@ contract OptimismPortal_Test is CommonTest { ...@@ -33,7 +33,7 @@ contract OptimismPortal_Test is CommonTest {
/// @dev Tests that the constructor sets the correct values. /// @dev Tests that the constructor sets the correct values.
function test_constructor_succeeds() external { function test_constructor_succeeds() external {
address guardian = cfg.portalGuardian(); address guardian = deploy.cfg().portalGuardian();
assertEq(address(optimismPortal.L2_ORACLE()), address(l2OutputOracle)); assertEq(address(optimismPortal.L2_ORACLE()), address(l2OutputOracle));
assertEq(address(optimismPortal.l2Oracle()), address(l2OutputOracle)); assertEq(address(optimismPortal.l2Oracle()), address(l2OutputOracle));
assertEq(optimismPortal.GUARDIAN(), guardian); assertEq(optimismPortal.GUARDIAN(), guardian);
...@@ -270,7 +270,7 @@ contract OptimismPortal_Test is CommonTest { ...@@ -270,7 +270,7 @@ contract OptimismPortal_Test is CommonTest {
/// @dev Tests that `isOutputFinalized` succeeds for an EOA depositing a tx with ETH and data. /// @dev Tests that `isOutputFinalized` succeeds for an EOA depositing a tx with ETH and data.
function test_simple_isOutputFinalized_succeeds() external { function test_simple_isOutputFinalized_succeeds() external {
uint256 startingBlockNumber = cfg.l2OutputOracleStartingBlockNumber(); uint256 startingBlockNumber = deploy.cfg().l2OutputOracleStartingBlockNumber();
uint256 ts = block.timestamp; uint256 ts = block.timestamp;
vm.mockCall( vm.mockCall(
...@@ -904,7 +904,7 @@ contract OptimismPortalUpgradeable_Test is CommonTest { ...@@ -904,7 +904,7 @@ contract OptimismPortalUpgradeable_Test is CommonTest {
/// @dev Tests that the implementation cannot be initialized twice. /// @dev Tests that the implementation cannot be initialized twice.
function test_initialize_cannotInitImpl_reverts() external { function test_initialize_cannotInitImpl_reverts() external {
address opImpl = mustGetAddress("OptimismPortal"); address opImpl = deploy.mustGetAddress("OptimismPortal");
vm.expectRevert("Initializable: contract is already initialized"); vm.expectRevert("Initializable: contract is already initialized");
OptimismPortal(payable(opImpl)).initialize({ _paused: false }); OptimismPortal(payable(opImpl)).initialize({ _paused: false });
} }
......
...@@ -22,16 +22,16 @@ contract ProtocolVersions_Init is CommonTest { ...@@ -22,16 +22,16 @@ contract ProtocolVersions_Init is CommonTest {
function setUp() public virtual override { function setUp() public virtual override {
super.setUp(); super.setUp();
required = ProtocolVersion.wrap(cfg.requiredProtocolVersion()); required = ProtocolVersion.wrap(deploy.cfg().requiredProtocolVersion());
recommended = ProtocolVersion.wrap(cfg.recommendedProtocolVersion()); recommended = ProtocolVersion.wrap(deploy.cfg().recommendedProtocolVersion());
} }
} }
contract ProtocolVersions_Initialize_Test is ProtocolVersions_Init { contract ProtocolVersions_Initialize_Test is ProtocolVersions_Init {
/// @dev Tests that initialization sets the correct values. /// @dev Tests that initialization sets the correct values.
function test_initialize_values_succeeds() external { function test_initialize_values_succeeds() external {
ProtocolVersions protocolVersionsImpl = ProtocolVersions(mustGetAddress("ProtocolVersions")); ProtocolVersions protocolVersionsImpl = ProtocolVersions(deploy.mustGetAddress("ProtocolVersions"));
address owner = cfg.finalSystemOwner(); address owner = deploy.cfg().finalSystemOwner();
assertEq(ProtocolVersion.unwrap(protocolVersions.required()), ProtocolVersion.unwrap(required)); assertEq(ProtocolVersion.unwrap(protocolVersions.required()), ProtocolVersion.unwrap(required));
assertEq(ProtocolVersion.unwrap(protocolVersions.recommended()), ProtocolVersion.unwrap(recommended)); assertEq(ProtocolVersion.unwrap(protocolVersions.recommended()), ProtocolVersion.unwrap(recommended));
...@@ -44,7 +44,7 @@ contract ProtocolVersions_Initialize_Test is ProtocolVersions_Init { ...@@ -44,7 +44,7 @@ contract ProtocolVersions_Initialize_Test is ProtocolVersions_Init {
/// @dev Ensures that the events are emitted during initialization. /// @dev Ensures that the events are emitted during initialization.
function test_initialize_events_succeeds() external { function test_initialize_events_succeeds() external {
ProtocolVersions protocolVersionsImpl = ProtocolVersions(mustGetAddress("ProtocolVersions")); ProtocolVersions protocolVersionsImpl = ProtocolVersions(deploy.mustGetAddress("ProtocolVersions"));
assertEq(protocolVersionsImpl.owner(), address(0xdEad)); assertEq(protocolVersionsImpl.owner(), address(0xdEad));
// Wipe out the initialized slot so the proxy can be initialized again // Wipe out the initialized slot so the proxy can be initialized again
......
...@@ -22,12 +22,12 @@ contract SequencerFeeVault_Test is CommonTest { ...@@ -22,12 +22,12 @@ contract SequencerFeeVault_Test is CommonTest {
/// @dev Sets up the test suite. /// @dev Sets up the test suite.
function setUp() public override { function setUp() public override {
super.setUp(); super.setUp();
recipient = cfg.sequencerFeeVaultRecipient(); recipient = deploy.cfg().sequencerFeeVaultRecipient();
} }
/// @dev Tests that the minimum withdrawal amount is correct. /// @dev Tests that the minimum withdrawal amount is correct.
function test_minWithdrawalAmount_succeeds() external { function test_minWithdrawalAmount_succeeds() external {
assertEq(sequencerFeeVault.MIN_WITHDRAWAL_AMOUNT(), cfg.sequencerFeeVaultMinimumWithdrawalAmount()); assertEq(sequencerFeeVault.MIN_WITHDRAWAL_AMOUNT(), deploy.cfg().sequencerFeeVaultMinimumWithdrawalAmount());
} }
/// @dev Tests that the l1 fee wallet is correct. /// @dev Tests that the l1 fee wallet is correct.
...@@ -103,11 +103,11 @@ contract SequencerFeeVault_L2Withdrawal_Test is CommonTest { ...@@ -103,11 +103,11 @@ contract SequencerFeeVault_L2Withdrawal_Test is CommonTest {
vm.etch( vm.etch(
EIP1967Helper.getImplementation(Predeploys.SEQUENCER_FEE_WALLET), EIP1967Helper.getImplementation(Predeploys.SEQUENCER_FEE_WALLET),
address( address(
new SequencerFeeVault(cfg.sequencerFeeVaultRecipient(), cfg.sequencerFeeVaultMinimumWithdrawalAmount(), FeeVault.WithdrawalNetwork.L2) new SequencerFeeVault(deploy.cfg().sequencerFeeVaultRecipient(), deploy.cfg().sequencerFeeVaultMinimumWithdrawalAmount(), FeeVault.WithdrawalNetwork.L2)
).code ).code
); );
recipient = cfg.sequencerFeeVaultRecipient(); recipient = deploy.cfg().sequencerFeeVaultRecipient();
} }
/// @dev Tests that `withdraw` successfully initiates a withdrawal to L2. /// @dev Tests that `withdraw` successfully initiates a withdrawal to L2.
......
...@@ -32,15 +32,15 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init { ...@@ -32,15 +32,15 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init {
function setUp() public virtual override { function setUp() public virtual override {
super.setUp(); super.setUp();
batchInbox = cfg.batchInboxAddress(); batchInbox = deploy.cfg().batchInboxAddress();
owner = cfg.finalSystemOwner(); owner = deploy.cfg().finalSystemOwner();
overhead = cfg.gasPriceOracleOverhead(); overhead = deploy.cfg().gasPriceOracleOverhead();
scalar = cfg.gasPriceOracleScalar(); scalar = deploy.cfg().gasPriceOracleScalar();
batcherHash = bytes32(uint256(uint160(cfg.batchSenderAddress()))); batcherHash = bytes32(uint256(uint160(deploy.cfg().batchSenderAddress())));
gasLimit = uint64(cfg.l2GenesisBlockGasLimit()); gasLimit = uint64(deploy.cfg().l2GenesisBlockGasLimit());
unsafeBlockSigner = cfg.p2pSequencerAddress(); unsafeBlockSigner = deploy.cfg().p2pSequencerAddress();
systemConfigImpl = mustGetAddress("SystemConfig"); systemConfigImpl = deploy.mustGetAddress("SystemConfig");
optimismMintableERC20Factory = mustGetAddress("OptimismMintableERC20FactoryProxy"); optimismMintableERC20Factory = deploy.mustGetAddress("OptimismMintableERC20FactoryProxy");
} }
/// @dev Tests that initailization sets the correct values. /// @dev Tests that initailization sets the correct values.
...@@ -66,7 +66,7 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init { ...@@ -66,7 +66,7 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init {
contract SystemConfig_Initialize_TestFail is SystemConfig_Init { contract SystemConfig_Initialize_TestFail is SystemConfig_Init {
/// @dev Tests that initialization reverts if the gas limit is too low. /// @dev Tests that initialization reverts if the gas limit is too low.
function test_initialize_lowGasLimit_reverts() external { function test_initialize_lowGasLimit_reverts() external {
address systemConfigImpl = mustGetAddress("SystemConfig"); address systemConfigImpl = deploy.mustGetAddress("SystemConfig");
uint64 minimumGasLimit = systemConfig.minimumGasLimit(); uint64 minimumGasLimit = systemConfig.minimumGasLimit();
// Wipe out the initialized slot so the proxy can be initialized again // Wipe out the initialized slot so the proxy can be initialized again
......
...@@ -24,8 +24,8 @@ contract CommonTest is Setup, Test, Events { ...@@ -24,8 +24,8 @@ contract CommonTest is Setup, Test, Events {
vm.fee(1 gwei); vm.fee(1 gwei);
// Set sane initialize block numbers // Set sane initialize block numbers
vm.warp(cfg.l2OutputOracleStartingTimestamp() + 1); vm.warp(deploy.cfg().l2OutputOracleStartingTimestamp() + 1);
vm.roll(cfg.l2OutputOracleStartingBlockNumber() + 1); vm.roll(deploy.cfg().l2OutputOracleStartingBlockNumber() + 1);
alice = makeAddr("alice"); alice = makeAddr("alice");
bob = makeAddr("bob"); bob = makeAddr("bob");
...@@ -35,7 +35,7 @@ contract CommonTest is Setup, Test, Events { ...@@ -35,7 +35,7 @@ contract CommonTest is Setup, Test, Events {
// Deploy L1 // Deploy L1
Setup.L1(); Setup.L1();
// Deploy L2 // Deploy L2
Setup.L2({ cfg: cfg }); Setup.L2({ cfg: deploy.cfg() });
} }
/// @dev Helper function that wraps `TransactionDeposited` event. /// @dev Helper function that wraps `TransactionDeposited` event.
...@@ -67,7 +67,7 @@ contract CommonTest is Setup, Test, Events { ...@@ -67,7 +67,7 @@ contract CommonTest is Setup, Test, Events {
warpToProposeTime(nextBlockNumber); warpToProposeTime(nextBlockNumber);
uint256 proposedNumber = l2OutputOracle.latestBlockNumber(); uint256 proposedNumber = l2OutputOracle.latestBlockNumber();
uint256 submissionInterval = cfg.l2OutputOracleSubmissionInterval(); uint256 submissionInterval = deploy.cfg().l2OutputOracleSubmissionInterval();
// Ensure the submissionInterval is enforced // Ensure the submissionInterval is enforced
assertEq(nextBlockNumber, proposedNumber + submissionInterval); assertEq(nextBlockNumber, proposedNumber + submissionInterval);
...@@ -76,7 +76,7 @@ contract CommonTest is Setup, Test, Events { ...@@ -76,7 +76,7 @@ contract CommonTest is Setup, Test, Events {
vm.expectEmit(true, true, true, true); vm.expectEmit(true, true, true, true);
emit OutputProposed(proposedOutput2, nextOutputIndex, nextBlockNumber, block.timestamp); emit OutputProposed(proposedOutput2, nextOutputIndex, nextBlockNumber, block.timestamp);
address proposer = cfg.l2OutputOracleProposer(); address proposer = deploy.cfg().l2OutputOracleProposer();
vm.prank(proposer); vm.prank(proposer);
l2OutputOracle.proposeL2Output(proposedOutput2, nextBlockNumber, 0, 0); l2OutputOracle.proposeL2Output(proposedOutput2, nextBlockNumber, 0, 0);
} }
......
...@@ -29,13 +29,18 @@ import { AddressManager } from "src/legacy/AddressManager.sol"; ...@@ -29,13 +29,18 @@ import { AddressManager } from "src/legacy/AddressManager.sol";
import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol"; import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol";
import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol";
import { Executables } from "scripts/Executables.sol"; import { Executables } from "scripts/Executables.sol";
import { Vm } from "forge-std/Vm.sol";
/// @title Setup /// @title Setup
/// @dev This contact is responsible for setting up the contracts in state. It currently /// @dev This contact is responsible for setting up the contracts in state. It currently
/// sets the L2 contracts directly at the predeploy addresses instead of setting them /// sets the L2 contracts directly at the predeploy addresses instead of setting them
/// up behind proxies. In the future we will migrate to importing the genesis JSON /// up behind proxies. In the future we will migrate to importing the genesis JSON
/// file that is created to set up the L2 contracts instead of setting them up manually. /// file that is created to set up the L2 contracts instead of setting them up manually.
contract Setup is Deploy { contract Setup {
Vm private constant vm = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
Deploy internal deploy;
OptimismPortal optimismPortal; OptimismPortal optimismPortal;
L2OutputOracle l2OutputOracle; L2OutputOracle l2OutputOracle;
SystemConfig systemConfig; SystemConfig systemConfig;
...@@ -62,8 +67,20 @@ contract Setup is Deploy { ...@@ -62,8 +67,20 @@ contract Setup is Deploy {
GovernanceToken governanceToken = GovernanceToken(Predeploys.GOVERNANCE_TOKEN); GovernanceToken governanceToken = GovernanceToken(Predeploys.GOVERNANCE_TOKEN);
LegacyERC20ETH legacyERC20ETH = LegacyERC20ETH(Predeploys.LEGACY_ERC20_ETH); LegacyERC20ETH legacyERC20ETH = LegacyERC20ETH(Predeploys.LEGACY_ERC20_ETH);
function setUp() public virtual override { /// @dev Deploys the Deploy contract without including its bytecode in the bytecode
Deploy.setUp(); /// of this contract by fetching the bytecode dynamically using `vm.getCode()`.
/// Without this, it greatly increases the compile time.
function setUp() public virtual {
deploy = Deploy(_create(vm.getCode("Deploy.s.sol:Deploy")));
deploy.setUp();
}
/// @dev Simple wrapper around the `create` opcode
function _create(bytes memory _code) internal returns (address addr_) {
assembly {
addr_ := create(0, add(_code, 0x20), mload(_code))
}
require(addr_ != address(0), "Setup: cannot create");
} }
/// @dev Sets up the L1 contracts. /// @dev Sets up the L1 contracts.
...@@ -74,36 +91,36 @@ contract Setup is Deploy { ...@@ -74,36 +91,36 @@ contract Setup is Deploy {
hex"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3" hex"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"
); );
Deploy.run(); deploy.run();
optimismPortal = OptimismPortal(mustGetAddress("OptimismPortalProxy")); optimismPortal = OptimismPortal(deploy.mustGetAddress("OptimismPortalProxy"));
l2OutputOracle = L2OutputOracle(mustGetAddress("L2OutputOracleProxy")); l2OutputOracle = L2OutputOracle(deploy.mustGetAddress("L2OutputOracleProxy"));
systemConfig = SystemConfig(mustGetAddress("SystemConfigProxy")); systemConfig = SystemConfig(deploy.mustGetAddress("SystemConfigProxy"));
l1StandardBridge = L1StandardBridge(mustGetAddress("L1StandardBridgeProxy")); l1StandardBridge = L1StandardBridge(deploy.mustGetAddress("L1StandardBridgeProxy"));
l1CrossDomainMessenger = L1CrossDomainMessenger(mustGetAddress("L1CrossDomainMessengerProxy")); l1CrossDomainMessenger = L1CrossDomainMessenger(deploy.mustGetAddress("L1CrossDomainMessengerProxy"));
addressManager = AddressManager(mustGetAddress("AddressManager")); addressManager = AddressManager(deploy.mustGetAddress("AddressManager"));
l1ERC721Bridge = L1ERC721Bridge(mustGetAddress("L1ERC721BridgeProxy")); l1ERC721Bridge = L1ERC721Bridge(deploy.mustGetAddress("L1ERC721BridgeProxy"));
l1OptimismMintableERC20Factory = l1OptimismMintableERC20Factory =
OptimismMintableERC20Factory(mustGetAddress("OptimismMintableERC20FactoryProxy")); OptimismMintableERC20Factory(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy"));
protocolVersions = ProtocolVersions(mustGetAddress("ProtocolVersionsProxy")); protocolVersions = ProtocolVersions(deploy.mustGetAddress("ProtocolVersionsProxy"));
vm.label(address(l2OutputOracle), "L2OutputOracle"); vm.label(address(l2OutputOracle), "L2OutputOracle");
vm.label(mustGetAddress("L2OutputOracleProxy"), "L2OutputOracleProxy"); vm.label(deploy.mustGetAddress("L2OutputOracleProxy"), "L2OutputOracleProxy");
vm.label(address(optimismPortal), "OptimismPortal"); vm.label(address(optimismPortal), "OptimismPortal");
vm.label(mustGetAddress("OptimismPortalProxy"), "OptimismPortalProxy"); vm.label(deploy.mustGetAddress("OptimismPortalProxy"), "OptimismPortalProxy");
vm.label(address(systemConfig), "SystemConfig"); vm.label(address(systemConfig), "SystemConfig");
vm.label(mustGetAddress("SystemConfigProxy"), "SystemConfigProxy"); vm.label(deploy.mustGetAddress("SystemConfigProxy"), "SystemConfigProxy");
vm.label(address(l1StandardBridge), "L1StandardBridge"); vm.label(address(l1StandardBridge), "L1StandardBridge");
vm.label(mustGetAddress("L1StandardBridgeProxy"), "L1StandardBridgeProxy"); vm.label(deploy.mustGetAddress("L1StandardBridgeProxy"), "L1StandardBridgeProxy");
vm.label(address(l1CrossDomainMessenger), "L1CrossDomainMessenger"); vm.label(address(l1CrossDomainMessenger), "L1CrossDomainMessenger");
vm.label(mustGetAddress("L1CrossDomainMessengerProxy"), "L1CrossDomainMessengerProxy"); vm.label(deploy.mustGetAddress("L1CrossDomainMessengerProxy"), "L1CrossDomainMessengerProxy");
vm.label(address(addressManager), "AddressManager"); vm.label(address(addressManager), "AddressManager");
vm.label(address(l1ERC721Bridge), "L1ERC721Bridge"); vm.label(address(l1ERC721Bridge), "L1ERC721Bridge");
vm.label(mustGetAddress("L1ERC721BridgeProxy"), "L1ERC721BridgeProxy"); vm.label(deploy.mustGetAddress("L1ERC721BridgeProxy"), "L1ERC721BridgeProxy");
vm.label(address(l1OptimismMintableERC20Factory), "OptimismMintableERC20Factory"); vm.label(address(l1OptimismMintableERC20Factory), "OptimismMintableERC20Factory");
vm.label(mustGetAddress("OptimismMintableERC20FactoryProxy"), "OptimismMintableERC20FactoryProxy"); vm.label(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy"), "OptimismMintableERC20FactoryProxy");
vm.label(address(protocolVersions), "ProtocolVersions"); vm.label(address(protocolVersions), "ProtocolVersions");
vm.label(mustGetAddress("ProtocolVersionsProxy"), "ProtocolVersionsProxy"); vm.label(deploy.mustGetAddress("ProtocolVersionsProxy"), "ProtocolVersionsProxy");
vm.label(AddressAliasHelper.applyL1ToL2Alias(address(l1CrossDomainMessenger)), "L1CrossDomainMessenger_aliased"); vm.label(AddressAliasHelper.applyL1ToL2Alias(address(l1CrossDomainMessenger)), "L1CrossDomainMessenger_aliased");
} }
......
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