Skip to content

Kanas/omni node aura authority id type based on metadata checks#11107

Merged
iulianbarbu merged 28 commits intoparitytech:masterfrom
Kanasjnr:Kanas/omni-node-aura-warnings
Apr 6, 2026
Merged

Kanas/omni node aura authority id type based on metadata checks#11107
iulianbarbu merged 28 commits intoparitytech:masterfrom
Kanasjnr:Kanas/omni-node-aura-warnings

Conversation

@Kanasjnr
Copy link
Copy Markdown
Contributor

@Kanasjnr Kanasjnr commented Feb 18, 2026

Description

This PR implements optional metadata-based detection to automatically determine the correct Aura authority ID type from runtime metadata.

The library currently assumes that the Aura authority ID type is ed25519 for asset-hub-polkadot/statemint and sr25519 for all other chains. This PR adds the ability to detect the correct type from runtime metadata when available.

Further implementation of #11026

polkadot address: 12pCUGSwoW4Xek48TLUHCFhrvAdjmciMMLJoRJD8HWP5saXH

Integration

No integration changes required. This is a non-breaking enhancement that improves detection logic. Behavior remains backward compatible with existing fallback mechanisms.

Review Notes

Implementation Overview

This PR implements optional metadata detection for Aura authority IDs:

  • Optional metadata detection: Adds support to read the Aura authority ID type from runtime metadata when available

Changes Made

File: cumulus/polkadot-omni-node/lib/src/common/runtime.rs

  1. Added aura_consensus_id() method to MetadataInspector:

    • Scans runtime metadata types for sp_consensus_aura::sr25519::AuthorityId or sp_consensus_aura::ed25519::AuthorityId
    • Returns Some(AuraConsensusId) if found, None otherwise
    • Only checks if Aura pallet exists in metadata
  2. Updated DefaultRuntimeResolver::runtime():

    • Calls metadata_inspector.aura_consensus_id() for metadata-based detection
    • Uses detected type immediately when available
    • Falls back to chain spec ID check when metadata detection returns None
  3. Added test coverage:

    • Test verifies aura_consensus_id() correctly detects sr25519 from test runtime metadata

Example Behavior

Metadata detection workflow:

  • If metadata detection succeeds → uses detected type (sr25519 or ed25519)
  • If metadata unavailable or detection fails → uses chain spec ID heuristics (ed25519 for asset-hub-polkadot/statemint, sr25519 for others)

Code Example

+ fn aura_consensus_id(&self) -> Option<AuraConsensusId> {
+     if !self.pallet_exists(DEFAULT_AURA_PALLET_NAME) {
+         return None;
+     }
+ 
+     for portable_type in self.0.types().types() {
+         let path = &portable_type.ty.path;
+         let segments = path.segments();
+ 
+         if segments.len() >= 3 {
+             let last_three = &segments[segments.len() - 3..];
+             match last_three {
+                 ["sp_consensus_aura", "sr25519", "AuthorityId"] =>
+                     return Some(AuraConsensusId::Sr25519),
+                 ["sp_consensus_aura", "ed25519", "AuthorityId"] =>
+                     return Some(AuraConsensusId::Ed25519),
+                 _ => continue,
+             }
+         }
+     }
+     None
+ }

Testing

  • Added unit test test_aura_consensus_id() that verifies metadata detection works correctly with the test runtime (which uses sr25519)

Notes

  • The fallback logic preserves existing behavior while making assumptions explicit
  • Metadata detection is optional and gracefully falls back when metadata is unavailable or doesn't contain the required information

Checklist

  • My PR includes a detailed description as outlined in the "Description" and its two subsections above.
  • My PR follows the labeling requirements of this project (at minimum one label for T required)
    • External contributors: Use /cmd label <label-name> to add labels
    • Maintainers can also add labels manually
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

Bot Commands

You can use the following bot commands in comments to help manage your PR:

Labeling (Self-service for contributors):

  • /cmd label T1-FRAME - Add a single label
  • /cmd label T1-FRAME R0-no-crate-publish-required - Add multiple labels
  • /cmd label T6-XCM D2-substantial I5-enhancement - Add multiple labels at once
  • See label documentation for all available labels

