@@ -7,7 +7,7 @@ use aligned_sdk::core::types::{
77 ProofInvalidReason , ProvingSystemId , ValidityResponseMessage , VerificationData ,
88} ;
99use ethers:: types:: U256 ;
10- use log:: { debug, info , warn} ;
10+ use log:: { debug, warn} ;
1111use tokio:: sync:: MutexGuard ;
1212
1313pub ( crate ) async fn verify ( verification_data : & VerificationData ) -> bool {
@@ -85,50 +85,44 @@ pub(crate) async fn filter_disabled_verifiers(
8585 disabled_verifiers : MutexGuard < ' _ , U256 > ,
8686) -> BatchQueue {
8787 let mut removed_entries = Vec :: new ( ) ;
88- let filtered_batch_queue = batch_queue
89- . iter ( )
90- . filter_map ( |( entry, entry_priority) | {
91- info ! (
92- "Verifying proof for proving system {}" ,
93- entry
94- . nonced_verification_data
95- . verification_data
96- . proving_system
88+ let mut filtered_batch_queue = BatchQueue :: new ( ) ;
89+ for ( entry, entry_priority) in batch_queue. iter ( ) {
90+ let verification_data = & entry. nonced_verification_data . verification_data ;
91+ if is_verifier_disabled ( * disabled_verifiers, verification_data) {
92+ warn ! (
93+ "Verifier for proving system {} is now disabled, removing proofs from batch" ,
94+ verification_data. proving_system
9795 ) ;
98- let verification_data = & entry. nonced_verification_data . verification_data ;
99- if !is_verifier_disabled ( * disabled_verifiers, verification_data)
100- && !removed_entries
101- . iter ( )
102- . any ( |e : & BatchQueueEntry | e. sender == entry. sender )
103- {
104- Some ( ( entry. clone ( ) , entry_priority. clone ( ) ) )
105- } else {
106- warn ! (
107- "Verifier for proving system {} is now disabled, removing proofs from batch" ,
108- verification_data. proving_system
109- ) ;
110- removed_entries. push ( entry. clone ( ) ) ;
111-
112- None
96+ let ws_sink = entry. messaging_sink . as_ref ( ) ;
97+ if let Some ( ws_sink) = ws_sink {
98+ send_message (
99+ ws_sink. clone ( ) ,
100+ ValidityResponseMessage :: InvalidProof ( ProofInvalidReason :: DisabledVerifier (
101+ entry
102+ . nonced_verification_data
103+ . verification_data
104+ . proving_system ,
105+ ) ) ,
106+ )
107+ . await ;
113108 }
114- } )
115- . collect ( ) ;
116-
117- // Send invalid proof messages to the clients whose proofs were removed.
118- // This is outside the loop because we needed to use await to send the message and we can't do that inside the filter_map.
119- for entry in removed_entries {
120- let ws_sink = entry. messaging_sink . as_ref ( ) ;
121- if let Some ( ws_sink) = ws_sink {
122- send_message (
123- ws_sink. clone ( ) ,
124- ValidityResponseMessage :: InvalidProof ( ProofInvalidReason :: DisabledVerifier (
125- entry
126- . nonced_verification_data
127- . verification_data
128- . proving_system ,
129- ) ) ,
130- )
131- . await ;
109+ removed_entries. push ( entry. clone ( ) ) ;
110+ continue ;
111+ } else if removed_entries
112+ . iter ( )
113+ . any ( |e : & BatchQueueEntry | e. sender == entry. sender )
114+ {
115+ let ws_sink = entry. messaging_sink . as_ref ( ) ;
116+ if let Some ( ws_sink) = ws_sink {
117+ send_message (
118+ ws_sink. clone ( ) ,
119+ ValidityResponseMessage :: InvalidProof ( ProofInvalidReason :: PriorProofInvalidity ) ,
120+ )
121+ . await ;
122+ continue ;
123+ }
124+ } else {
125+ filtered_batch_queue. push ( entry. clone ( ) , entry_priority. clone ( ) ) ;
132126 }
133127 }
134128 filtered_batch_queue
0 commit comments