Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #88 from logion-network/feature/fix-sync
Browse files Browse the repository at this point in the history
Fix new node sync in MVP
  • Loading branch information
gdethier authored Jan 11, 2024
2 parents 5f45e56 + 31869ce commit 15c6060
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
use futures::FutureExt;
use logion_node_runtime::{self, opaque::Block, RuntimeApi};
use sc_client_api::{Backend, BlockBackend};
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams, CompatibilityMode};
use sc_consensus_grandpa::SharedVoterState;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sp_runtime::traits::NumberFor;
use std::{sync::Arc, time::Duration};

pub(crate) type FullClient = sc_service::TFullClient<
Expand Down Expand Up @@ -111,7 +112,7 @@ pub fn new_partial(
registry: config.prometheus_registry(),
check_for_equivocation: Default::default(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
compatibility_mode: Default::default(),
compatibility_mode: compatibility_mode(&config),
})?;

Ok(sc_service::PartialComponents {
Expand All @@ -126,6 +127,19 @@ pub fn new_partial(
})
}

fn compatibility_mode(config: &Configuration) -> CompatibilityMode<NumberFor<Block>> {
if config.chain_spec.id().contains("mvp") {
CompatibilityMode::UseInitializeBlock {
// On MVP chain, verification fails on block 0x2b4e96021b427ac071238e530dd1a10993c6e22bea6d61f106358d31ed0c3212
// which has number 1053452. So until must be set to 1053452 + 1
// (see https://github.com/paritytech/substrate/blob/master/client/consensus/aura/src/lib.rs#L94-L101).
until: 1053453
}
} else {
CompatibilityMode::None
}
}

/// Builds a new service for a full client.
pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let sc_service::PartialComponents {
Expand Down

0 comments on commit 15c6060

Please sign in to comment.