Skip to content

Deprecate para_id Field from Chain Specification#7546

Closed
Stephenlawrence00 wants to merge 5 commits intoparitytech:masterfrom
Stephenlawrence00:paraid-api
Closed

Deprecate para_id Field from Chain Specification#7546
Stephenlawrence00 wants to merge 5 commits intoparitytech:masterfrom
Stephenlawrence00:paraid-api

Conversation

@Stephenlawrence00
Copy link
Copy Markdown
Contributor

@Stephenlawrence00 Stephenlawrence00 commented Feb 12, 2025

@cla-bot-2021
Copy link
Copy Markdown

cla-bot-2021 Bot commented Feb 12, 2025

User @Stephenlawrence00, please sign the CLA here.

@iulianbarbu
Copy link
Copy Markdown
Contributor

Hi @Stephenlawrence00 , just wondering if you're still interested in getting this ready for review. I glanced over the changes and thought you might find useful this info: #75 (comment).

If you don't have time to still look into it, let us know. We're keen in assisting/owning the delivery of this in the next period.

Let us know if you have questions!

@Stephenlawrence00
Copy link
Copy Markdown
Contributor Author

Thanks @iulianbarbu

Still interested in getting this done.

@seemantaggarwal
Copy link
Copy Markdown
Contributor

@Stephenlawrence00 if you have something to parallelise or I can pick up, let me know

@iulianbarbu
Copy link
Copy Markdown
Contributor

Hey @Stephenlawrence00 , how is going? I was wondering if you got a chance to continue the work. Feel free to reach out in case implementation details are not clear.

For context, we want to have this functionality merged by mid of May so that it ends up in June release. FYI, the reviews and addressing them can take a few weeks, so IMO ideally we should kickstart the work this week/next week the latest. Does that sound doable on your end?

@Stephenlawrence00
Copy link
Copy Markdown
Contributor Author

Stephenlawrence00 commented Apr 3, 2025

Sounds good @iulianbarbu

Copy link
Copy Markdown
Contributor

@iulianbarbu iulianbarbu left a comment

Choose a reason for hiding this comment

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

I think this should be mostly it. Now I am wondering what's a good way to sunset parachain-info. @bkchr what are your thoughts?

LE: upsy, there is an issue for that: #2116. Based on it, I think we can start removing parachain info from our runtimes. What we need to double check though is if adding the para id in the runtimes' parameters is enough for downstream usage which might rely on the Get<ParaId> trait impl for Pallet<T> where T: Config.

LELE: once the above is done, we can start doing the actualy para_id field removal from chain specs, according to #7384

@iulianbarbu iulianbarbu requested a review from skunert April 14, 2025 10:40
@skunert
Copy link
Copy Markdown
Contributor

skunert commented Apr 14, 2025

Getting rid of ParachainInfo pallet is not needed for now. The pallet should stay for the reasons I outlined here: #2116 (comment).

The runtime API should return the para id that is present in ParachainInfo pallet. Then the node side should be modified in this PR to not use the para_id from the chainspec anymore if the runtime API is present. One example of this is here:

There we read the para_id from the chain_spec, which should not be the case anymore.

@iulianbarbu
Copy link
Copy Markdown
Contributor

iulianbarbu commented Apr 25, 2025

Hey @Stephenlawrence00 ! Looks like we still need return the 'para_id' of the ParachainInfo, instead of hardcoding it into the runtime to return it. It means we need to go back to this state mostly: 46004e3. Sorry for making you digress with my suggestion for hardcoding, but I missed the important point @skunert made here: #2116 (comment).

Separately, in addition to @skunert pointer to how to not use anymore the para_id from the chain spec like here:

, the runtime api call that should be made can be done somewhere around here:
let client = params.client.clone();
, by using the let para_id = client.runtime_api().id();. To be able to call GetParachainInfo::id() though you'd need to extend the NodeRuntimeApi here:
pub trait NodeRuntimeApi<Block: BlockT>:
.

Once we have this, I think we should be good with deprecating this:

. E.g. just add a #[deprecated] attribute, a comment that clarifies this is deprecated, and a link to a new issue which tracks its removal (for removal timeline, we can mention it will be removed in the next stable release, so by 25/09). Any objections on this deprecation notice @skunert ?

@skunert
Copy link
Copy Markdown
Contributor

