9292 // Helper to verify consensus is reached
9393 pub async fn verify_consensus ( & mut self ) {
9494 while let Some ( result) = self . consensus_rx . recv ( ) . await {
95+ // Confirm that consensus was reached
9596 assert ! ( result. reached_consensus, "Consensus was not reached" ) ;
97+
98+ // Confirm that the aggregated message contains a quorum of signatures
99+ let aggregated_commit = result
100+ . aggregated_commit
101+ . expect ( "If consensus was reached, this exists" ) ;
102+ assert ! (
103+ aggregated_commit. signatures( ) . len( ) as u64
104+ >= ( self . tester. size as u64 - self . tester. size. get_f( ) )
105+ ) ;
96106 }
97107 }
98108}
@@ -129,7 +139,7 @@ where
129139 // Track mapping from operator id to the respective manager
130140 managers : HashMap < OperatorId , Arc < QbftManager < ManualSlotClock > > > ,
131141 // The size of the committee
132- size : CommitteeSize ,
142+ pub size : CommitteeSize ,
133143 // Mapping of the data hash to the data identifier. This is to send data to the proper instance
134144 identifiers : HashMap < u64 , D :: Id > ,
135145 // Mapping from data to the results of the consensus
@@ -367,15 +377,6 @@ where
367377 drop ( consensus_tx) ;
368378 }
369379
370- fn signed_to_wrapped ( & self , signed : SignedSSVMessage ) -> WrappedQbftMessage {
371- let deser_qbft = QbftMessage :: from_ssz_bytes ( signed. ssv_message ( ) . data ( ) )
372- . expect ( "We have a valid qbft message" ) ;
373- WrappedQbftMessage {
374- signed_message : signed,
375- qbft_message : deser_qbft,
376- }
377- }
378-
379380 // Once an instance has completed, we want to record what happened
380381 fn handle_completion ( & self , hash : Hash256 , msg : Result < Completed < D > , QbftError > ) {
381382 // Decrement the amount of instances running for this data
@@ -415,6 +416,16 @@ where
415416 finished
416417 }
417418
419+ // Convert a signed ssv message into a wrapped ssv message
420+ fn signed_to_wrapped ( & self , signed : SignedSSVMessage ) -> WrappedQbftMessage {
421+ let deser_qbft = QbftMessage :: from_ssz_bytes ( signed. ssv_message ( ) . data ( ) )
422+ . expect ( "We have a valid qbft message" ) ;
423+ WrappedQbftMessage {
424+ signed_message : signed,
425+ qbft_message : deser_qbft,
426+ }
427+ }
428+
418429 // Process and send a network message to the correct instance
419430 fn process_network_message ( & self , mut wrapped_msg : WrappedQbftMessage ) {
420431 let sender_operator_id = wrapped_msg
@@ -424,6 +435,17 @@ where
424435 . expect ( "One signer" ) ;
425436 let sender_operator_id = OperatorId :: from ( * sender_operator_id) ;
426437
438+ // If this is a decided message, want to record it in the consensus results.
439+ // We know this is an aggregated commit if the number of signatures is > 1
440+ if wrapped_msg. signed_message . signatures ( ) . len ( ) > 1 {
441+ let mut results_write = self . results . write ( ) . unwrap ( ) ;
442+ let results = results_write
443+ . get_mut ( & wrapped_msg. qbft_message . root )
444+ . expect ( "Value exists" ) ;
445+ results. aggregated_commit = Some ( wrapped_msg. signed_message ) ;
446+ return ;
447+ }
448+
427449 // Now we have a message ready to be sent back into the instance. Get the id
428450 // corresponding to the message.
429451 let data_id = self
@@ -500,6 +522,7 @@ pub struct ConsensusResult {
500522 min_for_consensus : u64 ,
501523 successful : u64 ,
502524 timed_out : u64 ,
525+ aggregated_commit : Option < SignedSSVMessage > ,
503526}
504527
505528#[ cfg( test) ]
0 commit comments