Skip to content

Commit

Permalink
Use new SeqInbox init param
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Sep 19, 2024
1 parent ef4f1fb commit a6a3f55
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/rollup/BridgeCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ contract BridgeCreator is Ownable {
address adminProxy,
address rollup,
address nativeToken,
ISequencerInbox.MaxTimeVariation calldata maxTimeVariation
ISequencerInbox.MaxTimeVariation calldata maxTimeVariation,
IFeeTokenPricer feeTokenPricer
) external returns (BridgeContracts memory) {
// create ETH-based bridge if address zero is provided for native token, otherwise create ERC20-based bridge
BridgeContracts memory frame = _createBridge(
Expand All @@ -96,7 +97,7 @@ contract BridgeCreator is Ownable {
} else {
IERC20Bridge(address(frame.bridge)).initialize(IOwnable(rollup), nativeToken);
}
frame.sequencerInbox.initialize(IBridge(frame.bridge), maxTimeVariation);
frame.sequencerInbox.initialize(IBridge(frame.bridge), maxTimeVariation, feeTokenPricer);
frame.inbox.initialize(frame.bridge, frame.sequencerInbox);
frame.rollupEventInbox.initialize(frame.bridge);
frame.outbox.initialize(frame.bridge);
Expand Down
4 changes: 3 additions & 1 deletion src/rollup/RollupCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ contract RollupCreator is Ownable {
uint256 maxFeePerGasForRetryables;
address[] batchPosters;
address batchPosterManager;
IFeeTokenPricer feeTokenPricer;
}

BridgeCreator public bridgeCreator;
Expand Down Expand Up @@ -144,7 +145,8 @@ contract RollupCreator is Ownable {
address(proxyAdmin),
address(rollup),
deployParams.nativeToken,
deployParams.config.sequencerInboxMaxTimeVariation
deployParams.config.sequencerInboxMaxTimeVariation,
deployParams.feeTokenPricer
);

IChallengeManager challengeManager = IChallengeManager(
Expand Down
8 changes: 6 additions & 2 deletions test/foundry/BridgeCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ contract BridgeCreatorTest is Test {
address proxyAdmin = address(300);
address rollup = address(301);
address nativeToken = address(0);
address feeTokenPricer = address(0);
ISequencerInbox.MaxTimeVariation memory timeVars = ISequencerInbox.MaxTimeVariation(
10,
20,
Expand All @@ -128,7 +129,8 @@ contract BridgeCreatorTest is Test {
proxyAdmin,
rollup,
nativeToken,
timeVars
timeVars,
IFeeTokenPricer(feeTokenPricer)
);
(
IBridge bridge,
Expand Down Expand Up @@ -187,6 +189,7 @@ contract BridgeCreatorTest is Test {
address nativeToken = address(
new ERC20PresetFixedSupply("Appchain Token", "App", 1_000_000, address(this))
);
address feeTokenPricer = makeAddr("feeTokenPricer");
ISequencerInbox.MaxTimeVariation memory timeVars = ISequencerInbox.MaxTimeVariation(
10,
20,
Expand All @@ -199,7 +202,8 @@ contract BridgeCreatorTest is Test {
proxyAdmin,
rollup,
nativeToken,
timeVars
timeVars,
IFeeTokenPricer(feeTokenPricer)
);
(
IBridge bridge,
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 @@ -134,7 +134,8 @@ contract RollupCreatorTest is Test {
nativeToken: address(0),
deployFactoriesToL2: true,
maxFeePerGasForRetryables: MAX_FEE_PER_GAS,
batchPosterManager: batchPosterManager
batchPosterManager: batchPosterManager,
feeTokenPricer: IFeeTokenPricer(address(0))
});
address rollupAddress = rollupCreator.createRollup{value: factoryDeploymentFunds}(
deployParams
Expand Down Expand Up @@ -290,7 +291,8 @@ contract RollupCreatorTest is Test {
nativeToken: nativeToken,
deployFactoriesToL2: true,
maxFeePerGasForRetryables: MAX_FEE_PER_GAS,
batchPosterManager: batchPosterManager
batchPosterManager: batchPosterManager,
feeTokenPricer: IFeeTokenPricer(makeAddr("feeTokenPricer"))
});

address rollupAddress = rollupCreator.createRollup(deployParams);
Expand Down Expand Up @@ -443,7 +445,8 @@ contract RollupCreatorTest is Test {
nativeToken: address(0),
deployFactoriesToL2: true,
maxFeePerGasForRetryables: MAX_FEE_PER_GAS,
batchPosterManager: batchPosterManager
batchPosterManager: batchPosterManager,
feeTokenPricer: IFeeTokenPricer(address(0))
});
address rollupAddress = rollupCreator.createRollup{value: factoryDeploymentFunds}(
deployParams
Expand Down
12 changes: 6 additions & 6 deletions test/foundry/SequencerInbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ contract SequencerInboxTest is Test {
SequencerInbox seqInbox = SequencerInbox(
address(new TransparentUpgradeableProxy(address(seqInboxImpl), proxyAdmin, ""))
);
seqInbox.initialize(bridge, maxTimeVariation);
seqInbox.initialize(bridge, maxTimeVariation, IFeeTokenPricer(address(0)));

vm.prank(rollupOwner);
seqInbox.setIsBatchPoster(tx.origin, true);
Expand Down Expand Up @@ -112,7 +112,7 @@ contract SequencerInboxTest is Test {
SequencerInbox seqInbox = SequencerInbox(
address(new TransparentUpgradeableProxy(address(seqInboxImpl), proxyAdmin, ""))
);
seqInbox.initialize(bridge, maxTimeVariation);
seqInbox.initialize(bridge, maxTimeVariation, IFeeTokenPricer(makeAddr("feeTokenPricer")));

vm.prank(rollupOwner);
seqInbox.setIsBatchPoster(tx.origin, true);
Expand Down Expand Up @@ -280,7 +280,7 @@ contract SequencerInboxTest is Test {

address seqInboxLogic = address(new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, false));
SequencerInbox seqInboxProxy = SequencerInbox(TestUtil.deployProxy(seqInboxLogic));
seqInboxProxy.initialize(IBridge(_bridge), maxTimeVariation);
seqInboxProxy.initialize(IBridge(_bridge), maxTimeVariation, IFeeTokenPricer(address(0)));

assertEq(seqInboxProxy.isUsingFeeToken(), false, "Invalid isUsingFeeToken");
assertEq(address(seqInboxProxy.bridge()), address(_bridge), "Invalid bridge");
Expand All @@ -296,7 +296,7 @@ contract SequencerInboxTest is Test {

address seqInboxLogic = address(new SequencerInbox(MAX_DATA_SIZE, dummyReader4844, true));
SequencerInbox seqInboxProxy = SequencerInbox(TestUtil.deployProxy(seqInboxLogic));
seqInboxProxy.initialize(IBridge(_bridge), maxTimeVariation);
seqInboxProxy.initialize(IBridge(_bridge), maxTimeVariation, IFeeTokenPricer(makeAddr("feeTokenPricer")));

assertEq(seqInboxProxy.isUsingFeeToken(), true, "Invalid isUsingFeeToken");
assertEq(address(seqInboxProxy.bridge()), address(_bridge), "Invalid bridge");
Expand All @@ -313,7 +313,7 @@ contract SequencerInboxTest is Test {
SequencerInbox seqInboxProxy = SequencerInbox(TestUtil.deployProxy(seqInboxLogic));

vm.expectRevert(abi.encodeWithSelector(NativeTokenMismatch.selector));
seqInboxProxy.initialize(IBridge(_bridge), maxTimeVariation);
seqInboxProxy.initialize(IBridge(_bridge), maxTimeVariation, IFeeTokenPricer(address(0)));
}

function testInitialize_revert_NativeTokenMismatch_FeeTokenEth() public {
Expand All @@ -327,7 +327,7 @@ contract SequencerInboxTest is Test {
SequencerInbox seqInboxProxy = SequencerInbox(TestUtil.deployProxy(seqInboxLogic));

vm.expectRevert(abi.encodeWithSelector(NativeTokenMismatch.selector));
seqInboxProxy.initialize(IBridge(_bridge), maxTimeVariation);
seqInboxProxy.initialize(IBridge(_bridge), maxTimeVariation, IFeeTokenPricer(makeAddr("feeTokenPricer")));
}

function testAddSequencerL2BatchFromOrigin_ArbitrumHosted() public {
Expand Down

0 comments on commit a6a3f55

Please sign in to comment.