Skip to content

Commit fb4157c

Browse files
committed
better babe to aura handling
1 parent f19b42c commit fb4157c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

node/src/command.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ fn start_babe_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
253253
}) {
254254
Ok(_) => Ok(()),
255255
Err(e) => {
256-
// Handle node needs to be in Aura mode.
256+
// Handle node needs to be in Aura mode. InvalidAuthoritiesSet error is returned when
257+
// the runtime is not a valid Babe runtime.
257258
if matches!(
258259
e,
259-
sc_service::Error::Client(sp_blockchain::Error::VersionInvalid(ref msg))
260-
if msg == "Unsupported or invalid BabeApi version"
260+
sc_service::Error::Consensus(sp_consensus::Error::InvalidAuthoritiesSet)
261261
) {
262262
log::info!(
263263
"💡 Chain is using Aura consensus. Switching to Aura service until Babe block is detected.",

node/src/consensus/babe_consensus.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::{
99
use fc_consensus::FrontierBlockImport;
1010
use jsonrpsee::Methods;
1111
use node_subtensor_runtime::opaque::Block;
12+
use num_traits::Zero as _;
1213
use sc_client_api::{AuxStore, BlockOf};
1314
use sc_consensus::{BlockImport, BoxBlockImport};
1415
use sc_consensus_babe::{BabeLink, BabeWorkerHandle};
@@ -138,8 +139,13 @@ impl ConsensusMechanism for BabeConsensus {
138139
telemetry: Option<TelemetryHandle>,
139140
grandpa_block_import: GrandpaBlockImport,
140141
transaction_pool: Arc<TransactionPoolHandle<Block, FullClient>>| {
142+
let configuration = sc_consensus_babe::configuration(&*client)?;
143+
if configuration.authorities.len().is_zero() {
144+
return Err(sc_service::Error::Consensus(sp_consensus::Error::InvalidAuthoritiesSet));
145+
}
146+
141147
let (babe_import, babe_link) = sc_consensus_babe::block_import(
142-
sc_consensus_babe::configuration(&*client)?,
148+
configuration,
143149
grandpa_block_import.clone(),
144150
client.clone(),
145151
)?;

0 commit comments

Comments
 (0)