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
17 changes: 9 additions & 8 deletions test/integration/IntegrationBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ abstract contract IntegrationBase is Test {
uint256 internal _mainnetForkId;
uint256 internal _opMainnetForkId;
uint256 internal _inkMainnetForkId;
uint256 internal _soneiumMainnetForkId;

// Shared upgrader contract
RevShareContractsUpgrader public revShareUpgrader;
Expand All @@ -33,6 +34,7 @@ abstract contract IntegrationBase is Test {
address internal constant PROXY_ADMIN_OWNER = 0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A;
address internal constant OP_MAINNET_PORTAL = 0xbEb5Fc579115071764c7423A4f12eDde41f106Ed;
address internal constant INK_MAINNET_PORTAL = 0x5d66C1782664115999C47c9fA5cd031f495D3e4F;
address internal constant SONEIUM_MAINNET_PORTAL = 0x88e529A6ccd302c948689Cd5156C83D4614FAE92;
address internal constant REV_SHARE_UPGRADER_ADDRESS = 0x0000000000000000000000000000000000001337;

// L2 predeploys (same across all OP Stack chains)
Expand All @@ -42,13 +44,6 @@ abstract contract IntegrationBase is Test {
address internal constant L1_FEE_VAULT = 0x420000000000000000000000000000000000001A;
address internal constant FEE_SPLITTER = 0x420000000000000000000000000000000000002B;

// Expected deployed contracts (deterministic CREATE2 addresses)
address internal constant OP_L1_WITHDRAWER = 0xB3AeB34b88D73Fb4832f65BEa5Bd865017fB5daC;
address internal constant OP_REV_SHARE_CALCULATOR = 0x3E806Fd8592366E850197FEC8D80608b5526Bba2;

address internal constant INK_L1_WITHDRAWER = 0x70e26B12a578176BccCD3b7e7f58f605871c5eF7;
address internal constant INK_REV_SHARE_CALCULATOR = 0xd7a5307B4Ce92B0269903191007b95dF42552Dfa;

// Test configuration - OP Mainnet
uint256 internal constant OP_MIN_WITHDRAWAL_AMOUNT = 350000;
address internal constant OP_L1_WITHDRAWAL_RECIPIENT = 0x0000000000000000000000000000000000000001;
Expand All @@ -58,9 +53,15 @@ abstract contract IntegrationBase is Test {
// Test configuration - Ink Mainnet
uint256 internal constant INK_MIN_WITHDRAWAL_AMOUNT = 500000;
address internal constant INK_L1_WITHDRAWAL_RECIPIENT = 0x0000000000000000000000000000000000000002;
uint32 internal constant INK_WITHDRAWAL_GAS_LIMIT = 1000000;
uint32 internal constant INK_WITHDRAWAL_GAS_LIMIT = 800000;
address internal constant INK_CHAIN_FEES_RECIPIENT = 0x0000000000000000000000000000000000000002;

// Test configuration - Soneium Mainnet
uint256 internal constant SONEIUM_MIN_WITHDRAWAL_AMOUNT = 500000;
address internal constant SONEIUM_L1_WITHDRAWAL_RECIPIENT = 0x0000000000000000000000000000000000000003;
uint32 internal constant SONEIUM_WITHDRAWAL_GAS_LIMIT = 800000;
address internal constant SONEIUM_CHAIN_FEES_RECIPIENT = 0x0000000000000000000000000000000000000003;

bool internal constant IS_SIMULATE = true;
/// @notice Relay all deposit transactions from L1 to multiple L2s
/// @param _forkIds Array of fork IDs for each L2 chain
Expand Down
106 changes: 79 additions & 27 deletions test/integration/RevShareSetupIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ contract RevShareSetupIntegrationTest is IntegrationBase {
bytes internal DEFAULT_FEE_VAULT_CREATION_CODE = FeeVaultUpgrader.defaultFeeVaultCreationCode;
bytes internal FEE_SPLITTER_CREATION_CODE = FeeSplitterSetup.feeSplitterCreationCode;

// Implementation addresses (deployed and etched in setUp)
address internal _operatorFeeVaultImpl;
address internal _sequencerFeeVaultImpl;
address internal _defaultFeeVaultImpl;
address internal _feeSplitterImpl;

function setUp() public {
// Create forks for L1 (mainnet) and L2 (OP Mainnet)
// Create forks for L1 (mainnet) and L2s (OP Mainnet, Ink, Soneium)
_mainnetForkId = vm.createFork("http://127.0.0.1:8545");
_opMainnetForkId = vm.createFork("http://127.0.0.1:9545");
_inkMainnetForkId = vm.createFork("http://127.0.0.1:9546");
_soneiumMainnetForkId = vm.createFork("http://127.0.0.1:9547");

// Deploy contracts on L1
vm.selectFork(_mainnetForkId);
Expand All @@ -41,16 +48,16 @@ contract RevShareSetupIntegrationTest is IntegrationBase {
revShareTask = new RevShareSetup();

// Deploy implementations once to get their addresses and bytecode
address operatorFeeVaultImpl = _deployFromCreationCode(OPERATOR_FEE_VAULT_CREATION_CODE);
address sequencerFeeVaultImpl = _deployFromCreationCode(SEQUENCER_FEE_VAULT_CREATION_CODE);
address defaultFeeVaultImpl = _deployFromCreationCode(DEFAULT_FEE_VAULT_CREATION_CODE);
address feeSplitterImpl = _deployFromCreationCode(FEE_SPLITTER_CREATION_CODE);
_operatorFeeVaultImpl = _deployFromCreationCode(OPERATOR_FEE_VAULT_CREATION_CODE);
_sequencerFeeVaultImpl = _deployFromCreationCode(SEQUENCER_FEE_VAULT_CREATION_CODE);
_defaultFeeVaultImpl = _deployFromCreationCode(DEFAULT_FEE_VAULT_CREATION_CODE);
_feeSplitterImpl = _deployFromCreationCode(FEE_SPLITTER_CREATION_CODE);

// Get implementation bytecodes
bytes memory operatorFeeVaultImplCode = operatorFeeVaultImpl.code;
bytes memory sequencerFeeVaultImplCode = sequencerFeeVaultImpl.code;
bytes memory defaultFeeVaultImplCode = defaultFeeVaultImpl.code;
bytes memory feeSplitterImplCode = feeSplitterImpl.code;
bytes memory operatorFeeVaultImplCode = _operatorFeeVaultImpl.code;
bytes memory sequencerFeeVaultImplCode = _sequencerFeeVaultImpl.code;
bytes memory defaultFeeVaultImplCode = _defaultFeeVaultImpl.code;
bytes memory feeSplitterImplCode = _feeSplitterImpl.code;

// Deploy a proxy to get its bytecode
Proxy proxyTemplate = new Proxy(address(this));
Expand All @@ -59,33 +66,49 @@ contract RevShareSetupIntegrationTest is IntegrationBase {
// Etch predeploys on OP Mainnet fork
vm.selectFork(_opMainnetForkId);
_etchImplementations(
operatorFeeVaultImpl,
sequencerFeeVaultImpl,
defaultFeeVaultImpl,
feeSplitterImpl,
_operatorFeeVaultImpl,
_sequencerFeeVaultImpl,
_defaultFeeVaultImpl,
_feeSplitterImpl,
operatorFeeVaultImplCode,
sequencerFeeVaultImplCode,
defaultFeeVaultImplCode,
feeSplitterImplCode
);
_setupProxyPredeploys(
proxyCode, operatorFeeVaultImpl, sequencerFeeVaultImpl, defaultFeeVaultImpl, feeSplitterImpl
proxyCode, _operatorFeeVaultImpl, _sequencerFeeVaultImpl, _defaultFeeVaultImpl, _feeSplitterImpl
);

// Etch predeploys on Ink Mainnet fork
vm.selectFork(_inkMainnetForkId);
_etchImplementations(
operatorFeeVaultImpl,
sequencerFeeVaultImpl,
defaultFeeVaultImpl,
feeSplitterImpl,
_operatorFeeVaultImpl,
_sequencerFeeVaultImpl,
_defaultFeeVaultImpl,
_feeSplitterImpl,
operatorFeeVaultImplCode,
sequencerFeeVaultImplCode,
defaultFeeVaultImplCode,
feeSplitterImplCode
);
_setupProxyPredeploys(
proxyCode, _operatorFeeVaultImpl, _sequencerFeeVaultImpl, _defaultFeeVaultImpl, _feeSplitterImpl
);

// Etch predeploys on Soneium Mainnet fork
vm.selectFork(_soneiumMainnetForkId);
_etchImplementations(
_operatorFeeVaultImpl,
_sequencerFeeVaultImpl,
_defaultFeeVaultImpl,
_feeSplitterImpl,
operatorFeeVaultImplCode,
sequencerFeeVaultImplCode,
defaultFeeVaultImplCode,
feeSplitterImplCode
);
_setupProxyPredeploys(
proxyCode, operatorFeeVaultImpl, sequencerFeeVaultImpl, defaultFeeVaultImpl, feeSplitterImpl
proxyCode, _operatorFeeVaultImpl, _sequencerFeeVaultImpl, _defaultFeeVaultImpl, _feeSplitterImpl
);

// Switch back to mainnet fork after setup
Expand Down Expand Up @@ -175,21 +198,26 @@ contract RevShareSetupIntegrationTest is IntegrationBase {
revShareTask.simulate("test/tasks/example/eth/017-revshare-setup/config.toml");

// Step 3: Relay deposit transactions from L1 to all L2s
uint256[] memory forkIds = new uint256[](2);
uint256[] memory forkIds = new uint256[](3);
forkIds[0] = _opMainnetForkId;
forkIds[1] = _inkMainnetForkId;
forkIds[2] = _soneiumMainnetForkId;

address[] memory portals = new address[](2);
address[] memory portals = new address[](3);
portals[0] = OP_MAINNET_PORTAL;
portals[1] = INK_MAINNET_PORTAL;
portals[2] = SONEIUM_MAINNET_PORTAL;

_relayAllMessages(forkIds, IS_SIMULATE, portals);

// Step 4: Assert the state of the OP Mainnet contracts
vm.selectFork(_opMainnetForkId);
address opL1Withdrawer =
_computeL1WithdrawerAddress(OP_MIN_WITHDRAWAL_AMOUNT, OP_L1_WITHDRAWAL_RECIPIENT, OP_WITHDRAWAL_GAS_LIMIT);
address opRevShareCalculator = _computeRevShareCalculatorAddress(opL1Withdrawer, OP_CHAIN_FEES_RECIPIENT);
_assertL2State(
OP_L1_WITHDRAWER,
OP_REV_SHARE_CALCULATOR,
opL1Withdrawer,
opRevShareCalculator,
OP_MIN_WITHDRAWAL_AMOUNT,
OP_L1_WITHDRAWAL_RECIPIENT,
OP_WITHDRAWAL_GAS_LIMIT,
Expand All @@ -198,22 +226,43 @@ contract RevShareSetupIntegrationTest is IntegrationBase {

// Step 5: Assert the state of the Ink Mainnet contracts
vm.selectFork(_inkMainnetForkId);
address inkL1Withdrawer = _computeL1WithdrawerAddress(
INK_MIN_WITHDRAWAL_AMOUNT, INK_L1_WITHDRAWAL_RECIPIENT, INK_WITHDRAWAL_GAS_LIMIT
);
address inkRevShareCalculator = _computeRevShareCalculatorAddress(inkL1Withdrawer, INK_CHAIN_FEES_RECIPIENT);
_assertL2State(
INK_L1_WITHDRAWER,
INK_REV_SHARE_CALCULATOR,
inkL1Withdrawer,
inkRevShareCalculator,
INK_MIN_WITHDRAWAL_AMOUNT,
INK_L1_WITHDRAWAL_RECIPIENT,
INK_WITHDRAWAL_GAS_LIMIT,
INK_CHAIN_FEES_RECIPIENT
);

// Step 6: Do a withdrawal flow
// Step 6: Assert the state of the Soneium Mainnet contracts
vm.selectFork(_soneiumMainnetForkId);
address soneiumL1Withdrawer = _computeL1WithdrawerAddress(
SONEIUM_MIN_WITHDRAWAL_AMOUNT, SONEIUM_L1_WITHDRAWAL_RECIPIENT, SONEIUM_WITHDRAWAL_GAS_LIMIT
);
address soneiumRevShareCalculator =
_computeRevShareCalculatorAddress(soneiumL1Withdrawer, SONEIUM_CHAIN_FEES_RECIPIENT);
_assertL2State(
soneiumL1Withdrawer,
soneiumRevShareCalculator,
SONEIUM_MIN_WITHDRAWAL_AMOUNT,
SONEIUM_L1_WITHDRAWAL_RECIPIENT,
SONEIUM_WITHDRAWAL_GAS_LIMIT,
SONEIUM_CHAIN_FEES_RECIPIENT
);

// Step 7: Do a withdrawal flow

// Fund vaults with amount > minWithdrawalAmount
_fundVaults(1 ether, _opMainnetForkId);
_fundVaults(1 ether, _inkMainnetForkId);
_fundVaults(1 ether, _soneiumMainnetForkId);

// Disburse fees in both chains and expect the L1Withdrawer to trigger the withdrawal
// Disburse fees in all chains and expect the L1Withdrawer to trigger the withdrawal
// Expected L1Withdrawer share = 3 ether * 15% = 0.45 ether
// It is 3 ether instead of 4 because net revenue doesn't count L1FeeVault's balance
// For details on the rev share calculation, check the SuperchainRevSharesCalculator contract.
Expand All @@ -222,5 +271,8 @@ contract RevShareSetupIntegrationTest is IntegrationBase {

_executeDisburseAndAssertWithdrawal(_opMainnetForkId, OP_L1_WITHDRAWAL_RECIPIENT, expectedWithdrawalAmount);
_executeDisburseAndAssertWithdrawal(_inkMainnetForkId, INK_L1_WITHDRAWAL_RECIPIENT, expectedWithdrawalAmount);
_executeDisburseAndAssertWithdrawal(
_soneiumMainnetForkId, SONEIUM_L1_WITHDRAWAL_RECIPIENT, expectedWithdrawalAmount
);
}
}
6 changes: 3 additions & 3 deletions test/tasks/Regression.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ contract RegressionTest is Test {
function testRegressionCallDataMatches_RevShareSetup() public {
string memory taskConfigFilePath = "test/tasks/example/eth/017-revshare-setup/config.toml";
string memory expectedCallData =
"0x82ad56cb0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000006fee65a372d63295e8eb12574652f0bfeb913149000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000184cdab407800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000beb5fc579115071764c7423a4f12edde41f106ed0000000000000000000000000000000000000000000000000000000000055730000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000c350000000000000000000000000000000000000000000000000000000000000000010000000000000000000000005d66c1782664115999c47c9fa5cd031f495d3e4f000000000000000000000000000000000000000000000000000000000007a120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000";
"0x82ad56cb0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000006fee65a372d63295e8eb12574652f0bfeb913149000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000224cdab407800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000beb5fc579115071764c7423a4f12edde41f106ed0000000000000000000000000000000000000000000000000000000000055730000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000c350000000000000000000000000000000000000000000000000000000000000000010000000000000000000000005d66c1782664115999c47c9fa5cd031f495d3e4f000000000000000000000000000000000000000000000000000000000007a120000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000c3500000000000000000000000000000000000000000000000000000000000000000200000000000000000000000088e529a6ccd302c948689cd5156c83d4614fae92000000000000000000000000000000000000000000000000000000000007a120000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000c3500000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000";
MultisigTask multisigTask = new RevShareSetup();
address rootSafe = address(0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A);
address foundationChildMultisig = 0x847B5c174615B1B7fDF770882256e2D3E95b9D92;
Expand All @@ -1004,10 +1004,10 @@ contract RegressionTest is Test {

// Foundation
expectedDataToSign[0] =
"0x1901a4a9c312badf3fcaa05eafe5dc9bee8bd9316c78ee8b0bebe3115bb21b732672babdaa6c60c018aea833417700ce7e0a97768f0941586fcba368f0a8a874c277";
"0x1901a4a9c312badf3fcaa05eafe5dc9bee8bd9316c78ee8b0bebe3115bb21b7326725ee24803aca0a6af16bc1c33df420238c2447291f5ab417a1a6fe8375a17d5c0";
// Security council
expectedDataToSign[1] =
"0x1901df53d510b56e539b90b369ef08fce3631020fbf921e3136ea5f8747c20bce96715194e3147a0c8a32ef87e4beed5390c7d4abea66d51a9863c04959bc09f4765";
"0x1901df53d510b56e539b90b369ef08fce3631020fbf921e3136ea5f8747c20bce9678d870bb68459395de3d3ba0b1a21834e6c6802a206a8797c4442d74f8a96cecb";

_assertDataToSignNestedMultisig(multisigTask, actions, expectedDataToSign, MULTICALL3_ADDRESS, rootSafe);
}
Expand Down
26 changes: 15 additions & 11 deletions test/tasks/example/eth/017-revshare-setup/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,36 @@
templateName = "RevShareSetup"

# L2 chains to target
l2chains = [{name = "OP Mainnet", chainId = 10}, {name = "Ink", chainId = 57073}]
l2chains = [{name = "OP Mainnet", chainId = 10}, {name = "Ink", chainId = 57073}, {name = "Soneium", chainId = 1868}]

safeAddress = "ProxyAdminOwner"

# RevShareContractsUpgrader address
# TODO: Update to the corresponding address after audit
revShareUpgrader = "0x6fee65A372d63295E8EB12574652F0BfEb913149"
revShareUpgrader = "0x6fee65A372d63295E8EB12574652F0BfEb913149"

# RevShare configurations (one per chain) - flattened arrays
portals = [
"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed", # OP Mainnet Portal
"0x5d66C1782664115999C47c9fA5cd031f495D3e4F" # Ink Mainnet Portal
"0x5d66C1782664115999C47c9fA5cd031f495D3e4F", # Ink Mainnet Portal
"0x88e529A6ccd302c948689Cd5156C83D4614FAE92" # Soneium Mainnet Portal
]
chainFeesRecipients = [
"0x0000000000000000000000000000000000000001", # Update to the corresponding address once defined
"0x0000000000000000000000000000000000000002" # Update to the corresponding address once defined
"0x0000000000000000000000000000000000000001", # TODO: Update to the corresponding address once defined
"0x0000000000000000000000000000000000000002", # TODO: Update to the corresponding address once defined
"0x0000000000000000000000000000000000000003" # TODO: Update to the corresponding address once defined
]
l1WithdrawerMinWithdrawalAmounts = [350000, 500000]
l1WithdrawerMinWithdrawalAmounts = [350000, 500000, 500000]

l1WithdrawerRecipients = [
# TODO(17505): Update to the corresponding (e.g. FeesDepositor) address once defined
"0x0000000000000000000000000000000000000001",
# TODO(17505): Update to the corresponding (e.g. FeesDepositor) address once defined
"0x0000000000000000000000000000000000000002"
# TODO: Update to the corresponding (e.g. FeesDepositor) address once defined
"0x0000000000000000000000000000000000000001",
# TODO: Update to the corresponding (e.g. FeesDepositor) address once defined
"0x0000000000000000000000000000000000000002",
# TODO: Update to the corresponding (e.g. FeesDepositor) address once defined
"0x0000000000000000000000000000000000000003"
]
l1WithdrawerGasLimits = [800000, 1000000]
l1WithdrawerGasLimits = [800000, 800000, 800000]

[addresses]
ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A"