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

Add aggregator and task generator setters #292

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
16 changes: 16 additions & 0 deletions contracts/evm/src/eth/SFFLTaskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,22 @@ contract SFFLTaskManager is Initializable, OwnableUpgradeable, Pausable, BLSSign
return (true, hashOfNonSigners);
}

/**
* @notice Sets the aggregator address
* @param _aggregator New aggregator address
*/
function setAggregator(address _aggregator) external onlyOwner {
aggregator = _aggregator;
}

/**
* @notice Sets the task generator address
* @param _generator New task generator address
*/
function setGenerator(address _generator) external onlyOwner {
generator = _generator;
}

function _validateChallenge(
Checkpoint.Task calldata, /* task */
Checkpoint.TaskResponse calldata /* taskResponse */
Expand Down
8 changes: 8 additions & 0 deletions contracts/evm/src/rollup/SFFLRegistryRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ contract SFFLRegistryRollup is Initializable, OwnableUpgradeable, Pausable, SFFL
_operatorSet.update(message.operators);
}

/**
* @notice Sets the aggregator address
* @param _aggregator New aggregator address
*/
function setAggregator(address _aggregator) external onlyOwner {
aggregator = _aggregator;
}

/**
* @notice Sets the operator set quorum weight threshold
* @param newQuorumThreshold New quorum threshold, based on
Expand Down
15 changes: 15 additions & 0 deletions contracts/evm/test/SFFLRegistryRollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,19 @@ contract SFFLRegistryRollupTest is TestUtils {

registry.forceOperatorSetUpdate(message);
}

function test_setAggregator() public {
address newAggregator = addr("newAggregator");

vm.prank(addr("owner"));
registry.setAggregator(newAggregator);

assertEq(registry.aggregator(), newAggregator);
}

function test_setAggregator_RevertWhen_CallerNotOwner() public {
vm.expectRevert("Ownable: caller is not the owner");

registry.setAggregator(addr("newAggregator"));
}
}
36 changes: 33 additions & 3 deletions contracts/evm/test/SFFLTaskManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract SFFLTaskManagerTest is TestUtils {
uint32 public constant TASK_RESPONSE_WINDOW_BLOCK = 30;
address public aggregator;
address public generator;
address owner;
uint32 public thresholdDenominator;

event CheckpointTaskCreated(uint32 indexed taskIndex, Checkpoint.Task task);
Expand All @@ -52,16 +53,15 @@ contract SFFLTaskManagerTest is TestUtils {

aggregator = addr("aggregator");
generator = addr("generator");
owner = addr("owner");

address impl = address(new SFFLTaskManagerHarness(registryCoordinator, TASK_RESPONSE_WINDOW_BLOCK));

taskManager = SFFLTaskManagerHarness(
deployProxy(
impl,
address(proxyAdmin),
abi.encodeWithSelector(
taskManager.initialize.selector, pauserRegistry, registryCoordinatorOwner, aggregator, generator
)
abi.encodeWithSelector(taskManager.initialize.selector, pauserRegistry, owner, aggregator, generator)
)
);

Expand Down Expand Up @@ -946,4 +946,34 @@ contract SFFLTaskManagerTest is TestUtils {
assertFalse(success);
assertEq(signatoryRecordHash, expectedSignatoryRecordHash);
}

function test_setAggregator() public {
address newAggregator = addr("newAggregator");

vm.prank(owner);
taskManager.setAggregator(newAggregator);

assertEq(taskManager.aggregator(), newAggregator);
}

function test_setAggregator_RevertWhen_CallerNotOwner() public {
vm.expectRevert("Ownable: caller is not the owner");

taskManager.setAggregator(addr("newAggregator"));
}

function test_setGenerator() public {
address newGenerator = addr("newGenerator");

vm.prank(owner);
taskManager.setGenerator(newGenerator);

assertEq(taskManager.generator(), newGenerator);
}

function test_setGenerator_RevertWhen_CallerNotOwner() public {
vm.expectRevert("Ownable: caller is not the owner");

taskManager.setGenerator(addr("newGenerator"));
}
}

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/anvil/data/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
}
},
"number": "11",
"number": "9",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"config": {
Expand Down
2 changes: 1 addition & 1 deletion tests/anvil/data/rollup-avs-deployed-anvil-state.json

Large diffs are not rendered by default.

Loading