Skip to content

Commit d41de60

Browse files
committed
feat: add option to avoid denying senders
1 parent abcd7fe commit d41de60

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

crates/config/src/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ pub struct TapConfig {
382382
pub sender_timeout_secs: Duration,
383383

384384
pub sender_aggregator_endpoints: HashMap<Address, Url>,
385+
/// Set of sender addresses that will not be added to the denylist
386+
#[serde(default)]
387+
pub trusted_senders: Vec<Address>,
385388
}
386389

387390
#[derive(Debug, Deserialize)]

crates/tap-agent/src/agent/sender_account.rs

+14
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ pub struct SenderAccountConfig {
329329
pub max_amount_willing_to_lose_grt: u128,
330330
/// What value triggers a new Rav request
331331
pub trigger_value: u128,
332+
/// Set of sender addresses that will not be added to the denylist
333+
pub trusted_senders: HashSet<Address>,
332334

333335
// allocation config
334336
/// Timeout config for rav requests
@@ -355,6 +357,7 @@ impl SenderAccountConfig {
355357
escrow_polling_interval: config.subgraphs.escrow.config.syncing_interval_secs,
356358
max_amount_willing_to_lose_grt: config.tap.max_amount_willing_to_lose_grt.get_value(),
357359
trigger_value: config.tap.get_trigger_value(),
360+
trusted_senders: config.tap.trusted_senders.iter().copied().collect(),
358361
rav_request_timeout: config.tap.rav_request.request_timeout_secs,
359362
tap_sender_timeout: config.tap.sender_timeout_secs,
360363
}
@@ -549,6 +552,17 @@ impl State {
549552

550553
/// Will update [`State::denied`], as well as the denylist table in the database.
551554
async fn add_to_denylist(&mut self) {
555+
if self.config.trusted_senders.contains(&self.sender) {
556+
tracing::warn!(
557+
fee_tracker = self.sender_fee_tracker.get_total_fee(),
558+
rav_tracker = self.rav_tracker.get_total_fee(),
559+
max_amount_willing_to_lose = self.config.max_amount_willing_to_lose_grt,
560+
sender_balance = self.sender_balance.to_u128(),
561+
"Trusted sender would be denied."
562+
);
563+
return;
564+
}
565+
552566
tracing::warn!(
553567
fee_tracker = self.sender_fee_tracker.get_total_fee(),
554568
rav_tracker = self.rav_tracker.get_total_fee(),

crates/tap-agent/src/test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub fn get_sender_account_config() -> &'static SenderAccountConfig {
7676
rav_request_buffer: RAV_REQUEST_BUFFER,
7777
max_amount_willing_to_lose_grt: TRIGGER_VALUE + 100,
7878
trigger_value: TRIGGER_VALUE,
79+
trusted_senders: Default::default(),
7980
rav_request_timeout: Duration::from_secs(30),
8081
rav_request_receipt_limit: 1000,
8182
indexer_address: INDEXER.1,
@@ -105,6 +106,7 @@ pub async fn create_sender_account(
105106
rav_request_buffer: BUFFER_DURATION,
106107
max_amount_willing_to_lose_grt,
107108
trigger_value: rav_request_trigger_value,
109+
trusted_senders: Default::default(),
108110
rav_request_timeout: RAV_REQUEST_TIMEOUT,
109111
rav_request_receipt_limit,
110112
indexer_address: INDEXER.1,

crates/tap-agent/tests/tap_agent_test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ pub async fn start_agent(
8282
rav_request_buffer: Duration::from_millis(500),
8383
max_amount_willing_to_lose_grt: 50,
8484
trigger_value: 150,
85+
trusted_senders: Default::default(),
8586
rav_request_timeout: Duration::from_secs(60),
8687
rav_request_receipt_limit: 10,
8788
indexer_address: INDEXER_ADDRESS,

0 commit comments

Comments
 (0)