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: fix filtering of statements for elastic parachains #3879

Merged
merged 19 commits into from
Apr 3, 2024

Conversation

sandreim
Copy link
Contributor

@sandreim sandreim commented Mar 28, 2024

fixes #3775

Additionally moves the claim queue fetch utilities into subsystem-util.

TODO:

  • fix tests
  • add elastic scaling tests

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
@sandreim sandreim added the R0-silent Changes should not be mentioned in any release notes label Mar 28, 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/5687708

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
…reim/elastic_statement_dist

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
@sandreim sandreim marked this pull request as ready for review March 29, 2024 12:50
Copy link
Contributor

@alindima alindima left a comment

Choose a reason for hiding this comment

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

Looks good! Can we add the zombienet test for proper elastic scaling? or do you want to do that as a follow-up?

Copy link
Contributor

@alexggh alexggh left a comment

Choose a reason for hiding this comment

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

The approach seems sane to me, left you some comments with some unclarities that I have.

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
@sandreim
Copy link
Contributor Author

sandreim commented Apr 1, 2024

Looks good! Can we add the zombienet test for proper elastic scaling? or do you want to do that as a follow-up?

I'll craft a new PR with the test.

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
claim_queue
.keys()
.filter_map(|core_index| {
let Some(scheduled_core) = fetch_next_scheduled_on_core(&claim_queue, *core_index)
Copy link
Member

Choose a reason for hiding this comment

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

Ok, first (not introduced here): I find the name of this function vastly misleading as it does not fetch anything.

Second, why are we iterating only keys of the claim queue to fetch the actual element for each key, instead of iterating key/values to begin with?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to reuse the fn, but you are right, it is actually useless in this case. A wrapper for this BTreeMap with a method like iter_claims(depth: BlockNumber) returning an iterator over (core_index, para) so we can lookup as far into the future as the lookahead param/ async backing settings allow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tdimitrov wdyt ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

polkadot/node/network/statement-distribution/src/v2/mod.rs Outdated Show resolved Hide resolved
@@ -693,15 +695,24 @@ pub(crate) async fn handle_active_leaves_update<Context>(
}
});

let maybe_claim_queue = fetch_claim_queue(ctx.sender(), new_relay_parent)
Copy link
Member

Choose a reason for hiding this comment

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

Given that we pass per value (can't re-use the result), might make sense to move that call into determine_groups_per_para.

The result of request_availability_cores is used in find_active_validator_state, but wrongly. It uses para_id a function we should remove, as it makes no sense to either return the ParaId of the occupying para or the scheduled one.*)

Regardless, I would move the fetching code into the function that need the data. handle_active_leaves_update is already pages of code.

*) Note: This is obviously unrelated, so can be a separate PR, but it should be fixed for Coretime asap. @tdimitrov

Copy link
Member

Choose a reason for hiding this comment

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

polkadot/node/network/statement-distribution/src/v2/mod.rs Outdated Show resolved Hide resolved
@@ -312,6 +312,66 @@ fn useful_cluster_statement_from_non_cluster_peer_rejected() {
});
}

// Both validators in the test are part of backing groups assigned to same parachain
#[test]
fn elastic_scaling_useful_cluster_statement_from_non_cluster_peer_rejected() {
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@eskimor
Copy link
Member

eskimor commented Apr 2, 2024

Looks good, nevertheless had to leave a few nits.

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
@sandreim sandreim added this pull request to the merge queue Apr 3, 2024
max_candidate_depth: usize,
) -> HashMap<ParaId, Vec<GroupIndex>> {
let maybe_claim_queue = fetch_claim_queue(sender, relay_parent)
Copy link
Member

Choose a reason for hiding this comment

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

Ok, my thinking was to move all fetches here, including availability_cores for consistency. It's weird if we pass in one thing, but fetch the other our selves. I know this is used in one other place as well (wrongly), but given that we pass per value already, there is not much gain in avoiding the double fetch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LocalValidatorState is built outside this fn and requires availability_cores

.iter()
.any(|g| g == &manifest_summary.claimed_group_index)
{
if !expected_groups.iter().any(|g| g == &manifest_summary.claimed_group_index) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Merged via the queue into master with commit e8e201f Apr 3, 2024
136 of 138 checks passed
@sandreim sandreim deleted the sandreim/elastic_statement_dist branch April 3, 2024 08:57
github-merge-queue bot pushed a commit that referenced this pull request Apr 5, 2024
On top of #3879

I've also moved the previous test where we ensure multiple cores per
para doesn't break non elastic parachains.

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Co-authored-by: Javier Viola <363911+pepoviola@users.noreply.github.com>
Ank4n pushed a commit that referenced this pull request Apr 9, 2024
…hains (#3879)

fixes #3775

Additionally moves the claim queue fetch utilities into
`subsystem-util`.

TODO:
- [x] fix tests
- [x] add elastic scaling tests

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Ank4n pushed a commit that referenced this pull request Apr 9, 2024
On top of #3879

I've also moved the previous test where we ensure multiple cores per
para doesn't break non elastic parachains.

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Co-authored-by: Javier Viola <363911+pepoviola@users.noreply.github.com>
dharjeezy pushed a commit to dharjeezy/polkadot-sdk that referenced this pull request Apr 9, 2024
…hains (paritytech#3879)

fixes paritytech#3775

Additionally moves the claim queue fetch utilities into
`subsystem-util`.

TODO:
- [x] fix tests
- [x] add elastic scaling tests

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
dharjeezy pushed a commit to dharjeezy/polkadot-sdk that referenced this pull request Apr 9, 2024
On top of paritytech#3879

I've also moved the previous test where we ensure multiple cores per
para doesn't break non elastic parachains.

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Co-authored-by: Javier Viola <363911+pepoviola@users.noreply.github.com>
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
Projects
Status: Scheduled
Development

Successfully merging this pull request may close these issues.

statement-distribution: elastic scaling support
5 participants