Wrong maxKESEvolutions

Open
#79 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
haskell

Research direction

Start with kes-agent-crypto/src/Cardano/KESAgent/Protocols/StandardCrypto.hs at the comparison noted in the issue, then trace EvolutionConfig in kes-agent-crypto/src/Cardano/KESAgent/KES/Evolution.hs. Determine how the genesis maxKESEvolutions value should reach the evolution logic instead of the fixed 2^6 limit. Done means the agent respects a genesis value of 60 and no longer evolves through period 64 in the described scenario.

Written by the indexing model from the issue text.

Description

I shortened slotsPerKesPeriod to test the evolutions:

shelley genesis has:
"maxKESEvolutions": 60,

however, in the kes-agent-control I see Current evolution: 12 / 64

kes-agent-control info --control
--- Agent ---
Agent version: 0.2.0.0-dev-20251203151322
Connected via: control.socket
Current time: 2025-12-03 22:34:58 UTC
Current KES period: 12
Current KES period started: 2025-12-03 22:31:33 UTC
Next KES period starts: 2025-12-03 22:35:43 UTC
--- Installed KES SignKey ---
Timestamp: 2025-12-03 21:42:29 UTC
VerKey: b2d8ab926ce326b2cbc6cfbe8906bae530a2956fe707973afc6af4c68b279da0
Valid from period: 0
Current evolution: 12 / 64
OpCert number: 1
OpCert signature: 419d7ec678f4a53831bd28aeb39e5cfa2950bd887e5e03f2f5a6c642d1de0637815c5b32bc7816af99d4b4275d33735dda3fb7f5b2ae7796e6077c60c2ce9d07

The kes-agent does evolve the key 64 times

1764813593.821 Notice  Agent: key evolved (KESPeriod 61) (KESPeriod 62) 
 1764813843.815 Notice  Agent: key evolved (KESPeriod 62) (KESPeriod 63) 
 1764814093.741 Warning Agent: key expired (KESPeriod 63) (KESPeriod 64)

On the node's side, as expected, we see it only evolves the key up to 60 (the value from genesis file), and we get a proper warning: Operational key will expire in 1 KES periods. In this cluster, slotsPerKesPeriod is set to 500, so in this run the next period starts at slot 15000, and indeed the very last block this pool produced was this one in the logs at slot 14994

[focus:cardano.node:Alert:42] [2025-12-04 01:51:27.00 UTC] Operational key will expire in 1 KES periods.
[focus:cardano.node.Forge:Debug:42] [2025-12-04 01:51:27.00 UTC] TraceLabelCreds "Cardano" (CurrentEraForgeStateUpdated S (S (S (S (S (S (Z (WrapForgeStateInfo {unwrapForgeStateInfo = KESInfo {kesStartPeriod = KESPeriod 0, kesEndPeriod = KESPeriod 60, kesEvolution = 59}}))))))))
[focus:cardano.node.Forge:Info:42] [2025-12-04 01:51:27.00 UTC] fromList [("credentials",String "Cardano"),("val",Object (fromList [("kind",String "TraceNodeIsLeader"),("slot",Number 14994.0)]))]
[focus:cardano.node.Forge:Debug:42] [2025-12-04 01:51:27.00 UTC] fromList [("credentials",String "Cardano"),("val",Object (fromList [("kind",String "TraceForgeTickedLedgerState"),("prev",String "721b11b6c186a7c95a38ce7a8e73c393e1e2aaaa7542c54e7327ca365344ca91@14988"),("slot",Number 14994.0)]))]
[focus:cardano.node.Forge:Debug:42] [2025-12-04 01:51:27.00 UTC] fromList [("credentials",String "Cardano"),("val",Object (fromList [("kind",String "TraceForgingMempoolSnapshot"),("mempoolHash",String "721b11b6c186a7c95a38ce7a8e73c393e1e2aaaa7542c54e7327ca365344ca91"),("mempoolSlot",Number 14989.0),("prev",String "721b11b6c186a7c95a38ce7a8e73c393e1e2aaaa7542c54e7327ca365344ca91@14988"),("slot",Number 14994.0)]))]
[focus:cardano.node.Forge:Info:42] [2025-12-04 01:51:27.00 UTC] fromList [("credentials",String "Cardano"),("val",Object (fromList [("block",String "124f5b64976cf3c20502ff5a981e84e5ce8e297eef8893145646cf15dbf7441b"),("blockNo",Number 1451.0),("blockPrev",String "721b11b6c186a7c95a38ce7a8e73c393e1e2aaaa7542c54e7327ca365344ca91"),("kind",String "TraceForgedBlock"),("slot",Number 14994.0)]))]

Thomas Vellekoop pointed out that it's probably this: https://github.com/input-output-hk/kes-agent/blob/6d0f51fba415d3c641a8a8da37130e7adfc3ea01/kes-agent-crypto/src/Cardano/KESAgent/Protocols/StandardCrypto.hs#L36 ,

we compare against 2^6 = 64, but it should compare from a genesis file

from EvolutionConfig it seems we are not trying to look into the genesis for maxKESevolutions

data EvolutionConfig
  = EvolutionConfig
  { slotLength :: Int
  , slotsPerKESPeriod :: Int
  , systemStart :: UTCTime
  }
  deriving (Show, Eq, Ord)

https://github.com/input-output-hk/kes-agent/blob/6d0f51fba415d3c641a8a8da37130e7adfc3ea01/kes-agent-crypto/src/Cardano/KESAgent/KES/Evolution.hs#L29

Dominant language
Haskell
Stars
2
Forks
13
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IntersectMBO/kes-agent

All issues in IntersectMBO/kes-agent

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.