Unverified Commit b5cdfbea authored by Bastian Köcher's avatar Bastian Köcher Committed by GitHub
Browse files

Fixes required for Cumulus (#485)

* Collator node need to register all gossip validators as well

* Make sure that parachain authorities are only written once at genesis

* Fix test
parent 946940e6
Pipeline #54435 failed with stages
in 15 minutes and 39 seconds
......@@ -155,7 +155,7 @@ const WATERMARK_QUEUE_SIZE: usize = 20000;
decl_storage! {
trait Store for Module<T: Trait> as Parachains {
/// All authorities' keys at the moment.
pub Authorities get(authorities) config(authorities): Vec<ValidatorId>;
pub Authorities get(authorities): Vec<ValidatorId>;
/// The parachains registered at present.
pub Code get(parachain_code): map ParaId => Option<Vec<u8>>;
/// The heads of the parachains registered at present.
......@@ -187,6 +187,10 @@ decl_storage! {
/// None if not yet updated.
pub DidUpdate: Option<Vec<ParaId>>;
}
add_extra_genesis {
config(authorities): Vec<ValidatorId>;
build(|config| Module::<T>::initialize_authorities(&config.authorities))
}
}
decl_module! {
......@@ -814,6 +818,13 @@ impl<T: Trait> Module<T> {
})
}
fn initialize_authorities(authorities: &[ValidatorId]) {
if !authorities.is_empty() {
assert!(Authorities::get().is_empty(), "Authorities are already initialized!");
Authorities::put(authorities);
}
}
/*
// TODO: Consider integrating if needed. (https://github.com/paritytech/polkadot/issues/223)
/// Extract the parachain heads from the block.
......@@ -837,14 +848,14 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
fn on_genesis_session<'a, I: 'a>(validators: I)
where I: Iterator<Item=(&'a T::AccountId, Self::Key)>
{
<Self as Store>::Authorities::put(&validators.map(|(_, key)| key).collect::<Vec<_>>())
Self::initialize_authorities(&validators.map(|(_, key)| key).collect::<Vec<_>>());
}
fn on_new_session<'a, I: 'a>(changed: bool, validators: I, _queued: I)
where I: Iterator<Item=(&'a T::AccountId, Self::Key)>
{
if changed {
Self::on_genesis_session(validators)
<Self as Store>::Authorities::put(validators.map(|(_, key)| key).collect::<Vec<_>>());
}
}
......@@ -1132,7 +1143,7 @@ mod tests {
GenesisConfig {
authorities: authorities.clone(),
}.assimilate_storage(&mut t).unwrap();
}.assimilate_storage::<Test>(&mut t).unwrap();
registrar::GenesisConfig::<Test> {
parachains,
......
......@@ -765,7 +765,7 @@ mod tests {
parachains::GenesisConfig {
authorities: authorities.clone(),
}.assimilate_storage(&mut t).unwrap();
}.assimilate_storage::<Test>(&mut t).unwrap();
GenesisConfig::<Test> {
parachains,
......
......@@ -141,8 +141,8 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
{
use substrate_network::DhtEvent;
let is_authority = config.roles.is_authority();
let is_collator = config.custom.collating_for.is_some();
let is_authority = config.roles.is_authority() && !is_collator;
let force_authoring = config.force_authoring;
let max_block_data_size = config.custom.max_block_data_size;
let db_path = config.database_path.clone();
......@@ -169,13 +169,6 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
let (block_import, link_half, babe_link) = import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
if is_collator {
info!(
"The node cannot start as an authority because it is also configured to run as a collator."
);
return Ok(service);
}
let client = service.client();
let known_oracle = client.clone();
let select_chain = if let Some(select_chain) = service.select_chain() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment