-
Notifications
You must be signed in to change notification settings - Fork 438
feat: hourglass (task-based AVS framework) #1534
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
Changes from all commits
242dfea
2be9a43
6446f6e
5128eed
39c8b4f
0a5e469
f1b2cbd
1db4e85
26a3a31
0dff4f7
b4da151
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.27; | ||
|
||
import {ITaskMailbox} from "../../interfaces/ITaskMailbox.sol"; | ||
import {IKeyRegistrarTypes} from "../../interfaces/IKeyRegistrar.sol"; | ||
|
||
/** | ||
* @title TaskMailboxStorage | ||
* @author Layr Labs, Inc. | ||
* @notice Storage contract for the TaskMailbox contract. | ||
*/ | ||
abstract contract TaskMailboxStorage is ITaskMailbox { | ||
/// @notice Equivalent to 100%, but in basis points. | ||
uint16 internal constant ONE_HUNDRED_IN_BIPS = 10_000; | ||
|
||
/// @notice Immutable BN254 certificate verifier | ||
address public immutable BN254_CERTIFICATE_VERIFIER; | ||
|
||
/// @notice Immutable ECDSA certificate verifier | ||
address public immutable ECDSA_CERTIFICATE_VERIFIER; | ||
|
||
/// @notice Global counter for tasks created across the TaskMailbox | ||
uint256 internal _globalTaskCount; | ||
|
||
/// @notice Mapping from task hash to task details | ||
mapping(bytes32 taskHash => Task task) internal _tasks; | ||
|
||
/// @notice Mapping to track registered executor operator sets by their keys | ||
mapping(bytes32 operatorSetKey => bool isRegistered) public isExecutorOperatorSetRegistered; | ||
|
||
/// @notice Mapping from executor operator set key to its task configuration | ||
mapping(bytes32 operatorSetKey => ExecutorOperatorSetTaskConfig config) internal _executorOperatorSetTaskConfigs; | ||
|
||
/// @notice The fee split percentage in basis points (0-10000) | ||
uint16 public feeSplit; | ||
|
||
/// @notice The address that receives the fee split | ||
address public feeSplitCollector; | ||
|
||
/** | ||
* @notice Constructor for TaskMailboxStorage | ||
* @param _bn254CertificateVerifier Address of the BN254 certificate verifier | ||
* @param _ecdsaCertificateVerifier Address of the ECDSA certificate verifier | ||
*/ | ||
constructor(address _bn254CertificateVerifier, address _ecdsaCertificateVerifier) { | ||
BN254_CERTIFICATE_VERIFIER = _bn254CertificateVerifier; | ||
ECDSA_CERTIFICATE_VERIFIER = _ecdsaCertificateVerifier; | ||
} | ||
|
||
/** | ||
* @dev This empty reserved space is put in place to allow future versions to add new | ||
* variables without shifting down storage in the inheritance chain. | ||
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps | ||
*/ | ||
uint256[45] private __gap; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.27; | ||
|
||
import {ITaskMailboxTypes} from "./ITaskMailbox.sol"; | ||
import {OperatorSet} from "../libraries/OperatorSetLib.sol"; | ||
|
||
/** | ||
* @title IAVSTaskHook | ||
* @author Layr Labs, Inc. | ||
* @notice Interface for AVS-specific task lifecycle hooks. | ||
* @dev This interface allows AVSs to implement custom validation logic for tasks. | ||
*/ | ||
interface IAVSTaskHook { | ||
/** | ||
* @notice Validates a task before it is created | ||
* @param caller Address that is creating the task | ||
* @param taskParams Task parameters | ||
* @dev This function should revert if the task should not be created | ||
*/ | ||
0xrajath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
function validatePreTaskCreation(address caller, ITaskMailboxTypes.TaskParams memory taskParams) external view; | ||
|
||
/** | ||
* @notice Handles a task after it is created | ||
* @param taskHash Unique identifier of the task | ||
* @dev This function can be used to perform additional validation or update AVS-specific state | ||
*/ | ||
function handlePostTaskCreation( | ||
bytes32 taskHash | ||
) external; | ||
|
||
/** | ||
* @notice Validates a task before it is submitted for verification | ||
* @param caller Address that is submitting the result | ||
* @param taskHash Unique identifier of the task | ||
* @param cert Certificate proving the validity of the result | ||
* @param result Task execution result data | ||
* @dev This function should revert if the task should not be verified | ||
*/ | ||
function validatePreTaskResultSubmission( | ||
address caller, | ||
bytes32 taskHash, | ||
bytes memory cert, | ||
bytes memory result | ||
) external view; | ||
|
||
/** | ||
* @notice Handles a task result submission | ||
* @param taskHash Unique identifier of the task | ||
* @dev This function can be used to perform additional validation or update AVS-specific state | ||
*/ | ||
function handlePostTaskResultSubmission( | ||
bytes32 taskHash | ||
) external; | ||
|
||
/** | ||
* @notice Calculates the fee for a task payload against a specific fee market | ||
* @param taskParams The task parameters | ||
* @return The fee for the task | ||
*/ | ||
function calculateTaskFee( | ||
ITaskMailboxTypes.TaskParams memory taskParams | ||
) external view returns (uint96); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.