Skip to content

Commit 375e25c

Browse files
authored
refactor: create senders based on escrow account version (#624)
* refactor: create senders based on escrow account Signed-off-by: Gustavo Inacio <[email protected]> * refactor: implement get_pending_sender_allocation_id_v2 Signed-off-by: Gustavo Inacio <[email protected]> * test: update test-log to print debug messages Signed-off-by: Gustavo Inacio <[email protected]> * test: update create_manager() to receive list of initial accounts Signed-off-by: Gustavo Inacio <[email protected]> * refactor: pass sender_type to sender_account Signed-off-by: Gustavo Inacio <[email protected]> * chore: add just ci cmd Signed-off-by: Gustavo Inacio <[email protected]> * test: add back where last Signed-off-by: Gustavo Inacio <[email protected]> * docs: add just ci docs Signed-off-by: Gustavo Inacio <[email protected]> * perf: update queries to load up v2 Signed-off-by: Gustavo Inacio <[email protected]> --------- Signed-off-by: Gustavo Inacio <[email protected]>
1 parent c5b115e commit 375e25c

14 files changed

+562
-133
lines changed

.sqlx/query-b1d4dfcd202af310df032edc34d83dabb56d7b947b023ee3a8b32b24b07bcd18.json renamed to .sqlx/query-1644e9aa44b08e99180cff30a6b0cc1fe1e5367bd545ca489d116de0a709a6ee.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-386e6b18da62b478ccdba5439490817f582abaec68e1ba01d55daee1e1edcbbd.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-7bf9c412120de537eecb8efb64da5b4ace9acc032be502cd1d9fc72c5b9ed50a.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/monitor/src/escrow_accounts.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,33 @@ pub async fn escrow_accounts(
9595
reject_thawing_signers: bool,
9696
) -> Result<EscrowAccountsWatcher, anyhow::Error> {
9797
indexer_watcher::new_watcher(interval, move || {
98-
get_escrow_accounts(escrow_subgraph, indexer_address, reject_thawing_signers)
98+
get_escrow_accounts_v1(escrow_subgraph, indexer_address, reject_thawing_signers)
9999
})
100100
.await
101101
}
102102

103-
async fn get_escrow_accounts(
103+
pub async fn escrow_accounts_v2(
104+
escrow_subgraph: &'static SubgraphClient,
105+
indexer_address: Address,
106+
interval: Duration,
107+
reject_thawing_signers: bool,
108+
) -> Result<EscrowAccountsWatcher, anyhow::Error> {
109+
indexer_watcher::new_watcher(interval, move || {
110+
get_escrow_accounts_v2(escrow_subgraph, indexer_address, reject_thawing_signers)
111+
})
112+
.await
113+
}
114+
115+
// TODO implement escrow accounts v2 query
116+
async fn get_escrow_accounts_v2(
117+
_escrow_subgraph: &'static SubgraphClient,
118+
_indexer_address: Address,
119+
_reject_thawing_signers: bool,
120+
) -> anyhow::Result<EscrowAccounts> {
121+
Ok(EscrowAccounts::new(HashMap::new(), HashMap::new()))
122+
}
123+
124+
async fn get_escrow_accounts_v1(
104125
escrow_subgraph: &'static SubgraphClient,
105126
indexer_address: Address,
106127
reject_thawing_signers: bool,

crates/monitor/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub use crate::{
1515
deployment_to_allocation::{deployment_to_allocation, DeploymentToAllocationWatcher},
1616
dispute_manager::{dispute_manager, DisputeManagerWatcher},
1717
escrow_accounts::{
18-
escrow_accounts, EscrowAccounts, EscrowAccountsError, EscrowAccountsWatcher,
18+
escrow_accounts, escrow_accounts_v2, EscrowAccounts, EscrowAccountsError,
19+
EscrowAccountsWatcher,
1920
},
2021
};

crates/tap-agent/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ tempfile = "3.8.0"
6262
wiremock.workspace = true
6363
wiremock-grpc = "0.0.3-alpha3"
6464
test-assets = { path = "../test-assets" }
65-
test-log = { version = "0.2.12", default-features = false }
65+
test-log = { version = "0.2.12", features = ["trace"] }
6666
bon = "3.3"
6767
rstest = "0.24.0"

crates/tap-agent/src/agent.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ use indexer_config::{
3939
Config, EscrowSubgraphConfig, GraphNodeConfig, IndexerConfig, NetworkSubgraphConfig,
4040
SubgraphConfig, SubgraphsConfig, TapConfig,
4141
};
42-
use indexer_monitor::{escrow_accounts, indexer_allocations, DeploymentDetails, SubgraphClient};
42+
use indexer_monitor::{
43+
escrow_accounts, escrow_accounts_v2, indexer_allocations, DeploymentDetails, SubgraphClient,
44+
};
4345
use ractor::{concurrency::JoinHandle, Actor, ActorRef};
4446
use sender_account::SenderAccountConfig;
4547
use sender_accounts_manager::SenderAccountsManager;
@@ -154,7 +156,16 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
154156
.await,
155157
));
156158

157-
let escrow_accounts = escrow_accounts(
159+
let escrow_accounts_v1 = escrow_accounts(
160+
escrow_subgraph,
161+
*indexer_address,
162+
*escrow_sync_interval,
163+
false,
164+
)
165+
.await
166+
.expect("Error creating escrow_accounts channel");
167+
168+
let escrow_accounts_v2 = escrow_accounts_v2(
158169
escrow_subgraph,
159170
*indexer_address,
160171
*escrow_sync_interval,
@@ -170,7 +181,8 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
170181
domain_separator: EIP_712_DOMAIN.clone(),
171182
pgpool,
172183
indexer_allocations,
173-
escrow_accounts,
184+
escrow_accounts_v1,
185+
escrow_accounts_v2,
174186
escrow_subgraph,
175187
network_subgraph,
176188
sender_aggregator_endpoints: sender_aggregator_endpoints.clone(),

0 commit comments

Comments
 (0)