-
Notifications
You must be signed in to change notification settings - Fork 124
/
IIncredibleSquaringTaskManager.sol
74 lines (59 loc) · 3 KB
/
IIncredibleSquaringTaskManager.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;
import "@eigenlayer-middleware/src/libraries/BN254.sol";
interface IIncredibleSquaringTaskManager {
// EVENTS
event NewTaskCreated(uint32 indexed taskIndex, Task task);
event TaskResponded(TaskResponse taskResponse, TaskResponseMetadata taskResponseMetadata);
event TaskCompleted(uint32 indexed taskIndex);
event TaskChallengedSuccessfully(uint32 indexed taskIndex, address indexed challenger);
event TaskChallengedUnsuccessfully(uint32 indexed taskIndex, address indexed challenger);
event AggregatorUpdated(address indexed oldAggregator, address indexed newAggregator);
event GeneratorUpdated(address indexed oldGenerator, address indexed newGenerator);
// STRUCTS
struct Task {
uint256 numberToBeSquared;
uint32 taskCreatedBlock;
// task submitter decides on the criteria for a task to be completed
// note that this does not mean the task was "correctly" answered (i.e. the number was squared correctly)
// this is for the challenge logic to verify
// task is completed (and contract will accept its TaskResponse) when each quorumNumbers specified here
// are signed by at least quorumThresholdPercentage of the operators
// note that we set the quorumThresholdPercentage to be the same for all quorumNumbers, but this could be changed
bytes quorumNumbers;
uint32 quorumThresholdPercentage;
}
// Task response is hashed and signed by operators.
// These signatures are aggregated and sent to the contract as response.
struct TaskResponse {
// Can be obtained by the operator from the event NewTaskCreated.
uint32 referenceTaskIndex;
// This is just the response that the operator has to compute by itself.
uint256 numberSquared;
}
// Extra information related to taskResponse, which is filled inside the contract.
// It thus cannot be signed by operators, so we keep it in a separate struct than TaskResponse
// This metadata is needed by the challenger, so we emit it in the TaskResponded event
struct TaskResponseMetadata {
uint32 taskRespondedBlock;
bytes32 hashOfNonSigners;
}
// FUNCTIONS
// NOTE: this function creates a new task.
function createNewTask(
uint256 numberToBeSquared,
uint32 quorumThresholdPercentage,
bytes calldata quorumNumbers
) external;
/// @notice Returns the current 'taskNumber' for the middleware
function taskNumber() external view returns (uint32);
// NOTE: this function raises a challenge to existing tasks.
function raiseAndResolveChallenge(
Task calldata task,
TaskResponse calldata taskResponse,
TaskResponseMetadata calldata taskResponseMetadata,
BN254.G1Point[] memory pubkeysOfNonSigningOperators
) external;
/// @notice Returns the TASK_RESPONSE_WINDOW_BLOCK
function getTaskResponseWindowBlock() external view returns (uint32);
}