Skip to content

Commit f43d517

Browse files
authored
feat: no consensus config (#1574)
**Motivation:** The TaskMailbox needs an option to allow no consensus config to be set, such that the AVS can define their own consensus logic in their `handlePostTaskResultSubmission` hook. **Modifications:** * Consensus.NONE is a valid consensus option. * Updated `handlePostTaskResultSubmission` to take `msg.sender` field as well. **Result:** More flexible consensus configs.
1 parent 2c4c7ea commit f43d517

File tree

11 files changed

+472
-51
lines changed

11 files changed

+472
-51
lines changed

docs/avs/task/TaskMailbox.md

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,52 @@ Executor operator sets define which operators are eligible to execute tasks and
143143
* [`registerExecutorOperatorSet`](#registerexecutoroperatorset)
144144
* [`getExecutorOperatorSetTaskConfig`](#getexecutoroperatorsettaskconfig)
145145

146+
### ExecutorOperatorSetTaskConfig Structure
147+
148+
The task configuration for an executor operator set contains the following fields:
149+
150+
```solidity
151+
struct ExecutorOperatorSetTaskConfig {
152+
IAVSTaskHook taskHook; // AVS-specific contract for custom validation
153+
uint96 taskSLA; // Time limit in seconds for task completion
154+
IERC20 feeToken; // Token used for task fees (zero address = no fees)
155+
address feeCollector; // Address to receive AVS portion of fees
156+
CurveType curveType; // Cryptographic curve (BN254 or ECDSA)
157+
Consensus consensus; // Consensus type and parameters
158+
bytes taskMetadata; // AVS-specific metadata
159+
}
160+
```
161+
162+
### Consensus Configuration
163+
164+
The consensus configuration determines how operator signatures are validated:
165+
166+
```solidity
167+
struct Consensus {
168+
ConsensusType consensusType; // Type of consensus validation
169+
bytes value; // Type-specific parameters
170+
}
171+
172+
enum ConsensusType {
173+
NONE, // AVS handles consensus validation
174+
STAKE_PROPORTION_THRESHOLD // Require minimum stake percentage
175+
}
176+
```
177+
178+
**Consensus Types:**
179+
180+
1. **NONE**:
181+
- The TaskMailbox only verifies certificate validity (signature, timestamp, message hash)
182+
- AVS is responsible for implementing custom consensus logic in task hooks
183+
- `value` must be empty bytes
184+
- Useful for AVSs with custom consensus mechanisms or off-chain validation
185+
186+
2. **STAKE_PROPORTION_THRESHOLD**:
187+
- Requires a minimum percentage of total stake to sign the result
188+
- `value` contains `abi.encode(uint16)` representing threshold in basis points (0-10000)
189+
- Example: 6667 = 66.67% stake required
190+
- Certificate verification will fail if threshold is not met
191+
146192
#### `setExecutorOperatorSetTaskConfig`
147193

148194
```solidity
@@ -178,6 +224,38 @@ Configures how tasks should be executed by a specific operator set. The configur
178224
* Consensus type and curve type must be valid
179225
* Consensus value must be properly formatted
180226

227+
**Example Configuration:**
228+
229+
```solidity
230+
// Example 1: Configure with 66.67% stake threshold
231+
ExecutorOperatorSetTaskConfig memory config = ExecutorOperatorSetTaskConfig({
232+
taskHook: IAVSTaskHook(0x...),
233+
taskSLA: 3600, // 1 hour
234+
feeToken: IERC20(0x...),
235+
feeCollector: 0x...,
236+
curveType: CurveType.BN254,
237+
consensus: Consensus({
238+
consensusType: ConsensusType.STAKE_PROPORTION_THRESHOLD,
239+
value: abi.encode(uint16(6667)) // 66.67%
240+
}),
241+
taskMetadata: bytes("")
242+
});
243+
244+
// Example 2: Configure with NONE consensus (AVS handles validation)
245+
ExecutorOperatorSetTaskConfig memory config = ExecutorOperatorSetTaskConfig({
246+
taskHook: IAVSTaskHook(0x...),
247+
taskSLA: 3600,
248+
feeToken: IERC20(address(0)), // No fees
249+
feeCollector: address(0),
250+
curveType: CurveType.ECDSA,
251+
consensus: Consensus({
252+
consensusType: ConsensusType.NONE,
253+
value: bytes("") // Must be empty
254+
}),
255+
taskMetadata: bytes("")
256+
});
257+
```
258+
181259
#### `registerExecutorOperatorSet`
182260

183261
```solidity
@@ -232,9 +310,16 @@ Submits the result of task execution along with proof of consensus. The method:
232310

233311
1. Validates the task exists and hasn't expired or been verified
234312
2. Calls AVS hook for pre-submission validation
235-
3. Verifies the certificate based on the configured curve type:
236-
- **BN254**: Verifies aggregated BLS signature
237-
- **ECDSA**: Verifies individual ECDSA signatures meet threshold
313+
3. Verifies the certificate based on both curve type and consensus type:
314+
- **ConsensusType.NONE**:
315+
- Validates certificate fields (reference timestamp, message hash, non-empty signature)
316+
- Calls certificate verifier to validate signature authenticity
317+
- Does NOT enforce any stake threshold requirements
318+
- AVS can implement custom consensus logic in `handlePostTaskResultSubmission`
319+
- **ConsensusType.STAKE_PROPORTION_THRESHOLD**:
320+
- Performs all validations from NONE
321+
- Additionally verifies that signers meet the configured stake threshold
322+
- Uses `verifyCertificateProportion` to ensure minimum stake percentage signed
238323
4. Distributes fees according to fee split configuration
239324
5. Stores the result and marks task as verified
240325
6. Calls AVS hook for post-submission handling
@@ -250,7 +335,7 @@ Submits the result of task execution along with proof of consensus. The method:
250335
* Task must exist and be in CREATED status
251336
* Current timestamp must be after task creation time
252337
* Certificate must have valid signature(s)
253-
* Certificate verification must pass consensus threshold
338+
* Certificate verification must pass consensus threshold (reverts with `ThresholdNotMet` if not)
254339
* AVS validation must pass
255340

256341
#### `getTaskResult`
@@ -379,7 +464,10 @@ interface IAVSTaskHook {
379464
) external view;
380465
381466
// Called after successful result submission for any side effects
382-
function handlePostTaskResultSubmission(bytes32 taskHash) external;
467+
function handlePostTaskResultSubmission(
468+
address caller,
469+
bytes32 taskHash
470+
) external;
383471
384472
// Calculates the fee for a task based on its parameters
385473
function calculateTaskFee(

pkg/bindings/IAVSTaskHook/binding.go

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/ITaskMailbox/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/TaskMailbox/binding.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/TaskMailboxStorage/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)