Skip to content

Commit 5c6a9f0

Browse files
committed
chore: rename gateway to sender
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent da7ac0f commit 5c6a9f0

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

crates/config/maximal-config-example.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ max_receipt_value_grt = "0.001" # 0.001 GRT. We use strings to prevent rounding
124124
# max_amount_willing_to_lose_grt = "0.1"
125125
max_amount_willing_to_lose_grt = 20
126126

127-
# List of Gateways that are allowed to spend up to `max_amount_willing_to_lose_grt`
127+
# List of Senders that are allowed to spend up to `max_amount_willing_to_lose_grt`
128128
# over the escrow balance
129-
trusted_gateways = ["0xdeadbeefcafebabedeadbeefcafebabedeadbeef"]
129+
trusted_senders = ["0xdeadbeefcafebabedeadbeefcafebabedeadbeef"]
130130

131131

132132
# Receipts query timeout

crates/config/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,9 @@ pub struct TapConfig {
383383

384384
pub sender_aggregator_endpoints: HashMap<Address, Url>,
385385

386-
/// gateways that are allowed to spend up to
387-
/// `max_amount_willing_to_lose_grt` over the escrow balance
388-
pub trusted_gateways: HashSet<Address>,
386+
/// Senders that are allowed to spend up to `max_amount_willing_to_lose_grt`
387+
/// over the escrow balance
388+
pub trusted_senders: HashSet<Address>,
389389
}
390390

391391
#[derive(Debug, Deserialize)]

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ pub struct State {
317317
// reset in case of a successful response
318318
backoff_info: BackoffInfo,
319319

320-
/// Allows the gateway to go over escrow balance
320+
/// Allows the sender to go over escrow balance
321321
/// limited to `max_amount_willing_to_lose_grt`
322-
trusted_gateway: bool,
322+
trusted_sender: bool,
323323

324324
// Config forwarded to [SenderAllocation]
325325
config: &'static SenderAccountConfig,
@@ -347,9 +347,9 @@ pub struct SenderAccountConfig {
347347
///
348348
/// This is reached if the database is too slow
349349
pub tap_sender_timeout: Duration,
350-
/// Gateways that are allowed to spend up to
351-
/// `max_amount_willing_to_lose_grt` over the escrow balance
352-
pub trusted_gateways: HashSet<Address>,
350+
/// Senders that are allowed to spend up to `max_amount_willing_to_lose_grt`
351+
/// over the escrow balance
352+
pub trusted_senders: HashSet<Address>,
353353
}
354354

355355
impl SenderAccountConfig {
@@ -364,7 +364,7 @@ impl SenderAccountConfig {
364364
trigger_value: config.tap.get_trigger_value(),
365365
rav_request_timeout: config.tap.rav_request.request_timeout_secs,
366366
tap_sender_timeout: config.tap.sender_timeout_secs,
367-
trusted_gateways: config.tap.trusted_gateways.clone(),
367+
trusted_senders: config.tap.trusted_senders.clone(),
368368
}
369369
}
370370
}
@@ -541,8 +541,8 @@ impl State {
541541
let unaggregated_fees = self.sender_fee_tracker.get_total_fee();
542542
let max_amount_willing_to_lose = self.config.max_amount_willing_to_lose_grt;
543543

544-
// if it's a trusted gateway, allow to spend up to max_amount_willing_to_lose
545-
let balance = if self.trusted_gateway {
544+
// if it's a trusted sender, allow to spend up to max_amount_willing_to_lose
545+
let balance = if self.trusted_sender {
546546
self.sender_balance + U256::from(max_amount_willing_to_lose)
547547
} else {
548548
self.sender_balance
@@ -856,7 +856,7 @@ impl Actor for SenderAccount {
856856
aggregator_v1,
857857
aggregator_v2,
858858
backoff_info: BackoffInfo::default(),
859-
trusted_gateway: config.trusted_gateways.contains(&sender_id),
859+
trusted_sender: config.trusted_senders.contains(&sender_id),
860860
config,
861861
};
862862

@@ -2002,12 +2002,12 @@ pub mod tests {
20022002
}
20032003

20042004
#[sqlx::test(migrations = "../../migrations")]
2005-
async fn test_trusted_gateway(pgpool: PgPool) {
2005+
async fn test_trusted_sender(pgpool: PgPool) {
20062006
let max_amount_willing_to_lose_grt = ESCROW_VALUE / 10;
20072007
// initialize with no trigger value and no max receipt deny
20082008
let (sender_account, notify, prefix, _) = create_sender_account()
20092009
.pgpool(pgpool)
2010-
.trusted_gateway(true)
2010+
.trusted_sender(true)
20112011
.rav_request_trigger_value(u128::MAX)
20122012
.max_amount_willing_to_lose_grt(max_amount_willing_to_lose_grt)
20132013
.call()

crates/tap-agent/src/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub fn get_sender_account_config() -> &'static SenderAccountConfig {
9393
indexer_address: INDEXER.1,
9494
escrow_polling_interval: ESCROW_POLLING_INTERVAL,
9595
tap_sender_timeout: Duration::from_secs(63),
96-
trusted_gateways: HashSet::new(),
96+
trusted_senders: HashSet::new(),
9797
}))
9898
}
9999

@@ -108,14 +108,14 @@ pub async fn create_sender_account(
108108
network_subgraph_endpoint: Option<&str>,
109109
#[builder(default = RECEIPT_LIMIT)] rav_request_receipt_limit: u64,
110110
aggregator_endpoint: Option<Url>,
111-
#[builder(default = false)] trusted_gateway: bool,
111+
#[builder(default = false)] trusted_sender: bool,
112112
) -> (
113113
ActorRef<SenderAccountMessage>,
114114
Arc<Notify>,
115115
String,
116116
Sender<EscrowAccounts>,
117117
) {
118-
let trusted_gateways = if trusted_gateway {
118+
let trusted_senders = if trusted_sender {
119119
HashSet::from([SENDER.1])
120120
} else {
121121
HashSet::new()
@@ -129,7 +129,7 @@ pub async fn create_sender_account(
129129
indexer_address: INDEXER.1,
130130
escrow_polling_interval: Duration::default(),
131131
tap_sender_timeout: TAP_SENDER_TIMEOUT,
132-
trusted_gateways,
132+
trusted_senders,
133133
}));
134134

135135
let network_subgraph = Box::leak(Box::new(

crates/tap-agent/tests/tap_agent_test.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use std::{collections::HashMap, str::FromStr, sync::Arc, time::Duration};
4+
use std::{
5+
collections::{HashMap, HashSet},
6+
str::FromStr,
7+
sync::Arc,
8+
time::Duration,
9+
};
510

611
use indexer_monitor::{DeploymentDetails, EscrowAccounts, SubgraphClient};
712
use indexer_tap_agent::{
@@ -87,6 +92,7 @@ pub async fn start_agent(
8792
indexer_address: INDEXER_ADDRESS,
8893
escrow_polling_interval: Duration::from_secs(10),
8994
tap_sender_timeout: Duration::from_secs(30),
95+
trusted_senders: HashSet::new(),
9096
}));
9197

9298
let args = SenderAccountsManagerArgs {

0 commit comments

Comments
 (0)