Skip to content

Commit

Permalink
Merge pull request #2954 from autonomys/snap-sync-dev
Browse files Browse the repository at this point in the history
Override sync_mode by dev flag.
  • Loading branch information
shamil-gadelshin committed Jul 29, 2024
2 parents e075aea + ef9c347 commit 14e043e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/subspace-node/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub async fn run(run_options: RunOptions) -> Result<(), Error> {

if maybe_domain_configuration.is_some() && subspace_configuration.sync == ChainSyncMode::Snap {
return Err(Error::Other(
"Snap sync mode is not supported for domains".to_string(),
"Snap sync mode is not supported for domains, use full sync".to_string(),
));
}

Expand Down
16 changes: 13 additions & 3 deletions crates/subspace-node/src/commands/run/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,10 @@ pub(super) struct ConsensusChainOptions {
timekeeper_options: TimekeeperOptions,

/// Sync mode
#[arg(long, default_value_t = ChainSyncMode::Snap)]
sync: ChainSyncMode,
///
/// Examples: `snap`, `full`
#[arg(long, default_value = None)]
sync: Option<ChainSyncMode>,
}

pub(super) struct PrometheusConfiguration {
Expand Down Expand Up @@ -451,11 +453,12 @@ pub(super) fn create_consensus_chain_configuration(
dsn_options,
storage_monitor,
mut timekeeper_options,
sync,
mut sync,
} = consensus_node_options;

let transaction_pool;
let rpc_cors;

// Development mode handling is limited to this section
{
if dev {
Expand All @@ -468,6 +471,10 @@ pub(super) fn create_consensus_chain_configuration(
force_authoring = true;
network_options.allow_private_ips = true;
timekeeper_options.timekeeper = true;

if sync.is_none() {
sync.replace(ChainSyncMode::Full);
}
}

transaction_pool = pool_config.transaction_pool(dev);
Expand All @@ -487,6 +494,9 @@ pub(super) fn create_consensus_chain_configuration(
});
}

// Snap sync is the default mode.
let sync = sync.unwrap_or(ChainSyncMode::Snap);

let chain_spec = match chain.as_deref() {
Some("gemini-3h-compiled") => chain_spec::gemini_3h_compiled()?,
Some("gemini-3h") => chain_spec::gemini_3h_config()?,
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl FromStr for ChainSyncMode {
match input {
"full" => Ok(Self::Full),
"snap" => Ok(Self::Snap),
_ => Err("Unsupported sync type".to_string()),
_ => Err("Unsupported sync type: use full or snap".to_string()),
}
}
}
Expand Down

0 comments on commit 14e043e

Please sign in to comment.