Skip to content

Commit e5e4564

Browse files
committed
Fix qKesKesKeyExpiry to not always be null
1 parent 7cafc3a commit e5e4564

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

cardano-cli/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
- Query protocol parameters from the node in the `transaction build` command ([PR 4431](https://github.com/input-output-hk/cardano-node/pull/4431))
2929

30+
- Fix `qKesKesKeyExpiry` in `kes-period-info` ([PR 4909](https://github.com/input-output-hk/cardano-node/pull/4909))
31+
3032
## 1.35.3 -- August 2022
3133

3234
- Update build and build-raw commands to accept simple reference minting scripts (#4087)

cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ runQueryKesPeriodInfo (AnyConsensusModeParams cModeParams) network nodeOpCertFil
448448
eraHistory <- lift (queryNodeLocalState localNodeConnInfo Nothing eraHistoryQuery)
449449
& onLeft (left . ShelleyQueryCmdAcquireFailure)
450450

451-
let eInfo = toEpochInfo eraHistory
451+
let eInfo = toTentativeEpochInfo eraHistory
452452

453453

454454
-- We get the operational certificate counter from the protocol state and check that
@@ -515,13 +515,13 @@ runQueryKesPeriodInfo (AnyConsensusModeParams cModeParams) network nodeOpCertFil
515515
opCertNodeAndOnDiskCounters o Nothing = OpCertNoBlocksMintedYet o
516516

517517
opCertExpiryUtcTime
518-
:: EpochInfo (Either Text)
518+
:: Tentative (EpochInfo (Either Text))
519519
-> GenesisParameters
520520
-> OpCertEndingKesPeriod
521521
-> Maybe UTCTime
522522
opCertExpiryUtcTime eInfo gParams (OpCertEndingKesPeriod oCertExpiryKesPeriod) =
523523
let time = epochInfoSlotToUTCTime
524-
eInfo
524+
(tentative eInfo)
525525
(SystemStart $ protocolParamSystemStart gParams)
526526
(fromIntegral $ oCertExpiryKesPeriod * fromIntegral (protocolParamSlotsPerKESPeriod gParams))
527527
in case time of
@@ -576,7 +576,7 @@ runQueryKesPeriodInfo (AnyConsensusModeParams cModeParams) network nodeOpCertFil
576576
createQueryKesPeriodInfoOutput
577577
:: OpCertIntervalInformation
578578
-> OpCertNodeAndOnDiskCounterInformation
579-
-> EpochInfo (Either Text)
579+
-> Tentative (EpochInfo (Either Text))
580580
-> GenesisParameters
581581
-> O.QueryKesPeriodInfoOutput
582582
createQueryKesPeriodInfoOutput oCertIntervalInfo oCertCounterInfo eInfo gParams =
@@ -1415,9 +1415,25 @@ queryResult eAcq = pure eAcq
14151415

14161416
toEpochInfo :: EraHistory CardanoMode -> EpochInfo (Either Text)
14171417
toEpochInfo (EraHistory _ interpreter) =
1418-
hoistEpochInfo (first (Text.pack . show ) . runExcept)
1418+
hoistEpochInfo (first (Text.pack . show) . runExcept)
14191419
$ Consensus.interpreterToEpochInfo interpreter
14201420

1421+
-- | A value that is tentative or produces a tentative value if used. These values
1422+
-- are considered accurate only if some future event such as a hard fork does not
1423+
-- render them invalid.
1424+
newtype Tentative a = Tentative { tentative :: a } deriving (Eq, Show)
1425+
1426+
-- | Get an Epoch Info that computes tentative values. The values computed are
1427+
-- tentative because it uses an interpreter that is extended past the horizon.
1428+
-- This interpreter will compute accurate values into the future as long as a
1429+
-- a hard fork does not happen in the intervening time. Those values are thus
1430+
-- "tentative" because they can change in the event of a hard fork.
1431+
toTentativeEpochInfo :: EraHistory CardanoMode -> Tentative (EpochInfo (Either Text))
1432+
toTentativeEpochInfo (EraHistory _ interpreter) =
1433+
Tentative
1434+
$ hoistEpochInfo (first (Text.pack . show) . runExcept)
1435+
$ Consensus.interpreterToEpochInfo (Consensus.unsafeExtendSafeZone interpreter)
1436+
14211437
obtainLedgerEraClassConstraints
14221438
:: ShelleyLedgerEra era ~ ledgerera
14231439
=> Api.ShelleyBasedEra era

0 commit comments

Comments
 (0)