Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: disallow prune in devnet + add onlyOwners #8134

Merged
merged 1 commit into from
Aug 28, 2024
Merged
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
10 changes: 7 additions & 3 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,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 @@ -159,7 +163,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 @@ -170,7 +174,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 @@ -181,7 +185,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 @@ -79,6 +79,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 @@ -95,6 +102,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
Loading