From d9ef5b880708e1ae40571ea4b78b983e54b084ca Mon Sep 17 00:00:00 2001 From: Yuriy Lazaryev Date: Fri, 8 Apr 2022 09:27:24 +0200 Subject: [PATCH] Light Mode: hardcode time interpreter summary for the testnet --- .../Wallet/Shelley/Network/Blockfrost.hs | 97 ++++++++++++++++++- 1 file changed, 92 insertions(+), 5 deletions(-) diff --git a/lib/shelley/src/Cardano/Wallet/Shelley/Network/Blockfrost.hs b/lib/shelley/src/Cardano/Wallet/Shelley/Network/Blockfrost.hs index e9596a3e3f1..876b76b4da8 100644 --- a/lib/shelley/src/Cardano/Wallet/Shelley/Network/Blockfrost.hs +++ b/lib/shelley/src/Cardano/Wallet/Shelley/Network/Blockfrost.hs @@ -39,7 +39,10 @@ import qualified Data.Sequence as Seq import qualified Ouroboros.Consensus.HardFork.History.Qry as HF import Cardano.Api - ( AnyCardanoEra, NetworkId (Mainnet, Testnet) ) + ( AnyCardanoEra + , NetworkId (Mainnet, Testnet) + , NetworkMagic (NetworkMagic) + ) import Cardano.BM.Data.Severity ( Severity (..) ) import Cardano.BM.Tracer @@ -520,10 +523,94 @@ networkSummary = \case } } } - Testnet _ -> error - "In light-mode time interpreter is only available for the \ - \mainnet (interpreter uses a hard-coded history of hard forks). \ - \It doesn't seem viable to hardcode it for other networks yet." + Testnet (NetworkMagic 1097911063) -> -- Magic of the current public testnet + Summary + { getSummary + = NonEmptyCons EraSummary + { eraStart = Bound + { boundTime = RelativeTime 0 + , boundSlot = SlotNo 0 + , boundEpoch = Node.EpochNo 0 + } + , eraEnd = EraEnd Bound + { boundTime = RelativeTime 31968000 + , boundSlot = SlotNo 1598400 + , boundEpoch = Node.EpochNo 74 + } + , eraParams = EraParams + { eraEpochSize = EpochSize 21600 + , eraSlotLength = mkSlotLength 20 + , eraSafeZone = StandardSafeZone 4320 + } + } + $ NonEmptyCons EraSummary + { eraStart = Bound + { boundTime = RelativeTime 31968000 + , boundSlot = SlotNo 1598400 + , boundEpoch = Node.EpochNo 74 + } + , eraEnd = EraEnd Bound + { boundTime = RelativeTime 44064000 + , boundSlot = SlotNo 13694400 + , boundEpoch = Node.EpochNo 102 + } + , eraParams = EraParams + { eraEpochSize = EpochSize 432000 + , eraSlotLength = mkSlotLength 1 + , eraSafeZone = StandardSafeZone 129600 + } + } + $ NonEmptyCons EraSummary + { eraStart = Bound + { boundTime = RelativeTime 44064000 + , boundSlot = SlotNo 13694400 + , boundEpoch = Node.EpochNo 102 + } + , eraEnd = EraEnd Bound + { boundTime = RelativeTime 48384000 + , boundSlot = SlotNo 18014400 + , boundEpoch = Node.EpochNo 112 + } + , eraParams = EraParams + { eraEpochSize = EpochSize 432000 + , eraSlotLength = mkSlotLength 1 + , eraSafeZone = StandardSafeZone 129600 + } + } + $ NonEmptyCons EraSummary + { eraStart = Bound + { boundTime = RelativeTime 48384000 + , boundSlot = SlotNo 18014400 + , boundEpoch = Node.EpochNo 112 + } + , eraEnd = EraEnd Bound + { boundTime = RelativeTime 66528000 + , boundSlot = SlotNo 36158400 + , boundEpoch = Node.EpochNo 154 + } + , eraParams = EraParams + { eraEpochSize = EpochSize 432000 + , eraSlotLength = mkSlotLength 1 + , eraSafeZone = StandardSafeZone 129600 + } + } + $ NonEmptyOne EraSummary + { eraStart = Bound + { boundTime = RelativeTime 66528000 + , boundSlot = SlotNo 36158400 + , boundEpoch = Node.EpochNo 154 + } + , eraEnd = EraUnbounded + , eraParams = EraParams + { eraEpochSize = EpochSize 432000 + , eraSlotLength = mkSlotLength 1 + , eraSafeZone = StandardSafeZone 129600 + } + } + } + Testnet magic -> + error $ "Epoch/Era conversion isn't provided for the Testnet " + <> show magic {- Epoch-to-Era translation is not available in the Blockfrost API.