diff --git a/src/rollup/RollupCreator.sol b/src/rollup/RollupCreator.sol index 840cf2df..c1130425 100644 --- a/src/rollup/RollupCreator.sol +++ b/src/rollup/RollupCreator.sol @@ -45,6 +45,16 @@ contract RollupCreator is Ownable { address eigenDARollupManager; } + modifier onlyUnfrozen() { + require(!deploymentFrozen, "Deployment no longer permitted from this RollupCreator"); + _; + } + + modifier onlyOnce() { + require(!templatesSet, "Templates already set"); + _; + } + BridgeCreator public bridgeCreator; IOneStepProofEntry public osp; IChallengeManager public challengeManagerTemplate; @@ -57,6 +67,9 @@ contract RollupCreator is Ownable { DeployHelper public l2FactoriesDeployer; + bool public templatesSet; + bool public deploymentFrozen; + constructor() Ownable() {} // creator receives back excess fees (for deploying L2 factories) so it can refund the caller @@ -72,7 +85,7 @@ contract RollupCreator is Ownable { address _validatorUtils, address _validatorWalletCreator, DeployHelper _l2FactoriesDeployer - ) external onlyOwner { + ) external onlyOwner onlyOnce { bridgeCreator = _bridgeCreator; osp = _osp; challengeManagerTemplate = _challengeManagerLogic; @@ -82,6 +95,8 @@ contract RollupCreator is Ownable { validatorUtils = _validatorUtils; validatorWalletCreator = _validatorWalletCreator; l2FactoriesDeployer = _l2FactoriesDeployer; + + templatesSet = true; emit TemplatesUpdated(); } @@ -111,6 +126,7 @@ contract RollupCreator is Ownable { function createRollup(RollupDeploymentParams memory deployParams) public payable + onlyUnfrozen returns (address) { { @@ -236,6 +252,10 @@ contract RollupCreator is Ownable { return address(rollup); } + function freezeDeployment() external onlyOwner { + deploymentFrozen = true; + } + function _deployUpgradeExecutor(address rollupOwner, ProxyAdmin proxyAdmin) internal returns (address) @@ -335,4 +355,4 @@ contract RollupCreator is Ownable { } return scaledAmount; } -} +} \ No newline at end of file diff --git a/test/foundry/RollupCreator.t.sol b/test/foundry/RollupCreator.t.sol index 4f45bea7..da805057 100644 --- a/test/foundry/RollupCreator.t.sol +++ b/test/foundry/RollupCreator.t.sol @@ -407,6 +407,103 @@ contract RollupCreatorTest is Test { ); } + function test_freezeDeployment() public { + vm.startPrank(deployer); + + rollupCreator.freezeDeployment(); + assertTrue(rollupCreator.deploymentFrozen(), "rollupCreator not frozen"); + + ISequencerInbox.MaxTimeVariation memory timeVars = ISequencerInbox.MaxTimeVariation( + ((60 * 60 * 24) / 15), + 12, + 60 * 60 * 24, + 60 * 60 + ); + Config memory config = Config({ + confirmPeriodBlocks: 20, + extraChallengeTimeBlocks: 200, + stakeToken: address(0), + baseStake: 1000, + wasmModuleRoot: keccak256("wasm"), + owner: rollupOwner, + loserStakeEscrow: address(200), + chainId: 1337, + chainConfig: "abc", + genesisBlockNum: 15_000_000, + sequencerInboxMaxTimeVariation: timeVars + }); + + // prepare funds + uint256 factoryDeploymentFunds = 1 ether; + vm.deal(deployer, factoryDeploymentFunds); + + /// deploy rollup + address[] memory batchPosters = new address[](1); + batchPosters[0] = makeAddr("batch poster 1"); + address batchPosterManager = makeAddr("batch poster manager"); + address[] memory validators = new address[](2); + validators[0] = makeAddr("validator1"); + validators[1] = makeAddr("validator2"); + + address eigenDARollupManager = makeAddr("rollupManager"); + + RollupCreator.RollupDeploymentParams memory deployParams = RollupCreator + .RollupDeploymentParams({ + config: config, + batchPosters: batchPosters, + validators: validators, + maxDataSize: MAX_DATA_SIZE, + nativeToken: address(0), + deployFactoriesToL2: true, + maxFeePerGasForRetryables: MAX_FEE_PER_GAS, + batchPosterManager: batchPosterManager, + eigenDARollupManager: eigenDARollupManager + }); + + vm.expectRevert("Deployment no longer permitted from this RollupCreator"); + rollupCreator.createRollup{value: factoryDeploymentFunds}( + deployParams + ); + + vm.stopPrank(); + } + + function test_setTemplates_onlyOnce() public { + vm.startPrank(deployer); + + BridgeCreator bridgeCreator = new BridgeCreator(ethBasedTemplates, erc20BasedTemplates); + + IUpgradeExecutor upgradeExecutorLogic = new UpgradeExecutorMock(); + + ( + IOneStepProofEntry ospEntry, + IChallengeManager challengeManager, + IRollupAdmin _rollupAdmin, + IRollupUser _rollupUser + ) = _prepareRollupDeployment(); + + rollupAdmin = _rollupAdmin; + rollupUser = _rollupUser; + + ValidatorUtils validatorUtils = new ValidatorUtils(); + ValidatorWalletCreator validatorWalletCreator = new ValidatorWalletCreator(); + + vm.expectRevert("Templates already set"); + rollupCreator.setTemplates( + bridgeCreator, + ospEntry, + challengeManager, + _rollupAdmin, + _rollupUser, + upgradeExecutorLogic, + address(validatorUtils), + address(validatorWalletCreator), + deployHelper + ); + + vm.stopPrank(); + } + function test_upgrade() public { vm.startPrank(deployer); @@ -546,4 +643,4 @@ contract ProxyUpgradeAction { contract Dummy { function dummy() public {} -} +} \ No newline at end of file