Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ contract L2Genesis is Script {

/// @notice This predeploy is following the safety invariant #2,
function setSequencerFeeVault(Input memory _input) internal {
Types.WithdrawalNetwork withdrawalNetwork = Types.WithdrawalNetwork(_input.sequencerFeeVaultWithdrawalNetwork);

if (_input.isCustomGasToken && withdrawalNetwork == Types.WithdrawalNetwork.L1) {
revert("SequencerFeeVault: withdrawalNetwork type cannot be L1 when custom gas token is enabled");
}

ISequencerFeeVault vault = ISequencerFeeVault(
DeployUtils.create1({
_name: "SequencerFeeVault",
Expand All @@ -307,7 +313,7 @@ contract L2Genesis is Script {
(
_input.sequencerFeeVaultRecipient,
_input.sequencerFeeVaultMinimumWithdrawalAmount,
Types.WithdrawalNetwork(_input.sequencerFeeVaultWithdrawalNetwork)
withdrawalNetwork
)
)
)
Expand Down Expand Up @@ -402,17 +408,19 @@ contract L2Genesis is Script {

/// @notice This predeploy is following the safety invariant #2.
function setBaseFeeVault(Input memory _input) internal {
Types.WithdrawalNetwork withdrawalNetwork = Types.WithdrawalNetwork(_input.baseFeeVaultWithdrawalNetwork);

if (_input.isCustomGasToken && withdrawalNetwork == Types.WithdrawalNetwork.L1) {
revert("BaseFeeVault: withdrawalNetwork type cannot be L1 when custom gas token is enabled");
}

IBaseFeeVault vault = IBaseFeeVault(
DeployUtils.create1({
_name: "BaseFeeVault",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IBaseFeeVault.__constructor__,
(
_input.baseFeeVaultRecipient,
_input.baseFeeVaultMinimumWithdrawalAmount,
Types.WithdrawalNetwork(_input.baseFeeVaultWithdrawalNetwork)
)
(_input.baseFeeVaultRecipient, _input.baseFeeVaultMinimumWithdrawalAmount, withdrawalNetwork)
)
)
})
Expand All @@ -428,17 +436,19 @@ contract L2Genesis is Script {

/// @notice This predeploy is following the safety invariant #2.
function setL1FeeVault(Input memory _input) internal {
Types.WithdrawalNetwork withdrawalNetwork = Types.WithdrawalNetwork(_input.l1FeeVaultWithdrawalNetwork);

if (_input.isCustomGasToken && withdrawalNetwork == Types.WithdrawalNetwork.L1) {
revert("L1FeeVault: withdrawalNetwork type cannot be L1 when custom gas token is enabled");
}

IL1FeeVault vault = IL1FeeVault(
DeployUtils.create1({
_name: "L1FeeVault",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IL1FeeVault.__constructor__,
(
_input.l1FeeVaultRecipient,
_input.l1FeeVaultMinimumWithdrawalAmount,
Types.WithdrawalNetwork(_input.l1FeeVaultWithdrawalNetwork)
)
(_input.l1FeeVaultRecipient, _input.l1FeeVaultMinimumWithdrawalAmount, withdrawalNetwork)
)
)
})
Expand Down
32 changes: 31 additions & 1 deletion packages/contracts-bedrock/test/scripts/L2Genesis.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ contract L2Genesis_Run_Test is L2Genesis_TestInit {
testForks();
}

function test_run_cgt_succeeds() external {
/// @dev Modifier to set up the input for L2Genesis with CGT enabled.
modifier setInputCGTEnabled() {
input = L2Genesis.Input({
l1ChainID: 1,
l2ChainID: 2,
Expand All @@ -186,6 +187,12 @@ contract L2Genesis_Run_Test is L2Genesis_TestInit {
gasPayingTokenName: "Custom Gas Token",
gasPayingTokenSymbol: "CGT"
});
_;
}

/// @notice Tests that the run function succeeds when CGT is enabled.
/// @dev Tests that LiquidityController and NativeAssetLiquidity are deployed.
function test_run_cgt_succeeds() external setInputCGTEnabled {
genesis.run(input);

testProxyAdmin();
Expand All @@ -196,4 +203,27 @@ contract L2Genesis_Run_Test is L2Genesis_TestInit {
testForks();
testCGT();
}

/// @notice Tests that the run function reverts when CGT is enabled and the withdrawal network type of the FeeVaults
/// is L1.
function test_run_cgt_reverts() external setInputCGTEnabled {
// Expect revert when sequencerFeeVaultWithdrawalNetwork is L1
input.sequencerFeeVaultWithdrawalNetwork = 0;
vm.expectRevert("SequencerFeeVault: withdrawalNetwork type cannot be L1 when custom gas token is enabled");
genesis.run(input);
// Reset sequencerFeeVaultWithdrawalNetwork input to L2
input.sequencerFeeVaultWithdrawalNetwork = 1;

// Expect revert when baseFeeVaultWithdrawalNetwork is L1
input.baseFeeVaultWithdrawalNetwork = 0;
vm.expectRevert("BaseFeeVault: withdrawalNetwork type cannot be L1 when custom gas token is enabled");
genesis.run(input);
// Reset baseFeeVaultWithdrawalNetwork input to L2
input.baseFeeVaultWithdrawalNetwork = 1;

// Expect revert when l1FeeVaultWithdrawalNetwork is L1
input.l1FeeVaultWithdrawalNetwork = 0;
vm.expectRevert("L1FeeVault: withdrawalNetwork type cannot be L1 when custom gas token is enabled");
genesis.run(input);
}
}