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
03ad50f1
Unverified
Commit
03ad50f1
authored
Nov 28, 2023
by
Mark Tyneway
Committed by
GitHub
Nov 28, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8148 from ethereum-optimism/ctb/l2-load-allocs
contracts-bedrock: loadAllocs support
parents
e20690e2
f58cb3a5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
87 deletions
+38
-87
config.yml
.circleci/config.yml
+2
-2
package.json
packages/contracts-bedrock/package.json
+2
-1
generate-l2-genesis.sh
packages/contracts-bedrock/scripts/generate-l2-genesis.sh
+4
-6
FeeVault.t.sol
packages/contracts-bedrock/test/FeeVault.t.sol
+1
-1
SequencerFeeVault.t.sol
packages/contracts-bedrock/test/SequencerFeeVault.t.sol
+13
-10
CommonTest.sol
packages/contracts-bedrock/test/setup/CommonTest.sol
+7
-8
Setup.sol
packages/contracts-bedrock/test/setup/Setup.sol
+9
-59
No files found.
.circleci/config.yml
View file @
03ad50f1
...
@@ -346,7 +346,7 @@ jobs:
...
@@ -346,7 +346,7 @@ jobs:
contracts-bedrock-tests
:
contracts-bedrock-tests
:
docker
:
docker
:
-
image
:
<<pipeline.parameters.ci_builder_image>>
-
image
:
<<pipeline.parameters.ci_builder_image>>
resource_class
:
medium
resource_class
:
xlarge
steps
:
steps
:
-
checkout
-
checkout
-
run
:
-
run
:
...
@@ -378,7 +378,7 @@ jobs:
...
@@ -378,7 +378,7 @@ jobs:
contracts-bedrock-checks
:
contracts-bedrock-checks
:
docker
:
docker
:
-
image
:
<<pipeline.parameters.ci_builder_image>>
-
image
:
<<pipeline.parameters.ci_builder_image>>
resource_class
:
medium
resource_class
:
xlarge
steps
:
steps
:
-
checkout
-
checkout
-
run
:
-
run
:
...
...
packages/contracts-bedrock/package.json
View file @
03ad50f1
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
"build:go-ffi"
:
"(cd scripts/go-ffi && go build)"
,
"build:go-ffi"
:
"(cd scripts/go-ffi && go build)"
,
"autogen:invariant-docs"
:
"npx tsx scripts/invariant-doc-gen.ts"
,
"autogen:invariant-docs"
:
"npx tsx scripts/invariant-doc-gen.ts"
,
"test"
:
"pnpm build:go-ffi && forge test"
,
"test"
:
"pnpm build:go-ffi && forge test"
,
"genesis"
:
"./scripts/generate-l2-genesis.sh"
,
"coverage"
:
"pnpm build:go-ffi && forge coverage"
,
"coverage"
:
"pnpm build:go-ffi && forge coverage"
,
"coverage:lcov"
:
"pnpm build:go-ffi && forge coverage --report lcov"
,
"coverage:lcov"
:
"pnpm build:go-ffi && forge coverage --report lcov"
,
"deploy"
:
"./scripts/deploy.sh"
,
"deploy"
:
"./scripts/deploy.sh"
,
...
@@ -30,7 +31,7 @@
...
@@ -30,7 +31,7 @@
"validate-spacers"
:
"pnpm build && pnpm validate-spacers:no-build"
,
"validate-spacers"
:
"pnpm build && pnpm validate-spacers:no-build"
,
"slither"
:
"./scripts/slither.sh"
,
"slither"
:
"./scripts/slither.sh"
,
"slither:triage"
:
"TRIAGE_MODE=1 ./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"
,
"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: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"
,
"pre-pr"
:
"pnpm clean && pnpm build:go-ffi && pnpm build && pnpm pre-pr:no-build"
,
...
...
packages/contracts-bedrock/scripts/generate-l2-genesis.sh
View file @
03ad50f1
...
@@ -16,19 +16,17 @@ TESTDATA_DIR="$CONTRACTS_DIR/.testdata"
...
@@ -16,19 +16,17 @@ TESTDATA_DIR="$CONTRACTS_DIR/.testdata"
OUTFILE_L2
=
"
$TESTDATA_DIR
/genesis.json"
OUTFILE_L2
=
"
$TESTDATA_DIR
/genesis.json"
OUTFILE_ROLLUP
=
"
$TESTDATA_DIR
/rollup.json"
OUTFILE_ROLLUP
=
"
$TESTDATA_DIR
/rollup.json"
OUTFILE_ALLOC
=
"
$TESTDATA_DIR
/alloc.json
"
mkdir
-p
"
$TESTDATA_DIR
"
if
[
!
-f
"
$DEPLOY_ARTIFACT
"
]
;
then
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
fi
if
[
!
-d
"
$TESTDATA_DIR
"
]
;
then
if
[
!
-f
"
$OUTFILE_L2
"
]
;
then
mkdir
-p
"
$TESTDATA_DIR
"
go run
$OP_NODE
genesis l2
\
go run
$OP_NODE
genesis l2
\
--deploy-config
"
$CONTRACTS_DIR
/deploy-config/hardhat.json"
\
--deploy-config
"
$CONTRACTS_DIR
/deploy-config/hardhat.json"
\
--l1-deployments
"
$DEPLOY_ARTIFACT
"
\
--l1-deployments
"
$DEPLOY_ARTIFACT
"
\
--l1-starting-block
"
$L1_STARTING_BLOCK_PATH
"
\
--l1-starting-block
"
$L1_STARTING_BLOCK_PATH
"
\
--outfile
.l2
"
$OUTFILE_L2
"
\
--outfile
.l2
"
$OUTFILE_L2
"
\
--outfile
.rollup
"
$OUTFILE_ROLLUP
"
>
/dev/null 2>&1
--outfile
.rollup
"
$OUTFILE_ROLLUP
"
>
/dev/null 2>&1
fi
fi
packages/contracts-bedrock/test/FeeVault.t.sol
View file @
03ad50f1
...
@@ -13,7 +13,7 @@ contract FeeVault_Test is Bridge_Initializer {
...
@@ -13,7 +13,7 @@ contract FeeVault_Test is Bridge_Initializer {
function test_constructor_l1FeeVault_succeeds() external {
function test_constructor_l1FeeVault_succeeds() external {
assertEq(l1FeeVault.RECIPIENT(), cfg.l1FeeVaultRecipient());
assertEq(l1FeeVault.RECIPIENT(), cfg.l1FeeVaultRecipient());
assertEq(l1FeeVault.MIN_WITHDRAWAL_AMOUNT(), cfg.l1FeeVaultMinimumWithdrawalAmount());
assertEq(l1FeeVault.MIN_WITHDRAWAL_AMOUNT(), cfg.l1FeeVaultMinimumWithdrawalAmount());
assertEq(uint8(l1FeeVault.WITHDRAWAL_NETWORK()), uint8(FeeVault.WithdrawalNetwork.L
2
));
assertEq(uint8(l1FeeVault.WITHDRAWAL_NETWORK()), uint8(FeeVault.WithdrawalNetwork.L
1
));
}
}
/// @dev Tests that the constructor sets the correct values.
/// @dev Tests that the constructor sets the correct values.
...
...
packages/contracts-bedrock/test/SequencerFeeVault.t.sol
View file @
03ad50f1
...
@@ -5,6 +5,7 @@ pragma solidity 0.8.15;
...
@@ -5,6 +5,7 @@ pragma solidity 0.8.15;
import { CommonTest } from "test/setup/CommonTest.sol";
import { CommonTest } from "test/setup/CommonTest.sol";
import { Reverter } from "test/mocks/Callers.sol";
import { Reverter } from "test/mocks/Callers.sol";
import { StandardBridge } from "src/universal/StandardBridge.sol";
import { StandardBridge } from "src/universal/StandardBridge.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
// Libraries
// Libraries
import { Predeploys } from "src/libraries/Predeploys.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
...
@@ -17,8 +18,8 @@ import { SequencerFeeVault } from "src/L2/SequencerFeeVault.sol";
...
@@ -17,8 +18,8 @@ import { SequencerFeeVault } from "src/L2/SequencerFeeVault.sol";
contract SequencerFeeVault_Test is CommonTest {
contract SequencerFeeVault_Test is CommonTest {
address recipient;
address recipient;
/// @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 = cfg.sequencerFeeVaultRecipient();
...
@@ -56,14 +57,6 @@ contract SequencerFeeVault_Test is CommonTest {
...
@@ -56,14 +57,6 @@ contract SequencerFeeVault_Test is CommonTest {
/// @dev Tests that `withdraw` successfully initiates a withdrawal to L1.
/// @dev Tests that `withdraw` successfully initiates a withdrawal to L1.
function test_withdraw_toL1_succeeds() external {
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;
uint256 amount = sequencerFeeVault.MIN_WITHDRAWAL_AMOUNT() + 1;
vm.deal(address(sequencerFeeVault), amount);
vm.deal(address(sequencerFeeVault), amount);
...
@@ -99,11 +92,21 @@ contract SequencerFeeVault_Test is CommonTest {
...
@@ -99,11 +92,21 @@ contract SequencerFeeVault_Test is CommonTest {
}
}
contract SequencerFeeVault_L2Withdrawal_Test is CommonTest {
contract SequencerFeeVault_L2Withdrawal_Test is CommonTest {
/// @dev a cache for the config fee recipient
address recipient;
address recipient;
/// @dev Sets up the test suite.
/// @dev Sets up the test suite.
function setUp() public override {
function setUp() public override {
super.setUp();
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();
recipient = cfg.sequencerFeeVaultRecipient();
}
}
...
...
packages/contracts-bedrock/test/setup/CommonTest.sol
View file @
03ad50f1
...
@@ -9,20 +9,14 @@ import { FFIInterface } from "test/setup/FFIInterface.sol";
...
@@ -9,20 +9,14 @@ import { FFIInterface } from "test/setup/FFIInterface.sol";
/// @title CommonTest
/// @title CommonTest
/// @dev An extenstion to `Test` that sets up the optimism smart contracts.
/// @dev An extenstion to `Test` that sets up the optimism smart contracts.
contract CommonTest is Setup, Test, Events {
contract CommonTest is Setup, Test, Events {
address alice
= address(128)
;
address alice;
address bob
= address(256)
;
address bob;
bytes32 constant nonZeroHash = keccak256(abi.encode("NON_ZERO"));
bytes32 constant nonZeroHash = keccak256(abi.encode("NON_ZERO"));
FFIInterface ffi;
FFIInterface ffi;
function setUp() public virtual override {
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();
Setup.setUp();
ffi = new FFIInterface();
ffi = new FFIInterface();
...
@@ -33,6 +27,11 @@ contract CommonTest is Setup, Test, Events {
...
@@ -33,6 +27,11 @@ contract CommonTest is Setup, Test, Events {
vm.warp(cfg.l2OutputOracleStartingTimestamp() + 1);
vm.warp(cfg.l2OutputOracleStartingTimestamp() + 1);
vm.roll(cfg.l2OutputOracleStartingBlockNumber() + 1);
vm.roll(cfg.l2OutputOracleStartingBlockNumber() + 1);
alice = makeAddr("alice");
bob = makeAddr("bob");
vm.deal(alice, 10000 ether);
vm.deal(bob, 10000 ether);
// Deploy L1
// Deploy L1
Setup.L1();
Setup.L1();
// Deploy L2
// Deploy L2
...
...
packages/contracts-bedrock/test/setup/Setup.sol
View file @
03ad50f1
...
@@ -28,6 +28,7 @@ import { L1StandardBridge } from "src/L1/L1StandardBridge.sol";
...
@@ -28,6 +28,7 @@ import { L1StandardBridge } from "src/L1/L1StandardBridge.sol";
import { AddressManager } from "src/legacy/AddressManager.sol";
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";
/// @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
...
@@ -108,65 +109,14 @@ contract Setup is Deploy {
...
@@ -108,65 +109,14 @@ contract Setup is Deploy {
/// @dev Sets up the L2 contracts. Depends on `L1()` being called first.
/// @dev Sets up the L2 contracts. Depends on `L1()` being called first.
function L2(DeployConfig cfg) public {
function L2(DeployConfig cfg) public {
// Set up L2. There are currently no proxies set in the L2 initialization.
string[] memory args = new string[](3);
vm.etch(
args[0] = Executables.bash;
address(l2CrossDomainMessenger), address(new L2CrossDomainMessenger(address(l1CrossDomainMessenger))).code
args[1] = "-c";
);
args[2] = string.concat(vm.projectRoot(), "/scripts/generate-l2-genesis.sh");
l2CrossDomainMessenger.initialize();
vm.ffi(args);
vm.etch(address(l2ToL1MessagePasser), address(new L2ToL1MessagePasser()).code);
string memory allocsPath = string.concat(vm.projectRoot(), "/.testdata/genesis.json");
vm.loadAllocs(allocsPath);
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)
);
// Set the governance token's owner to be the final system owner
// Set the governance token's owner to be the final system owner
address finalSystemOwner = cfg.finalSystemOwner();
address finalSystemOwner = cfg.finalSystemOwner();
...
...
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