Skip to content

Commit 8260c98

Browse files
carllinbw-solana
authored andcommitted
Fix some panics (anza-xyz#100)
1 parent b921174 commit 8260c98

2 files changed

Lines changed: 48 additions & 22 deletions

File tree

core/src/consensus/progress_map.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,26 @@ impl ForkProgress {
193193
num_dropped_blocks_on_fork,
194194
);
195195

196-
if let Some(first_alpenglow_slot) = bank
197-
.feature_set
198-
.activated_slot(&solana_feature_set::secp256k1_program_enabled::id())
199-
{
200-
if let Some(num_expected_ticks) = Self::calculate_alpenglow_ticks(
201-
bank.slot(),
202-
first_alpenglow_slot,
203-
bank.parent_slot(),
204-
bank.ticks_per_slot(),
205-
) {
206-
bank.set_tick_height(bank.max_tick_height() - num_expected_ticks);
196+
// Don't need set ticks for our own leader banks, poh service will do that
197+
if bank.collector_id() != validator_identity {
198+
if let Some(first_alpenglow_slot) = bank
199+
.feature_set
200+
.activated_slot(&solana_feature_set::secp256k1_program_enabled::id())
201+
{
202+
if let Some(num_expected_ticks) = Self::calculate_alpenglow_ticks(
203+
bank.slot(),
204+
first_alpenglow_slot,
205+
bank.parent_slot(),
206+
bank.ticks_per_slot(),
207+
) {
208+
info!(
209+
"{} setting tick height for slot {} to {}",
210+
validator_identity,
211+
bank.slot(),
212+
bank.max_tick_height() - num_expected_ticks
213+
);
214+
bank.set_tick_height(bank.max_tick_height() - num_expected_ticks);
215+
}
207216
}
208217
}
209218

core/src/replay_stage.rs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,6 +2404,12 @@ impl ReplayStage {
24042404
leader_schedule_cache,
24052405
);
24062406
}
2407+
2408+
info!(
2409+
"new fork:{} parent:{} (leader) root:{}",
2410+
my_leader_slot, parent_slot, root_slot
2411+
);
2412+
24072413
let tpu_bank = Self::new_bank_from_parent_with_notify(
24082414
parent_bank.clone(),
24092415
my_leader_slot,
@@ -2476,6 +2482,17 @@ impl ReplayStage {
24762482
}
24772483
} else {
24782484
// We are in full alpenglow mode
2485+
let highest_certificate_slot = cert_pool.highest_certificate_slot();
2486+
if highest_certificate_slot < first_alpenglow_slot.unwrap() {
2487+
// We haven't got a notarization cert yet for any of the first
2488+
// alpenglow slots after the migration, wait for something to
2489+
// get notarized
2490+
info!(
2491+
"{} alpenglow maybe_start_leader no notarization certificates yet",
2492+
my_pubkey
2493+
);
2494+
return false;
2495+
}
24792496
info!(
24802497
"alpenglow maybe_start_leader certficates
24812498
higheset notarized slot: {},
@@ -2487,7 +2504,7 @@ impl ReplayStage {
24872504
);
24882505
(
24892506
cert_pool.highest_not_skip_certificate_slot(),
2490-
cert_pool.highest_certificate_slot() + 1,
2507+
highest_certificate_slot + 1,
24912508
)
24922509
}
24932510
};
@@ -2774,9 +2791,9 @@ impl ReplayStage {
27742791
return None;
27752792
};
27762793
info!(
2777-
"pushing into vote pool {} {}",
2778-
vote_bank.epoch_vote_account_stake(vote_account_pubkey),
2779-
vote_bank.total_epoch_stake()
2794+
"{} pushing into vote pool {:?}",
2795+
identity_keypair.pubkey(),
2796+
vote
27802797
);
27812798
let Ok(maybe_new_cert) = cert_pool.add_vote(
27822799
&vote,
@@ -3353,7 +3370,6 @@ impl ReplayStage {
33533370
.expect("alpenglow feature must have been enabled if migration is complete");
33543371
let highest_frozen_bank = bank_forks.read().unwrap().highest_frozen_bank();
33553372
assert!(highest_frozen_bank.is_frozen());
3356-
assert!(highest_frozen_bank.slot() >= first_alpenglow_slot);
33573373

33583374
let poh_start_slot = poh_recorder.read().unwrap().start_slot();
33593375
if poh_start_slot < highest_frozen_bank.slot() {
@@ -3366,7 +3382,8 @@ impl ReplayStage {
33663382
// was a skip certificate for your slot, so it's ok to abandon your leader slot
33673383
//
33683384
// TODO: move PohRecorder::would_be_leader() to skip loop timer
3369-
// TODO: test this scenario
3385+
// TODO: test this scenario if we reset immediately after starting up a
3386+
// leader block
33703387
Self::reset_poh_recorder(
33713388
my_pubkey,
33723389
blockstore,
@@ -3375,8 +3392,10 @@ impl ReplayStage {
33753392
leader_schedule_cache,
33763393
);
33773394
}
3395+
33783396
// Try to notarize the highest frozen bank
3379-
if vote_history.latest_notarize_vote.slot() != highest_frozen_bank.slot()
3397+
if highest_frozen_bank.slot() >= first_alpenglow_slot
3398+
&& vote_history.latest_notarize_vote.slot() != highest_frozen_bank.slot()
33803399
&& !vote_history.is_slot_skipped(highest_frozen_bank.slot())
33813400
{
33823401
// TODO: Consider if voting on duplicate requires a retry, or not necessary if the other one has already been notarized?
@@ -3414,10 +3433,8 @@ impl ReplayStage {
34143433

34153434
// Try to finalize the highest notarized block
34163435
let highest_notarized_slot = cert_pool.highest_notarized_slot();
3417-
// Validators shouldn't be notarizing non alpenglow slots
3418-
assert!(highest_notarized_slot >= first_alpenglow_slot);
3419-
3420-
if vote_history.latest_finalize_vote.slot() != highest_notarized_slot
3436+
if highest_notarized_slot >= first_alpenglow_slot
3437+
&& vote_history.latest_finalize_vote.slot() != highest_notarized_slot
34213438
&& !vote_history.is_slot_skipped(highest_notarized_slot)
34223439
{
34233440
let maybe_vote_bank = bank_forks.read().unwrap().get(highest_notarized_slot);

0 commit comments

Comments
 (0)