Skip to content

Commit 32224c3

Browse files
committed
Notify rpc of new root and supermajority roots (#70)
1 parent b59e7d4 commit 32224c3

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

core/src/replay_stage.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use {
7070
accounts_background_service::AbsRequestSender,
7171
bank::{bank_hash_details, Bank, NewBankOptions},
7272
bank_forks::{BankForks, SetRootError, MAX_ROOT_DISTANCE_FOR_VOTE_ONLY},
73-
commitment::BlockCommitmentCache,
73+
commitment::{BlockCommitmentCache, CommitmentSlots},
7474
installed_scheduler_pool::BankWithScheduler,
7575
prioritization_fee_cache::PrioritizationFeeCache,
7676
vote_sender_types::ReplayVoteSender,
@@ -1268,16 +1268,16 @@ impl ReplayStage {
12681268
.then_some(r_bank_forks.get(maybe_new_root).unwrap())
12691269
};
12701270
if let Some(new_root_bank) = maybe_new_root_bank {
1271+
let new_root_slot = new_root_bank.slot();
12711272
if let Err(e) = Self::alpenglow_handle_new_root(
12721273
&new_root_bank, // unnecessary here, just filling out a random bank
1273-
new_root_bank.slot(),
1274+
new_root_slot,
12741275
&bank_forks,
12751276
&mut progress,
12761277
&blockstore,
12771278
&leader_schedule_cache,
12781279
&accounts_background_request_sender,
12791280
&rpc_subscriptions,
1280-
&block_commitment_cache,
12811281
&mut heaviest_subtree_fork_choice,
12821282
&bank_notification_sender,
12831283
&mut duplicate_slots_tracker,
@@ -1296,6 +1296,12 @@ impl ReplayStage {
12961296
);
12971297
return;
12981298
}
1299+
rpc_subscriptions.notify_subscribers(CommitmentSlots {
1300+
slot: new_root_slot,
1301+
root: new_root_slot,
1302+
highest_confirmed_slot: new_root_slot,
1303+
highest_super_majority_root: new_root_slot,
1304+
});
12991305
}
13001306
}
13011307

@@ -2805,8 +2811,6 @@ impl ReplayStage {
28052811
saved_vote_history: SavedVoteHistoryVersions::from(saved_vote_history),
28062812
})
28072813
.unwrap_or_else(|err| warn!("Error: {:?}", err));
2808-
2809-
// TODO: update the commitmment cache
28102814
maybe_new_cert.and_then(|new_cert| new_cert.is_finalize().then_some(new_cert.slot()))
28112815
}
28122816

@@ -2861,6 +2865,12 @@ impl ReplayStage {
28612865
);
28622866
}
28632867
}
2868+
let highest_super_majority_root = Some(
2869+
block_commitment_cache
2870+
.read()
2871+
.unwrap()
2872+
.highest_super_majority_root(),
2873+
);
28642874
Self::check_and_handle_new_root(
28652875
bank,
28662876
new_root,
@@ -2870,7 +2880,7 @@ impl ReplayStage {
28702880
leader_schedule_cache,
28712881
accounts_background_request_sender,
28722882
rpc_subscriptions,
2873-
block_commitment_cache,
2883+
highest_super_majority_root,
28742884
heaviest_subtree_fork_choice,
28752885
bank_notification_sender,
28762886
duplicate_slots_tracker,
@@ -4699,7 +4709,6 @@ impl ReplayStage {
46994709
leader_schedule_cache: &Arc<LeaderScheduleCache>,
47004710
accounts_background_request_sender: &AbsRequestSender,
47014711
rpc_subscriptions: &Arc<RpcSubscriptions>,
4702-
block_commitment_cache: &Arc<RwLock<BlockCommitmentCache>>,
47034712
heaviest_subtree_fork_choice: &mut HeaviestSubtreeForkChoice,
47044713
bank_notification_sender: &Option<BankNotificationSenderConfig>,
47054714
duplicate_slots_tracker: &mut DuplicateSlotsTracker,
@@ -4723,7 +4732,7 @@ impl ReplayStage {
47234732
leader_schedule_cache,
47244733
accounts_background_request_sender,
47254734
rpc_subscriptions,
4726-
block_commitment_cache,
4735+
Some(new_root),
47274736
heaviest_subtree_fork_choice,
47284737
bank_notification_sender,
47294738
duplicate_slots_tracker,
@@ -4746,7 +4755,7 @@ impl ReplayStage {
47464755
leader_schedule_cache: &Arc<LeaderScheduleCache>,
47474756
accounts_background_request_sender: &AbsRequestSender,
47484757
rpc_subscriptions: &Arc<RpcSubscriptions>,
4749-
block_commitment_cache: &Arc<RwLock<BlockCommitmentCache>>,
4758+
highest_super_majority_root: Option<Slot>,
47504759
heaviest_subtree_fork_choice: &mut HeaviestSubtreeForkChoice,
47514760
bank_notification_sender: &Option<BankNotificationSenderConfig>,
47524761
duplicate_slots_tracker: &mut DuplicateSlotsTracker,
@@ -4785,12 +4794,6 @@ impl ReplayStage {
47854794
blockstore
47864795
.set_roots(rooted_slots.iter())
47874796
.expect("Ledger set roots failed");
4788-
let highest_super_majority_root = Some(
4789-
block_commitment_cache
4790-
.read()
4791-
.unwrap()
4792-
.highest_super_majority_root(),
4793-
);
47944797
Self::handle_new_root(
47954798
new_root,
47964799
bank_forks,

0 commit comments

Comments
 (0)