Skip to content

Commit

Permalink
Create a more realistic eraHistory fixture with a safe zone
Browse files Browse the repository at this point in the history
This will have time conversions fail after some point
  • Loading branch information
ch1bo authored and v0d1ch committed Sep 26, 2022
1 parent c0e7715 commit b279d0a
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion hydra-node/src/Hydra/Ledger/Cardano/Evaluate.hs
Expand Up @@ -34,6 +34,7 @@ import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
import Hydra.Cardano.Api (
CardanoMode,
ConsensusMode (CardanoMode),
EpochNo (EpochNo),
Era,
EraHistory (EraHistory),
EraInMode (BabbageEraInCardanoMode),
Expand All @@ -59,7 +60,8 @@ import Hydra.Cardano.Api (
import Hydra.Data.ContestationPeriod (posixToUTCTime)
import Ouroboros.Consensus.Cardano.Block (CardanoEras)
import Ouroboros.Consensus.HardFork.History (
EraEnd (EraUnbounded),
Bound (..),
EraEnd (EraEnd, EraUnbounded),
EraParams (..),
EraSummary (..),
SafeZone (..),
Expand Down Expand Up @@ -184,6 +186,7 @@ maxMem, maxCpu :: Natural
maxCpu = executionSteps maxTxExecutionUnits
maxMem = executionMemory maxTxExecutionUnits

-- | An artifical era history comprised by a single never ending (forking) era.
eraHistory :: EraHistory CardanoMode
eraHistory =
EraHistory CardanoMode (mkInterpreter summary)
Expand All @@ -207,6 +210,33 @@ eraHistory =
}
}

-- | An era history with a single era which will end at some point and has a
-- quite narrow safe zone. We have reconstructed this value from "real world"
-- 'EraHistory' values received from the cardano-node.
eraHistoryWithSafeZone :: EraHistory CardanoMode
eraHistoryWithSafeZone =
EraHistory CardanoMode (mkInterpreter summary)
where
summary :: Summary (CardanoEras StandardCrypto)
summary =
Summary . NonEmptyOne $
EraSummary
{ eraStart = initBound
, eraEnd =
EraEnd
Bound
{ boundTime = RelativeTime 10
, boundSlot = SlotNo 100
, boundEpoch = EpochNo 1
}
, eraParams =
EraParams
{ eraEpochSize = EpochSize 100
, eraSlotLength = mkSlotLength 1
, eraSafeZone = StandardSafeZone 30
}
}

epochInfo :: Monad m => EpochInfo m
epochInfo = fixedEpochInfo (EpochSize 100) slotLength

Expand Down

0 comments on commit b279d0a

Please sign in to comment.