Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP
Forked at: 461b971
Parent branch: origin/master
  • Loading branch information
cecton committed Apr 8, 2020
commit 132bfeaed63063582606deffe77e30decfe247d8
21 changes: 11 additions & 10 deletions test/parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,24 @@ pub fn run() -> Result<()> {
*/

// TODO
//let key = Arc::new(sp_core::Pair::from_seed(&[10; 32]));
let key = Arc::new(sp_core::Pair::from_seed(&[10; 32]));

//polkadot_config.config_dir = config.in_chain_config_dir("polkadot");

let polkadot_cli = PolkadotCli::from_iter(
[PolkadotCli::executable_name().to_string()].iter().chain(cli.relaychain_args.iter()),
);

let polkadot_runner = polkadot_cli.create_runner(&polkadot_cli)?;
runner.async_run(|config| {
let task_executor = config.task_executor.clone();
let polkadot_config = <PolkadotCli as SubstrateCli>::create_configuration(&polkadot_cli, &polkadot_cli, task_executor).expect("TODO");

match config.role {
ServiceRole::Light => unimplemented!("Light client not supported!"),
_ => crate::service::run_collator(config, key, polkadot_config),
}
});

/*
match config.role {
ServiceRole::Light => unimplemented!("Light client not supported!"),
_ => crate::service::run_collator(config, key, polkadot_config),
}
*/
Ok(())
},
}
Expand Down Expand Up @@ -286,8 +288,7 @@ impl CliConfiguration for PolkadotCli {
}

fn init<C: SubstrateCli>(&self) -> Result<()> {
// NOTE: already initialized so, skipping...
Ok(())
unreachable!("PolkadotCli is never initialized; qed");
}
}

Expand Down
85 changes: 39 additions & 46 deletions test/parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,53 +71,46 @@ macro_rules! new_full_start {
/// Run a collator node with the given parachain `Configuration` and relaychain `Configuration`
///
/// This function blocks until done.
pub fn run_collator(
pub async fn run_collator(
parachain_config: Configuration,
key: Arc<CollatorPair>,
mut polkadot_config: polkadot_collator::Configuration,
polkadot_config: polkadot_collator::Configuration,
) -> sc_cli::Result<()> {
todo!();
/*
sc_cli::run_service_until_exit(parachain_config, move |parachain_config| {
polkadot_config.task_executor = parachain_config.task_executor.clone();

let (builder, inherent_data_providers) = new_full_start!(parachain_config);
inherent_data_providers
.register_provider(sp_timestamp::InherentDataProvider)
.unwrap();

let service = builder
.with_finality_proof_provider(|client, backend| {
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})?
.build()?;

let proposer_factory = sc_basic_authorship::ProposerFactory::new(
service.client(),
service.transaction_pool(),
);

let block_import = service.client();
let client = service.client();
let builder = CollatorBuilder::new(
proposer_factory,
inherent_data_providers,
block_import,
crate::PARA_ID,
client,
);

let polkadot_future = polkadot_collator::start_collator(
builder,
crate::PARA_ID,
key,
polkadot_config,
).map(|_| ());
service.spawn_essential_task("polkadot", polkadot_future);

Ok(service)
})
*/
let (builder, inherent_data_providers) = new_full_start!(parachain_config);
inherent_data_providers
.register_provider(sp_timestamp::InherentDataProvider)
.unwrap();

let service = builder
.with_finality_proof_provider(|client, backend| {
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})?
.build()?;

let proposer_factory = sc_basic_authorship::ProposerFactory::new(
service.client(),
service.transaction_pool(),
);

let block_import = service.client();
let client = service.client();
let builder = CollatorBuilder::new(
proposer_factory,
inherent_data_providers,
block_import,
crate::PARA_ID,
client,
);

let polkadot_future = polkadot_collator::start_collator(
builder,
crate::PARA_ID,
key,
polkadot_config,
).map(|_| ());
service.spawn_essential_task("polkadot", polkadot_future);

service.await.map_err(Into::into)
}