Skip to content

Commit c736f96

Browse files
authored
refactor: disallow prune in devnet + add onlyOwners (#8134)
Fixes #8103. Disallow pruning when in devnet, and adds `onlyOwner` modifier to `setDevNet`, `setVerifier` and `setVkTreeRoot`.
1 parent daa57cc commit c736f96

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

l1-contracts/src/core/Rollup.sol

+7-3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
110110
* @dev Will revert if there is nothing to prune or if the chain is not ready to be pruned
111111
*/
112112
function prune() external override(IRollup) {
113+
if (isDevNet) {
114+
revert Errors.DevNet__NoPruningAllowed();
115+
}
116+
113117
if (pendingBlockCount == provenBlockCount) {
114118
revert Errors.Rollup__NothingToPrune();
115119
}
@@ -159,7 +163,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
159163
*
160164
* @param _devNet - Whether or not the contract is in devnet mode
161165
*/
162-
function setDevNet(bool _devNet) external override(ITestRollup) {
166+
function setDevNet(bool _devNet) external override(ITestRollup) onlyOwner {
163167
isDevNet = _devNet;
164168
}
165169

@@ -170,7 +174,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
170174
*
171175
* @param _verifier - The new verifier contract
172176
*/
173-
function setVerifier(address _verifier) external override(ITestRollup) {
177+
function setVerifier(address _verifier) external override(ITestRollup) onlyOwner {
174178
verifier = IVerifier(_verifier);
175179
}
176180

@@ -181,7 +185,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup {
181185
*
182186
* @param _vkTreeRoot - The new vkTreeRoot to be used by proofs
183187
*/
184-
function setVkTreeRoot(bytes32 _vkTreeRoot) external override(ITestRollup) {
188+
function setVkTreeRoot(bytes32 _vkTreeRoot) external override(ITestRollup) onlyOwner {
185189
vkTreeRoot = _vkTreeRoot;
186190
}
187191

l1-contracts/src/core/libraries/Errors.sol

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ pragma solidity >=0.8.18;
1010
* when there are multiple contracts that could have thrown the error.
1111
*/
1212
library Errors {
13+
// DEVNET related
14+
error DevNet__NoPruningAllowed(); // 0x6984c590
15+
1316
// Inbox
1417
error Inbox__Unauthorized(); // 0xe5336a6b
1518
error Inbox__ActorTooLarge(bytes32 actor); // 0xa776a06e

l1-contracts/test/Rollup.t.sol

+11
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ contract RollupTest is DecoderBase {
7979
}
8080

8181
function testRevertPrune() public setUpFor("mixed_block_1") {
82+
if (rollup.isDevNet()) {
83+
vm.expectRevert(abi.encodeWithSelector(Errors.DevNet__NoPruningAllowed.selector));
84+
rollup.prune();
85+
86+
return;
87+
}
88+
8289
vm.expectRevert(abi.encodeWithSelector(Errors.Rollup__NothingToPrune.selector));
8390
rollup.prune();
8491

@@ -95,6 +102,10 @@ contract RollupTest is DecoderBase {
95102
}
96103

97104
function testPrune() public setUpFor("mixed_block_1") {
105+
if (rollup.isDevNet()) {
106+
return;
107+
}
108+
98109
_testBlock("mixed_block_1", false);
99110

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

0 commit comments

Comments
 (0)