Other useful commands:

  • /cmd fmt - Format code (cargo +nightly fmt and taplo)
  • /cmd prdoc - Generate PR documentation
  • /cmd bench - Run benchmarks
  • /cmd update-ui - Update UI tests
  • /cmd --help - Show help for all available commands

This PR addresses issue paritytech#11026 by adding warnings when the library makes
assumptions about Aura authority ID types and implements optional metadata-based
detection.

The `polkadot-omni-node-lib` currently assumes that the Aura authority ID type is
`ed25519` for `asset-hub-polkadot` and `sr25519` for all other chains. This PR
adds warnings to make these assumptions explicit and implements optional
metadata-based detection to automatically determine the correct Aura authority ID
type from runtime metadata when available.

Changes:
1. Emit warning when assuming `ed25519` for `asset-hub-polkadot`/`statemint`
2. Emit warning when defaulting to `sr25519` for other chains
3. Add metadata-based detection for Aura authority ID type (optional step 3)
4. Proper fallback logic: defaults to `ed25519` for asset-hub-polkadot/statemint,
   `sr25519` for others when metadata is unavailable

Closes paritytech#11026

No breaking changes. This is a non-breaking enhancement that adds warnings and
improves detection logic. Downstream projects will see warnings when assumptions
are made, but behavior remains the same.

**Implementation details:**

1. **Warnings in `polkadot-parachain` RuntimeResolver:**
   - Warns when assuming `ed25519` for `asset-hub-polkadot`/`statemint`
   - Warns when defaulting to `sr25519` for other chains

2. **Metadata detection in `polkadot-omni-node-lib`:**
   - Added `aura_consensus_id()` method to `MetadataInspector` that scans runtime
     metadata types for `sp_consensus_aura::sr25519::AuthorityId` or
     `sp_consensus_aura::ed25519::AuthorityId`
   - If detection succeeds, uses detected type (no warning)
   - If detection fails, falls back to chain spec ID check:
     - `asset-hub-polkadot`/`statemint` → `ed25519` with warning
     - Others → `sr25519` with warning
   - Handles both cases: when metadata check fails entirely, and when metadata
     exists but detection returns None

3. **Test coverage:**
   - Added test for `aura_consensus_id()` to verify metadata detection works
     correctly with test runtime

The warnings follow the existing codebase style:
- `polkadot-parachain`: Simple warnings without emoji (matching existing style)
- `polkadot-omni-node-lib`: Warnings with emoji (matching existing style)
@Kanasjnr
Copy link
Copy Markdown
Contributor Author

/cmd prdoc

@cla-bot-2021
Copy link
Copy Markdown

cla-bot-2021 Bot commented Feb 18, 2026

User @cursoragent, please sign the CLA here.

@Kanasjnr Kanasjnr force-pushed the Kanas/omni-node-aura-warnings branch from d5ed816 to 70cd5d2 Compare February 18, 2026 21:24
@Kanasjnr
Copy link
Copy Markdown
Contributor Author

@iulianbarbu Kindly review

Comment thread prdoc/pr_11107.prdoc Outdated
Comment thread prdoc/pr_11107.prdoc Outdated
Comment thread prdoc/pr_11107.prdoc Outdated
Comment thread cumulus/polkadot-omni-node/lib/src/common/runtime.rs Outdated
@iulianbarbu iulianbarbu requested a review from a team February 19, 2026 13:15
@iulianbarbu iulianbarbu changed the title Kanas/omni node aura warnings Kanas/omni node aura authority id type based on metadata checks Feb 19, 2026
@iulianbarbu iulianbarbu added the T0-node This PR/Issue is related to the topic “node”. label Feb 19, 2026
@Kanasjnr Kanasjnr requested a review from iulianbarbu February 19, 2026 17:27
@Kanasjnr
Copy link
Copy Markdown
Contributor Author

@iulianbarbu I've made all changes kindly review now

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.

