refactor: introduce KesEvolutions type#2869
Conversation
4fb970f to
696521f
Compare
696521f to
c123ec6
Compare
There was a problem hiding this comment.
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
KesEvolutionsnewtype wrapper with arithmetic operations and conversions - Updates
KesPeriodto support arithmetic withKesEvolutions(subtraction yields evolutions, addition with evolutions yields periods) - Replaces all usages of
KesPeriodwithKesEvolutionswhere 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.
fb6b6ae to
199ba60
Compare
There was a problem hiding this comment.
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.
199ba60 to
f826001
Compare
Alenar
left a comment
There was a problem hiding this comment.
LGTM with one reservation.
I think we should not add any From to wrapper types except to i64 see the comment for the rational.
…esPeriod' and 'KesEvolutions'
38f48bf to
2677311
Compare
* 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`
2677311 to
adc361c
Compare
Content
This PR includes the introduction of the type
KesEvolutionsto avoid confusion withKesPeriodand detect mismatch at compile time.Pre-submit checklist
Issue(s)
Relates to #2833