From 2ace873f9e94401f4f847682bc91a509ed495d3b Mon Sep 17 00:00:00 2001 From: Asa Oines Date: Fri, 26 May 2023 15:28:37 -0400 Subject: [PATCH] Gracefully handle inconsistent RPC providers in ForwardMessageSyncCursor (#2302) ### Description RPC providers can be inconsistent. When a message has just been inserted into the mailbox, it's possible that one Mailbox.count() query returns N and a subsequent query returns N-1. ### Drive-by changes None --- rust/hyperlane-base/src/contract_sync/cursor.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rust/hyperlane-base/src/contract_sync/cursor.rs b/rust/hyperlane-base/src/contract_sync/cursor.rs index 7b640624d..64de50d24 100644 --- a/rust/hyperlane-base/src/contract_sync/cursor.rs +++ b/rust/hyperlane-base/src/contract_sync/cursor.rs @@ -121,7 +121,10 @@ impl ForwardMessageSyncCursor { Ok(Some((from, to, Duration::from_secs(0)))) } Ordering::Greater => { - panic!("Cursor is ahead of mailbox, this should never happen."); + // Providers may be internally inconsistent, e.g. RPC request A could hit a node + // whose tip is N and subsequent RPC request B could hit a node whose tip is < N. + debug!("Cursor count is greater than Mailbox count"); + Ok(None) } } }