Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statement-distribution: Ensure we deactivate leaves before activating #3042

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
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
4 changes: 3 additions & 1 deletion polkadot/node/network/statement-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,10 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
if let Some(ref activated) = activated {
let mode = prospective_parachains_mode(ctx.sender(), activated.hash).await?;
if let ProspectiveParachainsMode::Enabled { .. } = mode {
v2::handle_active_leaves_update(ctx, state, activated, mode).await?;
// Ensure we deactivate first, before we activate the new block.
// Activation can fail and then we would skip the deactivation.
v2::handle_deactivate_leaves(state, &deactivated);
v2::handle_active_leaves_update(ctx, state, activated, mode).await?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may cause issues as ordering was somewhat sensitive here.

Reference counts for active leaves may drop to zero and then be incremented back to 1 again. It would be more reliable to just ensure that we handle_deactivate_leaves even if handle_active_leaves_update fails.

} else if let ProspectiveParachainsMode::Disabled = mode {
for deactivated in &deactivated {
crate::legacy_v1::handle_deactivate_leaf(legacy_v1_state, *deactivated);
Expand Down