Commit 03ad50f1 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #8148 from ethereum-optimism/ctb/l2-load-allocs

contracts-bedrock: loadAllocs support
parents e20690e2 f58cb3a5
......@@ -346,7 +346,7 @@ jobs:
contracts-bedrock-tests:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
resource_class: medium
resource_class: xlarge
steps:
- checkout
- run:
......@@ -378,7 +378,7 @@ jobs:
contracts-bedrock-checks:
docker:
- image: <<pipeline.parameters.ci_builder_image>>
resource_class: medium
resource_class: xlarge
steps:
- checkout
- run:
......
......@@ -18,6 +18,7 @@
"build:go-ffi": "(cd scripts/go-ffi && go build)",
"autogen:invariant-docs": "npx tsx scripts/invariant-doc-gen.ts",
"test": "pnpm build:go-ffi && forge test",
"genesis": "./scripts/generate-l2-genesis.sh",
"coverage": "pnpm build:go-ffi && forge coverage",
"coverage:lcov": "pnpm build:go-ffi && forge coverage --report lcov",
"deploy": "./scripts/deploy.sh",
......@@ -30,7 +31,7 @@
"validate-spacers": "pnpm build && pnpm validate-spacers:no-build",
"slither": "./scripts/slither.sh",
"slither:triage": "TRIAGE_MODE=1 ./scripts/slither.sh",
"clean": "rm -rf ./artifacts ./forge-artifacts ./cache ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo ./scripts/go-ffi/go-ffi ./.testdata",
"clean": "rm -rf ./artifacts ./forge-artifacts ./cache ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo ./scripts/go-ffi/go-ffi ./.testdata ./deployments/hardhat/*",
"preinstall": "npx only-allow pnpm",
"pre-pr:no-build": "pnpm gas-snapshot:no-build && pnpm storage-snapshot && pnpm semver-lock && pnpm autogen:invariant-docs && pnpm lint && pnpm bindings:go",
"pre-pr": "pnpm clean && pnpm build:go-ffi && pnpm build && pnpm pre-pr:no-build",
......
......@@ -16,19 +16,17 @@ TESTDATA_DIR="$CONTRACTS_DIR/.testdata"
OUTFILE_L2="$TESTDATA_DIR/genesis.json"
OUTFILE_ROLLUP="$TESTDATA_DIR/rollup.json"
OUTFILE_ALLOC="$TESTDATA_DIR/alloc.json"
mkdir -p "$TESTDATA_DIR"
if [ ! -f "$DEPLOY_ARTIFACT" ]; then
forge script $CONTRACTS_DIR/scripts/Deploy.s.sol:Deploy 2>&1 /dev/null
forge script $CONTRACTS_DIR/scripts/Deploy.s.sol:Deploy > /dev/null 2>&1
fi
if [ ! -d "$TESTDATA_DIR" ]; then
mkdir -p "$TESTDATA_DIR"
if [ ! -f "$OUTFILE_L2" ]; then
go run $OP_NODE genesis l2 \
--deploy-config "$CONTRACTS_DIR/deploy-config/hardhat.json" \
--l1-deployments "$DEPLOY_ARTIFACT" \
--l1-starting-block "$L1_STARTING_BLOCK_PATH" \
--outfile.l2 "$OUTFILE_L2" \
--outfile.rollup "$OUTFILE_ROLLUP" >/dev/null 2>&1
--outfile.rollup "$OUTFILE_ROLLUP" > /dev/null 2>&1
fi
......@@ -13,7 +13,7 @@ contract FeeVault_Test is Bridge_Initializer {
function test_constructor_l1FeeVault_succeeds() external {
assertEq(l1FeeVault.RECIPIENT(), cfg.l1FeeVaultRecipient());
assertEq(l1FeeVault.MIN_WITHDRAWAL_AMOUNT(), cfg.l1FeeVaultMinimumWithdrawalAmount());
assertEq(uint8(l1FeeVault.WITHDRAWAL_NETWORK()), uint8(FeeVault.WithdrawalNetwork.L2));
assertEq(uint8(l1FeeVault.WITHDRAWAL_NETWORK()), uint8(FeeVault.WithdrawalNetwork.L1));
}
/// @dev Tests that the constructor sets the correct values.
......
......@@ -5,6 +5,7 @@ pragma solidity 0.8.15;
import { CommonTest } from "test/setup/CommonTest.sol";
import { Reverter } from "test/mocks/Callers.sol";
import { StandardBridge } from "src/universal/StandardBridge.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
// Libraries
import { Predeploys } from "src/libraries/Predeploys.sol";
......@@ -17,8 +18,8 @@ import { SequencerFeeVault } from "src/L2/SequencerFeeVault.sol";
contract SequencerFeeVault_Test is CommonTest {
address recipient;
/// @dev Sets up the test suite.
/// @dev Sets up the test suite.
function setUp() public override {
super.setUp();
recipient = cfg.sequencerFeeVaultRecipient();
......@@ -56,14 +57,6 @@ contract SequencerFeeVault_Test is CommonTest {
/// @dev Tests that `withdraw` successfully initiates a withdrawal to L1.
function test_withdraw_toL1_succeeds() external {
// Set the code with the withdrawal network set to L1
vm.etch(
Predeploys.SEQUENCER_FEE_WALLET,
address(
new SequencerFeeVault(cfg.sequencerFeeVaultRecipient(), cfg.sequencerFeeVaultMinimumWithdrawalAmount(), FeeVault.WithdrawalNetwork.L1)
).code
);
uint256 amount = sequencerFeeVault.MIN_WITHDRAWAL_AMOUNT() + 1;
vm.deal(address(sequencerFeeVault), amount);
......@@ -99,11 +92,21 @@ contract SequencerFeeVault_Test is CommonTest {
}
contract SequencerFeeVault_L2Withdrawal_Test is CommonTest {
/// @dev a cache for the config fee recipient
address recipient;
/// @dev Sets up the test suite.
/// @dev Sets up the test suite.
function setUp() public override {
super.setUp();
// Alter the deployment to use WithdrawalNetwork.L2
vm.etch(
EIP1967Helper.getImplementation(Predeploys.SEQUENCER_FEE_WALLET),
address(
new SequencerFeeVault(cfg.sequencerFeeVaultRecipient(), cfg.sequencerFeeVaultMinimumWithdrawalAmount(), FeeVault.WithdrawalNetwork.L2)
).code
);
recipient = cfg.sequencerFeeVaultRecipient();
}
......
......@@ -9,20 +9,14 @@ import { FFIInterface } from "test/setup/FFIInterface.sol";
/// @title CommonTest
/// @dev An extenstion to `Test` that sets up the optimism smart contracts.
contract CommonTest is Setup, Test, Events {
address alice = address(128);
address bob = address(256);
address alice;
address bob;
bytes32 constant nonZeroHash = keccak256(abi.encode("NON_ZERO"));
FFIInterface ffi;
function setUp() public virtual override {
vm.deal(alice, type(uint64).max);
vm.deal(bob, type(uint64).max);
vm.label(alice, "alice");
vm.label(bob, "bob");
Setup.setUp();
ffi = new FFIInterface();
......@@ -33,6 +27,11 @@ contract CommonTest is Setup, Test, Events {
vm.warp(cfg.l2OutputOracleStartingTimestamp() + 1);
vm.roll(cfg.l2OutputOracleStartingBlockNumber() + 1);
alice = makeAddr("alice");
bob = makeAddr("bob");
vm.deal(alice, 10000 ether);
vm.deal(bob, 10000 ether);
// Deploy L1
Setup.L1();
// Deploy L2
......
......@@ -28,6 +28,7 @@ import { L1StandardBridge } from "src/L1/L1StandardBridge.sol";
import { AddressManager } from "src/legacy/AddressManager.sol";
import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol";
import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol";
import { Executables } from "scripts/Executables.sol";
/// @title Setup
/// @dev This contact is responsible for setting up the contracts in state. It currently
......@@ -108,65 +109,14 @@ contract Setup is Deploy {
/// @dev Sets up the L2 contracts. Depends on `L1()` being called first.
function L2(DeployConfig cfg) public {
// Set up L2. There are currently no proxies set in the L2 initialization.
vm.etch(
address(l2CrossDomainMessenger), address(new L2CrossDomainMessenger(address(l1CrossDomainMessenger))).code
);
l2CrossDomainMessenger.initialize();
vm.etch(address(l2ToL1MessagePasser), address(new L2ToL1MessagePasser()).code);
vm.etch(address(l2StandardBridge), address(new L2StandardBridge(payable(l1StandardBridge))).code);
vm.etch(
address(l2OptimismMintableERC20Factory),
address(new OptimismMintableERC20Factory(address(l2StandardBridge))).code
);
vm.etch(address(legacyERC20ETH), address(new LegacyERC20ETH()).code);
vm.etch(
address(l2ERC721Bridge),
address(new L2ERC721Bridge(address(l2CrossDomainMessenger), address(l1ERC721Bridge))).code
);
vm.etch(
address(sequencerFeeVault),
address(
new SequencerFeeVault(cfg.sequencerFeeVaultRecipient(), cfg.sequencerFeeVaultMinimumWithdrawalAmount(), FeeVault.WithdrawalNetwork.L2)
).code
);
vm.etch(
address(baseFeeVault),
address(
new BaseFeeVault(cfg.baseFeeVaultRecipient(), cfg.baseFeeVaultMinimumWithdrawalAmount(), FeeVault.WithdrawalNetwork.L1)
).code
);
vm.etch(
address(l1FeeVault),
address(
new L1FeeVault(cfg.l1FeeVaultRecipient(), cfg.l1FeeVaultMinimumWithdrawalAmount(), FeeVault.WithdrawalNetwork.L2)
).code
);
vm.etch(address(l1Block), address(new L1Block()).code);
vm.etch(address(gasPriceOracle), address(new GasPriceOracle()).code);
vm.etch(address(legacyMessagePasser), address(new LegacyMessagePasser()).code);
vm.etch(address(governanceToken), address(new GovernanceToken()).code);
// Set the ERC20 token name and symbol
vm.store(
address(governanceToken),
bytes32(uint256(3)),
bytes32(0x4f7074696d69736d000000000000000000000000000000000000000000000010)
);
vm.store(
address(governanceToken),
bytes32(uint256(4)),
bytes32(0x4f50000000000000000000000000000000000000000000000000000000000004)
);
string[] memory args = new string[](3);
args[0] = Executables.bash;
args[1] = "-c";
args[2] = string.concat(vm.projectRoot(), "/scripts/generate-l2-genesis.sh");
vm.ffi(args);
string memory allocsPath = string.concat(vm.projectRoot(), "/.testdata/genesis.json");
vm.loadAllocs(allocsPath);
// Set the governance token's owner to be the final system owner
address finalSystemOwner = cfg.finalSystemOwner();
......
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