diff --git a/lib/jormungandr/src/Cardano/Wallet/Binary/Jormungandr.hs b/lib/jormungandr/src/Cardano/Wallet/Binary/Jormungandr.hs index 2b65a32fbcd..2d1825eecb2 100644 --- a/lib/jormungandr/src/Cardano/Wallet/Binary/Jormungandr.hs +++ b/lib/jormungandr/src/Cardano/Wallet/Binary/Jormungandr.hs @@ -228,21 +228,39 @@ getTokenTransfer = do -------------------------------------------------------------------------------} data ConfigParam - -- Seconds elapsed since 1-Jan-1970 (unix time) = Block0Date Word64 - | ConfigDiscrimination Network - | ConsensusVersion Word16 -- ? + -- ^ The official start time of the blockchain, in seconds since the Unix + -- epoch. + | Discrimination Network + -- ^ Address discrimination. Testnet / Mainnet. + | Consensus ConsensusVersion + -- ^ Consensus version. BFT / Genesis Praos. | SlotsPerEpoch Word32 + -- ^ Number of slots in an epoch. | SlotDuration Word8 + -- ^ Slot duration in seconds. | EpochStabilityDepth Word32 - | ConsensusGenesisPraosActiveSlotsCoeff Milli + -- ^ The length of the suffix of the chain (in blocks) considered unstable. + | ConsensusGenesisPraosParamF Milli + -- ^ Determines maximum probability of a stakeholder being elected as leader + -- in a slot. | MaxNumberOfTransactionsPerBlock Word32 + -- ^ Maximum number of transactions in a block. | BftSlotsRatio Milli + -- ^ Fraction of blocks to be created by BFT leaders. | AddBftLeader LeaderId + -- ^ Add a BFT Leader | RemoveBftLeader LeaderId + -- ^ Remove a BFT Leader | AllowAccountCreation Bool + -- ^ Enable/disable account creation. | ConfigLinearFee LinearFee + -- ^ Coefficients for fee calculations. | ProposalExpiration Word32 + -- ^ Number of epochs until an update proposal expires. + | KesUpdateSpeed Word32 + -- ^ Maximum number of seconds per update for KES keys known by the system + -- after start time. deriving (Eq, Show) getConfigParam :: Get ConfigParam @@ -257,13 +275,13 @@ getConfigParam = do let len = fromIntegral $ taglen .&. (63) -- 0b111111 isolate len $ case tag of - 1 -> ConfigDiscrimination <$> getNetwork + 1 -> Discrimination <$> getNetwork 2 -> Block0Date <$> getWord64be - 3 -> ConsensusVersion <$> getWord16be -- ? + 3 -> Consensus <$> getConsensusVersion 4 -> SlotsPerEpoch <$> getWord32be 5 -> SlotDuration <$> getWord8 6 -> EpochStabilityDepth <$> getWord32be - 8 -> ConsensusGenesisPraosActiveSlotsCoeff <$> getMilli + 8 -> ConsensusGenesisPraosParamF <$> getMilli 9 -> MaxNumberOfTransactionsPerBlock <$> getWord32be 10 -> BftSlotsRatio <$> getMilli 11 -> AddBftLeader <$> getLeaderId @@ -271,7 +289,8 @@ getConfigParam = do 13 -> AllowAccountCreation <$> getBool 14 -> ConfigLinearFee <$> getLinearFee 15 -> ProposalExpiration <$> getWord32be - a -> fail $ "Invalid config param with tag " ++ show a + 16 -> KesUpdateSpeed <$> getWord32be + other -> fail $ "Invalid config param with tag " ++ show other newtype Milli = Milli Word64 deriving (Eq, Show) @@ -282,11 +301,20 @@ newtype LeaderId = LeaderId ByteString data LinearFee = LinearFee Word64 Word64 Word64 deriving (Eq, Show) +data ConsensusVersion = BFT | GenesisPraos + deriving (Eq, Show) + +getConsensusVersion :: Get ConsensusVersion +getConsensusVersion = getWord16be >>= \case + 1 -> return BFT + 2 -> return GenesisPraos + other -> fail $ "Unknown consensus version: " ++ show other + getNetwork :: Get Network getNetwork = getWord8 >>= \case 1 -> return Mainnet 2 -> return Testnet - a -> fail $ "Invalid network/discrimination value: " ++ show a + other -> fail $ "Invalid network/discrimination value: " ++ show other getMilli :: Get Milli getMilli = Milli <$> getWord64be