Skip to content

Commit

Permalink
Translate the ledger tables in the HFC
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Feb 7, 2023
1 parent a39956b commit e827c3a
Showing 1 changed file with 33 additions and 1 deletion.
Expand Up @@ -14,6 +14,7 @@ module Ouroboros.Consensus.HardFork.Combinator.State.Types (
, TransitionInfo (..)
, Translate (..)
, TranslateForecast (..)
, TranslateLedgerState (..)
) where

import Prelude
Expand All @@ -26,6 +27,7 @@ import NoThunks.Class (NoThunks (..))
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Forecast
import Ouroboros.Consensus.HardFork.History (Bound)
import Ouroboros.Consensus.Ledger.Basics
import Ouroboros.Consensus.Ticked

import Ouroboros.Consensus.HardFork.Combinator.Util.Telescope
Expand Down Expand Up @@ -93,10 +95,40 @@ newtype TranslateForecast f g x y = TranslateForecast {
translateForecastWith ::
Bound -- 'Bound' of the transition (start of the new era)
-> SlotNo -- 'SlotNo' we're constructing a forecast for
-> f x
-> f x EmptyMK
-> Except OutsideForecastRange (Ticked (g y))
}

-- | Translate a LedgerState across an era transition.
--
-- As new tables might be populated on an era transition, the return map kind is
-- @ValuesMK@. If no tables are populated, normally this will be filled with
-- @polyEmptyLedgerTables@.
data TranslateLedgerState x y = TranslateLedgerState {
-- | How to translate a Ledger State during the era transition
translateLedgerStateWith ::
EpochNo
-> LedgerState x EmptyMK
-> LedgerState y DiffMK

-- | How to translate tables on an era transition.
--
-- This is a rather technical subtlety. When performing a ledger state
-- translation, the provided input ledger state will be initially
-- populated with a @polyEmptyLedgerTables@. This step is required so
-- that the operation provided to 'Telescope.extend' is an automorphism.
--
-- If we only extend by one era, this function is a no-op, as the input
-- will be empty ledger states. However, if we extend across multiple
-- eras, previous eras might populate tables thus creating Values that
-- now need to be translated to newer eras. This function fills that
-- hole and allows us to promote tables from one era into tables from
-- the next era.
, translateLedgerTablesWith ::
LedgerTables (LedgerState x) DiffMK
-> LedgerTables (LedgerState y) DiffMK
}

-- | Knowledge in a particular era of the transition to the next era
data TransitionInfo =
-- | No transition is yet known for this era
Expand Down

0 comments on commit e827c3a

Please sign in to comment.