skunert commented Apr 28, 2025

(for removal timeline, we can mention it will be removed in the next stable release, so by 25/09). Any objections on this deprecation notice @skunert ?

Nope, makes sense to me.

However, we should come up with a better name for the runtime api function than id(). Maybe just parachain_id() or para_id().

@skunert
Copy link
Copy Markdown
Contributor

skunert commented Apr 28, 2025

@Stephenlawrence00 Just checking in if you planning to continue with this. If not, we will internally find someone to work on this soon (end of week).

@Stephenlawrence00
Copy link
Copy Markdown
Contributor Author

Will have the changes in @skunert

@Stephenlawrence00
Copy link
Copy Markdown
Contributor Author

Stephenlawrence00 commented Apr 30, 2025

Would I need to add a test case in system chain runtimes?

for instance

#[test]
fn parachain_id_is_retrieved_from_runtime_api() {
    ExtBuilder::<Runtime>::default()
        .build()
        .execute_with(|| {
            // Get para_id from ParachainInfo pallet storage
            let expected_para_id = parachain_info::Pallet::<Runtime>::parachain_id();
            
            // Get para_id via runtime API
            let actual_para_id = Runtime::parachain_id();
            
            assert_eq!(
                actual_para_id, expected_para_id,
                "Runtime API para_id must match ParachainInfo storage"
            );
        });
}

Don't think this tests much really cc: @skunert @iulianbarbu

@skunert
Copy link
Copy Markdown
Contributor

skunert commented Apr 30, 2025

I agree, such test does not seem very useful

@Stephenlawrence00
Copy link
Copy Markdown
Contributor Author

Stephenlawrence00 commented Apr 30, 2025

I agree, such test does not seem very useful

What tests would you consider, regarding this pull request? @skunert

@skunert
Copy link
Copy Markdown
Contributor

skunert commented May 5, 2025

Hey,

thanks for driving this forward!
Please take a look at these missing occurences that require adjustment:

There is the chain-spec-builder, which we use to build chain-specs. When someone provides the --para-id arguments there, we should print that this argument is deprecated after stable2506 and will not be used by parachain nodes anymore. We can not just remove the arg, since there should be a proper migration phase.

As for testing, we have some tests that test the manual-seal functionality of omni-node:

fn omni_node_dev_mode_works() {

There it would be super easy to read the chain-spec, modify the para_id to something completely random and then write the chain spec to a temporary directory. Without the changes in your PR the test would fail, because there would be a mismatch between runtime and node. However this only tests this specific mode of operation.

In addition, we can have better test-coverage by removing the para_id field from chain-specs exported from the test-parachain node. Remove the Extension here and just pass Default::default().

Extensions { para_id: id.unwrap_or(cumulus_test_runtime::PARACHAIN_ID.into()).into() },

As a result, all chain-specs exported from test-parachain will not have the para_id field anymore and all our zombienet-tests will work with the runtime para_id. This is already a good chunk of testing. In the long run, we should remove the extension from the other chain-specs too, but IMO this should be done in the next release, so that the changes you introduce have some time to saturate.

@iulianbarbu
Copy link
Copy Markdown
Contributor

Hey @Stephenlawrence00 , how is going? Was wondering how the testing goes. Once we'll get past that we'll have leeway to focus on the last bits, related to para-id deprecation notices. Would be great to capture everything in the cutoff for next release, which has been pushed back with one more week roughly. Let us know how you feel about the left work and your availability.

@Stephenlawrence00
Copy link
Copy Markdown
Contributor Author

@iulianbarbu On it

@iulianbarbu
Copy link
Copy Markdown
Contributor

Hey @Stephenlawrence00 ! Hope you're well.

We decided to take the work you started here and continue it with dedicated capacity internally. The continuation will be based on your work so that your effort is not lost. We will do this because we want to ship this sometime sooner, to align with the next release. You can push any in-flight work here and I'll try to consider it for a new PR I'll open based on the existing state of the branch.

Hope this is understandable, and please don't hesistate to reach out if you want to contribute to other issues - hoppefully will mark better those that allow for a wider implementation/testing timespan.

github-merge-queue Bot pushed a commit that referenced this pull request Jun 22, 2025
# Description

Closes #7384
Closes #75
Closes #8692
Closes #8739 

## Integration

Node developers, node operators & runtime developers will not need to
generate chain specs that contain a `para_id` field starting with this
PR, but they'll have to implement the
`cumulus_primitives_core::GetParachainInfo` runtime API once they drop
the `para_id` field, so that new nodes versions will be able to query
the runtime for the parachain id.

Starting with `2512` the nodes will not support anymore reading the
parachain id from chain specs `para_id` field, so it will be mandatory
for runtime to implement the `cumulus_primitives_core::GetParachainInfo`
trait and be upgraded.

## Review Notes

This PR is based on prior work here:  #7546. It delivers the following:

### Deprecated `para_id` chain spec extension

- nodes like `polkadot-omni-node`/`polkadot-parachain`) will still
support running chainspecs with `para_id` extension for a while (until
stable2512)
- nodes like `test-parachain`/`parachain-template-node` are supporting
only runtimes that implement the new runtime API.
- `chain-spec-builder` will display that `para_id` is deprecated when
calling `help`, or when using the flag.

