Skip to content

feat: generic session keys & session pallet migration of PR 1026#1800

Merged
Klapeyron merged 30 commits into
mainfrom
feat/pc-pr-1026
Jul 16, 2026
Merged

feat: generic session keys & session pallet migration of PR 1026#1800
Klapeyron merged 30 commits into
mainfrom
feat/pc-pr-1026

Conversation

@Klapeyron

@Klapeyron Klapeyron commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Overview

Integrates upstream Partner Chains changes for automatic session key registration (#1026) and removal of pallet-partner-chains-session (#1025), adapted for midnight-node's polkadot-stable2603 workspace.
Partner Chains runtimes now use stock Substrate pallet_session directly. pallet_session_validator_management (SessionCommitteeManagement) implements SessionManager and ShouldEndSession inline (the old PalletSessionSupport wrapper and pallet-partner-chains-session crate are removed). Committee members' session keys are registered automatically at genesis and on each committee rotation via pallet_session::SessionInterface::set_keys, so block producers no longer need to call set_keys manually.
Midnight-node-specific wiring:

  • Runtime migrates off pallet-partner-chains-session to a direct pallet_session::Config impl delegated to SessionCommitteeManagement.
  • pallet_session::historical is enabled and wired (Historical pallet + historical::Config) so privileged SessionInterface::set_keys works under polkadot-stable2603's ownership-proof checks (dispatching the set_keys extrinsic with an empty proof silently fails).
  • pallet_session extrinsics are disabled via #[runtime::disable_call]; key registration is internal only.
  • Genesis chain spec no longer duplicates session keys — registration happens through committee management genesis.
  • The local session_manager module (ValidatorManagementSessionManager) is removed.
  • Runtime spec_version bumped to 002_001_000; metadata regenerated.

🗹 TODO before merging

  • Ready

📌 Submission Checklist

  • All commits are signed off (git commit -s) for the DCO
  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason:
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • Updated AGENTS.md if build commands, architecture, or workflows changed
  • No new todos introduced

🧪 Testing Evidence

Please describe any additional testing aside from CI:

  • Additional tests are provided (if possible)

🔱 Fork Strategy

  • Node Runtime Update
  • Node Client Update
  • Other:
  • N/A

Links

@Klapeyron Klapeyron self-assigned this Jul 1, 2026
@datadog-official

This comment has been minimized.

Comment thread partner-chains/toolkit/partner-chains-cli/src/create_chain_spec/mod.rs Outdated
Comment thread partner-chains/toolkit/partner-chains-cli/Cargo.toml Outdated
Comment thread partner-chains/toolkit/partner-chains-cli/Cargo.toml Outdated
AmbientTea and others added 15 commits July 7, 2026 21:50
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Two gaps between upstream's partner-chains pallet-session version and the
polkadot-stable2603 one pinned in midnight-node's workspace:

- pallet_session::Config requires Currency/KeyDeposit associated types under
  stable2603; upstream's version at the time of this PR didn't need them yet.
  Added to committee-selection/pallet's own mock.rs (demo/runtime's mock and
  the pallet itself already had this fixed by the squash commit; this pallet
  mock.rs still needed it).
- pretty_assertions dev-dependency missing from demo/runtime/Cargo.toml.

Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
…n; wire pallet_session historical bypass for automatic key registration

PR #1025 deletes the pallet-partner-chains-session crate from partner-chains/,
which midnight-node's own runtime and node depend on directly (outside the
partner-chains/ subtree). Migrate to the same approach used within
partner-chains/demo/runtime: wire pallet_session::Config directly, with
ShouldEndSession/SessionManager delegated to SessionCommitteeManagement
(pallet_session_validator_management), which implements them via
pallet_session_support.rs.

- runtime/src/lib.rs, mock.rs: replace impl_pallet_session_config! macro and
  the old dual PalletSession(stub)+Session(real) pallet setup with a single
  pallet_session::Config impl wired to SessionCommitteeManagement. Removes the
  now-dead session_manager module (ValidatorManagementSessionManager), whose
  role is filled directly by the committee-selection pallet.
