@@ -2,7 +2,7 @@ use std::ops::Add;
22
33use async_trait:: async_trait;
44use eyre:: { bail, Result } ;
5- use tracing:: { debug, instrument, trace} ;
5+ use tracing:: { debug, instrument, trace, warn } ;
66
77use hyperlane_core:: {
88 identifiers:: UniqueIdentifier , Decode , Encode , GasPaymentKey , HyperlaneDomain ,
@@ -94,20 +94,52 @@ impl HyperlaneRocksDB {
9494 trace ! ( hyp_message=?message, "Message already stored in db" ) ;
9595 // Still update max_seen_nonce to track indexer progress, even if message
9696 // was already stored by relay API
97- self . try_update_max_seen_message_nonce ( message. nonce ) ?;
97+ if let Err ( e) = self . try_update_max_seen_message_nonce ( message. nonce ) {
98+ warn ! (
99+ nonce = message. nonce,
100+ error = %e,
101+ "Failed to update max_seen_nonce for duplicate message (non-fatal)"
102+ ) ;
103+ }
98104
99105 // If the stored block number is 0 (from relay API) and we now have a real block number,
100106 // update it with the actual value from the indexer
101- if self
102- . retrieve_dispatched_block_number_by_nonce ( & message. nonce ) ?
103- . unwrap_or ( 0 )
104- == 0
105- && dispatched_block_number > 0
106- {
107- self . store_dispatched_block_number_by_nonce (
108- & message. nonce ,
109- & dispatched_block_number,
110- ) ?;
107+ match self . retrieve_dispatched_block_number_by_nonce ( & message. nonce ) {
108+ Ok ( Some ( stored_block) ) if stored_block == 0 && dispatched_block_number > 0 => {
109+ if let Err ( e) = self . store_dispatched_block_number_by_nonce (
110+ & message. nonce ,
111+ & dispatched_block_number,
112+ ) {
113+ warn ! (
114+ nonce = message. nonce,
115+ error = %e,
116+ "Failed to update block number for duplicate message (non-fatal)"
117+ ) ;
118+ }
119+ }
120+ Ok ( None ) if dispatched_block_number > 0 => {
121+ // No stored block number (shouldn't happen for duplicates, but handle it)
122+ if let Err ( e) = self . store_dispatched_block_number_by_nonce (
123+ & message. nonce ,
124+ & dispatched_block_number,
125+ ) {
126+ warn ! (
127+ nonce = message. nonce,
128+ error = %e,
129+ "Failed to store block number for duplicate message (non-fatal)"
130+ ) ;
131+ }
132+ }
133+ Err ( e) => {
134+ warn ! (
135+ nonce = message. nonce,
136+ error = %e,
137+ "Failed to retrieve block number for duplicate message (non-fatal)"
138+ ) ;
139+ }
140+ _ => {
141+ // Block number already set or dispatched_block_number is 0, nothing to do
142+ }
111143 }
112144
113145 return Ok ( false ) ;
0 commit comments