Skip to content

Commit

Permalink
rpc timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
carneiro-cw committed May 24, 2024
1 parent e3363d1 commit 9137934
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/bin/relayer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
mod importer_online;

use stratus::config::ExternalRelayerConfig;
use stratus::{GlobalServices, GlobalState};
use stratus::GlobalServices;
use stratus::GlobalState;

const TASK_NAME: &str = "relayer";

Expand Down Expand Up @@ -35,7 +36,7 @@ async fn run(config: ExternalRelayerConfig) -> anyhow::Result<()> {
None => {
tracing::info!("no pending block found");
tokio::time::sleep(backoff).await
},
}
};
}
}
23 changes: 18 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,29 @@ impl ExternalRelayerClientConfig {

#[derive(Parser, DebugAsJson, Clone, serde::Serialize)]
pub struct ExternalRelayerServerConfig {
#[arg(long = "relayer-db-url", env = "RELAYER_DB_URL")]
/// Postgresql url.
#[arg(long = "db-url", env = "DB_URL")]
pub url: String,
#[arg(long = "relayer-db-connections", env = "RELAYER_DB_CONNECTIONS", default_value = "5")]

/// Connections to database.
#[arg(long = "db-connections", env = "DB_CONNECTIONS", default_value = "5")]
pub connections: u32,
#[arg(long = "relayer-db-timeout", value_parser=parse_duration, env = "RELAYER_DB_TIMEOUT", default_value = "1s")]

/// Timeout to acquire connections to the database.
#[arg(long = "db-timeout", value_parser=parse_duration, env = "DB_TIMEOUT", default_value = "1s")]
pub acquire_timeout: Duration,
#[arg(long = "relayer-forward-to", env = "RELAYER_FORWARD_TO")]

/// RPC to forward to.
#[arg(long = "forward-to", env = "RELAYER_FORWARD_TO")]
pub forward_to: String,
#[arg(long = "relayer-db-backoff", value_parser=parse_duration, env = "RELAYER_DB_BACKOFF", default_value = "10ms")]

/// Backoff.
#[arg(long = "backoff", value_parser=parse_duration, env = "BACKOFF", default_value = "10ms")]
pub backoff: Duration,

/// RPC response timeout.
#[arg(long = "rpc-timeout", value_parser=parse_duration, env = "RPC_TIMEOUT", default_value = "2s")]
pub rpc_timeout: Duration,
}

impl ExternalRelayerServerConfig {
Expand Down
2 changes: 1 addition & 1 deletion src/eth/transaction_relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl ExternalRelayer {
.expect("should not fail to create pgpool");

Ok(Self {
substrate_chain: BlockchainClient::new_http(&config.forward_to).await?,
substrate_chain: BlockchainClient::new_http(&config.forward_to, config.rpc_timeout).await?,
pool,
})
}
Expand Down
5 changes: 4 additions & 1 deletion src/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ where
runtime.block_on(spawn_signal_handler())?;

// init tracing
runtime.block_on(infra::init_tracing(config.common().tracing_url.as_ref(), !config.common().disable_tokio_console));
runtime.block_on(infra::init_tracing(
config.common().tracing_url.as_ref(),
!config.common().disable_tokio_console,
));

Ok(Self {
config,
Expand Down

0 comments on commit 9137934

Please sign in to comment.