diff --git a/rust/main/agents/relayer/src/msg/processor.rs b/rust/main/agents/relayer/src/msg/processor.rs index 59ec32cb69..21c6b1def1 100644 --- a/rust/main/agents/relayer/src/msg/processor.rs +++ b/rust/main/agents/relayer/src/msg/processor.rs @@ -86,24 +86,29 @@ impl ForwardBackwardIterator { loop { let high_nonce_message_status = self.high_nonce_iter.try_get_next_nonce(metrics)?; let low_nonce_message_status = self.low_nonce_iter.try_get_next_nonce(metrics)?; - // Always prioritize the high nonce message + match (high_nonce_message_status, low_nonce_message_status) { - // Keep iterating if only processed messages are found + // Always prioritize advancing the the high nonce iterator, as + // we have a preference for higher nonces (MessageStatus::Processed, _) => { self.high_nonce_iter.iterate(); } - (_, MessageStatus::Processed) => { - self.low_nonce_iter.iterate(); - } - // Otherwise return - either a processable message or nothing to process (MessageStatus::Processable(high_nonce_message), _) => { self.high_nonce_iter.iterate(); return Ok(Some(high_nonce_message)); } + + // Low nonce messages are only processed if the high nonce iterator + // can't make any progress + (_, MessageStatus::Processed) => { + self.low_nonce_iter.iterate(); + } (_, MessageStatus::Processable(low_nonce_message)) => { self.low_nonce_iter.iterate(); return Ok(Some(low_nonce_message)); } + + // If both iterators give us unindexed messages, there are no messages at the moment (MessageStatus::Unindexed, MessageStatus::Unindexed) => return Ok(None), } // This loop may iterate through millions of processed messages, blocking the runtime. @@ -157,7 +162,7 @@ impl DirectionalNonceIterator { } fn try_get_next_nonce( - &mut self, + &self, metrics: &MessageProcessorMetrics, ) -> Result> { if let Some(message) = self.indexed_message_with_nonce()? { diff --git a/rust/sealevel/programs/hyperlane-sealevel-token-collateral/src/plugin.rs b/rust/sealevel/programs/hyperlane-sealevel-token-collateral/src/plugin.rs index 0fc224667e..ff8cf8dd7b 100644 --- a/rust/sealevel/programs/hyperlane-sealevel-token-collateral/src/plugin.rs +++ b/rust/sealevel/programs/hyperlane-sealevel-token-collateral/src/plugin.rs @@ -444,7 +444,7 @@ impl HyperlaneSealevelTokenPlugin for CollateralPlugin { vec![ AccountMeta::new_readonly(token.plugin_data.spl_token_program, false).into(), AccountMeta::new_readonly(spl_associated_token_account::id(), false).into(), - AccountMeta::new(token.plugin_data.mint, false).into(), + AccountMeta::new_readonly(token.plugin_data.mint, false).into(), AccountMeta::new(recipient_associated_token_account, false).into(), AccountMeta::new(ata_payer_account_key, false).into(), AccountMeta::new(token.plugin_data.escrow, false).into(),