From d101e29a0bb9d63c374705fe4d525d3399cf86a5 Mon Sep 17 00:00:00 2001 From: shiyasmohd Date: Sat, 1 Feb 2025 19:24:02 +0530 Subject: [PATCH 1/3] fix: check allocation id blocked before sending rav req --- crates/tap-agent/src/agent/sender_account.rs | 6 +++++- crates/tap-agent/src/tracker/generic_tracker.rs | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/tap-agent/src/agent/sender_account.rs b/crates/tap-agent/src/agent/sender_account.rs index 33436b37..903179f3 100644 --- a/crates/tap-agent/src/agent/sender_account.rs +++ b/crates/tap-agent/src/agent/sender_account.rs @@ -775,7 +775,11 @@ impl Actor for SenderAccount { "Total fee greater than the trigger value. Triggering RAV request" ); state.rav_request_for_heaviest_allocation().await - } else if counter_greater_receipt_limit { + } else if counter_greater_receipt_limit + && !state + .sender_fee_tracker + .is_allocation_id_blocked(&allocation_id) + { tracing::debug!( total_counter_for_allocation, rav_request_receipt_limit = state.config.rav_request_receipt_limit, diff --git a/crates/tap-agent/src/tracker/generic_tracker.rs b/crates/tap-agent/src/tracker/generic_tracker.rs index d81a392b..2827f0e8 100644 --- a/crates/tap-agent/src/tracker/generic_tracker.rs +++ b/crates/tap-agent/src/tracker/generic_tracker.rs @@ -214,6 +214,13 @@ where }); } + pub fn is_allocation_id_blocked(&self, address: &Address) -> bool { + self.id_to_fee + .get(address) + .map(|v| v.blocked) + .expect("Allocation ID not found") + } + pub fn can_trigger_rav(&self, allocation_id: Address) -> bool { self.id_to_fee .get(&allocation_id) From 2aa3252595f74ad4c30cf9deff6f6cc5d216ca52 Mon Sep 17 00:00:00 2001 From: shiyasmohd Date: Tue, 4 Feb 2025 23:14:13 +0530 Subject: [PATCH 2/3] refactor: use logging instead of panic when allocation id is not found --- crates/tap-agent/src/tracker/generic_tracker.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/tap-agent/src/tracker/generic_tracker.rs b/crates/tap-agent/src/tracker/generic_tracker.rs index 2827f0e8..c3f29be4 100644 --- a/crates/tap-agent/src/tracker/generic_tracker.rs +++ b/crates/tap-agent/src/tracker/generic_tracker.rs @@ -8,6 +8,7 @@ use std::{ }; use thegraph_core::alloy::primitives::Address; +use tracing::warn; use super::{ global_tracker::GlobalTracker, AllocationStats, DefaultFromExtra, DurationInfo, SenderFeeStats, @@ -215,10 +216,13 @@ where } pub fn is_allocation_id_blocked(&self, address: &Address) -> bool { - self.id_to_fee - .get(address) - .map(|v| v.blocked) - .expect("Allocation ID not found") + match self.id_to_fee.get(address).map(|v| v.blocked) { + Some(val) => val, + None => { + warn!("Allocation ID not found in the tracker"); + false + } + } } pub fn can_trigger_rav(&self, allocation_id: Address) -> bool { From b217c43440685705dddc0aaa6751ce4f410c681b Mon Sep 17 00:00:00 2001 From: shiyasmohd Date: Tue, 4 Feb 2025 23:18:14 +0530 Subject: [PATCH 3/3] refactor: add allocation address to log --- crates/tap-agent/src/tracker/generic_tracker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tap-agent/src/tracker/generic_tracker.rs b/crates/tap-agent/src/tracker/generic_tracker.rs index c3f29be4..2ec4c6d6 100644 --- a/crates/tap-agent/src/tracker/generic_tracker.rs +++ b/crates/tap-agent/src/tracker/generic_tracker.rs @@ -219,7 +219,7 @@ where match self.id_to_fee.get(address).map(|v| v.blocked) { Some(val) => val, None => { - warn!("Allocation ID not found in the tracker"); + warn!("Allocation ID {} not found in the tracker", address); false } }