- node/src/chain_spec/mod.rs: update genesis construction for pallet_session's
  real GenesisConfig{keys, non_authority_keys} shape; drop the leftover
  PalletSessionConfig field for the removed stub pallet.
- Cargo.toml, runtime/Cargo.toml: drop the pallet-partner-chains-session
  dependency.

Separately, PR #1026's automatic key registration (pallet_session_support.rs's
register_committee_keys) dispatches pallet_session::set_keys with an empty
ownership proof. That's a no-op against upstream's pinned polkadot-stable2509,
where OpaqueKeys::ownership_proof_is_valid defaults to true, but our workspace
pins polkadot-stable2603, where impl_opaque_keys! generates a real
proof-of-possession check, so every automatic registration silently failed
(the error is logged, not propagated).

polkadot-stable2603 added pallet_session::SessionInterface specifically for
this: privileged/internal callers can set keys without an ownership proof,
since the caller (not the extrinsic sender) already vouches for the keys.
Wire it up:
- pallet_session_support.rs: require T: pallet_session::historical::Config
  (SessionInterface is implemented for Pallet<T> only when historical::Config
  is also satisfied) and call SessionInterface::set_keys directly instead of
  dispatching the set_keys extrinsic with an empty proof.
- Root Cargo.toml: enable pallet-session's historical feature.
- runtime/src/lib.rs, mock.rs, demo/runtime/src/lib.rs, mock.rs, and the
  committee-selection pallet's own mock.rs: add the Historical pallet to
  construct_runtime! and implement historical::Config with a trivial
  FullIdentification = () (we don't use its NPoS/slashing features, only the
  SessionInterface bypass).
- runtime/src/lib.rs tests (check_aura_authorities_rotation,
  check_grandpa_authorities_rotation): update to the corrected 2-epoch
  committee-application delay, mirroring partner-chains/demo/runtime's
  already-updated tests. Real pallet_session's queue-then-apply model adds
  one full epoch of lag versus the old pallet-partner-chains-session behavior
  (PR #1038 later reduces this back down).

Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Session set_keys/purge_keys must not be dispatchable; committee keys are
registered automatically from Cardano registrations via the session manager.

Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
…1038)

Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
…mittee rotation

PR #1038 adds an additional session immediately after an epoch-triggered
rotation, collapsing the 1-extra-epoch lag from real pallet_session's
queue-then-apply model down to roughly 1 extra block. Update
check_aura_authorities_rotation and check_grandpa_authorities_rotation in
runtime/src/lib.rs to the corrected timing, mirroring the pattern already
present in partner-chains/demo/runtime/src/lib.rs's own (upstream-updated)
tests for the same PR.

Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
@Klapeyron Klapeyron linked an issue Jul 8, 2026 that may be closed by this pull request
Klapeyron added 2 commits July 8, 2026 09:38
feat: generic session keys & session pallet migration of PR 1025
feat: generic session keys & session pallet migration of PR 1038
@Klapeyron
Klapeyron marked this pull request as ready for review July 8, 2026 07:39
@Klapeyron
Klapeyron requested a review from a team as a code owner July 8, 2026 07:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2b149eff2f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread runtime/src/lib.rs
Comment thread partner-chains/changelog.md
Comment thread partner-chains/toolkit/committee-selection/pallet/src/pallet_session_support.rs Outdated
@Klapeyron
Klapeyron requested a review from LGLO July 15, 2026 16:52
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@Klapeyron
Klapeyron enabled auto-merge July 16, 2026 10:43
@Klapeyron
Klapeyron added this pull request to the merge queue Jul 16, 2026
Merged via the queue into main with commit 7759af7 Jul 16, 2026
36 checks passed
@Klapeyron
Klapeyron deleted the feat/pc-pr-1026 branch July 16, 2026 11:21
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
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.

[Aura→BABE] SPK-02 (spike) — Session-key carrier decision

4 participants