Skip to content

Commit a7637c1

Browse files
committed
Fix qKesKesKeyExpiry to not always be null
1 parent d9ff0ef commit a7637c1

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
@@ -18,6 +18,8 @@
1818

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

21+
- Fix `qKesKesKeyExpiry` in `kes-period-info` ([PR 4909](https://github.com/input-output-hk/cardano-node/pull/4909))
22+
2123
## 1.35.3 -- August 2022
2224

2325
- 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
@@ -442,7 +442,7 @@ runQueryKesPeriodInfo (AnyConsensusModeParams cModeParams) network nodeOpCertFil
442442
eraHistory <- lift (queryNodeLocalState localNodeConnInfo Nothing eraHistoryQuery)
443443
& onLeft (left . ShelleyQueryCmdAcquireFailure)
444444

445-
let eInfo = toEpochInfo eraHistory
445+
let eInfo = toTentativeEpochInfo eraHistory
446446

447447

448448
-- We get the operational certificate counter from the protocol state and check that
@@ -507,13 +507,13 @@ runQueryKesPeriodInfo (AnyConsensusModeParams cModeParams) network nodeOpCertFil
507507
opCertNodeAndOnDiskCounters o Nothing = OpCertNoBlocksMintedYet o
508508

509509
opCertExpiryUtcTime
510-
:: EpochInfo (Either Text)
510+
:: Tentative (EpochInfo (Either Text))
511511
-> GenesisParameters
512512
-> OpCertEndingKesPeriod
513513
-> Maybe UTCTime
514514
opCertExpiryUtcTime eInfo gParams (OpCertEndingKesPeriod oCertExpiryKesPeriod) =
515515
let time = epochInfoSlotToUTCTime
516-
eInfo
516+
(tentative eInfo)
517517
(SystemStart $ protocolParamSystemStart gParams)
518518
(fromIntegral $ oCertExpiryKesPeriod * fromIntegral (protocolParamSlotsPerKESPeriod gParams))
519519
in case time of
@@ -537,7 +537,7 @@ runQueryKesPeriodInfo (AnyConsensusModeParams cModeParams) network nodeOpCertFil
537537
createQueryKesPeriodInfoOutput
538538
:: OpCertIntervalInformation
539539
-> OpCertNodeAndOnDiskCounterInformation
540-
-> EpochInfo (Either Text)
540+
-> Tentative (EpochInfo (Either Text))
541541
-> GenesisParameters
542542
-> O.QueryKesPeriodInfoOutput
543543
createQueryKesPeriodInfoOutput oCertIntervalInfo oCertCounterInfo eInfo gParams =
@@ -1341,9 +1341,25 @@ queryResult eAcq = pure eAcq
13411341

13421342
toEpochInfo :: EraHistory CardanoMode -> EpochInfo (Either Text)
13431343
toEpochInfo (EraHistory _ interpreter) =
1344-
hoistEpochInfo (first (Text.pack . show ) . runExcept)
1344+
hoistEpochInfo (first (Text.pack . show) . runExcept)
13451345
$ Consensus.interpreterToEpochInfo interpreter
13461346

1347+
-- | A value that is tentative or produces a tentative value if used. These values
1348+
-- are considered accurate only if some future event such as a hard fork does not
1349+
-- render them invalid.
1350+
newtype Tentative a = Tentative { tentative :: a } deriving (Eq, Show)
1351+
1352+
-- | Get an Epoch Info that computes tentative values. The values computed are
1353+
-- tentative because it uses an interpreter that is extended past the horizon.
1354+
-- This interpreter will compute accurate values into the future as long as a
1355+
-- a hard fork does not happen in the intervening time. Those values are thus
1356+
-- "tentative" because they can change in the event of a hard fork.
1357+
toTentativeEpochInfo :: EraHistory CardanoMode -> Tentative (EpochInfo (Either Text))
1358+
toTentativeEpochInfo (EraHistory _ interpreter) =
1359+
Tentative
1360+
$ hoistEpochInfo (first (Text.pack . show) . runExcept)
1361+
$ Consensus.interpreterToEpochInfo (Consensus.unsafeExtendSafeZone interpreter)
1362+
13471363
obtainLedgerEraClassConstraints
13481364
:: ShelleyLedgerEra era ~ ledgerera
13491365
=> Api.ShelleyBasedEra era

0 commit comments

Comments
 (0)