@@ -39,6 +39,9 @@ adjusted where Amaru's importer still expects older ledger shapes:
3939 and DRep delegation are preserved; historical pointer indexes and the
4040 intermediate deposits accumulator are omitted because Amaru skips them
4141 during bootstrap.
42+ * Empty reward-update state is projected as a completed zero reward
43+ update. Amaru's import command runs in @has_rewards=true@ mode and
44+ unconditionally decodes a @Complete RewardUpdate@ at this position.
4245-}
4346module LedgerStateEmitter (
4447 emitLedgerSnapshot ,
@@ -58,6 +61,7 @@ import Cardano.Ledger.Conway.State qualified as Conway
5861import Cardano.Ledger.Core qualified as Core
5962import Cardano.Ledger.Dijkstra.State ()
6063import Cardano.Ledger.Shelley.LedgerState qualified as SL
64+ import Cardano.Ledger.Shelley.RewardUpdate qualified as ShelleyReward
6165import Cardano.Ledger.State qualified as Ledger
6266import Cardano.Slotting.Slot (SlotNo )
6367import Cardano.Tools.DBAnalyser.Block.Cardano (
@@ -81,11 +85,13 @@ import Control.ResourceRegistry (
8185import Data.ByteString.Lazy qualified as LBS
8286import Data.Functor.Contravariant ((>$<) )
8387import Data.Map.Strict qualified as Map
88+ import Data.Maybe.Strict (StrictMaybe (.. ))
8489import Data.Proxy (Proxy (Proxy ))
8590import Data.SOP.BasicFunctors (K (K ))
8691import Data.SOP.Functors (Flip (unFlip ))
8792import Data.SOP.Strict (NP (Nil , (:*) ), fn , type (-.-> ))
8893import HeaderExtractor (NodeConfig (NodeConfig ))
94+ import Lens.Micro ((^.) )
8995import Ouroboros.Consensus.Block (
9096 GetHeader ,
9197 blockNo ,
@@ -190,7 +196,6 @@ import Ouroboros.Consensus.Util.CBOR (
190196 )
191197import Ouroboros.Consensus.Util.Versioned (encodeVersion )
192198import Ouroboros.Network.Block (genesisPoint )
193- import Lens.Micro ((^.) )
194199import System.Directory (createDirectoryIfMissing )
195200import System.FilePath (takeDirectory )
196201
@@ -499,7 +504,8 @@ encodeShelleyLedgerStateCanonicalWith ::
499504 (SL. NewEpochState era -> CBOR. Encoding ) ->
500505 LedgerState (ShelleyBlock proto era ) EmptyMK ->
501506 CBOR. Encoding
502- encodeShelleyLedgerStateCanonicalWith encodeNewEpochState
507+ encodeShelleyLedgerStateCanonicalWith
508+ encodeNewEpochState
503509 ShelleyLedgerState
504510 { shelleyLedgerTip
505511 , shelleyLedgerState
@@ -562,18 +568,29 @@ encodeNewEpochStateCanonicalLedgerWith encodeCertState (SL.NewEpochState e bp bc
562568 , encCBOR bp
563569 , encCBOR bc
564570 , encodeEpochStateCanonicalWith encodeCertState es
565- , encCBOR ru
571+ , encodeRewardUpdateAmaru ru
566572 , encCBOR pd
567573 , encCBOR av
568574 ]
569575
576+ encodeRewardUpdateAmaru ::
577+ StrictMaybe ShelleyReward. PulsingRewUpdate ->
578+ LedgerEncoding
579+ encodeRewardUpdateAmaru =
580+ encCBOR . \ case
581+ SNothing ->
582+ SJust $
583+ ShelleyReward. Complete ShelleyReward. emptyRewardUpdate
584+ SJust ru -> SJust ru
585+
570586encodeEpochStateCanonicalWith ::
571587 forall era .
572588 (CanonicalShelleyLedgerCbor era ) =>
573589 (SL. CertState era -> LedgerEncoding ) ->
574590 SL. EpochState era ->
575591 LedgerEncoding
576- encodeEpochStateCanonicalWith encodeCertState
592+ encodeEpochStateCanonicalWith
593+ encodeCertState
577594 SL. EpochState
578595 { SL. esChainAccountState = esChainAccountState
579596 , SL. esLState = esLState
@@ -594,7 +611,8 @@ encodeLedgerStateCanonicalWith ::
594611 (SL. CertState era -> LedgerEncoding ) ->
595612 SL. LedgerState era ->
596613 LedgerEncoding
597- encodeLedgerStateCanonicalWith encodeCertState
614+ encodeLedgerStateCanonicalWith
615+ encodeCertState
598616 SL. LedgerState
599617 { SL. lsUTxOState = lsUTxOState
600618 , SL. lsCertState = lsCertState
0 commit comments