From f2fc9f1b71316229c55964d4e2bd11466c78e80e Mon Sep 17 00:00:00 2001 From: kamiyaa Date: Wed, 15 Jan 2025 14:47:27 +0800 Subject: [PATCH] add global constant for how many queues an OpSubmitter has --- rust/main/agents/relayer/src/msg/op_queue.rs | 1 - rust/main/agents/relayer/src/msg/op_submitter.rs | 2 ++ rust/main/agents/relayer/src/server/message_retry.rs | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rust/main/agents/relayer/src/msg/op_queue.rs b/rust/main/agents/relayer/src/msg/op_queue.rs index 10b0fad27e..bd963c2df7 100644 --- a/rust/main/agents/relayer/src/msg/op_queue.rs +++ b/rust/main/agents/relayer/src/msg/op_queue.rs @@ -72,7 +72,6 @@ impl OpQueue { // The other consideration is whether to put the channel receiver in the OpQueue or in a dedicated task // that also holds an Arc to the Mutex. For simplicity, we'll put it in the OpQueue for now. let mut message_retry_requests = vec![]; - // we only need to lock self.retry_receiver once { let mut retry_receiver = self.retry_receiver.lock().await; while let Ok(retry_request) = retry_receiver.try_recv() { diff --git a/rust/main/agents/relayer/src/msg/op_submitter.rs b/rust/main/agents/relayer/src/msg/op_submitter.rs index 84e26c6f56..41cf385223 100644 --- a/rust/main/agents/relayer/src/msg/op_submitter.rs +++ b/rust/main/agents/relayer/src/msg/op_submitter.rs @@ -37,6 +37,8 @@ use crate::server::MessageRetryRequest; use super::op_queue::OpQueue; use super::op_queue::OperationPriorityQueue; +pub const SUBMITTER_QUEUE_COUNT: usize = 3; + /// SerialSubmitter accepts operations over a channel. It is responsible for /// executing the right strategy to deliver those messages to the destination /// chain. It is designed to be used in a scenario allowing only one diff --git a/rust/main/agents/relayer/src/server/message_retry.rs b/rust/main/agents/relayer/src/server/message_retry.rs index d6a26cf0c8..ac450d847f 100644 --- a/rust/main/agents/relayer/src/server/message_retry.rs +++ b/rust/main/agents/relayer/src/server/message_retry.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use crate::settings::matching_list::MatchingList; +use crate::{msg::op_submitter::SUBMITTER_QUEUE_COUNT, settings::matching_list::MatchingList}; use axum::{extract::State, routing, Json, Router}; use derive_new::new; use serde::{Deserialize, Serialize}; @@ -52,7 +52,8 @@ async fn retry_message( // Create a channel that can hold each chain's SerialSubmitter // message retry responses. // 3 queues for each chain (prepare, submit, confirm) - let (transmitter, mut receiver) = mpsc::channel(3 * state.destination_chains); + let (transmitter, mut receiver) = + mpsc::channel(SUBMITTER_QUEUE_COUNT * state.destination_chains); state .retry_request_transmitter .send(Arc::new(MessageRetryRequest {