Skip to content

Commit

Permalink
breaking everything once again
Browse files Browse the repository at this point in the history
  • Loading branch information
girazoki committed Sep 11, 2024
1 parent 849e7f3 commit 19ea144
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
15 changes: 5 additions & 10 deletions pallets/registrar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,12 @@ pub mod pallet {
// Account for on_finalize weight
let mut weight = Weight::zero().saturating_add(T::DbWeight::get().reads(1));

let buffered_paras = BufferedParasToDeregister::<T>::get();
for _ in 0..buffered_paras.len() {
let buffered_paras = BufferedParasToDeregister::<T>::take();

for para_id in buffered_paras {
weight += T::InnerRegistrar::deregister_weight();
// Deregister (in the relay context) each paraId present inside the buffer
T::InnerRegistrar::deregister(para_id);
}
weight
}
Expand Down Expand Up @@ -466,14 +469,6 @@ pub mod pallet {

Ok(())
}

fn on_finalize(_: BlockNumberFor<T>) {
let buffered_paras = BufferedParasToDeregister::<T>::take();
for para_id in buffered_paras {
// Deregister (in the relay context) each paraId present inside the buffer.
T::InnerRegistrar::deregister(para_id);
}
}
}

#[pallet::call]
Expand Down
2 changes: 1 addition & 1 deletion solo-chains/runtime/starlight/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub mod system_parachain {
}

/// Starlight Treasury pallet instance.
pub const TREASURY_PALLET_ID: u8 = 18;
pub const TREASURY_PALLET_ID: u8 = 40;

#[cfg(test)]
mod tests {
Expand Down
1 change: 1 addition & 0 deletions solo-chains/runtime/starlight/src/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ pub fn start_block() {

// Initialize the new block
Babe::on_initialize(System::block_number());
ContainerRegistrar::on_initialize(System::block_number());
Session::on_initialize(System::block_number());
Initializer::on_initialize(System::block_number());
TanssiCollatorAssignment::on_initialize(System::block_number());
Expand Down
4 changes: 4 additions & 0 deletions solo-chains/runtime/starlight/src/tests/relay_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ fn deregister_calls_schedule_para_cleanup() {
assert_eq!(Runtime::genesis_data(1003.into()).as_ref(), None);

// Para should be offboarding after 2 sessions.
// we need one more block to trigger the on_initialize of containerRegistrar
// which should fully clean everything
start_block();
assert!(Paras::lifecycle(1003.into())
.expect("para should be offboarding")
.is_offboarding());
Expand Down Expand Up @@ -553,6 +556,7 @@ fn deregister_two_paras_in_the_same_block() {
assert_eq!(Runtime::genesis_data(1003.into()).as_ref(), None);
assert_eq!(Runtime::genesis_data(1004.into()).as_ref(), None);

start_block();
// Paras should be offboarding after 2 sessions.
assert!(Paras::lifecycle(1003.into())
.expect("para should be offboarding")
Expand Down
1 change: 1 addition & 0 deletions test/suites/dev-tanssi-relay/registrar/test_registrars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ describeSuite({
const onChainGenesisDataAfter = await polkadotJs.query.containerRegistrar.paraGenesisData(2002);
expect(onChainGenesisDataAfter.toHuman()).to.be.null;

await context.createBlock();
// Para should be offboarding
const isOffboarding = await polkadotJs.query.paras.paraLifecycles(2002);
expect(isOffboarding.toString()).to.eq("OffboardingParathread");
Expand Down

0 comments on commit 19ea144

Please sign in to comment.