lgtm! Thanks.

Comment thread cumulus/polkadot-omni-node/lib/src/common/runtime.rs Outdated
@iulianbarbu
Copy link
Copy Markdown
Contributor

Please fix clippy as well. CI is not green.

@github-actions github-actions Bot requested a review from iulianbarbu March 2, 2026 09:35
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 2, 2026

Review required! Latest push from author must always be reviewed

Kanasjnr and others added 2 commits March 2, 2026 10:49
Co-authored-by: Iulian Barbu <14218860+iulianbarbu@users.noreply.github.com>
@Kanasjnr
Copy link
Copy Markdown
Contributor Author

Kanasjnr commented Mar 2, 2026

@iulianbarbu I pushed a commit to resolve Ci errors kindly check

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.

Super sorry for the late review here! Everything looks good, will approve but I would add one more test first against assethub-polkadot chain spec. We can add a tests/chain-specs dir here to be used to infer runtime metadata that tests the other cases of detecting the authority id type.

Comment thread cumulus/polkadot-omni-node/lib/src/common/runtime.rs Outdated
@Kanasjnr
Copy link
Copy Markdown
Contributor Author

Super sorry for the late review here! Everything looks good, will approve but I would add one more test first against assethub-polkadot chain spec. We can add a tests/chain-specs dir here to be used to infer runtime metadata that tests the other cases of detecting the authority id type.

No worries! Thanks for the review! That’s a good suggestion tho. I will add the test and and introduce a tests/chain-specs directory
I will push the update shortly.

Copy link
Copy Markdown
Contributor

@serban300 serban300 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution ! Looks good to me, modulo Iulian's comment

@Kanasjnr
Copy link
Copy Markdown
Contributor Author

Kanasjnr commented Apr 2, 2026

@Kanasjnr I want to run the latest state against the fellowship ahp locally before merging this. The test that asserted against ed25519 was removed. I am not sure if that's because the resulted fellowship ahp chain spec still makes the associated test take a long time, even with a small size (similar to the ahp chain spec in the repo), or you couldn't produce a small ahp chain spec even if generating it based on the compressed.compact version. It should be considerably less than 5MiB to say that it should produce a difference in the test duration.

I only removed that test because I was following @serban300 suggestion to delete the entire chain-specs folder!

I definitely want it tested too. verify it locally against the fellowship AHP like you mentioned and lets see

Copy link
Copy Markdown
Contributor

@franciscoaguirre franciscoaguirre 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 to me. @serban300 @iulianbarbu you think we can merge?

@serban300
Copy link
Copy Markdown
Contributor

Looks good to me. @serban300 @iulianbarbu you think we can merge?

It's almost good to merge. It's pending on this

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.

Built the compact.compressed ahp and resulted in a 3.6 MB chain spec (with on-chain-release-build feature on). This is smaller than the one pushed before, and running your prev test as before locally takes ~4s. Definitely shorter than before (@serban300 had it running for 1min42s), maybe worth re-adding it, but I don't have a strong opinion of adding it now - can be in a follow-up.

@iulianbarbu iulianbarbu added this pull request to the merge queue Apr 6, 2026
Merged via the queue into paritytech:master with commit 7da81d6 Apr 6, 2026
394 of 410 checks passed
@Kanasjnr
Copy link
Copy Markdown
Contributor Author

Kanasjnr commented Apr 6, 2026

Glad to see this merged🤗

@iulianbarbu
Copy link
Copy Markdown
Contributor

/bot tip small

@Kanasjnr
Copy link
Copy Markdown
Contributor Author

Kanasjnr commented Apr 6, 2026

/bot tip small

Didn't go trough?🙁

@iulianbarbu
Copy link
Copy Markdown
Contributor

/tip small

@substrate-tip-bot
Copy link
Copy Markdown

@Kanasjnr Hey 👋, thanks for your contribution. We offer to propose a tip for you to OpenGov 🤩

You can pick between DOT or KSM. Please put either your Polkadot or Kusama address into the Pull Request description or your GitHub bio.
The format should be like this: `{network} address: {address}`  
Just replace `{network}` with either polkadot, kusama, rococo, westend and `{address}` with your actual address.

