@@ -32,6 +32,7 @@ import qualified Cardano.Protocol.TPraos.API as SL
3232import Cardano.Slotting.EpochInfo (hoistEpochInfo )
3333import Control.Monad (guard )
3434import Control.Monad.Except (runExcept , throwError , withExceptT )
35+ import Data.Coerce
3536import qualified Data.Map.Strict as Map
3637import Data.SOP.BasicFunctors
3738import Data.SOP.InPairs (RequiringBoth (.. ), ignoringBoth )
@@ -237,6 +238,35 @@ instance ShelleyCompatible proto era => HasPartialLedgerConfig (ShelleyBlock pro
237238 }
238239 }
239240
241+ translateChainDepStateAcrossShelley ::
242+ forall eraFrom eraTo protoFrom protoTo .
243+ ( TranslateProto protoFrom protoTo
244+ )
245+ => RequiringBoth
246+ WrapConsensusConfig
247+ (Translate WrapChainDepState )
248+ (ShelleyBlock protoFrom eraFrom )
249+ (ShelleyBlock protoTo eraTo )
250+ translateChainDepStateAcrossShelley =
251+ ignoringBoth $
252+ Translate $ \ _epochNo (WrapChainDepState chainDepState) ->
253+ -- Same protocol, same 'ChainDepState'. Note that we don't have to apply
254+ -- any changes related to an epoch transition, this is already done when
255+ -- ticking the state.
256+ WrapChainDepState $ translateChainDepState (Proxy @ (protoFrom , protoTo )) chainDepState
257+
258+ crossEraForecastAcrossShelley ::
259+ forall eraFrom eraTo protoFrom protoTo .
260+ ( TranslateProto protoFrom protoTo
261+ , LedgerSupportsProtocol (ShelleyBlock protoFrom eraFrom )
262+ )
263+ => RequiringBoth
264+ WrapLedgerConfig
265+ (CrossEraForecaster LedgerState WrapLedgerView )
266+ (ShelleyBlock protoFrom eraFrom )
267+ (ShelleyBlock protoTo eraTo )
268+ crossEraForecastAcrossShelley = coerce forecastAcrossShelley
269+
240270-- | Forecast from a Shelley-based era to the next Shelley-based era.
241271forecastAcrossShelley ::
242272 forall protoFrom protoTo eraFrom eraTo .
@@ -278,38 +308,6 @@ forecastAcrossShelley cfgFrom cfgTo transition forecastFor ledgerStateFrom
278308 (SL. stabilityWindow (shelleyLedgerGlobals cfgFrom))
279309 (SL. stabilityWindow (shelleyLedgerGlobals cfgTo))
280310
281- translateChainDepStateAcrossShelley ::
282- forall eraFrom eraTo protoFrom protoTo .
283- ( TranslateProto protoFrom protoTo
284- )
285- => RequiringBoth
286- WrapConsensusConfig
287- (Translate WrapChainDepState )
288- (ShelleyBlock protoFrom eraFrom )
289- (ShelleyBlock protoTo eraTo )
290- translateChainDepStateAcrossShelley =
291- ignoringBoth $
292- Translate $ \ _epochNo (WrapChainDepState chainDepState) ->
293- -- Same protocol, same 'ChainDepState'. Note that we don't have to apply
294- -- any changes related to an epoch transition, this is already done when
295- -- ticking the state.
296- WrapChainDepState $ translateChainDepState (Proxy @ (protoFrom , protoTo )) chainDepState
297-
298- crossEraForecastAcrossShelley ::
299- forall eraFrom eraTo protoFrom protoTo .
300- ( TranslateProto protoFrom protoTo
301- , LedgerSupportsProtocol (ShelleyBlock protoFrom eraFrom )
302- )
303- => RequiringBoth
304- WrapLedgerConfig
305- (CrossEraForecaster LedgerState WrapLedgerView )
306- (ShelleyBlock protoFrom eraFrom )
307- (ShelleyBlock protoTo eraTo )
308- crossEraForecastAcrossShelley =
309- RequireBoth $ \ (WrapLedgerConfig cfgFrom)
310- (WrapLedgerConfig cfgTo) ->
311- CrossEraForecaster $ forecastAcrossShelley cfgFrom cfgTo
312-
313311{- ------------------------------------------------------------------------------
314312 Translation from one Shelley-based era to another Shelley-based era
315313-------------------------------------------------------------------------------}
0 commit comments