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
1 change: 0 additions & 1 deletion src/template/DeployFeesDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ contract DeployFeesDepositor is SimpleTaskBase {
gasLimit = uint32(_gasLimitRaw);

proxyAdminOwner = simpleAddrRegistry.get("ProxyAdminOwner");
require(proxyAdminOwner != address(0), "proxyAdminOwner must be set");

_proxyInitCode = bytes.concat(type(Proxy).creationCode, abi.encode(proxyAdminOwner));

Expand Down
1 change: 0 additions & 1 deletion src/template/LateOptInRevenueShare.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ contract LateOptInRevenueShare is SimpleTaskBase {
string memory _toml = vm.readFile(_taskConfigFilePath);

portal = simpleAddrRegistry.get("OptimismPortal");
require(portal != address(0), "OptimismPortal must be set in the addresses block");

useOwnCalculator = _toml.readBool(".useOwnCalculator");

Expand Down
57 changes: 57 additions & 0 deletions test/template/deploy-fees-depositor/DeployFeesDepositor.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import {Test} from "forge-std/Test.sol";
import {DeployFeesDepositor} from "src/template/DeployFeesDepositor.sol";

/// @notice Test contract for the DeployFeesDepositor that expect reverts on misconfiguration of required fields.
contract DeployFeesDepositorRequiredFieldsTest is Test {
DeployFeesDepositor public template;

function setUp() public {
vm.createSelectFork("mainnet", 23197819);
template = new DeployFeesDepositor();
}

/// @notice Tests that the template reverts when the salt is an empty string.
function test_deployFeesDepositor_salt_empty_string_reverts() public {
string memory configPath = "test/template/deploy-fees-depositor/config/salt-empty-string-config.toml";
vm.expectRevert("salt must be set");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when the l2Recipient is a zero address.
function test_deployFeesDepositor_l2Recipient_zero_address_reverts() public {
string memory configPath = "test/template/deploy-fees-depositor/config/l2Recipient-zero-address-config.toml";
vm.expectRevert("l2Recipient must be set");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when the portal is a zero address.
function test_deployFeesDepositor_portal_zero_address_reverts() public {
string memory configPath = "test/template/deploy-fees-depositor/config/portal-zero-address-config.toml";
vm.expectRevert("portal must be set");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when the gasLimit is zero.
function test_deployFeesDepositor_gasLimit_zero_reverts() public {
string memory configPath = "test/template/deploy-fees-depositor/config/gasLimit-zero-config.toml";
vm.expectRevert("gasLimit must be set");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when the gasLimit is too high.
function test_deployFeesDepositor_gasLimit_too_high_reverts() public {
string memory configPath = "test/template/deploy-fees-depositor/config/gasLimit-too-high-config.toml";
vm.expectRevert("gasLimit must be less than uint32.max");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when the proxyAdminOwner is a zero address.
function test_deployFeesDepositor_proxyAdminOwner_zero_address_reverts() public {
string memory configPath = "test/template/deploy-fees-depositor/config/proxyAdminOwner-zero-address-config.toml";
vm.expectRevert("SimpleAddressRegistry: zero address for ProxyAdminOwner");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this line on FeesDepositor:

         require(proxyAdminOwner != address(0), "proxyAdminOwner must be set");

Since it fails before on .get()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thought leaving it for completeness as the require in the script was there already but definitely can be both removed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed here.

template.simulate(configPath);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
l2chains = []
templateName = "DeployFeesDepositor"

salt = "test-salt"
minDepositAmount = 1000000000000000000
gasLimit = 4294967296
portal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
l2Recipient = "0xdeadbeef1234567890abcdef1234567890abcdef"

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
l2chains = []
templateName = "DeployFeesDepositor"

salt = "test-salt"
gasLimit = 0
minDepositAmount = 1000000000000000000
l2Recipient = "0xdeadbeef1234567890abcdef1234567890abcdef"
portal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
l2chains = []
templateName = "DeployFeesDepositor"

minDepositAmount = 1000000000000000000
portal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
l2Recipient = "0x0000000000000000000000000000000000000000"
salt = "test-salt"
gasLimit = 1000000

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
l2chains = []
templateName = "DeployFeesDepositor"

minDepositAmount = 1000000000000000000
portal = "0x0000000000000000000000000000000000000000"
l2Recipient = "0xdeadbeef1234567890abcdef1234567890abcdef"
salt = "test-salt"
gasLimit = 1000000

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
l2chains = []
templateName = "DeployFeesDepositor"

portal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
l2Recipient = "0xdeadbeef1234567890abcdef1234567890abcdef"
salt = "test-salt"
gasLimit = 1000000

[addresses]
ProxyAdminOwner = "0x0000000000000000000000000000000000000000"


Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
l2chains = []
templateName = "DeployFeesDepositor"

portal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
l2Recipient = "0xdeadbeef1234567890abcdef1234567890abcdef"
salt = ""
gasLimit = 1000000

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,79 @@ contract LateOptInRevenueShareTest is Test {
}
}
}

/// @notice Test contract for the LateOptInRevenueShare that expect reverts on misconfiguration of required fields.
contract LateOptInRevenueShareRequiredFieldsTest is Test {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing portal != address(0)? Also, I think we can remove that require on the contract since get() already handles it. But worth checking

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it's the same as the previous comment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed here.

LateOptInRevenueShare public template;

function setUp() public {
vm.createSelectFork("mainnet", 23197819);
template = new LateOptInRevenueShare();
}

/// @notice Tests that the template reverts when the gasLimit is too low.
function test_lateOptInRevenueShare_too_low_gasLimit_reverts() public {
string memory configPath = "test/template/late-opt-in-rev-share/config/zero-gas-limit-config.toml";
vm.expectRevert("gasLimit must be set");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when the gasLimit is too high.
function test_lateOptInRevenueShare_too_high_gasLimit_reverts() public {
string memory configPath = "test/template/late-opt-in-rev-share/config/too-high-gas-limit-config.toml";
vm.expectRevert("gasLimit must be less than uint64.max");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when using own calculator and the calculator address is zero.
function test_lateOptInRevenueShare_calculator_zero_address_reverts() public {
string memory configPath = "test/template/late-opt-in-rev-share/config/calculator-zero-address-config.toml";
vm.expectRevert("calculator address must be set in config if opting to use own calculator");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when using default calculator and the salt seed is an empty string.
function test_lateOptInRevenueShare_saltSeed_empty_string_reverts() public {
string memory configPath = "test/template/late-opt-in-rev-share/config/salt-seed-empty-string-config.toml";
vm.expectRevert("saltSeed must be set in config");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when using default calculator and the l1 withdrawer recipient is a zero address.
function test_lateOptInRevenueShare_l1WithdrawerRecipient_zero_address_reverts() public {
string memory configPath =
"test/template/late-opt-in-rev-share/config/l1WithdrawerRecipient-zero-address-config.toml";
vm.expectRevert("l1WithdrawerRecipient must be set in config");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when using default calculator and the l1 withdrawer gas limit is zero.
function test_lateOptInRevenueShare_l1WithdrawerGasLimit_zero_reverts() public {
string memory configPath = "test/template/late-opt-in-rev-share/config/l1WithdrawerGasLimit-zero-config.toml";
vm.expectRevert("l1WithdrawerGasLimit must be greater than 0");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when using default calculator and the l1 withdrawer gas limit is too high.
function test_lateOptInRevenueShare_l1WithdrawerGasLimit_too_high_reverts() public {
string memory configPath =
"test/template/late-opt-in-rev-share/config/l1WithdrawerGasLimit-too-high-config.toml";
vm.expectRevert("l1WithdrawerGasLimit must be less than uint32.max");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when using default calculator and the chain fees recipient is a zero address.
function test_lateOptInRevenueShare_scRevShareCalcChainFeesRecipient_zero_address_reverts() public {
string memory configPath =
"test/template/late-opt-in-rev-share/config/scRevShareCalcChainFeesRecipient-zero-address-config.toml";
vm.expectRevert("scRevShareCalcChainFeesRecipient must be set in config");
template.simulate(configPath);
}

/// @notice Tests that the template reverts when the portal is a zero address.
function test_lateOptInRevenueShare_portal_zero_address_reverts() public {
string memory configPath = "test/template/late-opt-in-rev-share/config/portal-zero-address-config.toml";
vm.expectRevert("SimpleAddressRegistry: zero address for OptimismPortal");
template.simulate(configPath);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
templateName = "LateOptInRevenueShare"

# Revenue Share Configuration
# When using custom calculator, only the calculator address and the gas limit are required
useOwnCalculator = true
gasLimit = 300000
calculator = "0x0000000000000000000000000000000000000000"

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
templateName = "LateOptInRevenueShare"

# Revenue Share Configuration
# When using custom calculator, only the calculator address and the gas limit are required
useOwnCalculator = false
saltSeed = "DeploymentSalt"
l1WithdrawerMinWithdrawalAmount = 1000000000000000000
l1WithdrawerRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
l1WithdrawerGasLimit = 4294967296 # 2^32
scRevShareCalcChainFeesRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
gasLimit = 300000

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
templateName = "LateOptInRevenueShare"

# Revenue Share Configuration
# When using custom calculator, only the calculator address and the gas limit are required
useOwnCalculator = false
saltSeed = "DeploymentSalt"
l1WithdrawerMinWithdrawalAmount = 1000000000000000000
l1WithdrawerRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
l1WithdrawerGasLimit = 0
scRevShareCalcChainFeesRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
gasLimit = 300000

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
templateName = "LateOptInRevenueShare"

# Revenue Share Configuration
# When using custom calculator, only the calculator address and the gas limit are required
useOwnCalculator = false
saltSeed = "DeploymentSalt"
l1WithdrawerMinWithdrawalAmount = 1000000000000000000
l1WithdrawerRecipient = "0x0000000000000000000000000000000000000000"
l1WithdrawerGasLimit = 300000
scRevShareCalcChainFeesRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
gasLimit = 300000

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
templateName = "LateOptInRevenueShare"

# Revenue Share Configuration
useOwnCalculator = true
gasLimit = 300000
calculator = "0x8B0c0c8B8B0c0C8B8b0C0C8b8B0C0c8b8b0C0c8b"

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
OptimismPortal = "0x0000000000000000000000000000000000000000"

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
templateName = "LateOptInRevenueShare"

# Revenue Share Configuration
# When using custom calculator, only the calculator address and the gas limit are required
useOwnCalculator = false
saltSeed = ""
gasLimit = 300000

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
templateName = "LateOptInRevenueShare"

# Revenue Share Configuration
# When using custom calculator, only the calculator address and the gas limit are required
useOwnCalculator = false
saltSeed = "DeploymentSalt"
l1WithdrawerMinWithdrawalAmount = 1000000000000000000
l1WithdrawerRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
l1WithdrawerGasLimit = 300000
scRevShareCalcChainFeesRecipient = "0x0000000000000000000000000000000000000000"
gasLimit = 300000

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
templateName = "LateOptInRevenueShare"

# Revenue Share Configuration
# When using custom calculator, only the calculator address and the gas limit are required
useOwnCalculator = false
saltSeed = "DeploymentSalt"
l1WithdrawerMinWithdrawalAmount = 1000000000000000000
l1WithdrawerRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
l1WithdrawerGasLimit = 300000
scRevShareCalcChainFeesRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
gasLimit = 1.9e64 # Greater than uint64.max

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
templateName = "LateOptInRevenueShare"

# Revenue Share Configuration
# When using custom calculator, only the calculator address and the gas limit are required
useOwnCalculator = false
saltSeed = "DeploymentSalt"
l1WithdrawerMinWithdrawalAmount = 1000000000000000000
l1WithdrawerRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
l1WithdrawerGasLimit = 300000
scRevShareCalcChainFeesRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
gasLimit = 0 # gasLimit must be set

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"
OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"
Loading