@@ -125,6 +125,15 @@ use rand::Rng;
125125use std:: sync:: { Arc , OnceLock } ;
126126use tracing:: { debug, warn} ;
127127
128+ /// Which marshal cache a verified coded block should land in.
129+ #[ derive( Clone , Copy , Debug ) ]
130+ enum CodingPersistMode {
131+ /// Write to `verified_blocks` via `Mailbox::verified`.
132+ Verified ,
133+ /// Write to `notarized_blocks` via `Mailbox::certified`.
134+ Certified ,
135+ }
136+
128137/// The [`CodingConfig`] used for genesis blocks. These blocks are never broadcasted in
129138/// the proposal phase, and thus the configuration is irrelevant.
130139const GENESIS_CODING_CONFIG : CodingConfig = CodingConfig {
@@ -299,6 +308,7 @@ where
299308 consensus_context : Context < Commitment , <Z :: Scheme as CertificateScheme >:: PublicKey > ,
300309 commitment : Commitment ,
301310 prefetched_block : Option < CodedBlock < B , C , H > > ,
311+ persist : CodingPersistMode ,
302312 ) -> oneshot:: Receiver < bool > {
303313 let mut marshal = self . marshal . clone ( ) ;
304314 let mut application = self . application . clone ( ) ;
@@ -424,9 +434,15 @@ where
424434 is_valid = validity_request => is_valid,
425435 } ;
426436 timer. observe ( ) ;
427- if application_valid && !marshal. verified ( round, block) . await {
428- debug ! ( ?round, "marshal unable to accept block" ) ;
429- return ;
437+ if application_valid {
438+ let persisted = match persist {
439+ CodingPersistMode :: Verified => marshal. verified ( round, block) . await ,
440+ CodingPersistMode :: Certified => marshal. certified ( round, block) . await ,
441+ } ;
442+ if !persisted {
443+ debug ! ( ?round, "marshal unable to accept block" ) ;
444+ return ;
445+ }
430446 }
431447 tx. send_lossy ( application_valid) ;
432448 } ) ;
@@ -779,7 +795,8 @@ where
779795 // Kick off deferred verification early to hide verification latency behind
780796 // shard validity checks and network latency for collecting votes.
781797 let round = consensus_context. round ;
782- let task = self . deferred_verify ( consensus_context, payload, None ) ;
798+ let task =
799+ self . deferred_verify ( consensus_context, payload, None , CodingPersistMode :: Verified ) ;
783800 self . verification_tasks . insert ( round, payload, task) ;
784801
785802 match scheme. me ( ) {
@@ -917,18 +934,13 @@ where
917934
918935 // Use the block's embedded context for verification, passing the
919936 // prefetched block to avoid fetching it again inside deferred_verify.
920- let block_for_certify = block. clone ( ) ;
921- let verify_rx = marshaled. deferred_verify ( embedded_context, payload, Some ( block) ) ;
937+ let verify_rx = marshaled. deferred_verify (
938+ embedded_context,
939+ payload,
940+ Some ( block) ,
941+ CodingPersistMode :: Certified ,
942+ ) ;
922943 if let Ok ( result) = verify_rx. await {
923- if result
924- && !marshaled
925- . marshal
926- . certified ( round, block_for_certify)
927- . await
928- {
929- debug ! ( ?round, "marshal unable to accept certified block" ) ;
930- return ;
931- }
932944 tx. send_lossy ( result) ;
933945 }
934946 } ) ;
0 commit comments