Skip to content

Commit a67834c

Browse files
refactor: improve epoch_manager error handling and logging (#1697)
1. Increases log verbosity for key operations in `process_queue` (finding slots, waiting, sending txs) by changing several `trace!` calls to `info!`. 2. Modifies error handling within the main loop: - Errors encountered during the rollover check (`check_for_epoch_rollover`) are now logged as errors but no longer cause the `process_queue` function to return immediately. - Failures during `send_batched_transactions` are also logged as errors, but the function now continues processing the epoch instead of returning the error. This makes the forester more resilient to transient transaction send issues. 3. Removes a redundant `TODO` comment.
1 parent fde64cc commit a67834c

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

forester/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"test-state-batched-indexer-async": "RUST_LOG=forester=debug,forester_utils=debug cargo test --package forester test_state_indexer_async_batched -- --nocapture",
1111
"test-fetch-root": "RUST_LOG=forester=debug,forester_utils=debug cargo test --package forester test_state_indexer_fetch_root -- --nocapture",
1212
"test-address-batched-local": "RUST_LOG=forester=debug,forester_utils=debug cargo test --package forester test_address_batched -- --nocapture",
13-
"test-e2e-legacy-local": "cargo test --package forester test_epoch_monitor_with_2_foresters -- --nocapture",
13+
"test-e2e-legacy-local": "RUST_LOG=forester=debug,forester_utils=debug cargo test --package forester test_epoch_monitor_with_2_foresters -- --nocapture",
1414
"test-address-v2": "RUST_LOG=forester=debug,forester_utils=debug cargo test --package forester test_create_v2_address -- --nocapture",
1515
"docker:build": "docker build --tag forester -f Dockerfile .."
1616
},

forester/src/epoch_manager.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ impl<R: RpcConnection, I: Indexer<R> + IndexerType<R>> EpochManager<R, I> {
812812
mut tree: TreeForesterSchedule,
813813
) -> Result<()> {
814814
info!("enter process_queue");
815-
// TODO: sync at some point
815+
816816
let mut estimated_slot = self.slot_tracker.estimated_current_slot();
817817

818818
trace!(
@@ -821,7 +821,6 @@ impl<R: RpcConnection, I: Indexer<R> + IndexerType<R>> EpochManager<R, I> {
821821
epoch_info.phases.active.end
822822
);
823823
while estimated_slot < epoch_info.phases.active.end {
824-
trace!("Searching for next eligible slot");
825824
// search for next eligible slot
826825
let index_and_forester_slot = tree
827826
.slots
@@ -830,16 +829,18 @@ impl<R: RpcConnection, I: Indexer<R> + IndexerType<R>> EpochManager<R, I> {
830829
.find(|(_, slot)| slot.is_some());
831830

832831
if let Some((index, forester_slot)) = index_and_forester_slot {
833-
trace!(
834-
"Found eligible slot, index: {}, tree: {}",
835-
index,
836-
tree.tree_accounts.merkle_tree.to_string()
837-
);
838832
let forester_slot = forester_slot.as_ref().unwrap().clone();
839833
tree.slots.remove(index);
840834

835+
info!("Found eligible slot: {:?}", forester_slot);
836+
841837
let mut rpc = self.rpc_pool.get_connection().await?;
842-
// Wait until next eligible light slot is reached (until the start solana slot is reached)
838+
839+
info!(
840+
"Current solana slot: {}, waiting for slot {}",
841+
estimated_slot, forester_slot.start_solana_slot
842+
);
843+
843844
wait_until_slot_reached(
844845
&mut *rpc,
845846
&self.slot_tracker,
@@ -931,7 +932,7 @@ impl<R: RpcConnection, I: Indexer<R> + IndexerType<R>> EpochManager<R, I> {
931932
phantom: std::marker::PhantomData::<R>,
932933
};
933934

934-
trace!("Sending transactions...");
935+
info!("Sending transactions...");
935936
let start_time = Instant::now();
936937
let batch_tx_future = send_batched_transactions(
937938
&self.config.payer_keypair,
@@ -947,7 +948,9 @@ impl<R: RpcConnection, I: Indexer<R> + IndexerType<R>> EpochManager<R, I> {
947948

948949
// Wait for both operations to complete
949950
let (num_tx_sent, rollover_result) = tokio::join!(batch_tx_future, future);
950-
rollover_result?;
951+
if let Err(e) = rollover_result {
952+
error!("Error during rollover check: {:?}", e);
953+
}
951954

952955
match num_tx_sent {
953956
Ok(num_tx_sent) => {
@@ -986,13 +989,12 @@ impl<R: RpcConnection, I: Indexer<R> + IndexerType<R>> EpochManager<R, I> {
986989
}
987990
}
988991
}
989-
return Err(e);
992+
warn!("Continuing despite transaction send failure");
990993
}
991994
}
992995
}
993996
} else {
994-
debug!("No eligible slot found");
995-
// The forester is not eligible for any more slots in the current epoch
997+
info!("No eligible slot found");
996998
break;
997999
}
9981000

@@ -1003,10 +1005,9 @@ impl<R: RpcConnection, I: Indexer<R> + IndexerType<R>> EpochManager<R, I> {
10031005

10041006
estimated_slot = self.slot_tracker.estimated_current_slot();
10051007

1006-
trace!(
1008+
info!(
10071009
"Estimated slot: {}, epoch end: {}",
1008-
estimated_slot,
1009-
epoch_info.phases.active.end
1010+
estimated_slot, epoch_info.phases.active.end
10101011
);
10111012
}
10121013
Ok(())

0 commit comments

Comments
 (0)