From 8e6460f1b86ba67c1846fde6d5ae3345dbcc047c Mon Sep 17 00:00:00 2001 From: Alexis Asseman Date: Mon, 13 Nov 2023 11:15:21 -0800 Subject: [PATCH] fix: duration conversions Signed-off-by: Alexis Asseman --- tap-agent/src/agent.rs | 4 ++-- tap-agent/src/config.rs | 10 +++++----- tap-agent/src/tap/receipt_checks_adapter.rs | 8 ++++---- tap-agent/src/tap/sender_allocation_relationship.rs | 4 ++-- .../src/tap/sender_allocation_relationships_manager.rs | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tap-agent/src/agent.rs b/tap-agent/src/agent.rs index 5059f211..4b54c932 100644 --- a/tap-agent/src/agent.rs +++ b/tap-agent/src/agent.rs @@ -40,7 +40,7 @@ pub async fn start_agent(config: &'static config::Cli) { network_subgraph, config.ethereum.indexer_address, 1, - Duration::from_secs(config.network_subgraph.allocation_syncing_interval), + Duration::from_millis(config.network_subgraph.allocation_syncing_interval_ms), ); let escrow_subgraph = Box::leak(Box::new(SubgraphClient::new( @@ -64,7 +64,7 @@ pub async fn start_agent(config: &'static config::Cli) { let escrow_accounts = escrow_accounts( escrow_subgraph, config.ethereum.indexer_address, - Duration::from_secs(config.escrow_subgraph.escrow_syncing_interval), + Duration::from_millis(config.escrow_subgraph.escrow_syncing_interval_ms), ); // TODO: replace with a proper implementation once the gateway registry contract is ready diff --git a/tap-agent/src/config.rs b/tap-agent/src/config.rs index 5afe90a7..e48bb47d 100644 --- a/tap-agent/src/config.rs +++ b/tap-agent/src/config.rs @@ -179,7 +179,7 @@ pub struct NetworkSubgraph { default_value_t = 120_000, help = "Interval (in ms) for syncing indexer allocations from the network" )] - pub allocation_syncing_interval: u64, + pub allocation_syncing_interval_ms: u64, } #[derive(Clone, Debug, Args, Serialize, Deserialize, Default)] @@ -208,7 +208,7 @@ pub struct EscrowSubgraph { default_value_t = 120_000, help = "Interval (in ms) for syncing indexer escrow accounts from the escrow subgraph" )] - pub escrow_syncing_interval: u64, + pub escrow_syncing_interval_ms: u64, } #[derive(Clone, Debug, Args, Serialize, Deserialize, Default)] @@ -226,11 +226,11 @@ pub struct Tap { long, value_name = "rav-request-timestamp-buffer", env = "RAV_REQUEST_TIMESTAMP_BUFFER", - help = "Buffer (in ns) to add between the current time and the timestamp of the \ + help = "Buffer (in ms) to add between the current time and the timestamp of the \ last unaggregated fee when triggering a RAV request.", - default_value_t = 1_000_000_000 // 1 second + default_value_t = 1_000 // 1 second )] - pub rav_request_timestamp_buffer_ns: u64, + pub rav_request_timestamp_buffer_ms: u64, #[clap( long, value_name = "rav-request-timeout", diff --git a/tap-agent/src/tap/receipt_checks_adapter.rs b/tap-agent/src/tap/receipt_checks_adapter.rs index c4257ea1..0c0b0966 100644 --- a/tap-agent/src/tap/receipt_checks_adapter.rs +++ b/tap-agent/src/tap/receipt_checks_adapter.rs @@ -40,7 +40,7 @@ impl ReceiptChecksAdapter { sender_id, config.ethereum.indexer_address, escrow_subgraph, - config.escrow_subgraph.escrow_syncing_interval, + config.escrow_subgraph.escrow_syncing_interval_ms, ); Self { query_appraisals, @@ -137,7 +137,7 @@ impl ReceiptChecksAdapter { sender_address: Address, indexer_address: Address, escrow_subgraph: &'static SubgraphClient, - escrow_subgraph_polling_interval: u64, + escrow_subgraph_polling_interval_ms: u64, ) -> Eventual { #[derive(serde::Deserialize)] struct AllocationResponse { @@ -150,7 +150,7 @@ impl ReceiptChecksAdapter { transactions: Vec, } - timer(Duration::from_secs(escrow_subgraph_polling_interval)).map_with_retry( + timer(Duration::from_millis(escrow_subgraph_polling_interval_ms)).map_with_retry( move |_| async move { let response = escrow_subgraph .query::(&json!({ @@ -198,7 +198,7 @@ impl ReceiptChecksAdapter { "Failed to check the escrow redeem status for allocation {} and sender {}: {}", allocation_id, sender_address, error ); - sleep(Duration::from_secs(escrow_subgraph_polling_interval).div_f32(2.)) + sleep(Duration::from_millis(escrow_subgraph_polling_interval_ms).div_f32(2.)) }, ) } diff --git a/tap-agent/src/tap/sender_allocation_relationship.rs b/tap-agent/src/tap/sender_allocation_relationship.rs index 19d466ff..10551c7e 100644 --- a/tap-agent/src/tap/sender_allocation_relationship.rs +++ b/tap-agent/src/tap/sender_allocation_relationship.rs @@ -291,7 +291,7 @@ impl SenderAllocationRelationship { expected_rav, } = inner .tap_manager - .create_rav_request(inner.config.tap.rav_request_timestamp_buffer_ns) + .create_rav_request(inner.config.tap.rav_request_timestamp_buffer_ms * 1_000_000) .await?; // TODO: Request compression and response decompression. Also a fancy user agent? @@ -441,7 +441,7 @@ mod tests { }, tap: config::Tap { rav_request_trigger_value: 100, - rav_request_timestamp_buffer_ns: 1000, + rav_request_timestamp_buffer_ms: 1, rav_request_timeout_secs: 5, ..Default::default() }, diff --git a/tap-agent/src/tap/sender_allocation_relationships_manager.rs b/tap-agent/src/tap/sender_allocation_relationships_manager.rs index 7d401b59..f667dc56 100644 --- a/tap-agent/src/tap/sender_allocation_relationships_manager.rs +++ b/tap-agent/src/tap/sender_allocation_relationships_manager.rs @@ -329,7 +329,7 @@ mod tests { }, tap: config::Tap { rav_request_trigger_value: 100, - rav_request_timestamp_buffer_ns: 1000, + rav_request_timestamp_buffer_ms: 1, ..Default::default() }, ..Default::default()