mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +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! {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user