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

elastic scaling: preserve candidate ordering in provisioner #3778

Merged
merged 11 commits into from
Mar 25, 2024

Conversation

alindima
Copy link
Contributor

@alindima alindima added R0-silent Changes should not be mentioned in any release notes T8-polkadot This PR/Issue is related to/affects the Polkadot network. labels Mar 21, 2024
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-clippy
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5616955

polkadot/node/core/backing/src/tests/mod.rs Outdated Show resolved Hide resolved
polkadot/node/core/provisioner/src/lib.rs Outdated Show resolved Hide resolved
polkadot/node/core/provisioner/src/lib.rs Outdated Show resolved Hide resolved
polkadot/node/core/provisioner/src/tests.rs Outdated Show resolved Hide resolved
polkadot/node/core/provisioner/src/tests.rs Outdated Show resolved Hide resolved
Comment on lines 839 to 855
let mut stop_at_index = None;
for (index, candidate) in para_candidates.iter().enumerate() {
if candidate.candidate().commitments.new_validation_code.is_some() {
if with_validation_code {
stop_at_index = Some(index);
break
} else {
with_validation_code = true;
}
}

with_validation_code = true;
}

true
});
if let Some(stop_at_index) = stop_at_index {
merged_candidates.extend(para_candidates.into_iter().take(stop_at_index));
} else {
merged_candidates.extend(para_candidates.into_iter());
}
Copy link
Contributor

@sandreim sandreim Mar 25, 2024

Choose a reason for hiding this comment

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

We could get rid of the stop_index and do something like this:

for candidate in para_candidates.into_iter() {
      merged_candidates.push(candidate);
      // Stop accumulating at first candidate with code upgrade.
      if candidate.candidate().commitments.new_validation_code.is_some() {
           break
      }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't want to stop accumulating after the first code upgrade. we just want to not accumulate any more code upgrades after the first code upgrade.

I modified the code to not use a stop_at_index though. I figured it must be more performant to batch extend a vec than pushing one-by-one. However, it's likely negligible anyway and it's less readable

@alindima alindima enabled auto-merge March 25, 2024 13:21
@alindima alindima added this pull request to the merge queue Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes T8-polkadot This PR/Issue is related to/affects the Polkadot network.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elastic scaling: make sure to preserve candidate ordering in GetBackedCandidates
4 participants