Expand description
BLS Agreggation Service crate.
§BLS Aggregation Service
§Introduction
The BLS Aggregation Service provides functionality to aggregate BLS signatures from multiple operators into a single aggregated signature. This is used by the Aggregator to verify the signatures of the operators and send the aggregated response once the quorum is reached or time expires. AVS developers can use it to define and manage tasks, set quorum requirements and integrate aggregated results into their smart contracts.
§Key Features
- BLS Signature Aggregation: Combines multiple individual signatures into a single verifiable aggregated signature.
- Quorum Verification: Ensures that the required participation threshold is reached for each quorum.
- Task Management: Allows initializing tasks and processing signatures for those tasks.
- Configurable Time Window: Allows defining waiting periods for signature collection.
§Main Components
TaskMetadata: Defines task parameters, including quorums and thresholds.TaskSignature: Contains an individual BLS signature for a specific task.ServiceHandle: Interface for sending tasks and signatures to the service.AggregateReceiver: Channel for receiving aggregated responses.BlsAggregatorService: The main service that manages tasks and aggregates signatures.
§Usage
When you initialize the BLS Aggregation Service, it returns a tuple of ServiceHandle and AggregateReceiver. The ServiceHandle is used to interact with the service. The available messages to send to the service are:
initialize_task(metadata: TaskMetadata): Initializes a new task. If you want to set a time to expiry for the task, you can use thewith_window_duration()method in a builder pattern.process_signature(task_signature: TaskSignature): Processes a signature for a task
The AggregateReceiver is used to receive aggregated responses from the service. To get the aggregated response, you can use the receive_aggregated_response() method.
Once a task is initialized, the service will start processing the task in a loop in the background. The service will wait for the quorum to be reached or the time to expire. Once the quorum is reached or the time expires, the service will aggregate the signatures and send the aggregated response to the AggregateReceiver.
§Initialize the Service
let (service_handle, mut aggregate_receiver) =
BlsAggregatorService::new(avs_registry_service, logger).start();§Initialize a Task
let metadata = TaskMetadata::new(
task_index,
block_number,
quorum_numbers,
quorum_threshold_percentages,
time_to_expiry,
);
service_handle.initialize_task(metadata).await.unwrap();§Process a Signature
let task_signature = TaskSignature::new(
task_index,
task_response_digest,
bls_signature,
operator_id,
);
service_handle.process_signature(task_signature).await.unwrap();§Receive an Aggregated Response
match aggregate_receiver.receive_aggregated_response().await {
Ok(aggregated_response) => {
// Handle the aggregated response
}
Err(e) => {
// Handle the error
}
}§Example Diagram
The following diagram shows the sequence of events when a user creates the BLS Aggregator Service, starts the service, and then initializes a task. The service processes two signatures from the operators and then aggregates them into a single aggregated signature.
sequenceDiagram
participant U as Aggregator
participant SH as ServiceHandle
participant AR as AggregateReceiver
participant BLS as BlsAggregatorService
note over U: The user creates the BLS Aggregator Service
U->>BLS: new()
note over U: The user start the service
U->>BLS: start()
note over BLS: Main loop is running in the background
note over SH: ServiceHandle is returned when the service is started
BLS->>SH: ServiceHandle
note over AR: AggregateReceiver is returned when the service is started
BLS->>AR: AggregateReceiver
U->>SH: initialize_task() # REVIEW
SH->>BLS: initialize_task()
BLS->>BLS: single_task_aggregator()
U->>SH: process_signature() # REVIEW
SH->>BLS: process_signature()
BLS->>BLS: verify_signature()
BLS->>BLS: check_if_stake_thresholds_met()
note over BLS: Threshold not reached yet
U->>SH: process_signature() # REVIEW
SH->>BLS: process_signature()
BLS->>BLS: verify_signature()
BLS->>BLS: check_if_stake_thresholds_met()
note over BLS: Threshold reached
BLS->>BLS: build_aggregated_response()
BLS->>AR: send_aggregated_response()
AR->>U: receive_aggregated_response()
§Testing
To run the integration tests, you can use the following command:
cargo test --package eigen-services-blsaggregation --lib -- bls_agg_test::integration_test --show-output