Skip to content
Open
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: 1 addition & 0 deletions scripts/config.example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const config: PartialRollupParams = {
futureSeconds: ethers.BigNumber.from('3600'),
},
anyTrustFastConfirmer: ethers.constants.AddressZero,
dataCostEstimate: ethers.BigNumber.from('0'),
},
validators: [
'0x1234123412341234123412341234123412341234',
Expand Down
1 change: 1 addition & 0 deletions scripts/rollupCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ async function _getDevRollupConfig(
futureSeconds: ethers.BigNumber.from('3600'),
},
anyTrustFastConfirmer: ethers.constants.AddressZero,
dataCostEstimate: ethers.BigNumber.from('0'),
}

return {
Expand Down
14 changes: 10 additions & 4 deletions src/mocks/MockRollupEventInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ contract MockRollupEventInbox is IRollupEventInbox, IDelayedMessageProvider, Del

function rollupInitialized(
uint256 chainId,
string calldata chainConfig
string calldata chainConfig,
uint256 dataCostEstimate
) external override onlyRollup {
require(bytes(chainConfig).length > 0, "EMPTY_CHAIN_CONFIG");
uint8 initMsgVersion = 1;
uint256 currentDataCost = 1; // Set to a base fee of 1.
if (ArbitrumChecker.runningOnArbitrum()) {
currentDataCost += ArbGasInfo(address(0x6c)).getL1BaseFeeEstimate();
uint256 currentDataCost;
if (dataCostEstimate != 0) {
currentDataCost = dataCostEstimate;
} else {
currentDataCost = 1; // Set to a base fee of 1.
if (ArbitrumChecker.runningOnArbitrum()) {
currentDataCost += ArbGasInfo(address(0x6c)).getL1BaseFeeEstimate();
}
}
bytes memory initMsg =
abi.encodePacked(chainId, initMsgVersion, currentDataCost, chainConfig);
Expand Down
10 changes: 8 additions & 2 deletions src/rollup/AbsRollupEventInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ abstract contract AbsRollupEventInbox is

function rollupInitialized(
uint256 chainId,
string calldata chainConfig
string calldata chainConfig,
uint256 dataCostEstimate
) external override onlyRollup {
require(bytes(chainConfig).length > 0, "EMPTY_CHAIN_CONFIG");
uint8 initMsgVersion = 1;
uint256 currentDataCost = _currentDataCostToReport();
uint256 currentDataCost;
if (dataCostEstimate != 0) {
currentDataCost = dataCostEstimate;
} else {
currentDataCost = _currentDataCostToReport();
}
bytes memory initMsg =
abi.encodePacked(chainId, initMsgVersion, currentDataCost, chainConfig);
uint256 num = _enqueueInitializationMsg(initMsg);
Expand Down
3 changes: 2 additions & 1 deletion src/rollup/BOLDUpgradeAction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ contract BOLDUpgradeAction {
anyTrustFastConfirmer: address(0), // fast confirmer would be migrated from the old rollup if existed
numBigStepLevel: NUM_BIGSTEP_LEVEL,
challengeGracePeriodBlocks: CHALLENGE_GRACE_PERIOD_BLOCKS,
bufferConfig: bufferConfig
bufferConfig: bufferConfig,
dataCostEstimate: 0
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/rollup/Config.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ struct Config {
uint8 numBigStepLevel;
uint64 challengeGracePeriodBlocks;
BufferConfig bufferConfig;
/// @notice An estimate of the parent chain's base fee to include in the rollup initialization message
uint256 dataCostEstimate;
}

struct ContractDependencies {
Expand Down
6 changes: 5 additions & 1 deletion src/rollup/IRollupEventInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ interface IRollupEventInbox {

function updateRollupAddress() external;

function rollupInitialized(uint256 chainId, string calldata chainConfig) external;
function rollupInitialized(
uint256 chainId,
string calldata chainConfig,
uint256 l1BaseFeeEstimate
) external;
}
2 changes: 1 addition & 1 deletion src/rollup/RollupAdminLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl
address(connectedContracts.rollupEventInbox), true
);
connectedContracts.rollupEventInbox.rollupInitialized(
config.chainId, config.chainConfig
config.chainId, config.chainConfig, config.dataCostEstimate
);
}

Expand Down
3 changes: 2 additions & 1 deletion test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ contract RollupTest is Test {
anyTrustFastConfirmer: anyTrustFastConfirmer,
numBigStepLevel: 3,
challengeGracePeriodBlocks: CHALLENGE_GRACE_PERIOD_BLOCKS,
bufferConfig: BufferConfig({threshold: 600, max: 14400, replenishRateInBasis: 500})
bufferConfig: BufferConfig({threshold: 600, max: 14400, replenishRateInBasis: 500}),
dataCostEstimate: 0
});

vm.expectEmit(false, false, false, false);
Expand Down
1 change: 1 addition & 0 deletions test/e2e/orbitChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ describe('Orbit Chain', () => {
delaySeconds: ethers.BigNumber.from('86400'),
futureSeconds: ethers.BigNumber.from('3600'),
},
dataCostEstimate: ethers.BigNumber.from('0'),
}
const batchPosters = [ethers.Wallet.createRandom().address]
const batchPosterManager = ethers.Wallet.createRandom().address
Expand Down
6 changes: 3 additions & 3 deletions test/foundry/ERC20RollupEventInbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ contract ERC20RollupEventInboxTest is AbsRollupEventInboxTest {
);

vm.prank(rollup);
rollupEventInbox.rollupInitialized(chainId, chainConfig);
rollupEventInbox.rollupInitialized(chainId, chainConfig, 0);
}

function test_rollupInitialized_NonArbitrumHosted() public {
Expand Down Expand Up @@ -112,7 +112,7 @@ contract ERC20RollupEventInboxTest is AbsRollupEventInboxTest {
emit InboxMessageDelivered(0, expectedInitMsg);

vm.prank(rollup);
rollupEventInbox.rollupInitialized(chainId, chainConfig);
rollupEventInbox.rollupInitialized(chainId, chainConfig, 0);
}

function testFuzz_rollupInitialized(
Expand Down Expand Up @@ -174,7 +174,7 @@ contract ERC20RollupEventInboxTest is AbsRollupEventInboxTest {
}

vm.prank(rollup);
rollupEventInbox.rollupInitialized(chainId, chainConfig);
rollupEventInbox.rollupInitialized(chainId, chainConfig, 0);
}

function _calculateExpectedCurrentDataCost(
Expand Down
9 changes: 6 additions & 3 deletions test/foundry/RollupCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ contract RollupCreatorTest is Test {
anyTrustFastConfirmer: address(0),
numBigStepLevel: 1,
challengeGracePeriodBlocks: 10,
bufferConfig: BufferConfig({threshold: 600, max: 14400, replenishRateInBasis: 500})
bufferConfig: BufferConfig({threshold: 600, max: 14400, replenishRateInBasis: 500}),
dataCostEstimate: 0
});

// prepare funds
Expand Down Expand Up @@ -311,7 +312,8 @@ contract RollupCreatorTest is Test {
anyTrustFastConfirmer: address(0),
numBigStepLevel: 1,
challengeGracePeriodBlocks: 10,
bufferConfig: BufferConfig({threshold: 600, max: 14400, replenishRateInBasis: 500})
bufferConfig: BufferConfig({threshold: 600, max: 14400, replenishRateInBasis: 500}),
dataCostEstimate: 0
});

// approve fee token to pay for deployment of L2 factories
Expand Down Expand Up @@ -501,7 +503,8 @@ contract RollupCreatorTest is Test {
anyTrustFastConfirmer: address(0),
numBigStepLevel: 1,
challengeGracePeriodBlocks: 10,
bufferConfig: BufferConfig({threshold: 600, max: 14400, replenishRateInBasis: 500})
bufferConfig: BufferConfig({threshold: 600, max: 14400, replenishRateInBasis: 500}),
dataCostEstimate: 0
});

// prepare funds
Expand Down
4 changes: 2 additions & 2 deletions test/foundry/RollupEventInbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ contract RollupEventInboxTest is AbsRollupEventInboxTest {
emit InboxMessageDelivered(0, expectedInitMsg);

vm.prank(rollup);
rollupEventInbox.rollupInitialized(chainId, chainConfig);
rollupEventInbox.rollupInitialized(chainId, chainConfig, 0);
}

function test_rollupInitialized_ArbitrumHosted() public {
Expand Down Expand Up @@ -106,6 +106,6 @@ contract RollupEventInboxTest is AbsRollupEventInboxTest {
emit InboxMessageDelivered(0, expectedInitMsg);

vm.prank(rollup);
rollupEventInbox.rollupInitialized(chainId, chainConfig);
rollupEventInbox.rollupInitialized(chainId, chainConfig, 0);
}
}
Loading
Loading