Skip to content

feat: generic session keys & session pallet migration of PR 1105#1802

Open
Klapeyron wants to merge 20 commits into
feat/pc-pr-1026from
feat/pc-pr-1105
Open

feat: generic session keys & session pallet migration of PR 1105#1802
Klapeyron wants to merge 20 commits into
feat/pc-pr-1026from
feat/pc-pr-1105

Conversation

@Klapeyron

Copy link
Copy Markdown
Contributor

Overview

🗹 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.

@Klapeyron Klapeyron force-pushed the feat/pc-pr-1105 branch 2 times, most recently from 0faf3d6 to 64e096b Compare July 1, 2026 12:40
@Klapeyron Klapeyron force-pushed the feat/pc-pr-1105 branch 2 times, most recently from 6159020 to bdfa554 Compare July 6, 2026 09:08
@Klapeyron Klapeyron force-pushed the feat/pc-pr-1105 branch 2 times, most recently from a70b538 to f8ddf13 Compare July 6, 2026 10:09

## Added

* Added `partner-chains-node smart-contracts upsert-script` command for inserting and updating versioned scripts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems redundant

Base automatically changed from feat/pc-pr-1038 to feat/pc-pr-1026 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: 36e8f43bbc

ℹ️ 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".

//!
//! impl From<LegacyAuthorityKeys> for SessionKeys {
//! fn from(old: LegacyAuthorityKeys) -> Self {
//! SessionKeys { aura: old.aura, grandpa: old.grandpa, beefy: ecdsa::Public::default().into() }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use per-validator placeholders for added keys

When this example is followed for an upgrade that adds Beefy, every validator is assigned the same default Beefy key. pallet_session::upgrade_keys rewrites KeyOwner for each new key, so a shared added key leaves ownership pointing at whichever validator is processed last, and the migration's try-runtime checks currently skip newly added key types. Use a deterministic per-validator placeholder/derived key in the example, or explicitly require uniqueness, so chains do not copy a migration that corrupts new-key ownership.

Useful? React with 👍 / 👎.

AmbientTea and others added 20 commits July 8, 2026 14:53
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>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
…ement pallet (#1105)

Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
…ith midnight-node's runtime

Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
…align with midnight-node's runtime

Signed-off-by: Tomasz Bartos <tomasz.bartos@shielded.io>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Aura→BABE] RT-05 — AuthorityKeys idempotent storage migration

4 participants