mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 09:41:07 +00:00
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
This commit is contained in:
@@ -155,7 +155,7 @@ const WATERMARK_QUEUE_SIZE: usize = 20000;
|
|||||||
decl_storage! {
|
decl_storage! {
|
||||||
trait Store for Module<T: Trait> as Parachains {
|
trait Store for Module<T: Trait> as Parachains {
|
||||||
/// All authorities' keys at the moment.
|
/// 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.
|
/// The parachains registered at present.
|
||||||
pub Code get(parachain_code): map ParaId => Option<Vec<u8>>;
|
pub Code get(parachain_code): map ParaId => Option<Vec<u8>>;
|
||||||
/// The heads of the parachains registered at present.
|
/// The heads of the parachains registered at present.
|
||||||
@@ -187,6 +187,10 @@ decl_storage! {
|
|||||||
/// None if not yet updated.
|
/// None if not yet updated.
|
||||||
pub DidUpdate: Option<Vec<ParaId>>;
|
pub DidUpdate: Option<Vec<ParaId>>;
|
||||||
}
|
}
|
||||||
|
add_extra_genesis {
|
||||||
|
config(authorities): Vec<ValidatorId>;
|
||||||
|
build(|config| Module::<T>::initialize_authorities(&config.authorities))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decl_module! {
|
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)
|
// TODO: Consider integrating if needed. (https://github.com/paritytech/polkadot/issues/223)
|
||||||
/// Extract the parachain heads from the block.
|
/// 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)
|
fn on_genesis_session<'a, I: 'a>(validators: I)
|
||||||
where I: Iterator<Item=(&'a T::AccountId, Self::Key)>
|
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)
|
fn on_new_session<'a, I: 'a>(changed: bool, validators: I, _queued: I)
|
||||||
where I: Iterator<Item=(&'a T::AccountId, Self::Key)>
|
where I: Iterator<Item=(&'a T::AccountId, Self::Key)>
|
||||||
{
|
{
|
||||||
if changed {
|
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 {
|
GenesisConfig {
|
||||||
authorities: authorities.clone(),
|
authorities: authorities.clone(),
|
||||||
}.assimilate_storage(&mut t).unwrap();
|
}.assimilate_storage::<Test>(&mut t).unwrap();
|
||||||
|
|
||||||
registrar::GenesisConfig::<Test> {
|
registrar::GenesisConfig::<Test> {
|
||||||
parachains,
|
parachains,
|
||||||
|
|||||||
@@ -765,7 +765,7 @@ mod tests {
|
|||||||
|
|
||||||
parachains::GenesisConfig {
|
parachains::GenesisConfig {
|
||||||
authorities: authorities.clone(),
|
authorities: authorities.clone(),
|
||||||
}.assimilate_storage(&mut t).unwrap();
|
}.assimilate_storage::<Test>(&mut t).unwrap();
|
||||||
|
|
||||||
GenesisConfig::<Test> {
|
GenesisConfig::<Test> {
|
||||||
parachains,
|
parachains,
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
|||||||
{
|
{
|
||||||
use substrate_network::DhtEvent;
|
use substrate_network::DhtEvent;
|
||||||
|
|
||||||
let is_authority = config.roles.is_authority();
|
|
||||||
let is_collator = config.custom.collating_for.is_some();
|
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 force_authoring = config.force_authoring;
|
||||||
let max_block_data_size = config.custom.max_block_data_size;
|
let max_block_data_size = config.custom.max_block_data_size;
|
||||||
let db_path = config.database_path.clone();
|
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()
|
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");
|
.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 client = service.client();
|
||||||
let known_oracle = client.clone();
|
let known_oracle = client.clone();
|
||||||
let select_chain = if let Some(select_chain) = service.select_chain() {
|
let select_chain = if let Some(select_chain) = service.select_chain() {
|
||||||
|
|||||||
Reference in New Issue
Block a user