Skip to content

Conversation

@m2ux
Copy link
Contributor

@m2ux m2ux commented Dec 17, 2025

Summary

Migrate PC (Partners Chain) validator selection from Haskell-based Permissioned Candidates contracts to Aiken-based contracts, and source the D Parameter from pallet-system-parameters instead of from Cardano D Parameter contract.

🎫 Ticket #1 🎫 Ticket #2 📐 ADR 🧪 Test Plan


Motivation

The Haskell-based Permissioned Candidates contracts are being deprecated in favor of new Aiken-based contracts. Additionally, the D Parameter—which controls the ratio of permissioned to registered validators—was previously sourced from a Cardano contract, introducing latency and external dependencies.

By migrating to Aiken contracts and sourcing the D Parameter from pallet-system-parameters, we:

  • Remove dependencies on deprecated Haskell smart contracts
  • Eliminate D Parameter lookup latency (now on-chain)
  • Remove the centralization risk of the emergency DParameterOverride mechanism

Changes

New RPC Endpoint - systemParameters_getAriadneParameters:

  • Returns the same response schema as sidechain_getAriadneParameters
  • D Parameter: Sourced from pallet-system-parameters (on-chain)
  • Permissioned Candidates: Sourced from Cardano Aiken contract via db-sync (unchanged)
  • Registered Candidates: Sourced from Cardano via db-sync (unchanged)
  • Integrators should migrate from sidechain_getAriadneParameters to this endpoint

RPC Deprecation:

  • sidechain_getAriadneParameters marked as deprecated (still functional)
  • D Parameter in deprecated endpoint still comes from Cardano contract

D Parameter Integration:

  • D Parameter sourced from pallet-system-parameters via SystemParameters::get_d_parameter()
  • Runtime authority selection uses on-chain D Parameter values
  • Standalone endpoint systemParameters_getDParameter available

pallet-midnight:

  • Removed DParameterOverride storage item
  • Removed override_d_parameter extrinsic

Configuration:

  • Updated pc-chain-config.json files with new Aiken policy IDs for all environments

Depends on: PR #387 (Add System Parameters pallet)


📌 Submission Checklist

  • 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: Change file added
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • No new todos introduced

🔱 Fork Strategy

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

🗹 TODO before merging

@m2ux m2ux self-assigned this Dec 17, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

Logo
Checkmarx One – Scan Summary & Detailsdec894b6-d2da-4045-b455-561de5af619a

Great job! No new security vulnerabilities introduced in this pull request

@gilescope
Copy link
Contributor

It would be confusing to land the documentation without the implementation. Currently in the repo we document only what's done rather than what potentially might be upcoming...

@m2ux
Copy link
Contributor Author

m2ux commented Dec 17, 2025

I add the ADR as the first document as the record of architecture decisions should precede the implementation. Technically the test plan should also if TDD is followed.

@m2ux
Copy link
Contributor Author

m2ux commented Dec 18, 2025

/bot rebuild-metadata

@github-actions
Copy link
Contributor

❌ Metadata rebuild failed. Check the workflow logs for details.

@m2ux
Copy link
Contributor Author

m2ux commented Dec 18, 2025

/bot rebuild-metadata

@github-actions
Copy link
Contributor

✅ Metadata rebuild complete! Changes have been committed.

Copy link
Contributor

@NachoPal NachoPal left a comment

Choose a reason for hiding this comment

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

I don't think we need to overcomplicate it with a DParamProvider as we don't expect other providers. See how the DParam is directly queried from the pallet-system-parameters in #387

@m2ux
Copy link
Contributor Author

m2ux commented Dec 18, 2025

I don't think we need to overcomplicate it with a DParamProvider as we don't expect other providers. See how the DParam is directly queried from the pallet-system-parameters in #387

This was a generic approach used for mocking. Now 'pallet-system-parameters' is available I'll integrate accordingly.

NachoPal and others added 15 commits December 18, 2025 15:00
- Add DParameterProvider trait for mockable D Parameter sourcing
- Implement MockDParameterProvider (uses inherent data for backward compat)
- Implement FixedDParameterProvider for testing
- Update select_authorities to use select_authorities_with_provider
- Remove DParameterOverride storage and override_d_parameter extrinsic
- Update pc-chain-config.json with new Aiken policy IDs:
  - node-dev-01: 51f812332ccc276d1dfa9da923c2235b91a5150ff275b633a5fa1bdb
  - qa-net: 6c327f1fe5e3b2619c62ca642892146c7326a91dc47f6006f6cdf690
  - preview: 4057188de00d74c6679263989745309f02bf55f8806061943124489b
  - preprod: 369ee95be4c68a2984733a8c727ecd28df3039a3e5f1e80290b08eec
- Add test plan document

WP: Aiken Permissioned Candidates & D Parameter Migration
Ticket: PM-20994
- Change manual tests from ✅ to ⬜ (Not Started)
- Add ⬜ Not Started to legend
- Add Notes column to test matrix
- Add detailed Manual Verification Procedures section
- Include code review checklists for TC-0004-04/05/07
TC-0004-04 and TC-0004-05 are compile-time + code review only,
not unit tests. Changed Unit Test column from ✅ to ➖ (N/A).
- TC-0004-04/05: Now 'verified by compilation' (not manual review)
- TC-0004-07: Removed (config file content verified at dev time)
- Removed Manual Verification Procedures for code review items
- Renumber tests sequentially (TC-01 through TC-06)
- Remove compile-time verification entries (not tests)
- Remove config file verification (dev-time check)
- Remove future test cases section
- Simplify test matrix (unit tests only)
- Streamline test case descriptions
Document the migration from Haskell to Aiken Permissioned Candidates
contracts and the D Parameter provider abstraction.

WP: Aiken Permissioned Candidates Migration
The struct is only used in unit tests, not in runtime-benchmarks.
Restricting to #[cfg(test)] fixes dead_code warning when building
with --features runtime-benchmarks.
- Replace Good/Bad/Neutral format with flattened ✅/❌ icon list
- Remove Implementation Approach section (design work, not decision)
- Remove Technical Details section (policy IDs are implementation details)
- Consolidate structure: Decision Drivers → Options → Decision → Consequences
- Add proper Confirmation section with validation criteria

ADRs document decisions, not design.
m2ux and others added 5 commits December 18, 2025 15:34
- docs/decisions/0005-aiken-permissioned-candidates-d-parameter-migration.md -> docs/decisions/adr-aiken-permissioned-candidates-d-parameter-migration.md
- docs/tests/0005-aiken-permissioned-candidates-d-parameter-migration.md -> docs/tests/test-plan-aiken-permissioned-candidates-d-parameter-migration.md
- Add ADR: prefix to title
- Remove d_parameter.rs module (trait abstraction no longer needed)
- D Parameter now sourced directly from SystemParameters::get_d_parameter()
- Update ADR status to Accepted
- Update test plan to reflect pallet integration

Depends-on: PR #387
@m2ux m2ux force-pushed the feat/aiken-permissioned-candidates-migration branch from d3685a0 to cd09ff3 Compare December 18, 2025 15:42
@m2ux m2ux changed the base branch from main to nacho/add-system-parameters-pallet December 18, 2025 15:45
m2ux added 4 commits December 18, 2025 15:47
- Add PR link to header
- Use PR378-TC-## format for Test IDs with hyperlinks to source
- Add column width divs to table
- Hyperlink symbols in Overview to source definitions
- Use proper   <br> format for multi-step entries
Add new RPC endpoint that returns Ariadne parameters with D Parameter
sourced from pallet-system-parameters instead of Cardano contracts.

Changes:
- Add MidnightAriadneRpc module in node/src/ariadne_rpc.rs
- Compose with SessionValidatorManagementQuery for candidate data
- Override D Parameter with pallet-sourced value
- Add 11 unit tests covering mock API, serialization, and override logic
- Update UI config with new endpoint definition
- Mark deprecated flag on old sidechain_getAriadneParameters endpoint
- Update ADR with RPC migration notes

The new endpoint midnight_getAriadneParameters provides the authoritative
D Parameter value while maintaining backward-compatible response schema.
@m2ux m2ux requested a review from NachoPal December 18, 2025 17:01
@NachoPal
Copy link
Contributor

No need to create a new rpc file under node. pallet-system-parameter already have its own pallet-system-parameters-rpc. The new get_ariadne_parameters RPC endpoint should be placed there.

m2ux added 3 commits December 19, 2025 10:30
- Move get_ariadne_parameters RPC from node/src/ariadne_rpc.rs to
  pallets/system-parameters/rpc/src/lib.rs per review feedback
- Update SystemParametersRpc to include SessionValidatorManagementQueryApi
- Remove standalone MidnightAriadneRpc module
- Fix test plan line number reference (L1751 -> L1752)
- Add missing CHAINSPEC_SYSTEM_PARAMETERS_CONFIG env var required by pallet-system-parameters migration
- Update D Parameter values (10, 0) to match genesis config in res/dev/system-parameters-config.json
Base automatically changed from nacho/add-system-parameters-pallet to main December 19, 2025 14:45
m2ux added 8 commits December 19, 2025 14:54
…into feat/aiken-permissioned-candidates-migration
Add E2E test coverage for pallet-system-parameters RPC endpoints:
- verify_system_parameters_genesis_via_rpc: validates genesis values
- verify_system_parameters_response_format: checks camelCase format
- query_system_parameters_at_historical_block: tests historical queries

Add MidnightClient helper methods for system parameters RPC:
- get_terms_and_conditions / get_terms_and_conditions_at
- get_d_parameter / get_d_parameter_at
- get_best_block_hash / wait_for_next_finalized_block

Ref: PM-20991
Change TermsAndConditionsRpcResponse.hash from String to H256 for
improved type safety. The JSON wire format remains unchanged as H256
serializes to the same hex string format (0x-prefixed).
- pallet-system-parameters: remove unused 'log' dep, ignore 'serde' (used by frame_support macros)
- pallet-system-parameters-rpc: remove unused 'hex' dep (no longer needed after H256 refactor)
- midnight-primitives-system-parameters: remove unused parity-scale-codec, scale-info, sp-runtime, sp-core
…into feat/aiken-permissioned-candidates-migration
Remove T&C-related additions from e2e tests that were out of scope
for the Aiken permissioned candidates migration work package:

- Remove TermsAndConditionsResponse struct from midnight.rs
- Remove get_terms_and_conditions and get_terms_and_conditions_at methods
- Remove T&C constants and assertions from e2e tests
- Rename tests to focus on D Parameter verification only

D Parameter RPC tests remain as they are in scope for this migration.
@m2ux m2ux marked this pull request as ready for review December 29, 2025 16:10
@m2ux m2ux requested a review from a team as a code owner December 29, 2025 16:10
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