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