Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaner enabling of development service #260

Merged
merged 12 commits into from
Feb 23, 2021
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions moonbeam-types-bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ export const moonbeamDefinitions = {
nominators: "Vec<Bond>",
total: "Balance",
},
SystemInherentData: {
validation_data: "PersistedValidationData",
relay_chain_state: "StorageProof",
downward_messages: "Vec<InboundDownwardMessage>",
horizontal_messages: "BTreeMap<ParaId, Vec<InboundHrmpMessage>>",
},
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion moonbeam-types-bundle/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = 'moonbeam'
description = 'Moonbeam Collator'
homepage = 'https://moonbeam.network'
license = 'GPL-3.0-only'
version = '0.6.0'
version = '0.6.1'
authors = ["PureStake"]
build = 'build.rs'
edition = '2018'
Expand Down
2 changes: 1 addition & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn development_chain_spec() -> ChainSpec {
None,
Some(serde_json::from_str("{\"tokenDecimals\": 18}").expect("Provided valid json map")),
Extensions {
relay_chain: Default::default(),
relay_chain: "dev-service".into(),
para_id: Default::default(),
},
)
Expand Down
4 changes: 4 additions & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ pub struct RunCmd {
#[structopt(long)]
pub parachain_id: Option<u32>,

/// Enable the development service to run without a backing relay chain
#[structopt(long)]
pub dev_service: bool,

/// When blocks should be sealed in the dev service.
///
/// Options are "instant", "manual", or timer interval in milliseconds
Expand Down
41 changes: 27 additions & 14 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub fn run() -> Result<()> {
task_manager,
import_queue,
..
} = crate::service::new_partial(&config, None)?;
} = crate::service::new_partial(&config, None, false)?;
Ok((cmd.run(client, import_queue), task_manager))
})
}
Expand All @@ -187,7 +187,7 @@ pub fn run() -> Result<()> {
client,
task_manager,
..
} = crate::service::new_partial(&config, None)?;
} = crate::service::new_partial(&config, None, false)?;
Ok((cmd.run(client, config.database), task_manager))
})
}
Expand All @@ -198,7 +198,7 @@ pub fn run() -> Result<()> {
client,
task_manager,
..
} = crate::service::new_partial(&config, None)?;
} = crate::service::new_partial(&config, None, false)?;
Ok((cmd.run(client, config.chain_spec), task_manager))
})
}
Expand All @@ -210,7 +210,7 @@ pub fn run() -> Result<()> {
task_manager,
import_queue,
..
} = crate::service::new_partial(&config, None)?;
} = crate::service::new_partial(&config, None, false)?;
Ok((cmd.run(client, import_queue), task_manager))
})
}
Expand All @@ -226,7 +226,7 @@ pub fn run() -> Result<()> {
task_manager,
backend,
..
} = crate::service::new_partial(&config, None)?;
} = crate::service::new_partial(&config, None, false)?;
Ok((cmd.run(client, backend), task_manager))
})
}
Expand Down Expand Up @@ -285,26 +285,39 @@ pub fn run() -> Result<()> {

runner
.run_node_until_exit(|config| async move {
// If this is a --dev node, start up manual or instant seal.
let key = sp_core::Pair::generate().0;

let extension = chain_spec::Extensions::try_get(&*config.chain_spec);
let relay_chain_id = extension.map(|e| e.relay_chain.clone());
let para_id = extension.map(|e| e.para_id);

// If dev service was requested, start up manual or instant seal.
// Otherwise continue with the normal parachain node.
if cli.run.base.shared_params.dev {
// Dev service can be requested in two ways.
// 1. by providing the --dev-service flag to the CLI
// 2. by specifying "dev-service" in the chain spec's "relay-chain" field.
// NOTE: the --dev flag triggers the dev service by way of number 2
if cli.run.dev_service || relay_chain_id == Some("dev-service".to_string()) {
// --dev implies --collator
let collator = collator || cli.run.shared_params.dev;

// If no author id was supplied, use the one that is staked at genesis
// in the default development spec.
let author_id = author_id.or_else(|| {
Some(
AccountId::from_str("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")
.expect("Gerald is a valid account"),
)
});

return crate::dev_service::new_full(config, cli.run.sealing, author_id);
return crate::service::new_dev(
config,
cli.run.sealing,
author_id,
collator,
);
}

let key = sp_core::Pair::generate().0;

let extension = chain_spec::Extensions::try_get(&*config.chain_spec);
let relay_chain_id = extension.map(|e| e.relay_chain.clone());
let para_id = extension.map(|e| e.para_id);

let polkadot_cli = RelayChainCli::new(
config.base_path.as_ref().map(|x| x.path().join("polkadot")),
relay_chain_id,
Expand Down
Loading