Skip to content

Commit 49d13e1

Browse files
committed
Fix qKesKesKeyExpiry to not always be null
1 parent c8e5cb9 commit 49d13e1

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

Diff for: cardano-cli/ChangeLog.md

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

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

23+
- Fix `qKesKesKeyExpiry` in `kes-period-info` ([PR 4909](https://github.com/input-output-hk/cardano-node/pull/4909))
24+
2325
## 1.35.3 -- August 2022
2426

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

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

+21-5
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ runQueryKesPeriodInfo (AnyConsensusModeParams cModeParams) network nodeOpCertFil
446446
eraHistory <- lift (queryNodeLocalState localNodeConnInfo Nothing eraHistoryQuery)
447447
& onLeft (left . ShelleyQueryCmdAcquireFailure)
448448

449-
let eInfo = toEpochInfo eraHistory
449+
let eInfo = toTentativeEpochInfo eraHistory
450450

451451

452452
-- We get the operational certificate counter from the protocol state and check that
@@ -511,13 +511,13 @@ runQueryKesPeriodInfo (AnyConsensusModeParams cModeParams) network nodeOpCertFil
511511
opCertNodeAndOnDiskCounters o Nothing = OpCertNoBlocksMintedYet o
512512

513513
opCertExpiryUtcTime
514-
:: EpochInfo (Either Text)
514+
:: Tentative (EpochInfo (Either Text))
515515
-> GenesisParameters
516516
-> OpCertEndingKesPeriod
517517
-> Maybe UTCTime
518518
opCertExpiryUtcTime eInfo gParams (OpCertEndingKesPeriod oCertExpiryKesPeriod) =
519519
let time = epochInfoSlotToUTCTime
520-
eInfo
520+
(tentative eInfo)
521521
(SystemStart $ protocolParamSystemStart gParams)
522522
(fromIntegral $ oCertExpiryKesPeriod * fromIntegral (protocolParamSlotsPerKESPeriod gParams))
523523
in case time of
@@ -541,7 +541,7 @@ runQueryKesPeriodInfo (AnyConsensusModeParams cModeParams) network nodeOpCertFil
541541
createQueryKesPeriodInfoOutput
542542
:: OpCertIntervalInformation
543543
-> OpCertNodeAndOnDiskCounterInformation
544-
-> EpochInfo (Either Text)
544+
-> Tentative (EpochInfo (Either Text))
545545
-> GenesisParameters
546546
-> O.QueryKesPeriodInfoOutput
547547
createQueryKesPeriodInfoOutput oCertIntervalInfo oCertCounterInfo eInfo gParams =
@@ -1345,9 +1345,25 @@ queryResult eAcq = pure eAcq
13451345

13461346
toEpochInfo :: EraHistory CardanoMode -> EpochInfo (Either Text)
13471347
toEpochInfo (EraHistory _ interpreter) =
1348-
hoistEpochInfo (first (Text.pack . show ) . runExcept)
1348+
hoistEpochInfo (first (Text.pack . show) . runExcept)
13491349
$ Consensus.interpreterToEpochInfo interpreter
13501350

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

0 commit comments

Comments
 (0)