Skip to content
Merged
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
416 changes: 416 additions & 0 deletions docs/avs/task/TaskMailbox.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/BN254CertificateVerifier/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/ECDSACertificateVerifier/binding.go

Large diffs are not rendered by default.

144 changes: 95 additions & 49 deletions pkg/bindings/ECDSACertificateVerifierStorage/binding.go

Large diffs are not rendered by default.

325 changes: 325 additions & 0 deletions pkg/bindings/IAVSTaskHook/binding.go

Large diffs are not rendered by default.

144 changes: 95 additions & 49 deletions pkg/bindings/IECDSACertificateVerifier/binding.go

Large diffs are not rendered by default.

1,785 changes: 1,785 additions & 0 deletions pkg/bindings/ITaskMailbox/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/KeyRegistrar/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/bindings/OperatorTableUpdater/binding.go

Large diffs are not rendered by default.

2,413 changes: 2,413 additions & 0 deletions pkg/bindings/TaskMailbox/binding.go

Large diffs are not rendered by default.

1,979 changes: 1,979 additions & 0 deletions pkg/bindings/TaskMailboxStorage/binding.go

Large diffs are not rendered by default.

480 changes: 480 additions & 0 deletions src/contracts/avs/task/TaskMailbox.sol

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions src/contracts/avs/task/TaskMailboxStorage.sol
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;
}
63 changes: 63 additions & 0 deletions src/contracts/interfaces/IAVSTaskHook.sol
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
*/
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);
}
Loading