@@ -81,20 +81,22 @@ import Ouroboros.Consensus.Cardano.Block (
8181 ShelleyEra ,
8282 )
8383import Ouroboros.Consensus.Cardano.CanHardFork ()
84+ import Ouroboros.Consensus.Cardano.Ledger ()
8485import Ouroboros.Consensus.Config (
8586 TopLevelConfig ,
8687 configConsensus ,
8788 configLedger ,
8889 topLevelConfigLedger ,
8990 )
91+ import Ouroboros.Consensus.Shelley.Ledger.Ledger
9092
9193import Ouroboros.Consensus.Forecast (Forecast (.. ))
9294import qualified Ouroboros.Consensus.HardFork.Combinator.AcrossEras as Consensus
9395import Ouroboros.Consensus.HardFork.Combinator.Ledger ()
9496import qualified Ouroboros.Consensus.HardFork.Combinator.Mempool as Consensus
9597import Ouroboros.Consensus.HeaderValidation (headerStateChainDep )
9698import Ouroboros.Consensus.Ledger.Abstract (TickedLedgerState , applyChainTick )
97- import Ouroboros.Consensus.Ledger.Basics (ComputeLedgerEvents (.. ))
99+ import Ouroboros.Consensus.Ledger.Basics (ComputeLedgerEvents (.. ), ValuesMK )
98100import Ouroboros.Consensus.Ledger.Extended (ExtLedgerState , headerState , ledgerState )
99101import Ouroboros.Consensus.Ledger.SupportsMempool (
100102 ApplyTxErr ,
@@ -104,6 +106,7 @@ import Ouroboros.Consensus.Ledger.SupportsMempool (
104106 applyTx ,
105107 )
106108import Ouroboros.Consensus.Ledger.SupportsProtocol (ledgerViewForecastAt )
109+ import Ouroboros.Consensus.Ledger.Tables.Utils (forgetLedgerTables )
107110import Ouroboros.Consensus.Node.ProtocolInfo (
108111 ProtocolInfo ,
109112 pInfoConfig ,
@@ -118,7 +121,7 @@ import Ouroboros.Consensus.Protocol.Abstract (
118121import Ouroboros.Consensus.Protocol.Praos ()
119122import Ouroboros.Consensus.Protocol.TPraos ()
120123import Ouroboros.Consensus.Shelley.HFEras ()
121- import Ouroboros.Consensus.Shelley.Ledger (ShelleyBlock , Ticked , shelleyLedgerState )
124+ import Ouroboros.Consensus.Shelley.Ledger (ShelleyBlock )
122125import qualified Ouroboros.Consensus.Shelley.Ledger.Mempool as Consensus
123126import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol ()
124127import qualified Ouroboros.Consensus.TypeFamilyWrappers as Consensus
@@ -232,13 +235,13 @@ initInterpreter ::
232235initInterpreter pinfo forging traceForge mFingerprintFile = do
233236 let topLeverCfg = pInfoConfig pinfo
234237 let initSt = pInfoInitLedger pinfo
235- let ledgerView = mkForecast topLeverCfg initSt
238+ let ledgerView' = mkForecast topLeverCfg initSt
236239 (mode, fingerprint) <- mkFingerprint mFingerprintFile
237240 stvar <-
238241 newTVarIO $
239242 InterpreterState
240243 { istChain = initChainDB topLeverCfg initSt
241- , istForecast = ledgerView
244+ , istForecast = ledgerView'
242245 , istSlot = SlotNo 0
243246 , -- The first real Byron block (ie block that can contain txs) is number 1.
244247 istNextBlockNo = BlockNo 1
@@ -360,20 +363,22 @@ forgeNextLeaders interpreter txes possibleLeaders = do
360363 else throwIO $ FailedToValidateSlot currentSlot (lengthSlots <$> istFingerprint interState) (interpFingerFile interpreter)
361364 Just (proof, blockForging) -> do
362365 -- Tick the ledger state for the 'SlotNo' we're producing a block for
363- let tickedLedgerSt :: Ticked (LedgerState CardanoBlock )
364- ! tickedLedgerSt =
366+ let ledgerState' = ledgerState $ currentState (istChain interState)
367+
368+ tickedLedgerSt =
365369 applyChainTick
366370 ComputeLedgerEvents
367371 (configLedger cfg)
368372 currentSlot
369- (ledgerState . currentState $ istChain interState)
373+ (forgetLedgerTables ledgerState')
374+
370375 ! blk <-
371376 Block. forgeBlock
372377 blockForging
373378 cfg
374379 (istNextBlockNo interState)
375380 currentSlot
376- tickedLedgerSt
381+ (forgetLedgerTables tickedLedgerSt)
377382 (mkValidated <$> txes)
378383 proof
379384
@@ -384,7 +389,7 @@ forgeNextLeaders interpreter txes possibleLeaders = do
384389 _applyTxs ::
385390 [Consensus. GenTx CardanoBlock ] ->
386391 SlotNo ->
387- TickedLedgerState CardanoBlock ->
392+ TickedLedgerState CardanoBlock ValuesMK ->
388393 Either (ApplyTxErr CardanoBlock ) [Validated (GenTx CardanoBlock )]
389394 _applyTxs genTxs slotNo st =
390395 runExcept
@@ -405,7 +410,7 @@ tryAllForging interpreter interState currentSlot xs = do
405410 let cfg = interpTopLeverConfig interpreter
406411
407412 -- We require the ticked ledger view in order to construct the ticked 'ChainDepState'.
408- ledgerView <- case runExcept (forecastFor (istForecast interState) currentSlot) of
413+ ledgerView' <- case runExcept (forecastFor (istForecast interState) currentSlot) of
409414 Right lv -> pure (lv :: (LedgerView (BlockProtocol CardanoBlock )))
410415 -- Left can only happen if we cross an epoch boundary
411416 Left err -> throwIO $ ForecastError currentSlot err
@@ -417,7 +422,7 @@ tryAllForging interpreter interState currentSlot xs = do
417422 ! tickedChainDepState =
418423 tickChainDepState
419424 (configConsensus cfg)
420- ledgerView
425+ ledgerView'
421426 currentSlot
422427 (headerStateChainDep (headerState $ currentState $ istChain interState))
423428
@@ -471,7 +476,7 @@ rollbackInterpreter interpreter pnt = do
471476getCurrentInterpreterState :: Interpreter -> IO InterpreterState
472477getCurrentInterpreterState = readTVarIO . interpState
473478
474- getCurrentLedgerState :: Interpreter -> IO (ExtLedgerState CardanoBlock )
479+ getCurrentLedgerState :: Interpreter -> IO (ExtLedgerState CardanoBlock ValuesMK )
475480getCurrentLedgerState = fmap (currentState . istChain) . getCurrentInterpreterState
476481
477482getNextBlockNo :: Interpreter -> IO BlockNo
@@ -495,7 +500,7 @@ getCurrentSlot interp = istSlot <$> readTVarIO (interpState interp)
495500
496501withBabbageLedgerState ::
497502 Interpreter ->
498- (LedgerState (ShelleyBlock PraosStandard BabbageEra ) -> Either ForgingError a ) ->
503+ (LedgerState (ShelleyBlock PraosStandard BabbageEra ) ValuesMK -> Either ForgingError a ) ->
499504 IO a
500505withBabbageLedgerState inter mk = do
501506 st <- getCurrentLedgerState inter
@@ -507,7 +512,7 @@ withBabbageLedgerState inter mk = do
507512
508513withConwayLedgerState ::
509514 Interpreter ->
510- (LedgerState (ShelleyBlock PraosStandard ConwayEra ) -> Either ForgingError a ) ->
515+ (LedgerState (ShelleyBlock PraosStandard ConwayEra ) ValuesMK -> Either ForgingError a ) ->
511516 IO a
512517withConwayLedgerState inter mk = do
513518 st <- getCurrentLedgerState inter
@@ -519,7 +524,7 @@ withConwayLedgerState inter mk = do
519524
520525withAlonzoLedgerState ::
521526 Interpreter ->
522- (LedgerState (ShelleyBlock TPraosStandard AlonzoEra ) -> Either ForgingError a ) ->
527+ (LedgerState (ShelleyBlock TPraosStandard AlonzoEra ) ValuesMK -> Either ForgingError a ) ->
523528 IO a
524529withAlonzoLedgerState inter mk = do
525530 st <- getCurrentLedgerState inter
@@ -531,7 +536,7 @@ withAlonzoLedgerState inter mk = do
531536
532537withShelleyLedgerState ::
533538 Interpreter ->
534- (LedgerState (ShelleyBlock TPraosStandard ShelleyEra ) -> Either ForgingError a ) ->
539+ (LedgerState (ShelleyBlock TPraosStandard ShelleyEra ) ValuesMK -> Either ForgingError a ) ->
535540 IO a
536541withShelleyLedgerState inter mk = do
537542 st <- getCurrentLedgerState inter
@@ -623,9 +628,12 @@ mkValidated txe =
623628
624629mkForecast ::
625630 TopLevelConfig CardanoBlock ->
626- ExtLedgerState CardanoBlock ->
631+ ExtLedgerState CardanoBlock ValuesMK ->
627632 Forecast (LedgerView (BlockProtocol CardanoBlock ))
628- mkForecast cfg st = ledgerViewForecastAt (configLedger cfg) (ledgerState st)
633+ mkForecast cfg st = ledgerViewForecastAt (configLedger cfg) (ledgerState st')
634+ where
635+ st' :: ExtLedgerState CardanoBlock ValuesMK
636+ st' = st
629637
630638throwLeftIO :: Exception e => Either e a -> IO a
631639throwLeftIO = either throwIO pure
0 commit comments