Skip to content

Commit fb40725

Browse files
committed
fix warp sync
1 parent b81862a commit fb40725

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

node/src/consensus/aura_consensus.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,17 @@ impl ConsensusMechanism for AuraConsensus {
210210
loop {
211211
// Check if the runtime is Babe once per block.
212212
if let Ok(c) = sc_consensus_babe::configuration(&*client) {
213-
let warp_syncing = sync_service.status().await.is_ok_and(|status| status.warp_sync.is_some());
214-
if !c.authorities.is_empty() && !warp_syncing {
215-
log::info!("Babe runtime detected! Intentionally failing the essential handle `babe-switch` to trigger switch to Babe service.");
216-
if let Some(triggered) = triggered {
217-
triggered.store(true, std::sync::atomic::Ordering::SeqCst);
218-
};
219-
break;
220-
}
213+
// Aura Consensus uses the hybrid import queue which is able to import both
214+
// Aura and Babe blocks. Wait until sync finishes before switching to the
215+
// Babe service to not break warp sync.
216+
let syncing = sync_service.status().await.is_ok_and(|status| status.warp_sync.is_some() || status.state_sync.is_some());
217+
if !c.authorities.is_empty() && !syncing {
218+
log::info!("Babe runtime detected! Intentionally failing the essential handle `babe-switch` to trigger switch to Babe service.");
219+
if let Some(triggered) = triggered {
220+
triggered.store(true, std::sync::atomic::Ordering::SeqCst);
221+
};
222+
break;
223+
}
221224
};
222225
tokio::time::sleep(slot_duration.as_duration()).await;
223226
}
@@ -260,8 +263,8 @@ where
260263
.into_iter()
261264
.map(|a| (BabeAuthorityId::from(a.into_inner()), 1))
262265
.collect();
263-
let slot_duration = runtime_api.slot_duration(at_hash)?.as_millis();
264266

267+
let slot_duration = runtime_api.slot_duration(at_hash)?.as_millis();
265268
let epoch_config = node_subtensor_runtime::BABE_GENESIS_EPOCH_CONFIG;
266269
let config = sp_consensus_babe::BabeConfiguration {
267270
slot_duration,

0 commit comments

Comments
 (0)