Skip to main content

Crate eigen_services_blsaggregation

Crate eigen_services_blsaggregation 

Source
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

§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:

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).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

Modules§

bls_agg
bls_aggregation_service_error
bls_aggregation_service_response