Skip to content

Commit

Permalink
refactor: disallow prune in devnet + add onlyOwners
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Aug 22, 2024
1 parent 08854e9 commit 83d644e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
10 changes: 7 additions & 3 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
* @dev Will revert if there is nothing to prune or if the chain is not ready to be pruned
*/
function prune() external override(IRollup) {
if (isDevNet) {
revert Errors.DevNet__NoPruningAllowed();
}

if (pendingBlockCount == provenBlockCount) {
revert Errors.Rollup__NothingToPrune();
}
Expand Down Expand Up @@ -157,7 +161,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
*
* @param _devNet - Whether or not the contract is in devnet mode
*/
function setDevNet(bool _devNet) external override(ITestRollup) {
function setDevNet(bool _devNet) external override(ITestRollup) onlyOwner {
isDevNet = _devNet;
}

Expand All @@ -168,7 +172,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
*
* @param _verifier - The new verifier contract
*/
function setVerifier(address _verifier) external override(ITestRollup) {
function setVerifier(address _verifier) external override(ITestRollup) onlyOwner {
verifier = IVerifier(_verifier);
}

Expand All @@ -179,7 +183,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
*
* @param _vkTreeRoot - The new vkTreeRoot to be used by proofs
*/
function setVkTreeRoot(bytes32 _vkTreeRoot) external override(ITestRollup) {
function setVkTreeRoot(bytes32 _vkTreeRoot) external override(ITestRollup) onlyOwner {
vkTreeRoot = _vkTreeRoot;
}

Expand Down
3 changes: 3 additions & 0 deletions l1-contracts/src/core/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ pragma solidity >=0.8.18;
* when there are multiple contracts that could have thrown the error.
*/
library Errors {
// DEVNET related
error DevNet__NoPruningAllowed(); // 0x6984c590

// Inbox
error Inbox__Unauthorized(); // 0xe5336a6b
error Inbox__ActorTooLarge(bytes32 actor); // 0xa776a06e
Expand Down
11 changes: 11 additions & 0 deletions l1-contracts/test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ contract RollupTest is DecoderBase {
}

function testRevertPrune() public setUpFor("mixed_block_1") {
if (rollup.isDevNet()) {
vm.expectRevert(abi.encodeWithSelector(Errors.DevNet__NoPruningAllowed.selector));
rollup.prune();

return;
}

vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__NothingToPrune.selector));
rollup.prune();

Expand All @@ -96,6 +103,10 @@ contract RollupTest is DecoderBase {
}

function testPrune() public setUpFor("mixed_block_1") {
if (rollup.isDevNet()) {
return;
}

_testBlock("mixed_block_1", false);

assertEq(inbox.inProgress(), 3, "Invalid in progress");
Expand Down

0 comments on commit 83d644e

Please sign in to comment.