Skip to content

Commit 49553e6

Browse files
committed
chore(agent): handle child tasks in prod code
Signed-off-by: Joseph Livesey <[email protected]>
1 parent fe5f19f commit 49553e6

File tree

1 file changed

+43
-47
lines changed

1 file changed

+43
-47
lines changed

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

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ use crate::{
3636
use super::sender_allocation_task::SenderAllocationTask;
3737

3838
#[cfg(not(any(test, feature = "test")))]
39-
use tap_core::receipt::checks::CheckList;
39+
use tap_core::receipt::checks::{Check, CheckList};
40+
41+
#[cfg(not(any(test, feature = "test")))]
42+
use crate::tap::context::checks::{AllocationId as AllocationIdCheck, Signature};
4043

4144
#[cfg(any(test, feature = "test"))]
4245
use super::sender_allocation_task::SenderAllocationTask;
@@ -397,7 +400,7 @@ impl SenderAccountTask {
397400
#[cfg(any(test, feature = "test"))]
398401
{
399402
// Create a self-reference handle for the child to communicate back
400-
let (self_tx, mut self_rx) = mpsc::channel::<SenderAccountMessage>(10);
403+
let (self_tx, _self_rx) = mpsc::channel::<SenderAccountMessage>(10);
401404
let self_handle = TaskHandle::new(
402405
self_tx,
403406
Some(format!("sender_account_{}", state.sender)),
@@ -430,49 +433,6 @@ impl SenderAccountTask {
430433

431434
// Register the child task
432435
state.child_registry.register(task_name, child_handle).await;
433-
434-
// Create a proper message forwarder that handles child->parent communication
435-
// This simulates the child sending messages back to the parent task
436-
tokio::spawn(async move {
437-
while let Some(msg) = self_rx.recv().await {
438-
tracing::debug!(
439-
message = ?msg,
440-
"Child allocation task sent message to parent"
441-
);
442-
443-
// In production, this would route the message back to the parent's
444-
// main message handling loop. For our current proof-of-concept,
445-
// we just log that proper communication is happening.
446-
match msg {
447-
SenderAccountMessage::UpdateReceiptFees(allocation_id, _receipt_fees) => {
448-
tracing::debug!(
449-
allocation_id = ?allocation_id,
450-
"Child reported receipt fee update"
451-
);
452-
}
453-
SenderAccountMessage::UpdateInvalidReceiptFees(
454-
allocation_id,
455-
invalid_fees,
456-
) => {
457-
tracing::debug!(
458-
allocation_id = ?allocation_id,
459-
invalid_value = invalid_fees.value,
460-
"Child reported invalid receipt fees"
461-
);
462-
}
463-
SenderAccountMessage::UpdateRav(rav_info) => {
464-
tracing::debug!(
465-
allocation_id = %rav_info.allocation_id,
466-
rav_value = rav_info.value_aggregate,
467-
"Child reported new RAV"
468-
);
469-
}
470-
_ => {
471-
tracing::debug!("Child sent other message type");
472-
}
473-
}
474-
}
475-
});
476436
}
477437

478438
#[cfg(not(any(test, feature = "test")))]
@@ -520,11 +480,29 @@ impl SenderAccountTask {
520480
.escrow_accounts(state.escrow_accounts.clone())
521481
.build();
522482

483+
// Create proper receipt validation checks for Legacy (V1) network
484+
let required_checks: Vec<Arc<dyn Check<crate::tap::TapReceipt> + Send + Sync>> = vec![
485+
Arc::new(
486+
AllocationIdCheck::new(
487+
state.config.indexer_address,
488+
state.config.escrow_polling_interval,
489+
state.sender,
490+
tap_allocation_id,
491+
state.escrow_subgraph,
492+
)
493+
.await,
494+
),
495+
Arc::new(Signature::new(
496+
state.domain_separator.clone(),
497+
state.escrow_accounts.clone(),
498+
)),
499+
];
500+
523501
// Create TAP manager with proper domain separator and checks
524502
let tap_manager = tap_core::manager::Manager::new(
525503
state.domain_separator.clone(),
526504
tap_context_for_manager,
527-
CheckList::empty(), // TODO: Add proper checks in future iteration
505+
CheckList::new(required_checks),
528506
);
529507

530508
// Create Legacy (V1) aggregator client
@@ -576,11 +554,29 @@ impl SenderAccountTask {
576554
.escrow_accounts(state.escrow_accounts.clone())
577555
.build();
578556

557+
// Create proper receipt validation checks for Horizon (V2) network
558+
let required_checks: Vec<Arc<dyn Check<crate::tap::TapReceipt> + Send + Sync>> = vec![
559+
Arc::new(
560+
AllocationIdCheck::new(
561+
state.config.indexer_address,
562+
state.config.escrow_polling_interval,
563+
state.sender,
564+
tap_allocation_id,
565+
state.escrow_subgraph,
566+
)
567+
.await,
568+
),
569+
Arc::new(Signature::new(
570+
state.domain_separator.clone(),
571+
state.escrow_accounts.clone(),
572+
)),
573+
];
574+
579575
// Create TAP manager with proper domain separator and checks
580576
let tap_manager = tap_core::manager::Manager::new(
581577
state.domain_separator.clone(),
582578
tap_context_for_manager,
583-
CheckList::empty(), // TODO: Add proper checks in future iteration
579+
CheckList::new(required_checks),
584580
);
585581

586582
// Create Horizon (V2) aggregator client

0 commit comments

Comments
 (0)