Skip to content

Commit

Permalink
Merge pull request #36 from Layr-Labs/quaq--update-rollup-creator
Browse files Browse the repository at this point in the history
Update RollupCreator
  • Loading branch information
EthenNotEthan authored Dec 8, 2024
2 parents 023abf5 + 118ecc6 commit 563720c
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 3 deletions.
24 changes: 22 additions & 2 deletions src/rollup/RollupCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -82,6 +95,8 @@ contract RollupCreator is Ownable {
validatorUtils = _validatorUtils;
validatorWalletCreator = _validatorWalletCreator;
l2FactoriesDeployer = _l2FactoriesDeployer;

templatesSet = true;
emit TemplatesUpdated();
}

Expand Down Expand Up @@ -111,6 +126,7 @@ contract RollupCreator is Ownable {
function createRollup(RollupDeploymentParams memory deployParams)
public
payable
onlyUnfrozen
returns (address)
{
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -335,4 +355,4 @@ contract RollupCreator is Ownable {
}
return scaledAmount;
}
}
}
99 changes: 98 additions & 1 deletion test/foundry/RollupCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -546,4 +643,4 @@ contract ProxyUpgradeAction {

contract Dummy {
function dummy() public {}
}
}

0 comments on commit 563720c

Please sign in to comment.