pub struct BlsAggregatorService<A>where
A: Clone + AvsRegistryService,{
pub aggregated_response_receiver: Arc<Mutex<UnboundedReceiver<Result<BlsAggregationServiceResponse, BlsAggregationServiceError>>>>,
/* private fields */
}
Expand description
The BLS Aggregator Service main struct
Fields§
§aggregated_response_receiver: Arc<Mutex<UnboundedReceiver<Result<BlsAggregationServiceResponse, BlsAggregationServiceError>>>>
Implementations§
Source§impl<A: AvsRegistryService + Send + Sync + Clone + 'static> BlsAggregatorService<A>
impl<A: AvsRegistryService + Send + Sync + Clone + 'static> BlsAggregatorService<A>
Sourcepub fn new(avs_registry_service: A, logger: SharedLogger) -> Self
pub fn new(avs_registry_service: A, logger: SharedLogger) -> Self
Creates a new instance of the BlsAggregatorService with the given AVS registry service
Creates a tokio unbounded_channel to send and received aggregated responses.
§Arguments
avs_registry_service
- The AVS registry servicelogger
- Logger to log messages
Sourcepub async fn initialize_new_task(
&self,
task_index: TaskIndex,
task_created_block: u32,
quorum_nums: Vec<u8>,
quorum_threshold_percentages: QuorumThresholdPercentages,
time_to_expiry: Duration,
) -> Result<(), BlsAggregationServiceError>
pub async fn initialize_new_task( &self, task_index: TaskIndex, task_created_block: u32, quorum_nums: Vec<u8>, quorum_threshold_percentages: QuorumThresholdPercentages, time_to_expiry: Duration, ) -> Result<(), BlsAggregationServiceError>
Creates a new task meant to process new signed task responses for a task tokio channel.
§Arguments
task_index
- The index of the tasktask_created_block
- The block number at which the task was createdquorum_nums
- The quorum numbers for the taskquorum_threshold_percentages
- The quorum threshold percentages for the tasktime_to_expiry
- The timeout for the task reader to expire
§Error
Returns error if the task index already exists
Sourcepub async fn initialize_new_task_with_window(
&self,
task_index: TaskIndex,
task_created_block: u32,
quorum_nums: Vec<u8>,
quorum_threshold_percentages: QuorumThresholdPercentages,
time_to_expiry: Duration,
window_duration: Duration,
) -> Result<(), BlsAggregationServiceError>
pub async fn initialize_new_task_with_window( &self, task_index: TaskIndex, task_created_block: u32, quorum_nums: Vec<u8>, quorum_threshold_percentages: QuorumThresholdPercentages, time_to_expiry: Duration, window_duration: Duration, ) -> Result<(), BlsAggregationServiceError>
Creates a new task meant to process new signed task responses for a task tokio channel.
§Arguments
task_index
- The index of the tasktask_created_block
- The block number at which the task was createdquorum_nums
- The quorum numbers for the taskquorum_threshold_percentages
- The quorum threshold percentages for the tasktime_to_expiry
- The timeout for the task reader to expirewindow_duration
- The duration of the window to wait for signatures after quorum is reached
§Error
Returns error if the task index already exists
Sourcepub async fn process_new_signature(
&self,
task_index: TaskIndex,
task_response_digest: TaskResponseDigest,
bls_signature: Signature,
operator_id: FixedBytes<32>,
) -> Result<(), BlsAggregationServiceError>
pub async fn process_new_signature( &self, task_index: TaskIndex, task_response_digest: TaskResponseDigest, bls_signature: Signature, operator_id: FixedBytes<32>, ) -> Result<(), BlsAggregationServiceError>
Processes signatures received from the channel and sends the signed task response to the task channel.
§Arguments
task_index
- The index of the tasktask_response_digest
- The digest of the task responsebls_signature
- The BLS signature of the task responseoperator_id
- The operator ID of the operator that signed the task response
§Errors
Returns error:
TaskNotFound
- If the task is not found.ChannelError
- If there is an error while sending the task through the channel.SignatureVerificationError
- If the signature verification fails.
Sourcepub async fn single_task_aggregator(
avs_registry_service: A,
task_index: TaskIndex,
task_created_block: u32,
quorum_nums: Vec<u8>,
quorum_threshold_percentages: QuorumThresholdPercentages,
time_to_expiry: Duration,
aggregated_response_sender: UnboundedSender<Result<BlsAggregationServiceResponse, BlsAggregationServiceError>>,
signatures_rx: UnboundedReceiver<SignedTaskResponseDigest>,
window_duration: Duration,
logger: SharedLogger,
) -> Result<(), BlsAggregationServiceError>
pub async fn single_task_aggregator( avs_registry_service: A, task_index: TaskIndex, task_created_block: u32, quorum_nums: Vec<u8>, quorum_threshold_percentages: QuorumThresholdPercentages, time_to_expiry: Duration, aggregated_response_sender: UnboundedSender<Result<BlsAggregationServiceResponse, BlsAggregationServiceError>>, signatures_rx: UnboundedReceiver<SignedTaskResponseDigest>, window_duration: Duration, logger: SharedLogger, ) -> Result<(), BlsAggregationServiceError>
Processes each signed task responses given a task_index for a single task.
It reads the signed task responses from the receiver channel and aggregates them.
- If the quorum threshold is met, it sends the aggregated response to the aggregated response sender.
- If the time to expiry is reached, it sends a task expired error to the aggregated response sender.
- If the signature is incorrect, it sends an incorrect signature error to error channel.
§Arguments
task_index
- The index of the tasktask_created_block
- The block number at which the task was createdquorum_nums
- The quorum numbers for the taskquorum_threshold_percentages
- The quorum threshold percentages for the tasktime_to_expiry
- The timeout for the task reader to expireaggregated_response_sender
- The sender channel for the aggregated responsessignatures_rx
- The receiver channel for the signed task responseswindow_duration
- The duration of the window to wait for signatures after quorum is reachedlogger
- The logger to log messages.
Sourcepub async fn verify_signature(
task_index: TaskIndex,
signed_task_response_digest: &SignedTaskResponseDigest,
operator_avs_state: &HashMap<FixedBytes<32>, OperatorAvsState>,
logger: SharedLogger,
) -> Result<(), SignatureVerificationError>
pub async fn verify_signature( task_index: TaskIndex, signed_task_response_digest: &SignedTaskResponseDigest, operator_avs_state: &HashMap<FixedBytes<32>, OperatorAvsState>, logger: SharedLogger, ) -> Result<(), SignatureVerificationError>
Verifies the signature of the task response given a operator_avs_state
.
If the signature is correct, it returns Ok(())
, otherwise it returns an error.
§Arguments
task_index
- The index of the tasksigned_task_response_digest
- The signed task response digestoperator_avs_state
- A hashmap containing the staked of all the operator indexed by operator_id. This is used to get theoperator_state
to obtain the operator public key.logger
- The logger to log messages.
§Error
Returns error:
SignatureVerificationError::OperatorNotFound
if the operator is not found,SignatureVerificationError::OperatorPublicKeyNotFound
if the operator public key is not found,SignatureVerificationError::IncorrectSignature
if the signature is incorrect.
Sourcepub fn check_if_stake_thresholds_met(
signed_stake_per_quorum: &HashMap<u8, U256>,
total_stake_per_quorum: &HashMap<u8, U256>,
quorum_threshold_percentages_map: &HashMap<u8, QuorumThresholdPercentage>,
) -> bool
pub fn check_if_stake_thresholds_met( signed_stake_per_quorum: &HashMap<u8, U256>, total_stake_per_quorum: &HashMap<u8, U256>, quorum_threshold_percentages_map: &HashMap<u8, QuorumThresholdPercentage>, ) -> bool
Checks if the stake thresholds are met for the given set of quorum members.
§Arguments
signed_stake_per_quorum
- The signed stake per quorum.total_stake_per_quorum
- The total stake per quorum.quorum_threshold_percentages_map
- The quorum threshold percentages map, containing the quorum id as a key and its corresponding quorum threshold percentage.
§Returns
Returns true
if the stake thresholds are met for all the members, otherwise false
.
Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for BlsAggregatorService<A>where
A: Freeze,
impl<A> !RefUnwindSafe for BlsAggregatorService<A>
impl<A> Send for BlsAggregatorService<A>where
A: Send,
impl<A> Sync for BlsAggregatorService<A>where
A: Sync,
impl<A> Unpin for BlsAggregatorService<A>where
A: Unpin,
impl<A> !UnwindSafe for BlsAggregatorService<A>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.