Skip to content

Commit 6e81594

Browse files
committed
refactor: use network subgraph for v2 escrow accounts
1 parent a830b72 commit 6e81594

File tree

6 files changed

+45
-152
lines changed

6 files changed

+45
-152
lines changed

contrib/indexer-service/config.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap"
2020
deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"
2121
syncing_interval_secs = 30
2222

23-
[subgraphs.escrow_v2]
24-
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap-v2"
25-
deployment_id = "ESCROW_V2_DEPLOYMENT_PLACEHOLDER"
26-
syncing_interval_secs = 30
23+
# Note: V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
2724

2825
[blockchain]
2926
chain_id = 1337

contrib/tap-agent/config.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap"
2020
deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"
2121
syncing_interval_secs = 30
2222

23-
[subgraphs.escrow_v2]
24-
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap-v2"
25-
deployment_id = "ESCROW_V2_DEPLOYMENT_PLACEHOLDER"
26-
syncing_interval_secs = 30
23+
# Note: V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
2724

2825
[blockchain]
2926
chain_id = 1337

crates/config/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl MetricsConfig {
303303
pub struct SubgraphsConfig {
304304
pub network: NetworkSubgraphConfig,
305305
pub escrow: EscrowSubgraphConfig,
306-
pub escrow_v2: Option<EscrowSubgraphConfig>,
306+
// Note: V2 escrow accounts are in the network subgraph, not a separate escrow_v2 subgraph
307307
}
308308

309309
#[serde_as]

crates/service/src/service.rs

Lines changed: 31 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,7 @@ pub async fn run() -> anyhow::Result<()> {
7878
)
7979
.await;
8080

81-
let escrow_subgraph_v2 = if let Some(ref escrow_v2_config) = config.subgraphs.escrow_v2 {
82-
Some(
83-
create_subgraph_client(
84-
http_client.clone(),
85-
&config.graph_node,
86-
&escrow_v2_config.config,
87-
)
88-
.await,
89-
)
90-
} else {
91-
None
92-
};
81+
// V2 escrow accounts are in the network subgraph, not a separate escrow_v2 subgraph
9382

9483
// Establish Database connection necessary for serving indexer management
9584
// requests with defined schema
@@ -113,11 +102,8 @@ pub async fn run() -> anyhow::Result<()> {
113102

114103
// Capture individual fields needed for DIPS before they get moved
115104
let escrow_v1_query_url_for_dips = config.subgraphs.escrow.config.query_url.clone();
116-
let escrow_v2_query_url_for_dips = config
117-
.subgraphs
118-
.escrow_v2
119-
.as_ref()
120-
.map(|c| c.config.query_url.clone());
105+
// V2 escrow accounts are in the network subgraph
106+
let escrow_v2_query_url_for_dips = Some(config.subgraphs.network.config.query_url.clone());
121107

122108
// Configure router with escrow watchers based on Horizon mode
123109
use indexer_config::HorizonMode;
@@ -157,7 +143,7 @@ pub async fn run() -> anyhow::Result<()> {
157143
}
158144
HorizonMode::Transition => {
159145
tracing::info!("Horizon mode: Transition - using both escrow accounts v1 and v2");
160-
// Create both watchers for transition mode using separate subgraph clients
146+
// Create both watchers for transition mode
161147
let escrow_subgraph_v1 = create_subgraph_client(
162148
http_client.clone(),
163149
&config.graph_node,
@@ -174,78 +160,38 @@ pub async fn run() -> anyhow::Result<()> {
174160
.await
175161
.expect("Error creating escrow_accounts_v1 channel");
176162

177-
if let Some(escrow_v2_subgraph) = escrow_subgraph_v2 {
178-
let v2_watcher = indexer_monitor::escrow_accounts_v2(
179-
escrow_v2_subgraph,
180-
indexer_address,
181-
config
182-
.subgraphs
183-
.escrow_v2
184-
.as_ref()
185-
.unwrap()
186-
.config
187-
.syncing_interval_secs,
188-
true, // Reject thawing signers eagerly
189-
)
190-
.await
191-
.expect("Error creating escrow_accounts_v2 channel");
192-
193-
ServiceRouter::builder()
194-
.database(database.clone())
195-
.domain_separator(domain_separator.clone())
196-
.graph_node(config.graph_node)
197-
.http_client(http_client)
198-
.release(release)
199-
.indexer(config.indexer)
200-
.service(config.service)
201-
.blockchain(config.blockchain)
202-
.timestamp_buffer_secs(config.tap.rav_request.timestamp_buffer_secs)
203-
.network_subgraph(network_subgraph, config.subgraphs.network)
204-
.escrow_accounts_v1(v1_watcher)
205-
.escrow_accounts_v2(v2_watcher)
206-
.build()
207-
} else {
208-
tracing::warn!("Horizon mode is Transition but no escrow_v2 configuration provided, falling back to v1 only");
209-
ServiceRouter::builder()
210-
.database(database.clone())
211-
.domain_separator(domain_separator.clone())
212-
.graph_node(config.graph_node)
213-
.http_client(http_client)
214-
.release(release)
215-
.indexer(config.indexer)
216-
.service(config.service)
217-
.blockchain(config.blockchain)
218-
.timestamp_buffer_secs(config.tap.rav_request.timestamp_buffer_secs)
219-
.network_subgraph(network_subgraph, config.subgraphs.network)
220-
.escrow_accounts_v1(v1_watcher)
221-
.build()
222-
}
163+
// V2 escrow accounts are in the network subgraph
164+
let v2_watcher = indexer_monitor::escrow_accounts_v2(
165+
network_subgraph,
166+
indexer_address,
167+
config.subgraphs.network.config.syncing_interval_secs,
168+
true, // Reject thawing signers eagerly
169+
)
170+
.await
171+
.expect("Error creating escrow_accounts_v2 channel");
172+
173+
ServiceRouter::builder()
174+
.database(database.clone())
175+
.domain_separator(domain_separator.clone())
176+
.graph_node(config.graph_node)
177+
.http_client(http_client)
178+
.release(release)
179+
.indexer(config.indexer)
180+
.service(config.service)
181+
.blockchain(config.blockchain)
182+
.timestamp_buffer_secs(config.tap.rav_request.timestamp_buffer_secs)
183+
.network_subgraph(network_subgraph, config.subgraphs.network)
184+
.escrow_accounts_v1(v1_watcher)
185+
.escrow_accounts_v2(v2_watcher)
186+
.build()
223187
}
224188
HorizonMode::Full => {
225189
tracing::info!("Horizon mode: Full - using escrow accounts v2 only");
226-
// Only create v2 watcher for full Horizon mode
227-
let v2_subgraph = if let Some(escrow_v2_subgraph) = escrow_subgraph_v2 {
228-
escrow_v2_subgraph
229-
} else {
230-
tracing::warn!("Horizon mode is Full but no escrow_v2 configuration provided, falling back to escrow v1 endpoint for v2 queries");
231-
create_subgraph_client(
232-
http_client.clone(),
233-
&config.graph_node,
234-
&config.subgraphs.escrow.config,
235-
)
236-
.await
237-
};
238-
let v2_config = config
239-
.subgraphs
240-
.escrow_v2
241-
.as_ref()
242-
.map(|c| &c.config)
243-
.unwrap_or(&config.subgraphs.escrow.config);
244-
190+
// V2 escrow accounts are in the network subgraph
245191
let v2_watcher = indexer_monitor::escrow_accounts_v2(
246-
v2_subgraph,
192+
network_subgraph,
247193
indexer_address,
248-
v2_config.syncing_interval_secs,
194+
config.subgraphs.network.config.syncing_interval_secs,
249195
true, // Reject thawing signers eagerly
250196
)
251197
.await

crates/tap-agent/src/agent.rs

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
9898
syncing_interval_secs: escrow_sync_interval,
9999
},
100100
},
101-
escrow_v2,
102101
},
103102
tap:
104103
TapConfig {
@@ -157,29 +156,6 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
157156
.await,
158157
));
159158

160-
// Create v2 escrow subgraph client if configured
161-
let escrow_subgraph_v2 = if let Some(ref escrow_v2_config) = escrow_v2 {
162-
Some(Box::leak(Box::new(
163-
SubgraphClient::new(
164-
http_client.clone(),
165-
escrow_v2_config.config.deployment_id.map(|deployment| {
166-
DeploymentDetails::for_graph_node_url(
167-
graph_node_status_endpoint.clone(),
168-
graph_node_query_endpoint.clone(),
169-
deployment,
170-
)
171-
}),
172-
DeploymentDetails::for_query_url_with_token(
173-
escrow_v2_config.config.query_url.clone(),
174-
escrow_v2_config.config.query_auth_token.clone(),
175-
),
176-
)
177-
.await,
178-
)))
179-
} else {
180-
None
181-
};
182-
183159
let escrow_accounts_v1 = escrow_accounts_v1(
184160
escrow_subgraph,
185161
*indexer_address,
@@ -189,33 +165,15 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
189165
.await
190166
.expect("Error creating escrow_accounts channel");
191167

192-
// Check if v2 is configured before moving the value
193-
let has_escrow_v2 = escrow_subgraph_v2.is_some();
194-
195-
let escrow_accounts_v2 = if let Some(escrow_v2_subgraph) = escrow_subgraph_v2 {
196-
let escrow_v2_sync_interval = escrow_v2
197-
.as_ref()
198-
.map(|c| c.config.syncing_interval_secs)
199-
.unwrap_or(*escrow_sync_interval);
200-
escrow_accounts_v2(
201-
escrow_v2_subgraph,
202-
*indexer_address,
203-
escrow_v2_sync_interval,
204-
false,
205-
)
206-
.await
207-
.expect("Error creating escrow_accounts_v2 channel")
208-
} else {
209-
// Fall back to v1 subgraph for v2 watcher if no v2 config
210-
escrow_accounts_v2(
211-
escrow_subgraph,
212-
*indexer_address,
213-
*escrow_sync_interval,
214-
false,
215-
)
216-
.await
217-
.expect("Error creating escrow_accounts_v2 channel")
218-
};
168+
// V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
169+
let escrow_accounts_v2 = escrow_accounts_v2(
170+
network_subgraph,
171+
*indexer_address,
172+
*network_sync_interval,
173+
false,
174+
)
175+
.await
176+
.expect("Error creating escrow_accounts_v2 channel");
219177

220178
// Configure watchers based on Horizon mode
221179
use indexer_config::HorizonMode;
@@ -226,11 +184,6 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
226184
}
227185
HorizonMode::Transition => {
228186
tracing::info!("Horizon mode: Transition - both v1 and v2 receipts supported");
229-
if !has_escrow_v2 {
230-
tracing::warn!(
231-
"Horizon mode is Transition but no escrow_v2 configuration provided"
232-
);
233-
}
234187
(escrow_accounts_v1, escrow_accounts_v2)
235188
}
236189
HorizonMode::Full => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ where
803803
)
804804
.execute(&self.pgpool)
805805
.await
806-
.map_err(|e| {
806+
.map_err(|e: sqlx::Error| {
807807
tracing::error!("Failed to store invalid receipt: {}", e);
808808
anyhow!(e)
809809
})?;
@@ -893,7 +893,7 @@ where
893893
)
894894
.execute(&self.pgpool)
895895
.await
896-
.map_err(|e| {
896+
.map_err(|e: sqlx::Error| {
897897
tracing::error!("Failed to store invalid receipt: {}", e);
898898
anyhow!(e)
899899
})?;

0 commit comments

Comments
 (0)