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
10 changes: 5 additions & 5 deletions src/libraries/RevShareCodeRepo.sol

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/template/DeployFeesDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ contract DeployFeesDepositor is SimpleTaskBase {

/// @notice Sets up the template with implementation configurations from a TOML file.
/// State overrides are not applied yet. Keep this in mind when performing various pre-simulation assertions in this function.
function _templateSetup(string memory _taskConfigFilePath, address _rootSafe) internal override {
function _templateSetup(string memory _taskConfigFilePath, address) internal override {
string memory tomlContent = vm.readFile(_taskConfigFilePath);
salt = tomlContent.readString(".salt");
require(bytes(salt).length > 0, "salt must be set");
Expand Down Expand Up @@ -109,8 +109,7 @@ contract DeployFeesDepositor is SimpleTaskBase {
/// implicitly because if the calculated address of the Proxy would differ from the one we
/// calculated, the task would fail on the check for code to be present, since the changes
/// in build function revert and the parent contract validates that accessed accounts have code.
/// @param _rootSafe The address of the root safe (unused in this implementation).
function _build(address _rootSafe) internal override {
function _build(address) internal override {
// Deploy the FeesDepositor implementation contract using CREATE2
ICreate2Deployer(CREATE2_DEPLOYER).deploy(0, bytes32(bytes(salt)), RevShareCodeRepo.feesDepositorCreationCode);

Expand Down
2 changes: 1 addition & 1 deletion src/template/LateOptInRevenueShare.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ contract LateOptInRevenueShare is SimpleTaskBase {

/// @notice Sets up the template with implementation configurations from a TOML file.
/// State overrides are not applied yet. Keep this in mind when performing various pre-simulation assertions in this function.
function _templateSetup(string memory _taskConfigFilePath, address _rootSafe) internal override {
function _templateSetup(string memory _taskConfigFilePath, address) internal override {
string memory _toml = vm.readFile(_taskConfigFilePath);

portal = simpleAddrRegistry.get("OptimismPortal");
Expand Down
139 changes: 105 additions & 34 deletions src/template/RevenueShareUpgradePath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ interface IFeeSplitter {
function initialize(address _sharesCalculator) external;
}

/// @notice Interface for the vaults in L2.
interface IFeeVault {
function initialize(address _recipient, uint256 _minWithdrawalAmount, uint8 _withdrawalNetwork) external;
}

/// @notice Interface for ProxyAdmin.
interface IProxyAdmin {
function upgrade(address payable _proxy, address _implementation) external;
Expand Down Expand Up @@ -322,20 +327,15 @@ contract RevenueShareV100UpgradePath is SimpleTaskBase {

// Calculate addresses and data to deploy vaults
// Calculate addresses and data to deploy OperatorFeeVault
bytes memory _operatorFeeVaultInitCode = bytes.concat(
RevShareCodeRepo.operatorFeeVaultCreationCode,
abi.encode(
operatorFeeVaultRecipient, operatorFeeVaultMinWithdrawalAmount, operatorFeeVaultWithdrawalNetwork
)
);
bytes memory _operatorFeeVaultInitCode = RevShareCodeRepo.operatorFeeVaultCreationCode;
_operatorFeeVaultPrecalculatedAddress =
Utils.getCreate2Address(_getSalt(saltSeed, "OperatorFeeVault"), _operatorFeeVaultInitCode, CREATE2_DEPLOYER);

_operatorFeeVaultCalldata = abi.encodeCall(
ICreate2Deployer.deploy, (0, _getSalt(saltSeed, "OperatorFeeVault"), _operatorFeeVaultInitCode)
);

// Expected calls for OperatorFeeVault: 2 (deploy + upgrade)
// Expected calls for OperatorFeeVault: 2 (deploy + upgradeAndCall)
_incrementCallsToPortal(
abi.encodeCall(
IOptimismPortal2.depositTransaction,
Expand All @@ -351,20 +351,26 @@ contract RevenueShareV100UpgradePath is SimpleTaskBase {
UPGRADE_GAS_LIMIT,
false,
abi.encodeCall(
IProxyAdmin.upgrade,
(payable(OPERATOR_FEE_VAULT), address(_operatorFeeVaultPrecalculatedAddress))
IProxyAdmin.upgradeAndCall,
(
payable(OPERATOR_FEE_VAULT),
address(_operatorFeeVaultPrecalculatedAddress),
abi.encodeCall(
IFeeVault.initialize,
(
operatorFeeVaultRecipient,
operatorFeeVaultMinWithdrawalAmount,
operatorFeeVaultWithdrawalNetwork
)
)
)
)
)
)
);

// Calculate addresses and data to deploy SequencerFeeVault
bytes memory _sequencerFeeVaultInitCode = bytes.concat(
RevShareCodeRepo.sequencerFeeVaultCreationCode,
abi.encode(
sequencerFeeVaultRecipient, sequencerFeeVaultMinWithdrawalAmount, sequencerFeeVaultWithdrawalNetwork
)
);
bytes memory _sequencerFeeVaultInitCode = RevShareCodeRepo.sequencerFeeVaultCreationCode;
_sequencerFeeVaultPrecalculatedAddress = Utils.getCreate2Address(
_getSalt(saltSeed, "SequencerFeeVault"), _sequencerFeeVaultInitCode, CREATE2_DEPLOYER
);
Expand All @@ -388,24 +394,32 @@ contract RevenueShareV100UpgradePath is SimpleTaskBase {
UPGRADE_GAS_LIMIT,
false,
abi.encodeCall(
IProxyAdmin.upgrade,
(payable(SEQUENCER_FEE_VAULT), address(_sequencerFeeVaultPrecalculatedAddress))
IProxyAdmin.upgradeAndCall,
(
payable(SEQUENCER_FEE_VAULT),
address(_sequencerFeeVaultPrecalculatedAddress),
abi.encodeCall(
IFeeVault.initialize,
(
sequencerFeeVaultRecipient,
sequencerFeeVaultMinWithdrawalAmount,
sequencerFeeVaultWithdrawalNetwork
)
)
)
)
)
)
);

// Calculate addresses and data to deploy BaseFeeVault
bytes memory _baseFeeVaultInitCode = bytes.concat(
RevShareCodeRepo.baseFeeVaultCreationCode,
abi.encode(baseFeeVaultRecipient, baseFeeVaultMinWithdrawalAmount, baseFeeVaultWithdrawalNetwork)
);
bytes memory _baseFeeVaultInitCode = RevShareCodeRepo.baseFeeVaultCreationCode;
_baseFeeVaultPrecalculatedAddress =
Utils.getCreate2Address(_getSalt(saltSeed, "BaseFeeVault"), _baseFeeVaultInitCode, CREATE2_DEPLOYER);
_baseFeeVaultCalldata =
abi.encodeCall(ICreate2Deployer.deploy, (0, _getSalt(saltSeed, "BaseFeeVault"), _baseFeeVaultInitCode));

// Expected calls for BaseFeeVault: 2 (deploy + upgrade)
// Expected calls for BaseFeeVault: 2 (deploy + upgradeAndCall)
_incrementCallsToPortal(
abi.encodeCall(
IOptimismPortal2.depositTransaction,
Expand All @@ -421,23 +435,28 @@ contract RevenueShareV100UpgradePath is SimpleTaskBase {
UPGRADE_GAS_LIMIT,
false,
abi.encodeCall(
IProxyAdmin.upgrade, (payable(BASE_FEE_VAULT), address(_baseFeeVaultPrecalculatedAddress))
IProxyAdmin.upgradeAndCall,
(
payable(BASE_FEE_VAULT),
address(_baseFeeVaultPrecalculatedAddress),
abi.encodeCall(
IFeeVault.initialize,
(baseFeeVaultRecipient, baseFeeVaultMinWithdrawalAmount, baseFeeVaultWithdrawalNetwork)
)
)
)
)
)
);

// Calculate addresses and data to deploy L1FeeVault
bytes memory _l1FeeVaultInitCode = bytes.concat(
RevShareCodeRepo.l1FeeVaultCreationCode,
abi.encode(l1FeeVaultRecipient, l1FeeVaultMinWithdrawalAmount, l1FeeVaultWithdrawalNetwork)
);
bytes memory _l1FeeVaultInitCode = RevShareCodeRepo.l1FeeVaultCreationCode;
_l1FeeVaultPrecalculatedAddress =
Utils.getCreate2Address(_getSalt(saltSeed, "L1FeeVault"), _l1FeeVaultInitCode, CREATE2_DEPLOYER);
_l1FeeVaultCalldata =
abi.encodeCall(ICreate2Deployer.deploy, (0, _getSalt(saltSeed, "L1FeeVault"), _l1FeeVaultInitCode));

// Expected calls for L1FeeVault: 2 (deploy + upgrade)
// Expected calls for L1FeeVault: 2 (deploy + upgradeAndCall)
_incrementCallsToPortal(
abi.encodeCall(
IOptimismPortal2.depositTransaction,
Expand All @@ -453,7 +472,15 @@ contract RevenueShareV100UpgradePath is SimpleTaskBase {
UPGRADE_GAS_LIMIT,
false,
abi.encodeCall(
IProxyAdmin.upgrade, (payable(L1_FEE_VAULT), address(_l1FeeVaultPrecalculatedAddress))
IProxyAdmin.upgradeAndCall,
(
payable(L1_FEE_VAULT),
address(_l1FeeVaultPrecalculatedAddress),
abi.encodeCall(
IFeeVault.initialize,
(l1FeeVaultRecipient, l1FeeVaultMinWithdrawalAmount, l1FeeVaultWithdrawalNetwork)
)
)
)
)
)
Expand All @@ -467,7 +494,7 @@ contract RevenueShareV100UpgradePath is SimpleTaskBase {
_getSalt(saltSeed, "FeeSplitter"), RevShareCodeRepo.feeSplitterCreationCode, CREATE2_DEPLOYER
);

// Expected calls for FeeSplitter: 2 (deploy + upgrade)
// Expected calls for FeeSplitter: 2 (deploy + upgradeAndCall)
_incrementCallsToPortal(
abi.encodeCall(
IOptimismPortal2.depositTransaction,
Expand Down Expand Up @@ -561,7 +588,19 @@ contract RevenueShareV100UpgradePath is SimpleTaskBase {
UPGRADE_GAS_LIMIT,
false,
abi.encodeCall(
IProxyAdmin.upgrade, (payable(OPERATOR_FEE_VAULT), address(_operatorFeeVaultPrecalculatedAddress))
IProxyAdmin.upgradeAndCall,
(
payable(OPERATOR_FEE_VAULT),
address(_operatorFeeVaultPrecalculatedAddress),
abi.encodeCall(
IFeeVault.initialize,
(
operatorFeeVaultRecipient,
operatorFeeVaultMinWithdrawalAmount,
operatorFeeVaultWithdrawalNetwork
)
)
)
)
);

Expand All @@ -575,7 +614,19 @@ contract RevenueShareV100UpgradePath is SimpleTaskBase {
UPGRADE_GAS_LIMIT,
false,
abi.encodeCall(
IProxyAdmin.upgrade, (payable(SEQUENCER_FEE_VAULT), address(_sequencerFeeVaultPrecalculatedAddress))
IProxyAdmin.upgradeAndCall,
(
payable(SEQUENCER_FEE_VAULT),
address(_sequencerFeeVaultPrecalculatedAddress),
abi.encodeCall(
IFeeVault.initialize,
(
sequencerFeeVaultRecipient,
sequencerFeeVaultMinWithdrawalAmount,
sequencerFeeVaultWithdrawalNetwork
)
)
)
)
);

Expand All @@ -588,7 +639,17 @@ contract RevenueShareV100UpgradePath is SimpleTaskBase {
0,
UPGRADE_GAS_LIMIT,
false,
abi.encodeCall(IProxyAdmin.upgrade, (payable(BASE_FEE_VAULT), address(_baseFeeVaultPrecalculatedAddress)))
abi.encodeCall(
IProxyAdmin.upgradeAndCall,
(
payable(BASE_FEE_VAULT),
address(_baseFeeVaultPrecalculatedAddress),
abi.encodeCall(
IFeeVault.initialize,
(baseFeeVaultRecipient, baseFeeVaultMinWithdrawalAmount, baseFeeVaultWithdrawalNetwork)
)
)
)
);

// Deploy the l1 fee vault
Expand All @@ -600,7 +661,17 @@ contract RevenueShareV100UpgradePath is SimpleTaskBase {
0,
UPGRADE_GAS_LIMIT,
false,
abi.encodeCall(IProxyAdmin.upgrade, (payable(L1_FEE_VAULT), address(_l1FeeVaultPrecalculatedAddress)))
abi.encodeCall(
IProxyAdmin.upgradeAndCall,
(
payable(L1_FEE_VAULT),
address(_l1FeeVaultPrecalculatedAddress),
abi.encodeCall(
IFeeVault.initialize,
(l1FeeVaultRecipient, l1FeeVaultMinWithdrawalAmount, l1FeeVaultWithdrawalNetwork)
)
)
)
);
}

Expand Down
18 changes: 9 additions & 9 deletions test/tasks/Regression.t.sol

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions test/template/RevenueShareUpgradePath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ interface ICreate2Deployer {

interface IProxyAdmin {
function upgrade(address _proxy, address _implementation) external;
function upgradeAndCall(address _proxy, address _implementation, bytes memory _data) external payable returns (bytes memory);
function upgradeAndCall(address _proxy, address _implementation, bytes memory _data)
external
payable
returns (bytes memory);
}

contract RevenueShareUpgradePathTest is Test {
Expand Down Expand Up @@ -338,10 +341,7 @@ contract RevenueShareUpgradePathTest is Test {
/// @notice Verify the target address is the proxy admin
/// @param _to The target address
function _assertIsProxyAdmin(address _to) internal pure {
assertTrue(
_to == PROXY_ADMIN,
"Upgrade should target the proxy admin"
);
assertTrue(_to == PROXY_ADMIN, "Upgrade should target the proxy admin");
}

/// @notice Expect the portal events
Expand All @@ -355,7 +355,9 @@ contract RevenueShareUpgradePathTest is Test {
bytes memory _opaqueData = abi.encodePacked(uint256(0), uint256(0), _actualGasLimit, _isCreation, _data);

vm.expectEmit(true, true, true, true, PORTAL);
emit TransactionDeposited(AddressAliasHelper.applyL1ToL2Alias(PROXY_ADMIN_OWNER), _to, DEPOSIT_VERSION, _opaqueData);
emit TransactionDeposited(
AddressAliasHelper.applyL1ToL2Alias(PROXY_ADMIN_OWNER), _to, DEPOSIT_VERSION, _opaqueData
);
}
}
}