### Additional cleanup/changes

- fixed & renabled some omni-node/parachain-template-node tests from
`polkadot-sdk-docs` & `templates/zombienet`, which rely on the newly
added runtime API as wellI. Tests based on the `para_id` chain spec
extension are not present anymore, since omni-node will favour taking
the para id based on the runtime API if present.

- removed the concept of running `minimal` with omni-node. I returned to
an old idea of a few of us. At this moment we can't support it anymore
with omni-node since we'd need to add `parachain_info` to
`minimal-template-runtime`, which doesn't make much sense.

- most of the parachains runtimes (hope I haven't missed any relevant)
that run by using
`polkadot-parachain/polkadot-omni-node/test-parachain/parachain-template-node`
should fail to work with the previous nodes (that support them) after
`stable2512`. Probably that will be caught in the CI if I missed them
during this PR, but I doubt it.

## Reviewers request

- if there are other nodes used to run parachains runtimes, this is a
good moment to highlight them so that I can update them if needed in
terms of picking up the `parachain_id` from the runtime.

---------

Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Co-authored-by: Steven <stevenlawrence13e@gmail.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
# Description

Closes #7384
Closes #75
Closes #8692
Closes #8739 

## Integration

Node developers, node operators & runtime developers will not need to
generate chain specs that contain a `para_id` field starting with this
PR, but they'll have to implement the
`cumulus_primitives_core::GetParachainInfo` runtime API once they drop
the `para_id` field, so that new nodes versions will be able to query
the runtime for the parachain id.

Starting with `2512` the nodes will not support anymore reading the
parachain id from chain specs `para_id` field, so it will be mandatory
for runtime to implement the `cumulus_primitives_core::GetParachainInfo`
trait and be upgraded.

## Review Notes

This PR is based on prior work here:  #7546. It delivers the following:

### Deprecated `para_id` chain spec extension

- nodes like `polkadot-omni-node`/`polkadot-parachain`) will still
support running chainspecs with `para_id` extension for a while (until
stable2512)
- nodes like `test-parachain`/`parachain-template-node` are supporting
only runtimes that implement the new runtime API.
- `chain-spec-builder` will display that `para_id` is deprecated when
calling `help`, or when using the flag.

### Additional cleanup/changes

- fixed & renabled some omni-node/parachain-template-node tests from
`polkadot-sdk-docs` & `templates/zombienet`, which rely on the newly
added runtime API as wellI. Tests based on the `para_id` chain spec
extension are not present anymore, since omni-node will favour taking
the para id based on the runtime API if present.

- removed the concept of running `minimal` with omni-node. I returned to
an old idea of a few of us. At this moment we can't support it anymore
with omni-node since we'd need to add `parachain_info` to
`minimal-template-runtime`, which doesn't make much sense.

- most of the parachains runtimes (hope I haven't missed any relevant)
that run by using
`polkadot-parachain/polkadot-omni-node/test-parachain/parachain-template-node`
should fail to work with the previous nodes (that support them) after
`stable2512`. Probably that will be caught in the CI if I missed them
during this PR, but I doubt it.

## Reviewers request

- if there are other nodes used to run parachains runtimes, this is a
good moment to highlight them so that I can update them if needed in
terms of picking up the `parachain_id` from the runtime.

---------

Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Co-authored-by: Steven <stevenlawrence13e@gmail.com>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants