|
|
@@ -280,7 +280,7 @@ pub struct ReplayStageConfig {
|
|
|
}
|
|
|
|
|
|
pub struct ReplaySenders {
|
|
|
- pub rpc_subscriptions: Arc<RpcSubscriptions>,
|
|
|
+ pub rpc_subscriptions: Option<Arc<RpcSubscriptions>>,
|
|
|
pub slot_status_notifier: Option<SlotStatusNotifier>,
|
|
|
pub transaction_status_sender: Option<TransactionStatusSender>,
|
|
|
pub entry_notification_sender: Option<EntryNotifierSender>,
|
|
|
@@ -715,7 +715,7 @@ impl ReplayStage {
|
|
|
&blockstore,
|
|
|
&bank_forks,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&slot_status_notifier,
|
|
|
&mut progress,
|
|
|
&mut replay_timing,
|
|
|
@@ -741,7 +741,7 @@ impl ReplayStage {
|
|
|
&mut heaviest_subtree_fork_choice,
|
|
|
&replay_vote_sender,
|
|
|
&bank_notification_sender,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&slot_status_notifier,
|
|
|
&mut duplicate_slots_tracker,
|
|
|
&duplicate_confirmed_slots,
|
|
|
@@ -1002,7 +1002,7 @@ impl ReplayStage {
|
|
|
&leader_schedule_cache,
|
|
|
&lockouts_sender,
|
|
|
snapshot_controller.as_deref(),
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&block_commitment_cache,
|
|
|
&mut heaviest_subtree_fork_choice,
|
|
|
&bank_notification_sender,
|
|
|
@@ -1160,7 +1160,7 @@ impl ReplayStage {
|
|
|
&bank_forks,
|
|
|
&poh_recorder,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&slot_status_notifier,
|
|
|
&mut progress,
|
|
|
&retransmit_slots_sender,
|
|
|
@@ -2079,7 +2079,7 @@ impl ReplayStage {
|
|
|
bank_forks: &Arc<RwLock<BankForks>>,
|
|
|
poh_recorder: &Arc<RwLock<PohRecorder>>,
|
|
|
leader_schedule_cache: &Arc<LeaderScheduleCache>,
|
|
|
- rpc_subscriptions: &Arc<RpcSubscriptions>,
|
|
|
+ rpc_subscriptions: Option<&RpcSubscriptions>,
|
|
|
slot_status_notifier: &Option<SlotStatusNotifier>,
|
|
|
progress_map: &mut ProgressMap,
|
|
|
retransmit_slots_sender: &Sender<Slot>,
|
|
|
@@ -2257,7 +2257,7 @@ impl ReplayStage {
|
|
|
bank: &Bank,
|
|
|
root: Slot,
|
|
|
err: &BlockstoreProcessorError,
|
|
|
- rpc_subscriptions: &Arc<RpcSubscriptions>,
|
|
|
+ rpc_subscriptions: Option<&RpcSubscriptions>,
|
|
|
slot_status_notifier: &Option<SlotStatusNotifier>,
|
|
|
duplicate_slots_tracker: &mut DuplicateSlotsTracker,
|
|
|
duplicate_confirmed_slots: &DuplicateConfirmedSlots,
|
|
|
@@ -2309,11 +2309,13 @@ impl ReplayStage {
|
|
|
.notify_slot_dead(slot, parent_slot, err.clone());
|
|
|
}
|
|
|
|
|
|
- rpc_subscriptions.notify_slot_update(SlotUpdate::Dead {
|
|
|
- slot,
|
|
|
- err,
|
|
|
- timestamp: timestamp(),
|
|
|
- });
|
|
|
+ if let Some(rpc_subscriptions) = rpc_subscriptions {
|
|
|
+ rpc_subscriptions.notify_slot_update(SlotUpdate::Dead {
|
|
|
+ slot,
|
|
|
+ err,
|
|
|
+ timestamp: timestamp(),
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
let dead_state = DeadState::new_from_state(
|
|
|
slot,
|
|
|
@@ -2374,7 +2376,7 @@ impl ReplayStage {
|
|
|
leader_schedule_cache: &Arc<LeaderScheduleCache>,
|
|
|
lockouts_sender: &Sender<CommitmentAggregationData>,
|
|
|
snapshot_controller: Option<&SnapshotController>,
|
|
|
- rpc_subscriptions: &Arc<RpcSubscriptions>,
|
|
|
+ rpc_subscriptions: Option<&RpcSubscriptions>,
|
|
|
block_commitment_cache: &Arc<RwLock<BlockCommitmentCache>>,
|
|
|
heaviest_subtree_fork_choice: &mut HeaviestSubtreeForkChoice,
|
|
|
bank_notification_sender: &Option<BankNotificationSenderConfig>,
|
|
|
@@ -3051,7 +3053,7 @@ impl ReplayStage {
|
|
|
transaction_status_sender: Option<&TransactionStatusSender>,
|
|
|
heaviest_subtree_fork_choice: &mut HeaviestSubtreeForkChoice,
|
|
|
bank_notification_sender: &Option<BankNotificationSenderConfig>,
|
|
|
- rpc_subscriptions: &Arc<RpcSubscriptions>,
|
|
|
+ rpc_subscriptions: Option<&RpcSubscriptions>,
|
|
|
slot_status_notifier: &Option<SlotStatusNotifier>,
|
|
|
duplicate_slots_tracker: &mut DuplicateSlotsTracker,
|
|
|
duplicate_confirmed_slots: &DuplicateConfirmedSlots,
|
|
|
@@ -3355,7 +3357,7 @@ impl ReplayStage {
|
|
|
heaviest_subtree_fork_choice: &mut HeaviestSubtreeForkChoice,
|
|
|
replay_vote_sender: &ReplayVoteSender,
|
|
|
bank_notification_sender: &Option<BankNotificationSenderConfig>,
|
|
|
- rpc_subscriptions: &Arc<RpcSubscriptions>,
|
|
|
+ rpc_subscriptions: Option<&RpcSubscriptions>,
|
|
|
slot_status_notifier: &Option<SlotStatusNotifier>,
|
|
|
duplicate_slots_tracker: &mut DuplicateSlotsTracker,
|
|
|
duplicate_confirmed_slots: &DuplicateConfirmedSlots,
|
|
|
@@ -3980,7 +3982,7 @@ impl ReplayStage {
|
|
|
blockstore: &Blockstore,
|
|
|
leader_schedule_cache: &Arc<LeaderScheduleCache>,
|
|
|
snapshot_controller: Option<&SnapshotController>,
|
|
|
- rpc_subscriptions: &Arc<RpcSubscriptions>,
|
|
|
+ rpc_subscriptions: Option<&RpcSubscriptions>,
|
|
|
block_commitment_cache: &Arc<RwLock<BlockCommitmentCache>>,
|
|
|
heaviest_subtree_fork_choice: &mut HeaviestSubtreeForkChoice,
|
|
|
bank_notification_sender: &Option<BankNotificationSenderConfig>,
|
|
|
@@ -4042,7 +4044,9 @@ impl ReplayStage {
|
|
|
drop_bank_sender,
|
|
|
)?;
|
|
|
blockstore.slots_stats.mark_rooted(new_root);
|
|
|
- rpc_subscriptions.notify_roots(rooted_slots);
|
|
|
+ if let Some(rpc_subscriptions) = rpc_subscriptions {
|
|
|
+ rpc_subscriptions.notify_roots(rooted_slots);
|
|
|
+ }
|
|
|
if let Some(sender) = bank_notification_sender {
|
|
|
sender
|
|
|
.sender
|
|
|
@@ -4127,7 +4131,7 @@ impl ReplayStage {
|
|
|
blockstore: &Blockstore,
|
|
|
bank_forks: &RwLock<BankForks>,
|
|
|
leader_schedule_cache: &Arc<LeaderScheduleCache>,
|
|
|
- rpc_subscriptions: &Arc<RpcSubscriptions>,
|
|
|
+ rpc_subscriptions: Option<&RpcSubscriptions>,
|
|
|
slot_status_notifier: &Option<SlotStatusNotifier>,
|
|
|
progress: &mut ProgressMap,
|
|
|
replay_timing: &mut ReplayLoopTiming,
|
|
|
@@ -4222,11 +4226,13 @@ impl ReplayStage {
|
|
|
slot: u64,
|
|
|
root_slot: u64,
|
|
|
leader: &Pubkey,
|
|
|
- rpc_subscriptions: &Arc<RpcSubscriptions>,
|
|
|
+ rpc_subscriptions: Option<&RpcSubscriptions>,
|
|
|
slot_status_notifier: &Option<SlotStatusNotifier>,
|
|
|
new_bank_options: NewBankOptions,
|
|
|
) -> Bank {
|
|
|
- rpc_subscriptions.notify_slot(slot, parent.slot(), root_slot);
|
|
|
+ if let Some(rpc_subscriptions) = rpc_subscriptions {
|
|
|
+ rpc_subscriptions.notify_slot(slot, parent.slot(), root_slot);
|
|
|
+ }
|
|
|
if let Some(slot_status_notifier) = slot_status_notifier {
|
|
|
slot_status_notifier
|
|
|
.read()
|
|
|
@@ -4543,6 +4549,8 @@ pub(crate) mod tests {
|
|
|
bank1.freeze();
|
|
|
bank_forks.write().unwrap().insert(bank1);
|
|
|
|
|
|
+ let rpc_subscriptions = Some(rpc_subscriptions);
|
|
|
+
|
|
|
// Insert shreds for slot NUM_CONSECUTIVE_LEADER_SLOTS,
|
|
|
// chaining to slot 1
|
|
|
let (shreds, _) = make_slot_entries(
|
|
|
@@ -4562,7 +4570,7 @@ pub(crate) mod tests {
|
|
|
&blockstore,
|
|
|
&bank_forks,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&None,
|
|
|
&mut progress,
|
|
|
&mut replay_timing,
|
|
|
@@ -4591,7 +4599,7 @@ pub(crate) mod tests {
|
|
|
&blockstore,
|
|
|
&bank_forks,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&None,
|
|
|
&mut progress,
|
|
|
&mut replay_timing,
|
|
|
@@ -5101,13 +5109,15 @@ pub(crate) mod tests {
|
|
|
SlotStatusNotifierForTest::new(dead_slots.clone()),
|
|
|
)));
|
|
|
|
|
|
+ let rpc_subscriptions = Some(rpc_subscriptions);
|
|
|
+
|
|
|
if let Err(err) = &res {
|
|
|
ReplayStage::mark_dead_slot(
|
|
|
&blockstore,
|
|
|
&bank1,
|
|
|
0,
|
|
|
err,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&slot_status_notifier,
|
|
|
&mut DuplicateSlotsTracker::default(),
|
|
|
&DuplicateConfirmedSlots::new(),
|
|
|
@@ -5164,13 +5174,13 @@ pub(crate) mod tests {
|
|
|
let exit = Arc::new(AtomicBool::new(false));
|
|
|
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::default()));
|
|
|
let max_complete_transaction_status_slot = Arc::new(AtomicU64::default());
|
|
|
- let rpc_subscriptions = Arc::new(RpcSubscriptions::new_for_tests(
|
|
|
+ let rpc_subscriptions = Some(Arc::new(RpcSubscriptions::new_for_tests(
|
|
|
exit.clone(),
|
|
|
max_complete_transaction_status_slot,
|
|
|
bank_forks.clone(),
|
|
|
block_commitment_cache.clone(),
|
|
|
OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks),
|
|
|
- ));
|
|
|
+ )));
|
|
|
let (lockouts_sender, _) = AggregateCommitmentService::new(
|
|
|
exit,
|
|
|
block_commitment_cache.clone(),
|
|
|
@@ -6476,12 +6486,14 @@ pub(crate) mod tests {
|
|
|
);
|
|
|
blockstore.insert_shreds(shreds, None, false).unwrap();
|
|
|
|
|
|
+ let rpc_subscriptions = Some(rpc_subscriptions);
|
|
|
+
|
|
|
// 3 should now be an active bank
|
|
|
ReplayStage::generate_new_bank_forks(
|
|
|
&blockstore,
|
|
|
&bank_forks,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&None,
|
|
|
&mut progress,
|
|
|
&mut replay_timing,
|
|
|
@@ -6511,7 +6523,7 @@ pub(crate) mod tests {
|
|
|
&blockstore,
|
|
|
&bank_forks,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&None,
|
|
|
&mut progress,
|
|
|
&mut replay_timing,
|
|
|
@@ -6542,7 +6554,7 @@ pub(crate) mod tests {
|
|
|
&blockstore,
|
|
|
&bank_forks,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&None,
|
|
|
&mut progress,
|
|
|
&mut replay_timing,
|
|
|
@@ -6572,7 +6584,7 @@ pub(crate) mod tests {
|
|
|
&blockstore,
|
|
|
&bank_forks,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&None,
|
|
|
&mut progress,
|
|
|
&mut replay_timing,
|
|
|
@@ -8632,12 +8644,14 @@ pub(crate) mod tests {
|
|
|
// this test to use true to avoid skipping the leader slot
|
|
|
let has_new_vote_been_rooted = true;
|
|
|
|
|
|
+ let rpc_subscriptions = Some(rpc_subscriptions);
|
|
|
+
|
|
|
assert!(!ReplayStage::maybe_start_leader(
|
|
|
my_pubkey,
|
|
|
bank_forks,
|
|
|
&poh_recorder,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&None,
|
|
|
&mut progress,
|
|
|
&retransmit_slots_sender,
|
|
|
@@ -9285,6 +9299,8 @@ pub(crate) mod tests {
|
|
|
// this test to use true to avoid skipping the leader slot
|
|
|
let has_new_vote_been_rooted = true;
|
|
|
|
|
|
+ let rpc_subscriptions = Some(rpc_subscriptions);
|
|
|
+
|
|
|
// We should not attempt to start leader for the dummy_slot
|
|
|
assert_matches!(
|
|
|
poh_recorder.read().unwrap().reached_leader_slot(&my_pubkey),
|
|
|
@@ -9295,7 +9311,7 @@ pub(crate) mod tests {
|
|
|
&bank_forks,
|
|
|
&poh_recorder,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&None,
|
|
|
&mut progress,
|
|
|
&retransmit_slots_sender,
|
|
|
@@ -9321,7 +9337,7 @@ pub(crate) mod tests {
|
|
|
&bank_forks,
|
|
|
&poh_recorder,
|
|
|
&leader_schedule_cache,
|
|
|
- &rpc_subscriptions,
|
|
|
+ rpc_subscriptions.as_deref(),
|
|
|
&None,
|
|
|
&mut progress,
|
|
|
&retransmit_slots_sender,
|