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

Expose ClaimQueue via a runtime api and use it in collation-generation #3580

Merged
merged 13 commits into from
Mar 20, 2024

Conversation

tdimitrov
Copy link
Contributor

@tdimitrov tdimitrov commented Mar 5, 2024

The PR adds two things:

  1. Runtime API exposing the whole claim queue
  2. Consumes the API in collation-generation to fetch the next scheduled ParaEntry for an occupied core.

Related to #1797

@tdimitrov tdimitrov added the T8-polkadot This PR/Issue is related to/affects the Polkadot network. label Mar 11, 2024
@tdimitrov tdimitrov marked this pull request as ready for review March 11, 2024 08:37
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

Comment on lines 244 to 246
// TODO [now]: this assumes that next up == current.
// in practice we should only set `OccupiedCoreAssumption::Included`
// when the candidate occupying the core is also of the same para.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this TODO is being solved by this PR, isn't it? There's also a tracking issue here: #3327

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 guess you are right. But it is fixed thanks to the updated implementation of next_up_on_available?
Or I am missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, I think I was wrong actually. I think it should be fixed while implementing #3582

polkadot/node/collation-generation/src/lib.rs Show resolved Hide resolved
Comment on lines +628 to +633
if has_required_runtime(
sender,
relay_parent,
RuntimeApiRequest::CLAIM_QUEUE_RUNTIME_REQUIREMENT,
)
.await
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: instead of doing two requests (one for the version and another for the actual runtime API), we could directly try calling the runtime API and handle RuntimeApiError::NotSupported

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 see your point but I think it is more or less the same.

Each runtime call has got a version check before it (done by the runtime api subsystem). So in the current case we have got:
Version check (by has_required_runtime) -> Version check (by runtime api subsystem) -> Runtime call

If we call the new api directly on an old runtime and handle the error we will have the same:
Version check (by runtime api subsystem for the 'old call') -> Version check (by runtime api subsystem for the 'new call') -> Runtime call

So in terms of runtime calls - it's the same when we have got old runtime.

For a new runtime we do save one version check but (1) we will remove the version check once everything is released on Polkadot and (2) the runtime calls are cached and never hit the runtime.

Considering these - I'd stick with the current version because it is more explicit.

Another drawback of relying on NotSupported for version check is that the former happens in other weird cases - e.g. a runtime call being executed on pruned blocks. Having NotSupported errors polluting the logs won't be ideal especially when we chase bugs.

Copy link
Contributor

Choose a reason for hiding this comment

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

For a new runtime we do save one version check but (1) we will remove the version check once everything is released on Polkadot and (2) the runtime calls are cached and never hit the runtime.

yes, that's exactly my point, saving one version check for a new runtime. We'd also save one round-trip to the runtime API subsystem, regardless of the runtime version.

anyway, I don't have very strong feelings about this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your point is valid. I've created an issue for this - #3756

@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/5569954

@tdimitrov tdimitrov added this pull request to the merge queue Mar 20, 2024
Merged via the queue into master with commit e58e854 Mar 20, 2024
129 of 133 checks passed
@tdimitrov tdimitrov deleted the tsv-claimqueue-runtime-api branch March 20, 2024 07:23
dharjeezy pushed a commit to dharjeezy/polkadot-sdk that referenced this pull request Mar 24, 2024
…tion` (paritytech#3580)

The PR adds two things:
1. Runtime API exposing the whole claim queue
2. Consumes the API in `collation-generation` to fetch the next
scheduled `ParaEntry` for an occupied core.

Related to paritytech#1797
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants