Skip to content

refactor: introduce KesEvolutions type#2869

Merged
jpraynaud merged 8 commits into
mainfrom
jpraynaud/2833-introduce-kes-period-evolution-types
Jan 6, 2026
Merged

refactor: introduce KesEvolutions type#2869
jpraynaud merged 8 commits into
mainfrom
jpraynaud/2833-introduce-kes-period-evolution-types

Conversation

@jpraynaud

@jpraynaud jpraynaud commented Dec 19, 2025

Copy link
Copy Markdown
Member

Content

This PR includes the introduction of the type KesEvolutions to avoid confusion with KesPeriod and detect mismatch at compile time.

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation:
    • Add ADR blog post or Dev ADR entry (if relevant)

Issue(s)

Relates to #2833

@jpraynaud jpraynaud self-assigned this Dec 19, 2025
@jpraynaud
jpraynaud force-pushed the jpraynaud/2833-introduce-kes-period-evolution-types branch from 4fb970f to 696521f Compare December 19, 2025 16:38
Comment thread mithril-common/src/entities/signer.rs Fixed
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_evolutions.rs Fixed
Comment thread mithril-common/src/entities/signer.rs Fixed
@github-actions

github-actions Bot commented Dec 19, 2025

Copy link
Copy Markdown

Test Results

    4 files  ± 0    169 suites  ±0   22m 3s ⏱️ - 2m 15s
2 299 tests +14  2 299 ✅ +14  0 💤 ±0  0 ❌ ±0 
7 219 runs  +56  7 219 ✅ +56  0 💤 ±0  0 ❌ ±0 

Results for commit adc361c. ± Comparison against base commit 1daa3aa.

♻️ This comment has been updated with latest results.

@jpraynaud
jpraynaud force-pushed the jpraynaud/2833-introduce-kes-period-evolution-types branch from 696521f to c123ec6 Compare December 19, 2025 16:50
@jpraynaud
jpraynaud requested a review from Copilot December 19, 2025 16:51

Copilot AI 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.

Pull request overview

This PR introduces a new KesEvolutions type to distinguish it from KesPeriod at compile time, preventing potential type confusion and misuse. The PR creates a clear semantic separation between absolute KES periods (points in time on the blockchain) and KES evolutions (relative counts of key evolutions).

Key changes:

  • Introduces KesEvolutions newtype wrapper with arithmetic operations and conversions
  • Updates KesPeriod to support arithmetic with KesEvolutions (subtraction yields evolutions, addition with evolutions yields periods)
  • Replaces all usages of KesPeriod with KesEvolutions where the semantic meaning is a relative count rather than an absolute period

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
mithril-common/src/crypto_helper/cardano/kes/kes_evolutions.rs New type definition for KesEvolutions with Display, Deref, conversions, and arithmetic operations
mithril-common/src/crypto_helper/cardano/kes/kes_period.rs Updated KesPeriod type with arithmetic operations for KesEvolutions (Add and Sub)
mithril-common/src/crypto_helper/cardano/kes/mod.rs Exports the new KesEvolutions and KesPeriod types
mithril-common/src/crypto_helper/mod.rs Exports KesEvolutions in the public API
mithril-common/src/crypto_helper/cardano/opcert.rs Updates OpCert and OpCertWithoutColdVerificationKey to use KesPeriod for start_kes_period field
mithril-common/src/crypto_helper/cardano/key_certification.rs Updates error types and function signatures to use KesEvolutions where semantically appropriate
mithril-common/src/crypto_helper/cardano/kes/error.rs Updates error types to distinguish between KesEvolutions and KesPeriod
mithril-common/src/crypto_helper/cardano/kes/interface.rs Updates KesVerifier trait to use KesEvolutions parameter
mithril-common/src/crypto_helper/cardano/kes/verifier_standard.rs Updates KES verification to use KesEvolutions type
mithril-common/src/crypto_helper/cardano/kes/signer_with_key.rs Updates KES signing logic to use KesEvolutions for evolution count
mithril-common/src/entities/signer.rs Updates Signer and SignerWithStake entities to use KesEvolutions field type
mithril-common/src/messages/register_signer.rs Updates RegisterSignerMessage to use KesEvolutions field type
mithril-common/src/messages/message_parts/signer.rs Updates signer message parts to use KesEvolutions field type
mithril-common/src/messages/epoch_settings.rs Minor import reordering and test updates to use KesEvolutions
mithril-common/src/protocol/signer_builder.rs Updates to convert KesEvolutions to KesPeriod when needed for protocol initialization
mithril-common/src/test/* Multiple test files updated to use appropriate types (KesPeriod vs KesEvolutions)
mithril-signer/src/runtime/runner.rs Removes unnecessary type cast when computing kes_evolutions
mithril-aggregator/src/services/signer_registration/verifier.rs Removes unnecessary type cast when computing kes_evolutions
mithril-aggregator/src/database/* Updates database records and queries to use KesEvolutions type
internal/mithril-dmq/src/model/builder.rs Updates DMQ message builder to convert KesPeriod to u64 for serialization
internal/mithril-dmq/src/consumer/client/pallas.rs Updates to convert u64 to KesPeriod when deserializing operational certificates
internal/cardano-node/mithril-cardano-node-chain/src/chain_observer/* Updates chain observer implementations to use KesPeriod return type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_period.rs Outdated
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_evolutions.rs Outdated
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_period.rs
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_evolutions.rs Outdated
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_evolutions.rs Fixed
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_evolutions.rs Fixed
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_period.rs Fixed
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_period.rs Fixed
@jpraynaud
jpraynaud force-pushed the jpraynaud/2833-introduce-kes-period-evolution-types branch from fb6b6ae to 199ba60 Compare December 22, 2025 11:32
@jpraynaud
jpraynaud requested a review from Copilot December 22, 2025 11:32

Copilot AI 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.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_evolutions.rs Outdated
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_period.rs
@jpraynaud
jpraynaud force-pushed the jpraynaud/2833-introduce-kes-period-evolution-types branch from 199ba60 to f826001 Compare December 22, 2025 12:15
@jpraynaud
jpraynaud marked this pull request as ready for review December 22, 2025 12:42
@jpraynaud
jpraynaud requested a review from Alenar December 22, 2025 12:42
@jpraynaud
jpraynaud requested a review from curiecrypt December 22, 2025 16:03

@Alenar Alenar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM with one reservation.

I think we should not add any From to wrapper types except to i64 see the comment for the rational.

Comment thread mithril-common/src/protocol/signer_builder.rs
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_evolutions.rs Outdated
Comment thread mithril-common/src/crypto_helper/cardano/kes/kes_period.rs Outdated

@curiecrypt curiecrypt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@jpraynaud
jpraynaud force-pushed the jpraynaud/2833-introduce-kes-period-evolution-types branch from 38f48bf to 2677311 Compare January 6, 2026 11:14
* mithril-cardano-node-chain from `0.1.12` to `0.1.13`
* mithril-dmq from `0.1.16` to `0.1.17`
* mithril-aggregator from `0.8.5` to `0.8.6`
* mithril-common from `0.6.39` to `0.6.40`
* mithril-signer from `0.3.1` to `0.3.2`
@jpraynaud
jpraynaud force-pushed the jpraynaud/2833-introduce-kes-period-evolution-types branch from 2677311 to adc361c Compare January 6, 2026 11:32
@jpraynaud
jpraynaud merged commit 7cff813 into main Jan 6, 2026
108 of 109 checks passed
@jpraynaud
jpraynaud deleted the jpraynaud/2833-introduce-kes-period-evolution-types branch January 6, 2026 13:26
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.

5 participants