You still need to claim the tip after it was approved by OpenGov;
please check the [Contributing docs](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md#Tip) for help.

@Kanasjnr
Copy link
Copy Markdown
Contributor Author

Kanasjnr commented Apr 6, 2026

@Kanasjnr Hey 👋, thanks for your contribution. We offer to propose a tip for you to OpenGov 🤩

You can pick between DOT or KSM. Please put either your Polkadot or Kusama address into the Pull Request description or your GitHub bio.
The format should be like this: `{network} address: {address}`  
Just replace `{network}` with either polkadot, kusama, rococo, westend and `{address}` with your actual address.

You still need to claim the tip after it was approved by OpenGov;
please check the [Contributing docs](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md#Tip) for help.

Polkadot Address

12pCUGSwoW4Xek48TLUHCFhrvAdjmciMMLJoRJD8HWP5saXH

@mordamax
Copy link
Copy Markdown
Contributor

mordamax commented Apr 6, 2026

Polkadot Address

12pCUGSwoW4Xek48TLUHCFhrvAdjmciMMLJoRJD8HWP5saXH

iirc you have to add either to profile bio or in the PR description

@Kanasjnr
Copy link
Copy Markdown
Contributor Author

Kanasjnr commented Apr 6, 2026

Polkadot Address

12pCUGSwoW4Xek48TLUHCFhrvAdjmciMMLJoRJD8HWP5saXH

iirc you have to add either to profile bio or in the PR description

It's on my profile bio already 🙁
But will add it to the description

@Kanasjnr
Copy link
Copy Markdown
Contributor Author

Kanasjnr commented Apr 6, 2026

Polkadot Address

12pCUGSwoW4Xek48TLUHCFhrvAdjmciMMLJoRJD8HWP5saXH

iirc you have to add either to profile bio or in the PR description

@mordamax Done🙁

@mordamax
Copy link
Copy Markdown
Contributor

mordamax commented Apr 6, 2026

/tip small

@substrate-tip-bot
Copy link
Copy Markdown

@Kanasjnr Invalid network: "`Polkadot". Please select one of: polkadot, kusama, rococo, westend.

@mordamax
Copy link
Copy Markdown
Contributor

mordamax commented Apr 6, 2026

/tip small

@substrate-tip-bot
Copy link
Copy Markdown

Tip for 12pCUGSwoW4Xek48TLUHCFhrvAdjmciMMLJoRJD8HWP5saXH referendum status is 👎: InvalidTxError: {
"type": "Invalid",
"value": {
"type": "Payment"
}
}

@mordamax
Copy link
Copy Markdown
Contributor

mordamax commented Apr 6, 2026

Ok that's differnt story :) i will followup here soon

@Kanasjnr
Copy link
Copy Markdown
Contributor Author

Kanasjnr commented Apr 6, 2026

Ok that's differnt story :) i will followup here soon

was supposed to be small p i added capital but i changed it already tho🙈

@mordamax
Copy link
Copy Markdown
Contributor

mordamax commented Apr 6, 2026

@Kanasjnr as i mentioned i will followup The issue was not the case of first latter unfortunately

@Kanasjnr
Copy link
Copy Markdown
Contributor Author

Kanasjnr commented Apr 6, 2026

@Kanasjnr as i mentioned i will followup The issue was not the case of first latter unfortunately

ohh my bad

@mordamax
Copy link
Copy Markdown
Contributor

mordamax commented Apr 6, 2026

/tip small

@substrate-tip-bot
Copy link
Copy Markdown

@mordamax A referendum for a small (20 DOT) tip was successfully submitted for @Kanasjnr (12pCUGSwoW4Xek48TLUHCFhrvAdjmciMMLJoRJD8HWP5saXH on polkadot).

Referendum number: 1876.
tip

@substrate-tip-bot
Copy link
Copy Markdown

The referendum has appeared on Polkassembly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T0-node This PR/Issue is related to the topic “node”.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants