@@ -21,10 +21,12 @@ pub(crate) struct EventContext {
2121 pub ( crate ) log_index : Option < u64 > ,
2222}
2323
24+ type CiphertextDigest = FixedBytes < 32 > ;
25+
2426#[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
2527struct DigestPair {
26- ciphertext_digest : FixedBytes < 32 > ,
27- ciphertext128_digest : FixedBytes < 32 > ,
28+ ciphertext_digest : CiphertextDigest ,
29+ ciphertext128_digest : CiphertextDigest ,
2830}
2931
3032#[ derive( Clone , Copy , Debug ) ]
@@ -77,7 +79,11 @@ enum HandleDisposition {
7779
7880pub ( crate ) struct DriftDetector {
7981 current_expected_senders : Vec < Address > ,
80- open_handles : HashMap < FixedBytes < 32 > , HandleState > ,
82+ /// Handles waiting for consensus or post-consensus grace. Bounded implicitly:
83+ /// `evict_stale` removes entries after `no_consensus_timeout_blocks` (no consensus)
84+ /// or `post_consensus_grace_blocks` (consensus reached). Steady-state size is
85+ /// proportional to handle throughput * max(timeout, grace) in blocks.
86+ open_handles : HashMap < CiphertextDigest , HandleState > ,
8187 host_chain_id : ChainId ,
8288 local_node_id : String ,
8389 no_consensus_timeout_blocks : u64 ,
@@ -250,7 +256,7 @@ impl DriftDetector {
250256
251257 async fn try_check_local_consensus (
252258 & mut self ,
253- handle : FixedBytes < 32 > ,
259+ handle : CiphertextDigest ,
254260 db_pool : & Pool < Postgres > ,
255261 ) -> anyhow:: Result < ( ) > {
256262 if self . replaying {
@@ -437,13 +443,6 @@ impl DriftDetector {
437443 }
438444
439445 pub ( crate ) fn flush_metrics ( & mut self ) {
440- if self . deferred_drift_detected == 0
441- && self . deferred_consensus_timeout == 0
442- && self . deferred_missing_submission == 0
443- {
444- return ;
445- }
446-
447446 DRIFT_DETECTED_COUNTER . inc_by ( self . deferred_drift_detected ) ;
448447 CONSENSUS_TIMEOUT_COUNTER . inc_by ( self . deferred_consensus_timeout ) ;
449448 MISSING_SUBMISSION_COUNTER . inc_by ( self . deferred_missing_submission ) ;
@@ -545,7 +544,7 @@ impl DriftDetector {
545544 }
546545 }
547546
548- fn finish_if_complete ( & mut self , handle : FixedBytes < 32 > ) {
547+ fn finish_if_complete ( & mut self , handle : CiphertextDigest ) {
549548 let Some ( state) = self . open_handles . get ( & handle) else {
550549 return ;
551550 } ;
@@ -742,9 +741,9 @@ mod tests {
742741 }
743742
744743 fn make_submission_event (
745- handle : FixedBytes < 32 > ,
746- ciphertext_digest : FixedBytes < 32 > ,
747- ciphertext128_digest : FixedBytes < 32 > ,
744+ handle : CiphertextDigest ,
745+ ciphertext_digest : CiphertextDigest ,
746+ ciphertext128_digest : CiphertextDigest ,
748747 sender : Address ,
749748 ) -> CiphertextCommits :: AddCiphertextMaterial {
750749 CiphertextCommits :: AddCiphertextMaterial {
@@ -757,9 +756,9 @@ mod tests {
757756 }
758757
759758 fn make_consensus_event (
760- handle : FixedBytes < 32 > ,
761- ciphertext_digest : FixedBytes < 32 > ,
762- ciphertext128_digest : FixedBytes < 32 > ,
759+ handle : CiphertextDigest ,
760+ ciphertext_digest : CiphertextDigest ,
761+ ciphertext128_digest : CiphertextDigest ,
763762 senders : Vec < Address > ,
764763 ) -> CiphertextCommits :: AddCiphertextMaterialConsensus {
765764 CiphertextCommits :: AddCiphertextMaterialConsensus {
@@ -782,9 +781,9 @@ mod tests {
782781
783782 fn submit_digest_event_and_drift_check (
784783 d : & mut DriftDetector ,
785- handle : FixedBytes < 32 > ,
786- ct : impl Into < FixedBytes < 32 > > ,
787- ct128 : impl Into < FixedBytes < 32 > > ,
784+ handle : CiphertextDigest ,
785+ ct : impl Into < CiphertextDigest > ,
786+ ct128 : impl Into < CiphertextDigest > ,
788787 sender : Address ,
789788 block : u64 ,
790789 ) {
@@ -808,8 +807,8 @@ mod tests {
808807
809808 fn make_consensus_state (
810809 block_number : u64 ,
811- ciphertext_digest : FixedBytes < 32 > ,
812- ciphertext128_digest : FixedBytes < 32 > ,
810+ ciphertext_digest : CiphertextDigest ,
811+ ciphertext128_digest : CiphertextDigest ,
813812 senders : Vec < Address > ,
814813 ) -> ConsensusState {
815814 ConsensusState {
0 commit comments