From c8751880164239dd8e2cd5f6790c684468f06c10 Mon Sep 17 00:00:00 2001 From: Thomas Winant Date: Mon, 16 Nov 2020 15:23:49 +0100 Subject: [PATCH 1/7] Correct era names for Shelley-based eras We had an instance of `SingleEraBlock` for `ShelleyBlock` that was parametric in the era, causing all Shelley-based eras (Shelley, Allegra, Mary) to have the "Shelley" name. Fix this by adding a `shelleyBasedEraName` method to the new `ShelleyBasedEra` class, which combines the new method with the ledger-defined class of the same name. See its docstring for more details. --- .../ApplyTxErr_Allegra | 2 +- .../ApplyTxErr_Mary | 2 +- .../CardanoNodeToClientVersion1/GenTx_Allegra | 2 +- .../CardanoNodeToClientVersion1/GenTx_Mary | 2 +- .../Query_Allegra_GetCurrentPParams | 2 +- .../Query_Allegra_GetEpochNo | 2 +- .../Query_Allegra_GetGenesisConfig | 2 +- .../Query_Allegra_GetLedgerTip | 2 +- .../Query_Allegra_GetNonMyopicMemberRewards | 2 +- .../Query_Allegra_GetProposedPParamsUpdates | 2 +- .../Query_Allegra_GetStakeDistribution | 2 +- .../Query_Mary_GetCurrentPParams | 2 +- .../Query_Mary_GetEpochNo | 2 +- .../Query_Mary_GetGenesisConfig | 2 +- .../Query_Mary_GetLedgerTip | 2 +- .../Query_Mary_GetNonMyopicMemberRewards | 2 +- .../Query_Mary_GetProposedPParamsUpdates | 2 +- .../Query_Mary_GetStakeDistribution | 2 +- .../Result_Allegra_EmptyPParams | 2 +- .../Result_Allegra_EpochNo | 2 +- .../Result_Allegra_GenesisConfig | 2 +- .../Result_Allegra_LedgerTip | 2 +- .../Result_Allegra_NonMyopicMemberRewards | 2 +- .../Result_Allegra_ProposedPParamsUpdates | 2 +- .../Result_Allegra_StakeDistribution | 2 +- .../Result_Mary_EmptyPParams | 2 +- .../Result_Mary_EpochNo | 2 +- .../Result_Mary_GenesisConfig | 2 +- .../Result_Mary_LedgerTip | 2 +- .../Result_Mary_NonMyopicMemberRewards | 2 +- .../Result_Mary_ProposedPParamsUpdates | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../ApplyTxErr_Allegra | 2 +- .../ApplyTxErr_Mary | 2 +- .../CardanoNodeToClientVersion2/GenTx_Allegra | 2 +- .../CardanoNodeToClientVersion2/GenTx_Mary | 2 +- .../Query_Allegra_GetCurrentPParams | 2 +- .../Query_Allegra_GetEpochNo | 2 +- .../Query_Allegra_GetGenesisConfig | 2 +- .../Query_Allegra_GetLedgerTip | 2 +- .../Query_Allegra_GetNonMyopicMemberRewards | 2 +- .../Query_Allegra_GetProposedPParamsUpdates | 2 +- .../Query_Allegra_GetStakeDistribution | 2 +- .../Query_Mary_GetCurrentPParams | 2 +- .../Query_Mary_GetEpochNo | 2 +- .../Query_Mary_GetGenesisConfig | 2 +- .../Query_Mary_GetLedgerTip | 2 +- .../Query_Mary_GetNonMyopicMemberRewards | 2 +- .../Query_Mary_GetProposedPParamsUpdates | 2 +- .../Query_Mary_GetStakeDistribution | 2 +- .../Result_Allegra_EmptyPParams | 2 +- .../Result_Allegra_EpochNo | 2 +- .../Result_Allegra_GenesisConfig | 2 +- .../Result_Allegra_LedgerTip | 2 +- .../Result_Allegra_NonMyopicMemberRewards | 2 +- .../Result_Allegra_ProposedPParamsUpdates | 2 +- .../Result_Allegra_StakeDistribution | 2 +- .../Result_Mary_EmptyPParams | 2 +- .../Result_Mary_EpochNo | 2 +- .../Result_Mary_GenesisConfig | 2 +- .../Result_Mary_LedgerTip | 2 +- .../Result_Mary_NonMyopicMemberRewards | 2 +- .../Result_Mary_ProposedPParamsUpdates | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../ApplyTxErr_Allegra | 2 +- .../ApplyTxErr_Mary | 2 +- .../CardanoNodeToClientVersion3/GenTx_Allegra | 2 +- .../CardanoNodeToClientVersion3/GenTx_Mary | 2 +- .../Query_Allegra_GetCurrentPParams | 2 +- .../Query_Allegra_GetEpochNo | 2 +- .../Query_Allegra_GetGenesisConfig | 2 +- .../Query_Allegra_GetLedgerTip | 2 +- .../Query_Allegra_GetNonMyopicMemberRewards | 2 +- .../Query_Allegra_GetProposedPParamsUpdates | 2 +- .../Query_Allegra_GetStakeDistribution | 2 +- .../Query_Mary_GetCurrentPParams | 2 +- .../Query_Mary_GetEpochNo | 2 +- .../Query_Mary_GetGenesisConfig | 2 +- .../Query_Mary_GetLedgerTip | 2 +- .../Query_Mary_GetNonMyopicMemberRewards | 2 +- .../Query_Mary_GetProposedPParamsUpdates | 2 +- .../Query_Mary_GetStakeDistribution | 2 +- .../Result_Allegra_EmptyPParams | 2 +- .../Result_Allegra_EpochNo | 2 +- .../Result_Allegra_GenesisConfig | 2 +- .../Result_Allegra_LedgerTip | 2 +- .../Result_Allegra_NonMyopicMemberRewards | 2 +- .../Result_Allegra_ProposedPParamsUpdates | 2 +- .../Result_Allegra_StakeDistribution | 2 +- .../Result_Mary_EmptyPParams | 2 +- .../Result_Mary_EpochNo | 2 +- .../Result_Mary_GenesisConfig | 2 +- .../Result_Mary_LedgerTip | 2 +- .../Result_Mary_NonMyopicMemberRewards | 2 +- .../Result_Mary_ProposedPParamsUpdates | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../ApplyTxErr_Mary | 2 +- .../CardanoNodeToClientVersion4/GenTx_Mary | 2 +- .../Query_Mary_GetCurrentPParams | 2 +- .../Query_Mary_GetEpochNo | 2 +- .../Query_Mary_GetGenesisConfig | 2 +- .../Query_Mary_GetLedgerTip | 2 +- .../Query_Mary_GetNonMyopicMemberRewards | 2 +- .../Query_Mary_GetProposedPParamsUpdates | 2 +- .../Query_Mary_GetStakeDistribution | 2 +- .../Result_Mary_EmptyPParams | 2 +- .../Result_Mary_EpochNo | 2 +- .../Result_Mary_GenesisConfig | 2 +- .../Result_Mary_LedgerTip | 2 +- .../Result_Mary_NonMyopicMemberRewards | 2 +- .../Result_Mary_ProposedPParamsUpdates | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../CardanoNodeToNodeVersion1/GenTxId_Allegra | 2 +- .../CardanoNodeToNodeVersion1/GenTxId_Mary | 2 +- .../CardanoNodeToNodeVersion1/GenTx_Allegra | 2 +- .../CardanoNodeToNodeVersion1/GenTx_Mary | 2 +- .../CardanoNodeToNodeVersion1/Header_Allegra | 2 +- .../CardanoNodeToNodeVersion1/Header_Mary | 2 +- .../SerialisedHeader_Allegra | 2 +- .../SerialisedHeader_Mary | 2 +- .../CardanoNodeToNodeVersion2/GenTxId_Allegra | 2 +- .../CardanoNodeToNodeVersion2/GenTxId_Mary | 2 +- .../CardanoNodeToNodeVersion2/GenTx_Allegra | 2 +- .../CardanoNodeToNodeVersion2/GenTx_Mary | 2 +- .../CardanoNodeToNodeVersion2/Header_Allegra | 2 +- .../CardanoNodeToNodeVersion2/Header_Mary | 2 +- .../SerialisedHeader_Allegra | 2 +- .../SerialisedHeader_Mary | 2 +- .../CardanoNodeToNodeVersion3/GenTxId_Mary | 2 +- .../CardanoNodeToNodeVersion3/GenTx_Mary | 2 +- .../CardanoNodeToNodeVersion3/Header_Mary | 2 +- .../SerialisedHeader_Mary | 2 +- .../Consensus/Cardano/CanHardFork.hs | 2 +- .../src/Ouroboros/Consensus/Shelley/Eras.hs | 40 ++++++++++++++++++- 134 files changed, 171 insertions(+), 135 deletions(-) diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/ApplyTxErr_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/ApplyTxErr_Allegra index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/ApplyTxErr_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/ApplyTxErr_Allegra @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/ApplyTxErr_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/ApplyTxErr_Mary index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/ApplyTxErr_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/ApplyTxErr_Mary @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/GenTx_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/GenTx_Allegra index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/GenTx_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/GenTx_Allegra @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/GenTx_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/GenTx_Mary index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/GenTx_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/GenTx_Mary @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetCurrentPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetCurrentPParams index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetCurrentPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetCurrentPParams @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetEpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetEpochNo index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetEpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetEpochNo @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetGenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetGenesisConfig index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetGenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetGenesisConfig @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetLedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetLedgerTip index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetLedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetLedgerTip @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetNonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetNonMyopicMemberRewards index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetNonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetNonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetProposedPParamsUpdates index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetStakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetStakeDistribution index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetStakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Allegra_GetStakeDistribution @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetCurrentPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetCurrentPParams index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetCurrentPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetCurrentPParams @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetEpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetEpochNo index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetEpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetEpochNo @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetGenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetGenesisConfig index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetGenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetGenesisConfig @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetLedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetLedgerTip index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetLedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetLedgerTip @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetNonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetNonMyopicMemberRewards index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetNonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetNonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetProposedPParamsUpdates index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetStakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetStakeDistribution index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetStakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Query_Mary_GetStakeDistribution @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_EmptyPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_EmptyPParams index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_EmptyPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_EmptyPParams @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_EpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_EpochNo index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_EpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_EpochNo @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_GenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_GenesisConfig index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_GenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_GenesisConfig @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_LedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_LedgerTip index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_LedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_LedgerTip @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_NonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_NonMyopicMemberRewards index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_NonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_NonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_ProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_ProposedPParamsUpdates index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_ProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_ProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_StakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_StakeDistribution index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_StakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Allegra_StakeDistribution @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_EmptyPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_EmptyPParams index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_EmptyPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_EmptyPParams @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_EpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_EpochNo index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_EpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_EpochNo @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_GenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_GenesisConfig index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_GenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_GenesisConfig @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_LedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_LedgerTip index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_LedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_LedgerTip @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_NonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_NonMyopicMemberRewards index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_NonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_NonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_ProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_ProposedPParamsUpdates index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_ProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_ProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_StakeDistribution index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion1/Result_Mary_StakeDistribution @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/ApplyTxErr_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/ApplyTxErr_Allegra index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/ApplyTxErr_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/ApplyTxErr_Allegra @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/ApplyTxErr_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/ApplyTxErr_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/ApplyTxErr_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/ApplyTxErr_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/GenTx_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/GenTx_Allegra index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/GenTx_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/GenTx_Allegra @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/GenTx_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/GenTx_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/GenTx_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/GenTx_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetCurrentPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetCurrentPParams index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetCurrentPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetCurrentPParams @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetEpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetEpochNo index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetEpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetEpochNo @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetGenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetGenesisConfig index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetGenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetGenesisConfig @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetLedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetLedgerTip index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetLedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetLedgerTip @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetNonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetNonMyopicMemberRewards index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetNonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetNonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetProposedPParamsUpdates index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetStakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetStakeDistribution index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetStakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Allegra_GetStakeDistribution @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetCurrentPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetCurrentPParams index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetCurrentPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetCurrentPParams @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetEpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetEpochNo index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetEpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetEpochNo @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetGenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetGenesisConfig index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetGenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetGenesisConfig @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetLedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetLedgerTip index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetLedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetLedgerTip @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetNonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetNonMyopicMemberRewards index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetNonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetNonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetProposedPParamsUpdates index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetStakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetStakeDistribution index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetStakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Query_Mary_GetStakeDistribution @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_EmptyPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_EmptyPParams index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_EmptyPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_EmptyPParams @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_EpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_EpochNo index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_EpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_EpochNo @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_GenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_GenesisConfig index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_GenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_GenesisConfig @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_LedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_LedgerTip index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_LedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_LedgerTip @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_NonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_NonMyopicMemberRewards index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_NonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_NonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_ProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_ProposedPParamsUpdates index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_ProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_ProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_StakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_StakeDistribution index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_StakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Allegra_StakeDistribution @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_EmptyPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_EmptyPParams index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_EmptyPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_EmptyPParams @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_EpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_EpochNo index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_EpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_EpochNo @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_GenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_GenesisConfig index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_GenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_GenesisConfig @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_LedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_LedgerTip index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_LedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_LedgerTip @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_NonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_NonMyopicMemberRewards index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_NonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_NonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_ProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_ProposedPParamsUpdates index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_ProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_ProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_StakeDistribution index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion2/Result_Mary_StakeDistribution @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/ApplyTxErr_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/ApplyTxErr_Allegra index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/ApplyTxErr_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/ApplyTxErr_Allegra @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/ApplyTxErr_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/ApplyTxErr_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/ApplyTxErr_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/ApplyTxErr_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/GenTx_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/GenTx_Allegra index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/GenTx_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/GenTx_Allegra @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/GenTx_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/GenTx_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/GenTx_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/GenTx_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetCurrentPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetCurrentPParams index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetCurrentPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetCurrentPParams @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetEpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetEpochNo index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetEpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetEpochNo @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetGenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetGenesisConfig index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetGenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetGenesisConfig @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetLedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetLedgerTip index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetLedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetLedgerTip @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetNonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetNonMyopicMemberRewards index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetNonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetNonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetProposedPParamsUpdates index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetStakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetStakeDistribution index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetStakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Allegra_GetStakeDistribution @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetCurrentPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetCurrentPParams index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetCurrentPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetCurrentPParams @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetEpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetEpochNo index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetEpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetEpochNo @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetGenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetGenesisConfig index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetGenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetGenesisConfig @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetLedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetLedgerTip index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetLedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetLedgerTip @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetNonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetNonMyopicMemberRewards index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetNonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetNonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetProposedPParamsUpdates index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetStakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetStakeDistribution index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetStakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Query_Mary_GetStakeDistribution @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_EmptyPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_EmptyPParams index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_EmptyPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_EmptyPParams @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_EpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_EpochNo index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_EpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_EpochNo @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_GenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_GenesisConfig index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_GenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_GenesisConfig @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_LedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_LedgerTip index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_LedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_LedgerTip @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_NonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_NonMyopicMemberRewards index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_NonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_NonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_ProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_ProposedPParamsUpdates index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_ProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_ProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_StakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_StakeDistribution index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_StakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Allegra_StakeDistribution @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_EmptyPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_EmptyPParams index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_EmptyPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_EmptyPParams @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_EpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_EpochNo index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_EpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_EpochNo @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_GenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_GenesisConfig index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_GenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_GenesisConfig @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_LedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_LedgerTip index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_LedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_LedgerTip @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_NonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_NonMyopicMemberRewards index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_NonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_NonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_ProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_ProposedPParamsUpdates index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_ProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_ProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_StakeDistribution index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion3/Result_Mary_StakeDistribution @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/ApplyTxErr_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/ApplyTxErr_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/ApplyTxErr_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/ApplyTxErr_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/GenTx_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/GenTx_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/GenTx_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/GenTx_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetCurrentPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetCurrentPParams index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetCurrentPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetCurrentPParams @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetEpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetEpochNo index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetEpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetEpochNo @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetGenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetGenesisConfig index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetGenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetGenesisConfig @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetLedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetLedgerTip index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetLedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetLedgerTip @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetNonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetNonMyopicMemberRewards index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetNonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetNonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetProposedPParamsUpdates index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetStakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetStakeDistribution index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetStakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Query_Mary_GetStakeDistribution @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_EmptyPParams b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_EmptyPParams index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_EmptyPParams +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_EmptyPParams @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_EpochNo b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_EpochNo index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_EpochNo +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_EpochNo @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_GenesisConfig b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_GenesisConfig index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_GenesisConfig +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_GenesisConfig @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_LedgerTip b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_LedgerTip index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_LedgerTip +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_LedgerTip @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_NonMyopicMemberRewards b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_NonMyopicMemberRewards index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_NonMyopicMemberRewards +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_NonMyopicMemberRewards @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_ProposedPParamsUpdates b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_ProposedPParamsUpdates index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_ProposedPParamsUpdates +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_ProposedPParamsUpdates @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_StakeDistribution index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToClientVersion4/Result_Mary_StakeDistribution @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTxId_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTxId_Allegra index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTxId_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTxId_Allegra @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTxId_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTxId_Mary index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTxId_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTxId_Mary @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTx_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTx_Allegra index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTx_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTx_Allegra @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTx_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTx_Mary index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTx_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/GenTx_Mary @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/Header_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/Header_Allegra index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/Header_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/Header_Allegra @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/Header_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/Header_Mary index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/Header_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/Header_Mary @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/SerialisedHeader_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/SerialisedHeader_Allegra index 45f258a5174..51e0eec8f6c 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/SerialisedHeader_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/SerialisedHeader_Allegra @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/SerialisedHeader_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/SerialisedHeader_Mary index 45f258a5174..2c94c9e2c03 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/SerialisedHeader_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion1/SerialisedHeader_Mary @@ -1 +1 @@ -HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderFutureEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTxId_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTxId_Allegra index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTxId_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTxId_Allegra @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTxId_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTxId_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTxId_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTxId_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTx_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTx_Allegra index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTx_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTx_Allegra @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTx_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTx_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTx_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/GenTx_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/Header_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/Header_Allegra index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/Header_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/Header_Allegra @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/Header_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/Header_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/Header_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/Header_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/SerialisedHeader_Allegra b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/SerialisedHeader_Allegra index 2da60925395..37001f75cd4 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/SerialisedHeader_Allegra +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/SerialisedHeader_Allegra @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Allegra"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/SerialisedHeader_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/SerialisedHeader_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/SerialisedHeader_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion2/SerialisedHeader_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/GenTxId_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/GenTxId_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/GenTxId_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/GenTxId_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/GenTx_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/GenTx_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/GenTx_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/GenTx_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/Header_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/Header_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/Header_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/Header_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/SerialisedHeader_Mary b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/SerialisedHeader_Mary index 2da60925395..11181e3d694 100644 --- a/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/SerialisedHeader_Mary +++ b/ouroboros-consensus-cardano-test/test/golden/CardanoNodeToNodeVersion3/SerialisedHeader_Mary @@ -1 +1 @@ -HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Shelley"}) \ No newline at end of file +HardForkEncoderDisabledEra (SingleEraInfo {singleEraName = "Mary"}) \ No newline at end of file diff --git a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/CanHardFork.hs b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/CanHardFork.hs index bffb0f24765..ff8d2ef0e4c 100644 --- a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/CanHardFork.hs +++ b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/CanHardFork.hs @@ -308,7 +308,7 @@ instance ShelleyBasedEra era => SingleEraBlock (ShelleyBlock era) where ledgerState singleEraInfo _ = SingleEraInfo { - singleEraName = "Shelley" + singleEraName = shelleyBasedEraName (Proxy @era) } instance PraosCrypto c => HasPartialConsensusConfig (TPraos c) where diff --git a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Eras.hs b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Eras.hs index b87d80d5e80..451f8aa1009 100644 --- a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Eras.hs +++ b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Eras.hs @@ -1,3 +1,6 @@ +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE UndecidableSuperClasses #-} module Ouroboros.Consensus.Shelley.Eras ( -- * Eras based on the Shelley ledger ShelleyEra @@ -8,20 +11,22 @@ module Ouroboros.Consensus.Shelley.Eras ( , StandardAllegra , StandardMary -- * Shelley-based era - , ShelleyBasedEra + , ShelleyBasedEra (..) -- * Type synonyms for convenience , EraCrypto -- * Re-exports , StandardCrypto ) where +import Data.Text (Text) + import Cardano.Ledger.Allegra (AllegraEra) import Cardano.Ledger.Era (Crypto) import Cardano.Ledger.Mary (MaryEra) import Cardano.Ledger.Shelley (ShelleyEra) import Ouroboros.Consensus.Shelley.Protocol.Crypto (StandardCrypto) -import Shelley.Spec.Ledger.API (ShelleyBasedEra) +import qualified Shelley.Spec.Ledger.API as SL {------------------------------------------------------------------------------- Eras instantiated with standard crypto @@ -45,3 +50,34 @@ type StandardMary = MaryEra StandardCrypto -- of them qualified, define 'EraCrypto' as an alias of the former: /return the -- crypto used by this era/. type EraCrypto era = Crypto era + +{------------------------------------------------------------------------------- + Era polymorphism +-------------------------------------------------------------------------------} + +-- | The ledger already defines 'SL.ShelleyBasedEra' as /the/ top-level +-- constraint on an era, however, consensus often needs some more functionality +-- than the ledger currently provides. +-- +-- Either the functionality shouldn't or can't live in the ledger, in which case +-- it can be part and remain part of 'ShelleyBasedEra'. Or, the functionality +-- /should/ live in the ledger, but hasn't yet been added to the ledger, or it +-- hasn't yet been propagated to this repository, in which case it can be added +-- to this class until that is the case. +-- +-- By having the same name as the class defined in ledger, we can, if this class +-- becomes redundant, switch to the ledger-defined one without having to update +-- all the code using it. We can just export the right one from this module. +class SL.ShelleyBasedEra era => ShelleyBasedEra era where + -- | Return the name of the Shelley-based era, e.g., @"Shelley"@, @"Allegra"@, + -- etc. + shelleyBasedEraName :: proxy era -> Text + +instance SL.PraosCrypto c => ShelleyBasedEra (ShelleyEra c) where + shelleyBasedEraName _ = "Shelley" + +instance SL.PraosCrypto c => ShelleyBasedEra (AllegraEra c) where + shelleyBasedEraName _ = "Allegra" + +instance SL.PraosCrypto c => ShelleyBasedEra (MaryEra c) where + shelleyBasedEraName _ = "Mary" From 9aa3cb03deb367f5f237ab694d2c9e01b6cf431f Mon Sep 17 00:00:00 2001 From: Thomas Winant Date: Tue, 17 Nov 2020 15:07:03 +0100 Subject: [PATCH 2/7] ProtocolInfo: 'sequence' pInfoBlockForging Make the following change: ```diff - , pInfoBlockForging :: [m (BlockForging m b)] + , pInfoBlockForging :: m [BlockForging m b] ``` This is more general and will allow us to, e.g., do create multiple `BlockForging` records in one monadic call. --- .../src/Ouroboros/Consensus/ByronDual/Node.hs | 3 +- .../test/Test/ThreadNet/Byron.hs | 28 ++++++++++--------- .../src/Ouroboros/Consensus/Byron/Node.hs | 2 +- .../src/Ouroboros/Consensus/Cardano/Node.hs | 2 +- .../src/Ouroboros/Consensus/Mock/Node/BFT.hs | 2 +- .../src/Ouroboros/Consensus/Mock/Node/PBFT.hs | 2 +- .../Ouroboros/Consensus/Mock/Node/Praos.hs | 2 +- .../Consensus/Mock/Node/PraosRule.hs | 2 +- .../src/Ouroboros/Consensus/Shelley/Node.hs | 2 +- .../src/Test/ThreadNet/Network.hs | 8 ++++-- .../src/Test/ThreadNet/Rekeying.hs | 7 +++-- .../Test/Consensus/HardFork/Combinator.hs | 6 ++-- .../src/Ouroboros/Consensus/Node.hs | 4 +-- .../Ouroboros/Consensus/Node/ProtocolInfo.hs | 2 +- 14 files changed, 39 insertions(+), 33 deletions(-) diff --git a/ouroboros-consensus-byron-test/src/Ouroboros/Consensus/ByronDual/Node.hs b/ouroboros-consensus-byron-test/src/Ouroboros/Consensus/ByronDual/Node.hs index 937d55fdc22..3e65b619d80 100644 --- a/ouroboros-consensus-byron-test/src/Ouroboros/Consensus/ByronDual/Node.hs +++ b/ouroboros-consensus-byron-test/src/Ouroboros/Consensus/ByronDual/Node.hs @@ -119,8 +119,7 @@ protocolInfoDualByron abstractGenesis@ByronSpecGenesis{..} params credss = , headerState = genesisHeaderState S.empty } , pInfoBlockForging = - return . dualByronBlockForging . byronLeaderCredentials - <$> credss + return $ dualByronBlockForging . byronLeaderCredentials <$> credss } where initUtxo :: Impl.UTxO diff --git a/ouroboros-consensus-byron-test/test/Test/ThreadNet/Byron.hs b/ouroboros-consensus-byron-test/test/Test/ThreadNet/Byron.hs index 8a74d036612..aebd26db595 100644 --- a/ouroboros-consensus-byron-test/test/Test/ThreadNet/Byron.hs +++ b/ouroboros-consensus-byron-test/test/Test/ThreadNet/Byron.hs @@ -20,6 +20,7 @@ module Test.ThreadNet.Byron ( import Control.Monad (join) import qualified Data.ByteString as BS import Data.Coerce (coerce) +import Data.Functor ((<&>)) import qualified Data.Map.Strict as Map import Data.Maybe (listToMaybe, mapMaybe) import qualified Data.Set as Set @@ -1291,20 +1292,21 @@ mkRekeyUpd -> ProtocolInfo m ByronBlock -> EpochNo -> Crypto.SignKeyDSIGN Crypto.ByronDSIGN - -> Maybe (TestNodeInitialization m ByronBlock) + -> m (Maybe (TestNodeInitialization m ByronBlock)) mkRekeyUpd genesisConfig genesisSecrets cid pInfo eno newSK = - case listToMaybe (pInfoBlockForging pInfo) of - Nothing -> Nothing - Just _ -> - let genSK = genesisSecretFor genesisConfig genesisSecrets cid - creds' = updSignKey genSK bcfg cid (coerce eno) newSK - blockForging' = byronBlockForging creds' - pInfo' = pInfo { pInfoBlockForging = [return blockForging'] } - - in Just TestNodeInitialization - { tniCrucialTxs = [dlgTx (blcDlgCert creds')] - , tniProtocolInfo = pInfo' - } + pInfoBlockForging pInfo <&> \blockForging -> + case listToMaybe blockForging of + Nothing -> Nothing + Just _ -> + let genSK = genesisSecretFor genesisConfig genesisSecrets cid + creds' = updSignKey genSK bcfg cid (coerce eno) newSK + blockForging' = byronBlockForging creds' + pInfo' = pInfo { pInfoBlockForging = return [blockForging'] } + + in Just TestNodeInitialization + { tniCrucialTxs = [dlgTx (blcDlgCert creds')] + , tniProtocolInfo = pInfo' + } where bcfg = configBlock (pInfoConfig pInfo) diff --git a/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Node.hs b/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Node.hs index 0d34e355c68..db9a5626ea4 100644 --- a/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Node.hs +++ b/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Node.hs @@ -196,7 +196,7 @@ protocolInfoByron ProtocolParamsByron { , headerState = genesisHeaderState S.empty } , pInfoBlockForging = - return . byronBlockForging <$> maybeToList mLeaderCreds + return $ byronBlockForging <$> maybeToList mLeaderCreds } where compactedGenesisConfig = compactGenesisConfig genesisConfig diff --git a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs index 64b7db88081..8653444c36f 100644 --- a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs +++ b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs @@ -382,7 +382,7 @@ protocolInfoCardano protocolParamsByron@ProtocolParamsByron { WrapChainDepState $ headerStateChainDep initHeaderStateByron } - , pInfoBlockForging = mconcat [ + , pInfoBlockForging = sequence $ mconcat [ [ return $ hardForkBlockForging $ Z $ byronBlockForging credsByron | credsByron <- maybeToList mCredsByron ] diff --git a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/BFT.hs b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/BFT.hs index d460e6017d9..b1cd568e287 100644 --- a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/BFT.hs +++ b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/BFT.hs @@ -46,7 +46,7 @@ protocolInfoBft numCoreNodes nid securityParam eraParams = } , pInfoInitLedger = ExtLedgerState (genesisSimpleLedgerState addrDist) (genesisHeaderState ()) - , pInfoBlockForging = [return (simpleBlockForging nid forgeBftExt)] + , pInfoBlockForging = return [simpleBlockForging nid forgeBftExt] } where signKey :: CoreNodeId -> SignKeyDSIGN MockDSIGN diff --git a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PBFT.hs b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PBFT.hs index 41f59e976f8..be523dffeeb 100644 --- a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PBFT.hs +++ b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PBFT.hs @@ -45,7 +45,7 @@ protocolInfoMockPBFT params eraParams nid = } , pInfoInitLedger = ExtLedgerState (genesisSimpleLedgerState addrDist) (genesisHeaderState S.empty) - , pInfoBlockForging = [return (pbftBlockForging canBeLeader)] + , pInfoBlockForging = return [pbftBlockForging canBeLeader] } where canBeLeader :: PBftCanBeLeader PBftMockCrypto diff --git a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/Praos.hs b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/Praos.hs index 2017b0fdf1f..a7dc01aa8b4 100644 --- a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/Praos.hs +++ b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/Praos.hs @@ -56,7 +56,7 @@ protocolInfoPraos numCoreNodes nid params eraParams eta0 = ledgerState = genesisSimpleLedgerState addrDist , headerState = genesisHeaderState (PraosChainDepState []) } - , pInfoBlockForging = [praosBlockForging nid initHotKey] + , pInfoBlockForging = sequence [praosBlockForging nid initHotKey] } where signKeyVRF :: CoreNodeId -> SignKeyVRF MockVRF diff --git a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PraosRule.hs b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PraosRule.hs index 9bebf2356af..aa0ff776695 100644 --- a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PraosRule.hs +++ b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PraosRule.hs @@ -57,7 +57,7 @@ protocolInfoPraosRule numCoreNodes { ledgerState = genesisSimpleLedgerState addrDist , headerState = genesisHeaderState () } - , pInfoBlockForging = [return (simpleBlockForging () forgePraosRuleExt)] + , pInfoBlockForging = return [simpleBlockForging () forgePraosRuleExt] } where addrDist :: AddrDist diff --git a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs index 50ce410b944..1859de381d3 100644 --- a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs +++ b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs @@ -194,7 +194,7 @@ protocolInfoShelley ProtocolParamsShelley { ProtocolInfo { pInfoConfig = topLevelConfig , pInfoInitLedger = initExtLedgerState - , pInfoBlockForging = shelleyBlockForging tpraosParams <$> toList credentialss + , pInfoBlockForging = sequence $ shelleyBlockForging tpraosParams <$> toList credentialss } where maxMajorProtVer :: MaxMajorProtVer diff --git a/ouroboros-consensus-test/src/Test/ThreadNet/Network.hs b/ouroboros-consensus-test/src/Test/ThreadNet/Network.hs index 1fa72f03c24..5e72d15a8ef 100644 --- a/ouroboros-consensus-test/src/Test/ThreadNet/Network.hs +++ b/ouroboros-consensus-test/src/Test/ThreadNet/Network.hs @@ -884,9 +884,11 @@ runThreadNetwork systemTime ThreadNetworkArgs void $ ChainDB.addBlock chainDB ebb pure blk - blockForging <- forM pInfoBlockForging $ \initBlockForging -> do - bf <- initBlockForging - return bf { forgeBlock = customForgeBlock bf } + origBlockForging <- pInfoBlockForging + let blockForging = + [ bf { forgeBlock = customForgeBlock bf } + | bf <- origBlockForging + ] -- This variable holds the number of the earliest slot in which the -- crucial txs have not yet been added. In other words, it holds the diff --git a/ouroboros-consensus-test/src/Test/ThreadNet/Rekeying.hs b/ouroboros-consensus-test/src/Test/ThreadNet/Rekeying.hs index 70804c2eacc..e9b34c1260a 100644 --- a/ouroboros-consensus-test/src/Test/ThreadNet/Rekeying.hs +++ b/ouroboros-consensus-test/src/Test/ThreadNet/Rekeying.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ExistentialQuantification #-} +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} module Test.ThreadNet.Rekeying ( @@ -6,6 +7,8 @@ module Test.ThreadNet.Rekeying ( fromRekeyingToRekeyM, ) where +import Data.Functor ((<&>)) + import Ouroboros.Consensus.Block import Ouroboros.Consensus.Node.ProtocolInfo import Ouroboros.Consensus.NodeId @@ -33,7 +36,7 @@ data Rekeying m blk = forall opKey. Rekeying -> ProtocolInfo m blk -> EpochNo -> opKey - -> Maybe (TestNodeInitialization m blk) + -> m (Maybe (TestNodeInitialization m blk)) -- ^ new config and any corresponding delegation certificate transactions -- -- The given epoch contains the first nominal slot whose block will @@ -57,6 +60,6 @@ fromRekeyingToRekeyM Rekeying{rekeyFreshSKs, rekeyOracle, rekeyUpd} = do x :< xs <- readTVar rekeyVar x <$ writeTVar rekeyVar xs eno <- mkEno s' - pure $ case rekeyUpd cid pInfo eno x of + rekeyUpd cid pInfo eno x <&> \case Nothing -> plainTestNodeInitialization pInfo Just tni -> tni diff --git a/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator.hs b/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator.hs index 752c33d8966..4e819d384e5 100644 --- a/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator.hs +++ b/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator.hs @@ -235,9 +235,9 @@ prop_simple_hfc_convergence testSetup@TestSetup{..} = initHardForkState (WrapChainDepState initChainDepState) } - , pInfoBlockForging = - [ return $ hardForkBlockForging $ Z blockForgingA - , return $ hardForkBlockForging $ S $ Z blockForgingB + , pInfoBlockForging = return + [ hardForkBlockForging $ Z blockForgingA + , hardForkBlockForging $ S $ Z blockForgingB ] } diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/Node.hs b/ouroboros-consensus/src/Ouroboros/Consensus/Node.hs index 1bc76740ce1..add641e6400 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/Node.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/Node.hs @@ -474,7 +474,7 @@ mkNodeKernelArgs -> Int -> StdGen -> TopLevelConfig blk - -> [m (BlockForging m blk)] + -> m [BlockForging m blk] -> Tracers m (ConnectionId addrNTN) (ConnectionId addrNTC) blk -> BlockchainTime m -> ChainDB m blk @@ -489,7 +489,7 @@ mkNodeKernelArgs btime chainDB = do - blockForging <- sequence initBlockForging + blockForging <- initBlockForging return NodeKernelArgs { tracers , registry diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/Node/ProtocolInfo.hs b/ouroboros-consensus/src/Ouroboros/Consensus/Node/ProtocolInfo.hs index 8faae8dcc6e..7837d297f94 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/Node/ProtocolInfo.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/Node/ProtocolInfo.hs @@ -38,7 +38,7 @@ enumCoreNodes (NumCoreNodes numNodes) = data ProtocolInfo m b = ProtocolInfo { pInfoConfig :: TopLevelConfig b , pInfoInitLedger :: ExtLedgerState b -- ^ At genesis - , pInfoBlockForging :: [m (BlockForging m b)] + , pInfoBlockForging :: m [BlockForging m b] } -- | Data required by clients of a node running the specified protocol. From 2194d81d745c75dda57063ba89e56e1ec6b37753 Mon Sep 17 00:00:00 2001 From: Thomas Winant Date: Tue, 17 Nov 2020 15:59:12 +0100 Subject: [PATCH 3/7] Use a single set of credentials for all Shelley-based eras For each era, there will be a thread periodically trying to evolve the KES key and securely forget the previous one. Previously, we required a set of credentials for each Shelley-based era, e.g., Shelley, Allegra, and Mary. In practice, most users will want to use the same credentials for, e.g., Shelley and Allegra. However, when using the same in-memory KES key for multiple eras, multiple threads will try to evolve and secure forget the *same KES key*. Depending on the implementation of secure forgetting for KES keys, this could lead to segfaults. Instead of having a separate set of credentials per Shelley-based era (this remains independent of how Byron credentials are handled), we now share a single set of credentials for all of them. We use the new `shelleySharedBlockForging` function to do this in a safe way, i.e., by sharing the same thread-safe `HotKey` across the threads. We refactor the protocol parameters for Shelley/Allegra/Mary to handle the shared key: we now have a `ProtocolParamsShelleyBased` record which contains everything needed for a Shelley-based chain, i.e., the genesis config and the credentials. This record should be combined with the right era-specific ones. This also paves the way for adding a Mary-only mode. --- .../test/Test/ThreadNet/Cardano.hs | 20 +-- .../src/Ouroboros/Consensus/Cardano.hs | 16 ++- .../src/Ouroboros/Consensus/Cardano/Node.hs | 75 ++++++----- .../tools/db-analyser/Block/Cardano.hs | 22 +-- .../tools/db-analyser/Block/Shelley.hs | 18 ++- .../src/Test/ThreadNet/Infra/Shelley.hs | 15 ++- .../src/Ouroboros/Consensus/Shelley/Node.hs | 127 +++++++++++++----- 7 files changed, 184 insertions(+), 109 deletions(-) diff --git a/ouroboros-consensus-cardano-test/test/Test/ThreadNet/Cardano.hs b/ouroboros-consensus-cardano-test/test/Test/ThreadNet/Cardano.hs index f972caf19c3..87a09da052e 100644 --- a/ouroboros-consensus-cardano-test/test/Test/ThreadNet/Cardano.hs +++ b/ouroboros-consensus-cardano-test/test/Test/ThreadNet/Cardano.hs @@ -751,26 +751,26 @@ mkProtocolCardanoAndHardForkTxs , byronSoftwareVersion = softVerByron , byronLeaderCredentials = Just leaderCredentialsByron } + ProtocolParamsShelleyBased { + shelleyBasedGenesis = genesisShelley + , shelleyBasedInitialNonce = initialNonce + , shelleyBasedLeaderCredentials = Just leaderCredentialsShelley + } ProtocolParamsShelley { - shelleyGenesis = genesisShelley - , shelleyInitialNonce = initialNonce - , shelleyProtVer = SL.ProtVer shelleyMajorVersion 0 - , shelleyLeaderCredentials = Just leaderCredentialsShelley + shelleyProtVer = SL.ProtVer shelleyMajorVersion 0 } ProtocolParamsAllegra { - allegraProtVer = SL.ProtVer allegraMajorVersion 0 - , allegraLeaderCredentials = Nothing + allegraProtVer = SL.ProtVer allegraMajorVersion 0 } ProtocolParamsMary { - maryProtVer = SL.ProtVer maryMajorVersion 0 - , maryLeaderCredentials = Nothing + maryProtVer = SL.ProtVer maryMajorVersion 0 } protocolParamsByronShelley ProtocolParamsTransition { - transitionTrigger = TriggerHardForkAtVersion allegraMajorVersion + transitionTrigger = TriggerHardForkAtVersion allegraMajorVersion } ProtocolParamsTransition { - transitionTrigger = TriggerHardForkAtVersion maryMajorVersion + transitionTrigger = TriggerHardForkAtVersion maryMajorVersion } -- Byron diff --git a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano.hs b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano.hs index 1df49960f92..650d2f24877 100644 --- a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano.hs +++ b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano.hs @@ -89,15 +89,17 @@ data Protocol (m :: Type -> Type) blk p where -- | Run TPraos against the real Shelley ledger ProtocolShelley - :: ProtocolParamsShelley StandardCrypto [] + :: ProtocolParamsShelleyBased StandardShelley [] + -> ProtocolParamsShelley -> Protocol m (ShelleyBlockHFC StandardShelley) ProtocolShelley -- | Run the protocols of /the/ Cardano block ProtocolCardano :: ProtocolParamsByron - -> ProtocolParamsShelley StandardCrypto Maybe - -> ProtocolParamsAllegra StandardCrypto Maybe - -> ProtocolParamsMary StandardCrypto Maybe + -> ProtocolParamsShelleyBased StandardShelley Maybe + -> ProtocolParamsShelley + -> ProtocolParamsAllegra + -> ProtocolParamsMary -> ProtocolParamsTransition ByronBlock (ShelleyBlock StandardShelley) @@ -124,11 +126,12 @@ protocolInfo :: forall m blk p. IOLike m protocolInfo (ProtocolByron params) = inject $ protocolInfoByron params -protocolInfo (ProtocolShelley params) = - inject $ protocolInfoShelley params +protocolInfo (ProtocolShelley paramsShelleyBased paramsShelley) = + inject $ protocolInfoShelley paramsShelleyBased paramsShelley protocolInfo (ProtocolCardano paramsByron + paramsShelleyBased paramsShelley paramsAllegra paramsMary @@ -137,6 +140,7 @@ protocolInfo (ProtocolCardano paramsAllegraMary) = protocolInfoCardano paramsByron + paramsShelleyBased paramsShelley paramsAllegra paramsMary diff --git a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs index 8653444c36f..c01fa23df63 100644 --- a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs +++ b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -41,7 +42,7 @@ import Control.Exception (assert) import qualified Data.ByteString.Short as Short import qualified Data.Map.Strict as Map import Data.Maybe (maybeToList) -import Data.SOP.Strict (K (..), NP (..), NS (..)) +import Data.SOP.Strict (K (..), NP (..), NS (..), unComp) import Data.Word (Word16) import Cardano.Binary (DecoderError (..), enforceSize) @@ -329,9 +330,10 @@ data ProtocolParamsTransition eraFrom eraTo = ProtocolParamsTransition { protocolInfoCardano :: forall c m. (IOLike m, CardanoHardForkConstraints c) => ProtocolParamsByron - -> ProtocolParamsShelley c Maybe - -> ProtocolParamsAllegra c Maybe - -> ProtocolParamsMary c Maybe + -> ProtocolParamsShelleyBased (ShelleyEra c) Maybe + -> ProtocolParamsShelley + -> ProtocolParamsAllegra + -> ProtocolParamsMary -> ProtocolParamsTransition ByronBlock (ShelleyBlock (ShelleyEra c)) @@ -346,28 +348,28 @@ protocolInfoCardano protocolParamsByron@ProtocolParamsByron { byronGenesis = genesisByron , byronLeaderCredentials = mCredsByron } + ProtocolParamsShelleyBased { + shelleyBasedGenesis = genesisShelley + , shelleyBasedInitialNonce = initialNonceShelley + , shelleyBasedLeaderCredentials = mCredsShelleyBased + } ProtocolParamsShelley { - shelleyGenesis = genesisShelley - , shelleyInitialNonce = initialNonceShelley - , shelleyProtVer = protVerShelley - , shelleyLeaderCredentials = mCredsShelley + shelleyProtVer = protVerShelley } ProtocolParamsAllegra { - allegraProtVer = protVerAllegra - , allegraLeaderCredentials = mCredsAllegra + allegraProtVer = protVerAllegra } ProtocolParamsMary { - maryProtVer = protVerMary - , maryLeaderCredentials = mCredsMary + maryProtVer = protVerMary } ProtocolParamsTransition { - transitionTrigger = triggerHardForkByronShelley + transitionTrigger = triggerHardForkByronShelley } ProtocolParamsTransition { - transitionTrigger = triggerHardForkShelleyAllegra + transitionTrigger = triggerHardForkShelleyAllegra } ProtocolParamsTransition { - transitionTrigger = triggerHardForkAllegraMary + transitionTrigger = triggerHardForkAllegraMary } = assertWithMsg (validateGenesis genesisShelley) $ ProtocolInfo { @@ -382,23 +384,26 @@ protocolInfoCardano protocolParamsByron@ProtocolParamsByron { WrapChainDepState $ headerStateChainDep initHeaderStateByron } - , pInfoBlockForging = sequence $ mconcat [ - [ return $ hardForkBlockForging $ Z $ byronBlockForging credsByron - | credsByron <- maybeToList mCredsByron - ] - , [ hardForkBlockForging . S . Z - <$> shelleyBlockForging tpraosParams credsShelley - | credsShelley <- maybeToList mCredsShelley - ] - , [ hardForkBlockForging . S . S . Z - <$> shelleyBlockForging tpraosParams credsAllegra - | credsAllegra <- maybeToList mCredsAllegra - ] - , [ hardForkBlockForging . S . S . S . Z - <$> shelleyBlockForging tpraosParams credsMary - | credsMary <- maybeToList mCredsMary - ] - ] + , pInfoBlockForging = do + let blockForgingByron = + [ hardForkBlockForging $ Z $ byronBlockForging creds + | creds <- maybeToList mCredsByron + ] + blockForgingShelleyBased <- case mCredsShelleyBased of + Nothing -> return [] + Just credsShelleyBased -> do + sharedBlockForgings <- + shelleySharedBlockForging + (Proxy @'[ShelleyEra c, AllegraEra c, MaryEra c]) + tpraosParams + credsShelleyBased + case sharedBlockForgings of + bfShelley :* bfAllegra :* bfMary :* Nil -> return [ + hardForkBlockForging $ S $ Z $ unComp bfShelley + , hardForkBlockForging $ S $ S $ Z $ unComp bfAllegra + , hardForkBlockForging $ S $ S $ S $ Z $ unComp bfMary + ] + return $ blockForgingByron <> blockForgingShelleyBased } where -- The major protocol version of the last era is the maximum major protocol @@ -445,7 +450,7 @@ protocolInfoCardano protocolParamsByron@ProtocolParamsByron { Shelley.mkShelleyBlockConfig protVerShelley genesisShelley - (tpraosBlockIssuerVKey <$> maybeToList mCredsShelley) + (tpraosBlockIssuerVKey <$> maybeToList mCredsShelleyBased) partialConsensusConfigShelley :: PartialConsensusConfig (BlockProtocol (ShelleyBlock (ShelleyEra c))) @@ -471,7 +476,7 @@ protocolInfoCardano protocolParamsByron@ProtocolParamsByron { Shelley.mkShelleyBlockConfig protVerAllegra genesisAllegra - (tpraosBlockIssuerVKey <$> maybeToList mCredsAllegra) + (tpraosBlockIssuerVKey <$> maybeToList mCredsShelleyBased) partialConsensusConfigAllegra :: PartialConsensusConfig (BlockProtocol (ShelleyBlock (AllegraEra c))) @@ -494,7 +499,7 @@ protocolInfoCardano protocolParamsByron@ProtocolParamsByron { Shelley.mkShelleyBlockConfig protVerMary genesisMary - (tpraosBlockIssuerVKey <$> maybeToList mCredsMary) + (tpraosBlockIssuerVKey <$> maybeToList mCredsShelleyBased) partialConsensusConfigMary :: PartialConsensusConfig (BlockProtocol (ShelleyBlock (MaryEra c))) diff --git a/ouroboros-consensus-cardano/tools/db-analyser/Block/Cardano.hs b/ouroboros-consensus-cardano/tools/db-analyser/Block/Cardano.hs index fbd26bd2fc7..3274dce82c6 100644 --- a/ouroboros-consensus-cardano/tools/db-analyser/Block/Cardano.hs +++ b/ouroboros-consensus-cardano/tools/db-analyser/Block/Cardano.hs @@ -97,28 +97,28 @@ mkCardanoProtocolInfo genesisByron signatureThreshold genesisShelley initialNonc , byronSoftwareVersion = Byron.Update.SoftwareVersion (Byron.Update.ApplicationName "db-analyser") 2 , byronLeaderCredentials = Nothing } + ProtocolParamsShelleyBased { + shelleyBasedGenesis = genesisShelley + , shelleyBasedInitialNonce = initialNonce + , shelleyBasedLeaderCredentials = Nothing + } ProtocolParamsShelley { - shelleyGenesis = genesisShelley - , shelleyInitialNonce = initialNonce - , shelleyProtVer = ProtVer 2 0 - , shelleyLeaderCredentials = Nothing + shelleyProtVer = ProtVer 2 0 } ProtocolParamsAllegra { - allegraProtVer = ProtVer 3 0 - , allegraLeaderCredentials = Nothing + allegraProtVer = ProtVer 3 0 } ProtocolParamsMary { - maryProtVer = ProtVer 4 0 - , maryLeaderCredentials = Nothing + maryProtVer = ProtVer 4 0 } ProtocolParamsTransition { - transitionTrigger = TriggerHardForkAtVersion 2 + transitionTrigger = TriggerHardForkAtVersion 2 } ProtocolParamsTransition { - transitionTrigger = TriggerHardForkAtVersion 3 + transitionTrigger = TriggerHardForkAtVersion 3 } ProtocolParamsTransition { - transitionTrigger = TriggerHardForkAtVersion 4 + transitionTrigger = TriggerHardForkAtVersion 4 } castHeaderHash :: diff --git a/ouroboros-consensus-cardano/tools/db-analyser/Block/Shelley.hs b/ouroboros-consensus-cardano/tools/db-analyser/Block/Shelley.hs index 42bba53f093..913277171f0 100644 --- a/ouroboros-consensus-cardano/tools/db-analyser/Block/Shelley.hs +++ b/ouroboros-consensus-cardano/tools/db-analyser/Block/Shelley.hs @@ -33,7 +33,8 @@ import Ouroboros.Consensus.Shelley.Eras (ShelleyBasedEra, import Ouroboros.Consensus.Shelley.Ledger.Block (ShelleyBlock) import qualified Ouroboros.Consensus.Shelley.Ledger.Block as Shelley import Ouroboros.Consensus.Shelley.Node (Nonce (..), - ProtocolParamsShelley (..), ShelleyGenesis, + ProtocolParamsShelley (..), + ProtocolParamsShelleyBased (..), ShelleyGenesis, protocolInfoShelley) import HasAnalysis @@ -75,12 +76,15 @@ mkShelleyProtocolInfo :: -> Nonce -> ProtocolInfo IO (ShelleyBlock StandardShelley) mkShelleyProtocolInfo genesis initialNonce = - protocolInfoShelley $ ProtocolParamsShelley { - shelleyGenesis = genesis - , shelleyInitialNonce = initialNonce - , shelleyProtVer = SL.ProtVer 2 0 - , shelleyLeaderCredentials = [] - } + protocolInfoShelley + ProtocolParamsShelleyBased { + shelleyBasedGenesis = genesis + , shelleyBasedInitialNonce = initialNonce + , shelleyBasedLeaderCredentials = [] + } + ProtocolParamsShelley { + shelleyProtVer = SL.ProtVer 2 0 + } parseShelleyArgs :: Parser ShelleyBlockArgs parseShelleyArgs = ShelleyBlockArgs diff --git a/ouroboros-consensus-shelley-test/src/Test/ThreadNet/Infra/Shelley.hs b/ouroboros-consensus-shelley-test/src/Test/ThreadNet/Infra/Shelley.hs index 0bdcfd9f3df..a0d8c827860 100644 --- a/ouroboros-consensus-shelley-test/src/Test/ThreadNet/Infra/Shelley.hs +++ b/ouroboros-consensus-shelley-test/src/Test/ThreadNet/Infra/Shelley.hs @@ -401,12 +401,15 @@ mkProtocolShelley :: -> CoreNode c -> ProtocolInfo m (ShelleyBlock (ShelleyEra c)) mkProtocolShelley genesis initialNonce protVer coreNode = - protocolInfoShelley $ ProtocolParamsShelley { - shelleyGenesis = genesis - , shelleyInitialNonce = initialNonce - , shelleyProtVer = protVer - , shelleyLeaderCredentials = Just $ mkLeaderCredentials coreNode - } + protocolInfoShelley + ProtocolParamsShelleyBased { + shelleyBasedGenesis = genesis + , shelleyBasedInitialNonce = initialNonce + , shelleyBasedLeaderCredentials = Just $ mkLeaderCredentials coreNode + } + ProtocolParamsShelley { + shelleyProtVer = protVer + } {------------------------------------------------------------------------------- Necessary transactions for updating the 'DecentralizationParam' -------------------------------------------------------------------------------} diff --git a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs index 1859de381d3..1cc88698862 100644 --- a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs +++ b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs @@ -3,18 +3,23 @@ {-# LANGUAGE DisambiguateRecordFields #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE UndecidableSuperClasses #-} {-# OPTIONS_GHC -Wno-orphans #-} module Ouroboros.Consensus.Shelley.Node ( protocolInfoShelley + , ProtocolParamsShelleyBased (..) , ProtocolParamsShelley (..) , ProtocolParamsAllegra (..) , ProtocolParamsMary (..) @@ -23,6 +28,7 @@ module Ouroboros.Consensus.Shelley.Node ( , SL.ShelleyGenesisStaking (..) , TPraosLeaderCredentials (..) , shelleyBlockForging + , shelleySharedBlockForging , tpraosBlockIssuerVKey , SL.ProtVer (..) , SL.Nonce (..) @@ -35,6 +41,7 @@ import Data.Bifunctor (first) import Data.Foldable (toList) import Data.Functor.Identity (Identity) import qualified Data.Map.Strict as Map +import Data.SOP.Strict import Data.Text (Text) import qualified Data.Text as Text @@ -65,6 +72,7 @@ import Ouroboros.Consensus.Shelley.Ledger.Inspect () import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion () import Ouroboros.Consensus.Shelley.Node.Serialisation () import Ouroboros.Consensus.Shelley.Protocol +import Ouroboros.Consensus.Shelley.Protocol.HotKey (HotKey) import qualified Ouroboros.Consensus.Shelley.Protocol.HotKey as HotKey {------------------------------------------------------------------------------- @@ -99,33 +107,72 @@ type instance ForgeStateInfo (ShelleyBlock era) = HotKey.KESInfo type instance ForgeStateUpdateError (ShelleyBlock era) = HotKey.KESEvolutionError +-- | Create a 'BlockForging' record for a single era. +-- +-- In case the same credentials should be shared across multiple Shelley-based +-- eras, use 'shelleySharedBlockForging'. shelleyBlockForging :: forall m era. (ShelleyBasedEra era, IOLike m) => TPraosParams -> TPraosLeaderCredentials (EraCrypto era) -> m (BlockForging m (ShelleyBlock era)) -shelleyBlockForging TPraosParams {..} +shelleyBlockForging tpraosParams credentials = + aux <$> shelleySharedBlockForging (Proxy @'[era]) tpraosParams credentials + where + aux :: + NP (BlockForging m :.: ShelleyBlock) '[era] + -> BlockForging m (ShelleyBlock era) + aux = unComp . hd + +-- | Needed in 'shelleySharedBlockForging' because we can't partially apply +-- equality constraints. +class (ShelleyBasedEra era, EraCrypto era ~ c) => ShelleyEraWithCrypto c era +instance (ShelleyBasedEra era, EraCrypto era ~ c) => ShelleyEraWithCrypto c era + +-- | Create a 'BlockForging' record for each of the given Shelley-based eras, +-- safely sharing the same set of credentials for all of them. +-- +-- The name of the era (separated by a @_@) will be appended to each +-- 'forgeLabel'. +shelleySharedBlockForging :: + forall m c eras. + ( PraosCrypto c + , All (ShelleyEraWithCrypto c) eras + , IOLike m + ) + => Proxy eras + -> TPraosParams + -> TPraosLeaderCredentials c + -> m (NP (BlockForging m :.: ShelleyBlock) eras) +shelleySharedBlockForging + _ + TPraosParams {..} TPraosLeaderCredentials { tpraosLeaderCredentialsInitSignKey = initSignKey , tpraosLeaderCredentialsCanBeLeader = canBeLeader , tpraosLeaderCredentialsLabel = label } = do - hotKey <- HotKey.mkHotKey initSignKey startPeriod tpraosMaxKESEvo - return BlockForging { - forgeLabel = label - , canBeLeader = canBeLeader - , updateForgeState = \curSlot -> - ForgeStateUpdateInfo <$> - HotKey.evolve hotKey (slotToPeriod curSlot) - , checkCanForge = \cfg curSlot _tickedChainDepState -> - tpraosCheckCanForge - (configConsensus cfg) - forgingVRFHash - curSlot - , forgeBlock = forgeShelleyBlock hotKey canBeLeader - } + hotKey <- HotKey.mkHotKey @m @c initSignKey startPeriod tpraosMaxKESEvo + return $ hcpure (Proxy @(ShelleyEraWithCrypto c)) (Comp (aux hotKey)) where - forgingVRFHash :: SL.Hash (EraCrypto era) (SL.VerKeyVRF (EraCrypto era)) + aux :: + forall era. ShelleyEraWithCrypto c era + => HotKey c m -> BlockForging m (ShelleyBlock era) + aux hotKey = BlockForging { + forgeLabel = label <> "_" <> shelleyBasedEraName (Proxy @era) + , canBeLeader = canBeLeader + , updateForgeState = \curSlot -> + ForgeStateUpdateInfo <$> + HotKey.evolve hotKey (slotToPeriod curSlot) + , checkCanForge = \cfg curSlot _tickedChainDepState -> + tpraosCheckCanForge + (configConsensus cfg) + forgingVRFHash + curSlot + , forgeBlock = forgeShelleyBlock hotKey canBeLeader + } + + forgingVRFHash :: SL.Hash c (SL.VerKeyVRF c) forgingVRFHash = SL.hashVerKeyVRF . VRF.deriveVerKeyVRF @@ -155,40 +202,52 @@ validateGenesis = first errsToString . SL.validateGenesis Text.unpack $ Text.unlines ("Invalid genesis config:" : map SL.describeValidationErr errs) --- | Parameters needed to run Shelley -data ProtocolParamsShelley c f = ProtocolParamsShelley { - shelleyGenesis :: SL.ShelleyGenesis (ShelleyEra c) +-- | Parameters common to all Shelley-based ledgers. +-- +-- When running a chain with multiple Shelley-based eras, in addition to the +-- per-era protocol parameters, one value of 'ProtocolParamsShelleyBased' will +-- be needed, which is shared among all Shelley-based eras. +-- +-- The @era@ parameter determines from which era the genesis config will be +-- used. +data ProtocolParamsShelleyBased era f = ProtocolParamsShelleyBased { + shelleyBasedGenesis :: SL.ShelleyGenesis era -- | The initial nonce, typically derived from the hash of Genesis -- config JSON file. -- -- WARNING: chains using different values of this parameter will be -- mutually incompatible. - , shelleyInitialNonce :: SL.Nonce - , shelleyProtVer :: SL.ProtVer - , shelleyLeaderCredentials :: f (TPraosLeaderCredentials c) + , shelleyBasedInitialNonce :: SL.Nonce + , shelleyBasedLeaderCredentials :: f (TPraosLeaderCredentials (EraCrypto era)) + } + +-- | Parameters needed to run Shelley +data ProtocolParamsShelley = ProtocolParamsShelley { + shelleyProtVer :: SL.ProtVer } -- | Parameters needed to run Allegra -data ProtocolParamsAllegra c f = ProtocolParamsAllegra { - allegraProtVer :: SL.ProtVer - , allegraLeaderCredentials :: f (TPraosLeaderCredentials c) +data ProtocolParamsAllegra = ProtocolParamsAllegra { + allegraProtVer :: SL.ProtVer } -- | Parameters needed to run Mary -data ProtocolParamsMary c f = ProtocolParamsMary { - maryProtVer :: SL.ProtVer - , maryLeaderCredentials :: f (TPraosLeaderCredentials c) +data ProtocolParamsMary = ProtocolParamsMary { + maryProtVer :: SL.ProtVer } protocolInfoShelley :: forall m c f. (IOLike m, ShelleyBasedEra (ShelleyEra c), Foldable f) - => ProtocolParamsShelley c f + => ProtocolParamsShelleyBased (ShelleyEra c) f + -> ProtocolParamsShelley -> ProtocolInfo m (ShelleyBlock (ShelleyEra c)) -protocolInfoShelley ProtocolParamsShelley { - shelleyGenesis = genesis - , shelleyInitialNonce = initialNonce - , shelleyProtVer = protVer - , shelleyLeaderCredentials = credentialss +protocolInfoShelley ProtocolParamsShelleyBased { + shelleyBasedGenesis = genesis + , shelleyBasedInitialNonce = initialNonce + , shelleyBasedLeaderCredentials = credentialss + } + ProtocolParamsShelley { + shelleyProtVer = protVer } = assertWithMsg (validateGenesis genesis) $ ProtocolInfo { From ac38c8c0cfe54a0b0d23128333dabc22da61621c Mon Sep 17 00:00:00 2001 From: Thomas Winant Date: Thu, 19 Nov 2020 09:04:47 +0100 Subject: [PATCH 4/7] Swap type argument order of Index This will make it possible to use it in combination with `NP`. --- .../src/Test/Consensus/Cardano/Examples.hs | 4 ++-- .../Consensus/HardFork/Combinator/Nary.hs | 14 +++++++------- .../src/Ouroboros/Consensus/Util/SOP.hs | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ouroboros-consensus-cardano-test/src/Test/Consensus/Cardano/Examples.hs b/ouroboros-consensus-cardano-test/src/Test/Consensus/Cardano/Examples.hs index 484c2c5716b..6df7c7a50e7 100644 --- a/ouroboros-consensus-cardano-test/src/Test/Consensus/Cardano/Examples.hs +++ b/ouroboros-consensus-cardano-test/src/Test/Consensus/Cardano/Examples.hs @@ -86,7 +86,7 @@ combineEras = mconcat . hcollapse . hap eraInjections injExamples :: String - -> Index blk (CardanoEras Crypto) + -> Index (CardanoEras Crypto) blk -> Examples blk -> Examples (CardanoBlock Crypto) injExamples eraName idx = @@ -107,7 +107,7 @@ instance Inject SomeResult where SomeResult (QueryIfCurrent (injectQuery idx q)) (Right r) instance Inject Examples where - inject startBounds (idx :: Index x xs) Golden.Examples {..} = Golden.Examples { + inject startBounds (idx :: Index xs x) Golden.Examples {..} = Golden.Examples { exampleBlock = inj (Proxy @I) exampleBlock , exampleSerialisedBlock = inj (Proxy @Serialised) exampleSerialisedBlock , exampleHeader = inj (Proxy @Header) exampleHeader diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Nary.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Nary.hs index e3b4116cdd4..2ad92cd859f 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Nary.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Nary.hs @@ -41,7 +41,7 @@ class Inject f where forall x xs. CanHardFork xs => Exactly xs History.Bound -- ^ Start bound of each era - -> Index x xs + -> Index xs x -> f x -> f (HardForkBlock xs) @@ -52,7 +52,7 @@ inject' :: , Coercible a (f x) , Coercible b (f (HardForkBlock xs)) ) - => Proxy f -> Exactly xs History.Bound -> Index x xs -> a -> b + => Proxy f -> Exactly xs History.Bound -> Index xs x -> a -> b inject' _ startBounds idx = coerce . inject @f startBounds idx . coerce {------------------------------------------------------------------------------- @@ -61,7 +61,7 @@ inject' _ startBounds idx = coerce . inject @f startBounds idx . coerce injectNestedCtxt_ :: forall f x xs a. - Index x xs + Index xs x -> NestedCtxt_ x f a -> NestedCtxt_ (HardForkBlock xs) f a injectNestedCtxt_ idx nc = case idx of @@ -70,7 +70,7 @@ injectNestedCtxt_ idx nc = case idx of injectQuery :: forall x xs result. - Index x xs + Index xs x -> Query x result -> QueryIfCurrent xs result injectQuery idx q = case idx of @@ -81,7 +81,7 @@ injectHardForkState :: forall f x xs. Exactly xs History.Bound -- ^ Start bound of each era - -> Index x xs + -> Index xs x -> f x -> HardForkState f xs injectHardForkState startBounds idx x = @@ -89,7 +89,7 @@ injectHardForkState startBounds idx x = where go :: Exactly xs' History.Bound - -> Index x xs' + -> Index xs' x -> Telescope (K State.Past) (State.Current f) xs' go (ExactlyCons start _) IZ = TZ (State.Current { currentStart = start, currentState = x }) @@ -115,7 +115,7 @@ instance Inject SerialisedHeader where . serialisedHeaderToPair instance Inject WrapHeaderHash where - inject _ (idx :: Index x xs) = + inject _ (idx :: Index xs x) = case dictIndexAll (Proxy @SingleEraBlock) idx of Dict -> WrapHeaderHash diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/Util/SOP.hs b/ouroboros-consensus/src/Ouroboros/Consensus/Util/SOP.hs index 7f954c8a0d9..15a7941d945 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/Util/SOP.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/Util/SOP.hs @@ -181,25 +181,25 @@ checkIsNonEmpty _ = case sList @xs of Indexing SOP types -------------------------------------------------------------------------------} -data Index x xs where - IZ :: Index x (x ': xs) - IS :: Index x xs -> Index x (y ': xs) +data Index xs x where + IZ :: Index (x ': xs) x + IS :: Index xs x -> Index (y ': xs) x -dictIndexAll :: All c xs => Proxy c -> Index x xs -> Dict c x +dictIndexAll :: All c xs => Proxy c -> Index xs x -> Dict c x dictIndexAll p = \case IZ -> Dict IS idx' -> dictIndexAll p idx' -injectNS :: forall f x xs. Index x xs -> f x -> NS f xs +injectNS :: forall f x xs. Index xs x -> f x -> NS f xs injectNS idx x = case idx of IZ -> Z x IS idx' -> S (injectNS idx' x) injectNS' :: forall f a b x xs. (Coercible a (f x), Coercible b (NS f xs)) - => Proxy f -> Index x xs -> a -> b + => Proxy f -> Index xs x -> a -> b injectNS' _ idx = coerce . injectNS @f idx . coerce -projectNP :: Index x xs -> NP f xs -> f x +projectNP :: Index xs x -> NP f xs -> f x projectNP IZ (x :* _) = x projectNP (IS idx) (_ :* xs) = projectNP idx xs From 18e228b4852e12f46c17104a3b9e7460c59c9945 Mon Sep 17 00:00:00 2001 From: Thomas Winant Date: Thu, 19 Nov 2020 09:44:39 +0100 Subject: [PATCH 5/7] Add indexed variants of h(c)map and h(c)zipWithX --- .../Combinator/Abstract/SingleEraBlock.hs | 4 + .../src/Ouroboros/Consensus/Util/SOP.hs | 109 ++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Abstract/SingleEraBlock.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Abstract/SingleEraBlock.hs index 8973be9d251..18a6480ea42 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Abstract/SingleEraBlock.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Abstract/SingleEraBlock.hs @@ -15,6 +15,7 @@ module Ouroboros.Consensus.HardFork.Combinator.Abstract.SingleEraBlock ( , EraIndex(..) , eraIndexEmpty , eraIndexFromNS + , eraIndexFromIndex , eraIndexZero , eraIndexSucc , eraIndexToInt @@ -147,6 +148,9 @@ eraIndexEmpty (EraIndex ns) = case ns of {} eraIndexFromNS :: SListI xs => NS f xs -> EraIndex xs eraIndexFromNS = EraIndex . hmap (const (K ())) +eraIndexFromIndex :: Index xs blk -> EraIndex xs +eraIndexFromIndex index = EraIndex $ injectNS index (K ()) + eraIndexZero :: EraIndex (x ': xs) eraIndexZero = EraIndex (Z (K ())) diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/Util/SOP.hs b/ouroboros-consensus/src/Ouroboros/Consensus/Util/SOP.hs index 15a7941d945..7921c10a00e 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/Util/SOP.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/Util/SOP.hs @@ -33,10 +33,20 @@ module Ouroboros.Consensus.Util.SOP ( , checkIsNonEmpty -- * Indexing SOP types , Index(..) + , indices , dictIndexAll , injectNS , injectNS' , projectNP + -- * Zipping with indices + , himap + , hcimap + , hizipWith + , hcizipWith + , hizipWith3 + , hcizipWith3 + , hizipWith4 + , hcizipWith4 ) where import Data.Coerce @@ -185,6 +195,11 @@ data Index xs x where IZ :: Index (x ': xs) x IS :: Index xs x -> Index (y ': xs) x +indices :: forall xs. SListI xs => NP (Index xs) xs +indices = case sList @xs of + SNil -> Nil + SCons -> IZ :* hmap IS indices + dictIndexAll :: All c xs => Proxy c -> Index xs x -> Dict c x dictIndexAll p = \case IZ -> Dict @@ -203,3 +218,97 @@ injectNS' _ idx = coerce . injectNS @f idx . coerce projectNP :: Index xs x -> NP f xs -> f x projectNP IZ (x :* _) = x projectNP (IS idx) (_ :* xs) = projectNP idx xs + +{------------------------------------------------------------------------------- + Zipping with indices +-------------------------------------------------------------------------------} + +hcimap :: + (HAp h, All c xs, Prod h ~ NP) + => proxy c + -> (forall a. c a => Index xs a -> f1 a -> f2 a) + -> h f1 xs + -> h f2 xs +hcimap p f xs1 = + hcpure p (fn_2 f) + `hap` indices + `hap` xs1 + +himap :: + (HAp h, SListI xs, Prod h ~ NP) + => (forall a. Index xs a -> f1 a -> f2 a) + -> h f1 xs + -> h f2 xs +himap = hcimap (Proxy @Top) + +hcizipWith :: + (HAp h, All c xs, Prod h ~ NP) + => proxy c + -> (forall a. c a => Index xs a -> f1 a -> f2 a -> f3 a) + -> NP f1 xs + -> h f2 xs + -> h f3 xs +hcizipWith p f xs1 xs2 = + hcpure p (fn_3 f) + `hap` indices + `hap` xs1 + `hap` xs2 + +hizipWith :: + (HAp h, SListI xs, Prod h ~ NP) + => (forall a. Index xs a -> f1 a -> f2 a -> f3 a) + -> NP f1 xs + -> h f2 xs + -> h f3 xs +hizipWith = hcizipWith (Proxy @Top) + +hcizipWith3 :: + (HAp h, All c xs, Prod h ~ NP) + => proxy c + -> (forall a. c a => Index xs a -> f1 a -> f2 a -> f3 a -> f4 a) + -> NP f1 xs + -> NP f2 xs + -> h f3 xs + -> h f4 xs +hcizipWith3 p f xs1 xs2 xs3 = + hcpure p (fn_4 f) + `hap` indices + `hap` xs1 + `hap` xs2 + `hap` xs3 + +hizipWith3 :: + (HAp h, SListI xs, Prod h ~ NP) + => (forall a. Index xs a -> f1 a -> f2 a -> f3 a -> f4 a) + -> NP f1 xs + -> NP f2 xs + -> h f3 xs + -> h f4 xs +hizipWith3 = hcizipWith3 (Proxy @Top) + +hcizipWith4 :: + (HAp h, All c xs, Prod h ~ NP) + => proxy c + -> (forall a. c a => Index xs a -> f1 a -> f2 a -> f3 a -> f4 a -> f5 a) + -> NP f1 xs + -> NP f2 xs + -> NP f3 xs + -> h f4 xs + -> h f5 xs +hcizipWith4 p f xs1 xs2 xs3 xs4 = + hcpure p (fn_5 f) + `hap` indices + `hap` xs1 + `hap` xs2 + `hap` xs3 + `hap` xs4 + +hizipWith4 :: + (HAp h, SListI xs, Prod h ~ NP) + => (forall a. Index xs a -> f1 a -> f2 a -> f3 a -> f4 a -> f5 a) + -> NP f1 xs + -> NP f2 xs + -> NP f3 xs + -> h f4 xs + -> h f5 xs +hizipWith4 = hcizipWith4 (Proxy @Top) From 378f927be9c325f349c92cd429dd9c4846e5bb78 Mon Sep 17 00:00:00 2001 From: Thomas Winant Date: Wed, 18 Nov 2020 17:37:03 +0100 Subject: [PATCH 6/7] BlockForging refactor: single forging thread for all eras Instead of a different thread per era, the hard fork combinator can now combine `BlockForging` records from multiple eras into one `BlockForging` record which picks the appropriate `BlockForging` based on the current era. This means that the KES key shared by the Shelley-based eras will only be tried to be evolved once, instead of once for each Shelley-based era (in the previous approach, all threads would try to evolve it, but all but one would be an identity operation). This should also improve tracing: instead of tracing messages for each era, only messages of the current era are traced. Note that multiple credentials *per era* (i.e. to benchmark multiple stakepools on one node) will still result in multiple forging threads. --- .../src/Ouroboros/Consensus/ByronDual/Node.hs | 5 +- .../src/Ouroboros/Consensus/Byron/Node.hs | 2 +- .../src/Ouroboros/Consensus/Cardano/Block.hs | 4 + .../src/Ouroboros/Consensus/Cardano/Node.hs | 101 ++++--- .../src/Ouroboros/Consensus/Mock/Node.hs | 2 +- .../src/Ouroboros/Consensus/Mock/Node/PBFT.hs | 2 +- .../Ouroboros/Consensus/Mock/Node/Praos.hs | 2 +- .../src/Ouroboros/Consensus/Shelley/Node.hs | 2 +- .../Test/Consensus/HardFork/Combinator.hs | 7 +- .../Test/Consensus/HardFork/Combinator/A.hs | 2 +- .../Test/Consensus/HardFork/Combinator/B.hs | 2 +- ouroboros-consensus/ouroboros-consensus.cabal | 2 + .../src/Ouroboros/Consensus/Block/Forging.hs | 21 +- .../Consensus/HardFork/Combinator.hs | 2 +- .../HardFork/Combinator/AcrossEras.hs | 15 +- .../Consensus/HardFork/Combinator/Forging.hs | 274 ++++++++++++------ .../Consensus/HardFork/Combinator/Protocol.hs | 45 +-- .../Consensus/HardFork/Combinator/Unary.hs | 41 ++- .../HardFork/Combinator/Util/DerivingVia.hs | 23 ++ .../src/Ouroboros/Consensus/Util/OptNP.hs | 211 ++++++++++++++ 20 files changed, 588 insertions(+), 177 deletions(-) create mode 100644 ouroboros-consensus/src/Ouroboros/Consensus/Util/OptNP.hs diff --git a/ouroboros-consensus-byron-test/src/Ouroboros/Consensus/ByronDual/Node.hs b/ouroboros-consensus-byron-test/src/Ouroboros/Consensus/ByronDual/Node.hs index 3e65b619d80..cec6eed0b1d 100644 --- a/ouroboros-consensus-byron-test/src/Ouroboros/Consensus/ByronDual/Node.hs +++ b/ouroboros-consensus-byron-test/src/Ouroboros/Consensus/ByronDual/Node.hs @@ -46,7 +46,7 @@ import Ouroboros.Consensus.NodeId import Ouroboros.Consensus.Protocol.PBFT import qualified Ouroboros.Consensus.Protocol.PBFT.State as S import Ouroboros.Consensus.Storage.ChainDB.Init (InitChainDB (..)) -import Ouroboros.Consensus.Util ((.....:)) +import Ouroboros.Consensus.Util ((.....:), (.:)) import Ouroboros.Consensus.Byron.Ledger import Ouroboros.Consensus.Byron.Node @@ -69,7 +69,8 @@ dualByronBlockForging dualByronBlockForging creds = BlockForging { forgeLabel = forgeLabel , canBeLeader = canBeLeader - , updateForgeState = fmap castForgeStateUpdateInfo . updateForgeState + , updateForgeState = \cfg -> + fmap castForgeStateUpdateInfo .: updateForgeState (dualTopLevelConfigMain cfg) , checkCanForge = checkCanForge . dualTopLevelConfigMain , forgeBlock = return .....: forgeDualByronBlock } diff --git a/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Node.hs b/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Node.hs index db9a5626ea4..1a951ebf470 100644 --- a/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Node.hs +++ b/ouroboros-consensus-byron/src/Ouroboros/Consensus/Byron/Node.hs @@ -130,7 +130,7 @@ byronBlockForging byronBlockForging creds = BlockForging { forgeLabel = blcLabel creds , canBeLeader - , updateForgeState = \_ -> return $ ForgeStateUpdateInfo $ Unchanged () + , updateForgeState = \_ _ _ -> return $ ForgeStateUpdateInfo $ Unchanged () , checkCanForge = \cfg slot tickedPBftState _isLeader () -> pbftCheckCanForge (configConsensus cfg) diff --git a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Block.hs b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Block.hs index 324fc4f4e2c..749a1f76e57 100644 --- a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Block.hs +++ b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Block.hs @@ -8,6 +8,7 @@ module Ouroboros.Consensus.Cardano.Block ( -- * Eras module Ouroboros.Consensus.Shelley.Eras , CardanoEras + , ShelleyBasedEras -- * Block , CardanoBlock -- Note: by exporting the pattern synonyms as part of the matching data @@ -164,6 +165,9 @@ type CardanoEras c = , ShelleyBlock (MaryEra c) ] +-- | The Shelley-based eras in the Cardano chain +type ShelleyBasedEras c = '[ShelleyEra c, AllegraEra c, MaryEra c] + {------------------------------------------------------------------------------- The block type of the Cardano block chain -------------------------------------------------------------------------------} diff --git a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs index c01fa23df63..928fd2ce32b 100644 --- a/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs +++ b/ouroboros-consensus-cardano/src/Ouroboros/Consensus/Cardano/Node.hs @@ -1,18 +1,19 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE InstanceSigs #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE InstanceSigs #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -Wno-orphans #-} module Ouroboros.Consensus.Cardano.Node ( protocolInfoCardano @@ -42,7 +43,7 @@ import Control.Exception (assert) import qualified Data.ByteString.Short as Short import qualified Data.Map.Strict as Map import Data.Maybe (maybeToList) -import Data.SOP.Strict (K (..), NP (..), NS (..), unComp) +import Data.SOP.Strict ((:.:), AllZip, K (..), NP (..), unComp) import Data.Word (Word16) import Cardano.Binary (DecoderError (..), enforceSize) @@ -62,6 +63,9 @@ import Ouroboros.Consensus.TypeFamilyWrappers import Ouroboros.Consensus.Util.Assert import Ouroboros.Consensus.Util.Counting import Ouroboros.Consensus.Util.IOLike +import Ouroboros.Consensus.Util.OptNP (OptNP (..)) +import qualified Ouroboros.Consensus.Util.OptNP as OptNP +import Ouroboros.Consensus.Util.SOP (Index (..)) import Ouroboros.Consensus.HardFork.Combinator import Ouroboros.Consensus.HardFork.Combinator.Serialisation @@ -384,26 +388,7 @@ protocolInfoCardano protocolParamsByron@ProtocolParamsByron { WrapChainDepState $ headerStateChainDep initHeaderStateByron } - , pInfoBlockForging = do - let blockForgingByron = - [ hardForkBlockForging $ Z $ byronBlockForging creds - | creds <- maybeToList mCredsByron - ] - blockForgingShelleyBased <- case mCredsShelleyBased of - Nothing -> return [] - Just credsShelleyBased -> do - sharedBlockForgings <- - shelleySharedBlockForging - (Proxy @'[ShelleyEra c, AllegraEra c, MaryEra c]) - tpraosParams - credsShelleyBased - case sharedBlockForgings of - bfShelley :* bfAllegra :* bfMary :* Nil -> return [ - hardForkBlockForging $ S $ Z $ unComp bfShelley - , hardForkBlockForging $ S $ S $ Z $ unComp bfAllegra - , hardForkBlockForging $ S $ S $ S $ Z $ unComp bfMary - ] - return $ blockForgingByron <> blockForgingShelleyBased + , pInfoBlockForging = maybeToList <$> mBlockForging } where -- The major protocol version of the last era is the maximum major protocol @@ -568,6 +553,31 @@ protocolInfoCardano protocolParamsByron@ProtocolParamsByron { (Shelley.ShelleyStorageConfig tpraosSlotsPerKESPeriod k) } + mBlockForging :: m (Maybe (BlockForging m (CardanoBlock c))) + mBlockForging = do + mShelleyBased <- mBlockForgingShelleyBased + return + $ fmap (hardForkBlockForging "Cardano") + $ OptNP.combine mBlockForgingByron mShelleyBased + + mBlockForgingByron :: Maybe (OptNP 'False (BlockForging m) (CardanoEras c)) + mBlockForgingByron = do + creds <- mCredsByron + return $ byronBlockForging creds `OptNP.at` IZ + + mBlockForgingShelleyBased :: m (Maybe (OptNP 'False (BlockForging m) (CardanoEras c))) + mBlockForgingShelleyBased = do + mShelleyBased <- + traverse + (shelleySharedBlockForging (Proxy @(ShelleyBasedEras c)) tpraosParams) + mCredsShelleyBased + return $ reassoc <$> mShelleyBased + where + reassoc :: + NP (BlockForging m :.: ShelleyBlock) (ShelleyBasedEras c) + -> OptNP 'False (BlockForging m) (CardanoEras c) + reassoc = OptSkip . injectShelley unComp . OptNP.fromNonEmptyNP + protocolClientInfoCardano :: forall c. -- Byron @@ -602,3 +612,22 @@ mkPartialLedgerConfigShelley genesisShelley maxMajorProtVer shelleyTriggerHardFo maxMajorProtVer , shelleyTriggerHardFork = shelleyTriggerHardFork } + +{------------------------------------------------------------------------------- + Injection from Shelley-based eras into the Cardano eras +-------------------------------------------------------------------------------} + +-- | Witness the relation between the Cardano eras and the Shelley-based eras. +class cardanoEra ~ ShelleyBlock shelleyEra => InjectShelley shelleyEra cardanoEra +instance cardanoEra ~ ShelleyBlock shelleyEra => InjectShelley shelleyEra cardanoEra + +injectShelley :: + AllZip InjectShelley shelleyEras cardanoEras + => ( forall shelleyEra cardanoEra. + InjectShelley shelleyEra cardanoEra + => f shelleyEra -> g cardanoEra + ) + -> OptNP empty f shelleyEras -> OptNP empty g cardanoEras +injectShelley _ OptNil = OptNil +injectShelley f (OptSkip xs) = OptSkip (injectShelley f xs) +injectShelley f (OptCons x xs) = OptCons (f x) (injectShelley f xs) diff --git a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node.hs b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node.hs index 4233ff9f0cf..f4e75f25b26 100644 --- a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node.hs +++ b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node.hs @@ -78,7 +78,7 @@ simpleBlockForging :: simpleBlockForging canBeLeader forgeExt = BlockForging { forgeLabel = "simpleBlockForging" , canBeLeader = canBeLeader - , updateForgeState = \_ -> return $ ForgeStateUpdateInfo $ Unchanged () + , updateForgeState = \_ _ _ -> return $ ForgeStateUpdateInfo $ Unchanged () , checkCanForge = \_ _ _ _ _ -> return () , forgeBlock = return .....: forgeSimple forgeExt } diff --git a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PBFT.hs b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PBFT.hs index be523dffeeb..341a37241e0 100644 --- a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PBFT.hs +++ b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/PBFT.hs @@ -87,7 +87,7 @@ pbftBlockForging :: pbftBlockForging canBeLeader = BlockForging { forgeLabel = "pbftBlockForging" , canBeLeader - , updateForgeState = \_ -> return $ ForgeStateUpdateInfo $ Unchanged () + , updateForgeState = \_ _ _ -> return $ ForgeStateUpdateInfo $ Unchanged () , checkCanForge = \cfg slot tickedPBftState _isLeader -> return $ pbftCheckCanForge diff --git a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/Praos.hs b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/Praos.hs index a7dc01aa8b4..e6df219ace7 100644 --- a/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/Praos.hs +++ b/ouroboros-consensus-mock/src/Ouroboros/Consensus/Mock/Node/Praos.hs @@ -99,7 +99,7 @@ praosBlockForging cid initHotKey = do return $ BlockForging { forgeLabel = "praosBlockForging" , canBeLeader = cid - , updateForgeState = \sno -> updateMVar varHotKey $ + , updateForgeState = \_ sno _ -> updateMVar varHotKey $ second ForgeStateUpdateInfo . evolveKey sno , checkCanForge = \_ _ _ _ _ -> return () , forgeBlock = \cfg bno sno tickedLedgerSt txs isLeader -> do diff --git a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs index 1cc88698862..b0b1d2a8876 100644 --- a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs +++ b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Node.hs @@ -161,7 +161,7 @@ shelleySharedBlockForging aux hotKey = BlockForging { forgeLabel = label <> "_" <> shelleyBasedEraName (Proxy @era) , canBeLeader = canBeLeader - , updateForgeState = \curSlot -> + , updateForgeState = \_ curSlot _ -> ForgeStateUpdateInfo <$> HotKey.evolve hotKey (slotToPeriod curSlot) , checkCanForge = \cfg curSlot _tickedChainDepState -> diff --git a/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator.hs b/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator.hs index 4e819d384e5..f8effb8ef71 100644 --- a/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator.hs +++ b/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator.hs @@ -49,6 +49,7 @@ import Ouroboros.Consensus.Protocol.LeaderSchedule (LeaderSchedule (..), leaderScheduleFor) import Ouroboros.Consensus.TypeFamilyWrappers import Ouroboros.Consensus.Util.Counting +import Ouroboros.Consensus.Util.OptNP (OptNP (..)) import Ouroboros.Consensus.Util.Orphans () import Ouroboros.Consensus.HardFork.Combinator @@ -236,8 +237,10 @@ prop_simple_hfc_convergence testSetup@TestSetup{..} = (WrapChainDepState initChainDepState) } , pInfoBlockForging = return - [ hardForkBlockForging $ Z blockForgingA - , hardForkBlockForging $ S $ Z blockForgingB + [ hardForkBlockForging "Test" + $ OptCons blockForgingA + $ OptCons blockForgingB + $ OptNil ] } diff --git a/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator/A.hs b/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator/A.hs index 8b5657509d5..c59bc4a7972 100644 --- a/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator/A.hs +++ b/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator/A.hs @@ -284,7 +284,7 @@ blockForgingA :: Monad m => BlockForging m BlockA blockForgingA = BlockForging { forgeLabel = "BlockA" , canBeLeader = () - , updateForgeState = \_ -> return $ ForgeStateUpdateInfo $ Unchanged () + , updateForgeState = \_ _ _ -> return $ ForgeStateUpdateInfo $ Unchanged () , checkCanForge = \_ _ _ _ _ -> return () , forgeBlock = return .....: forgeBlockA } diff --git a/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator/B.hs b/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator/B.hs index 1ff3c5a51dc..1e617dd33b2 100644 --- a/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator/B.hs +++ b/ouroboros-consensus-test/test-consensus/Test/Consensus/HardFork/Combinator/B.hs @@ -238,7 +238,7 @@ blockForgingB :: Monad m => BlockForging m BlockB blockForgingB = BlockForging { forgeLabel = "BlockB" , canBeLeader = () - , updateForgeState = \_ -> return $ ForgeStateUpdateInfo $ Unchanged () + , updateForgeState = \_ _ _ -> return $ ForgeStateUpdateInfo $ Unchanged () , checkCanForge = \_ _ _ _ _ -> return () , forgeBlock = return .....: forgeBlockB } diff --git a/ouroboros-consensus/ouroboros-consensus.cabal b/ouroboros-consensus/ouroboros-consensus.cabal index 2735990e516..6bb4b8dcb5b 100644 --- a/ouroboros-consensus/ouroboros-consensus.cabal +++ b/ouroboros-consensus/ouroboros-consensus.cabal @@ -166,6 +166,7 @@ library Ouroboros.Consensus.Util.MonadSTM.NormalForm Ouroboros.Consensus.Util.MonadSTM.RAWLock Ouroboros.Consensus.Util.MonadSTM.StrictMVar + Ouroboros.Consensus.Util.OptNP Ouroboros.Consensus.Util.Orphans Ouroboros.Consensus.Util.RedundantConstraints Ouroboros.Consensus.Util.ResourceRegistry @@ -295,6 +296,7 @@ library , stm >=2.5 && <2.6 , streaming , text >=1.2 && <1.3 + , these >=1.1 && <1.2 , time , transformers , vector >=0.12 && <0.13 diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/Block/Forging.hs b/ouroboros-consensus/src/Ouroboros/Consensus/Block/Forging.hs index f3fbf497017..ee01db9e38f 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/Block/Forging.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/Block/Forging.hs @@ -100,7 +100,11 @@ data BlockForging m blk = BlockForging { -- -- When 'UpdateFailed' is returned, we trace the 'ForgeStateUpdateError' -- and don't call 'checkCanForge'. - , updateForgeState :: SlotNo -> m (ForgeStateUpdateInfo blk) + , updateForgeState :: + TopLevelConfig blk + -> SlotNo + -> Ticked (ChainDepState (BlockProtocol blk)) + -> m (ForgeStateUpdateInfo blk) -- | After checking that the node indeed is a leader ('checkIsLeader' -- returned 'Just') and successfully updating the forge state @@ -109,11 +113,10 @@ data BlockForging m blk = BlockForging { -- -- When 'CannotForge' is returned, we don't call 'forgeBlock'. , checkCanForge :: - forall p. BlockProtocol blk ~ p - => TopLevelConfig blk + TopLevelConfig blk -> SlotNo - -> Ticked (ChainDepState p) - -> IsLeader p + -> Ticked (ChainDepState (BlockProtocol blk)) + -> IsLeader (BlockProtocol blk) -> ForgeStateInfo blk -- Proof that 'updateForgeState' did not fail -> Either (CannotForge blk) () @@ -182,7 +185,7 @@ checkShouldForge BlockForging{..} slot tickedChainDepState = do eForgeStateInfo <- - updateForgeState slot >>= \updateInfo -> + updateForgeState cfg slot tickedChainDepState >>= \updateInfo -> case getForgeStateUpdateInfo updateInfo of Updated info -> do traceWith forgeStateInfoTracer info @@ -197,6 +200,12 @@ checkShouldForge BlockForging{..} case eForgeStateInfo of Left err -> ForgeStateUpdateError err Right forgeStateInfo -> + -- WARNING: It is critical that we do not depend on the 'BlockForging' + -- record for the implementation of 'checkIsLeader'. Doing so would + -- make composing multiple 'BlockForging' values responsible for also + -- composing the 'checkIsLeader' checks, but that should be the + -- responsibility of the 'ConsensusProtocol' instance for the + -- composition of those blocks. case checkIsLeader (configConsensus cfg) canBeLeader slot tickedChainDepState of Nothing -> NotLeader Just isLeader -> diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator.hs index 3ffdd0ff2d7..2c051b62a5c 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator.hs @@ -60,7 +60,7 @@ import Ouroboros.Consensus.HardFork.Combinator.Translation as X -- Combinator for 'BlockForging' import Ouroboros.Consensus.HardFork.Combinator.Forging as X - (HardForkForgeStateInfo, hardForkBlockForging) + (HardForkForgeStateInfo (..), hardForkBlockForging) -- Instances for 'RunNode' and 'ConfigSupportsNode' import Ouroboros.Consensus.HardFork.Combinator.Node as X () diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/AcrossEras.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/AcrossEras.hs index a8a9ffa6d66..91e3b0ff288 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/AcrossEras.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/AcrossEras.hs @@ -25,10 +25,11 @@ module Ouroboros.Consensus.HardFork.Combinator.AcrossEras ( , PerEraCodecConfig(..) , PerEraLedgerConfig(..) , PerEraStorageConfig(..) + -- * Values for /some/ eras + , SomeErasCanBeLeader(..) -- * Value for /one/ era , OneEraApplyTxErr(..) , OneEraBlock(..) - , OneEraCanBeLeader(..) , OneEraCannotForge(..) , OneEraEnvelopeErr(..) , OneEraForgeStateInfo(..) @@ -75,6 +76,7 @@ import Ouroboros.Consensus.TypeFamilyWrappers import Ouroboros.Consensus.Util (allEqual) import Ouroboros.Consensus.Util.Assert import Ouroboros.Consensus.Util.Condense (Condense (..)) +import Ouroboros.Consensus.Util.OptNP (OptNP) import Ouroboros.Consensus.HardFork.Combinator.Abstract import Ouroboros.Consensus.HardFork.Combinator.Info @@ -93,13 +95,22 @@ newtype PerEraConsensusConfig xs = PerEraConsensusConfig { getPerEraConsensusCon newtype PerEraLedgerConfig xs = PerEraLedgerConfig { getPerEraLedgerConfig :: NP WrapPartialLedgerConfig xs } newtype PerEraStorageConfig xs = PerEraStorageConfig { getPerEraStorageConfig :: NP StorageConfig xs } +{------------------------------------------------------------------------------- + Values for /some/ eras + + The reason for using @OptNP 'False f xs@ as opposed to @NP (Maybe :.: f) xs@ + is to maintain the isomorphism between @blk@ and @HardForkBlock '[blk]@ in + "Ouroboros.Consensus.HardFork.Combinator.Unary" +-------------------------------------------------------------------------------} + +newtype SomeErasCanBeLeader xs = SomeErasCanBeLeader { getSomeErasCanBeLeader :: OptNP 'False WrapCanBeLeader xs } + {------------------------------------------------------------------------------- Value for /one/ era -------------------------------------------------------------------------------} newtype OneEraApplyTxErr xs = OneEraApplyTxErr { getOneEraApplyTxErr :: NS WrapApplyTxErr xs } newtype OneEraBlock xs = OneEraBlock { getOneEraBlock :: NS I xs } -newtype OneEraCanBeLeader xs = OneEraCanBeLeader { getOneEraCanBeLeader :: NS WrapCanBeLeader xs } newtype OneEraCannotForge xs = OneEraCannotForge { getOneEraCannotForge :: NS WrapCannotForge xs } newtype OneEraEnvelopeErr xs = OneEraEnvelopeErr { getOneEraEnvelopeErr :: NS WrapEnvelopeErr xs } newtype OneEraForgeStateInfo xs = OneEraForgeStateInfo { getOneEraForgeStateInfo :: NS WrapForgeStateInfo xs } diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Forging.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Forging.hs index f6bc593fc48..4d5bebfa448 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Forging.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Forging.hs @@ -1,25 +1,31 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} module Ouroboros.Consensus.HardFork.Combinator.Forging ( HardForkCannotForge , hardForkBlockForging - , HardForkForgeStateInfo + , HardForkForgeStateInfo(..) , HardForkForgeStateUpdateError ) where import Data.Functor.Product +import Data.Maybe (fromMaybe) import Data.SOP.BasicFunctors import Data.SOP.Strict +import Data.Text (Text) import Ouroboros.Consensus.Block import Ouroboros.Consensus.Config import Ouroboros.Consensus.Ledger.Abstract import Ouroboros.Consensus.TypeFamilyWrappers +import Ouroboros.Consensus.Util.OptNP (OptNP (..), ViewOptNP (..)) +import qualified Ouroboros.Consensus.Util.OptNP as OptNP import Ouroboros.Consensus.Util.SOP import Ouroboros.Consensus.HardFork.Combinator.Abstract @@ -38,7 +44,24 @@ type instance CannotForge (HardForkBlock xs) = HardForkCannotForge xs -- | For each era in which we want to forge blocks, we have a 'BlockForging', -- and thus 'ForgeStateInfo'. -type HardForkForgeStateInfo xs = OneEraForgeStateInfo xs +-- +-- When we update the hard fork forge state, we only update the forge state of +-- the current era. However, the current era /might not/ have a forge state as +-- it lacks a 'BlockForging'. +-- +-- TODO #2766: expire past 'ForgeState' +data HardForkForgeStateInfo xs where + -- | There is no 'BlockForging' record for the current era. + CurrentEraLacksBlockForging :: + EraIndex (x ': y ': xs) + -> HardForkForgeStateInfo (x ': y ': xs) + + -- | The 'ForgeState' of the current era was updated. + CurrentEraForgeStateUpdated :: + OneEraForgeStateInfo xs + -> HardForkForgeStateInfo xs + +deriving instance CanHardFork xs => Show (HardForkForgeStateInfo xs) type instance ForgeStateInfo (HardForkBlock xs) = HardForkForgeStateInfo xs @@ -51,11 +74,14 @@ type instance ForgeStateUpdateError (HardForkBlock xs) = hardForkBlockForging :: forall m xs. (CanHardFork xs, Monad m) - => NS (BlockForging m) xs + => Text + -- ^ Used as the 'forgeLabel', the labels of the given 'BlockForging's will + -- be ignored. + -> OptNP 'False (BlockForging m) xs -> BlockForging m (HardForkBlock xs) -hardForkBlockForging blockForging = +hardForkBlockForging forgeLabel blockForging = BlockForging { - forgeLabel = hcollapse $ hmap (K . forgeLabel) blockForging + forgeLabel = forgeLabel , canBeLeader = hardForkCanBeLeader blockForging , updateForgeState = hardForkUpdateForgeState blockForging , checkCanForge = hardForkCheckCanForge blockForging @@ -64,63 +90,117 @@ hardForkBlockForging blockForging = hardForkCanBeLeader :: CanHardFork xs - => NS (BlockForging m) xs -> HardForkCanBeLeader xs + => OptNP 'False (BlockForging m) xs -> HardForkCanBeLeader xs hardForkCanBeLeader = - OneEraCanBeLeader . hmap (WrapCanBeLeader . canBeLeader) + SomeErasCanBeLeader + . hmap (WrapCanBeLeader . canBeLeader) -- | POSTCONDITION: the returned 'ForgeStateUpdateInfo' is from the same era as --- the given 'NS' of 'BlockForging's. +-- the ticked 'ChainDepState'. hardForkUpdateForgeState :: forall m xs. (CanHardFork xs, Monad m) - => NS (BlockForging m) xs + => OptNP 'False (BlockForging m) xs + -> TopLevelConfig (HardForkBlock xs) -> SlotNo + -> Ticked (HardForkChainDepState xs) -> m (ForgeStateUpdateInfo (HardForkBlock xs)) -hardForkUpdateForgeState blockForging curSlot = - undistrib <$> htraverse' (flip updateForgeState curSlot) blockForging +hardForkUpdateForgeState blockForging + cfg + curSlot + (TickedHardForkChainDepState chainDepState ei) = + case OptNP.view blockForging of + OptNP_ExactlyOne blockForging' -> + injectSingle <$> + updateForgeState + blockForging' + (hd (distribTopLevelConfig ei cfg)) + curSlot + (unwrapTickedChainDepState . unComp . State.fromTZ $ chainDepState) + OptNP_AtLeastTwo -> + fmap undistrib + $ hsequence' + $ hzipWith3 + aux + (OptNP.toNP blockForging) + (distribTopLevelConfig ei cfg) + $ State.tip chainDepState where + injectSingle :: + xs ~ '[blk] + => ForgeStateUpdateInfo blk + -> ForgeStateUpdateInfo (HardForkBlock '[blk]) + injectSingle forgeStateUpdateInfo = ForgeStateUpdateInfo $ + case getForgeStateUpdateInfo forgeStateUpdateInfo of + Updated info -> Updated $ injInfo index info + Unchanged info -> Unchanged $ injInfo index info + UpdateFailed err -> UpdateFailed $ injUpdateError index err + where + index :: Index '[blk] blk + index = IZ + + aux :: + (Maybe :.: BlockForging m) blk + -> TopLevelConfig blk + -> (Ticked :.: WrapChainDepState) blk + -> (m :.: (Maybe :.: ForgeStateUpdateInfo)) blk + aux (Comp mBlockForging) cfg' (Comp chainDepState') = + Comp $ fmap Comp $ case mBlockForging of + Nothing -> return Nothing + Just blockForging' -> Just <$> + updateForgeState + blockForging' + cfg' + curSlot + (unwrapTickedChainDepState chainDepState') + + injInfo :: + Index xs blk + -> ForgeStateInfo blk + -> ForgeStateInfo (HardForkBlock xs) + injInfo index = + CurrentEraForgeStateUpdated + . OneEraForgeStateInfo + . injectNS index + . WrapForgeStateInfo + + injUpdateError :: + Index xs blk + -> ForgeStateUpdateError blk + -> ForgeStateUpdateError (HardForkBlock xs) + injUpdateError index = + OneEraForgeStateUpdateError + . injectNS index + . WrapForgeStateUpdateError + undistrib :: - NS ForgeStateUpdateInfo xs + xs ~ (x ': y ': zs) + => NS (Maybe :.: ForgeStateUpdateInfo) xs -> ForgeStateUpdateInfo (HardForkBlock xs) - undistrib = hcollapse . hzipWith3 inj injections injections + undistrib = hcollapse . himap inj where inj :: forall blk. - Injection WrapForgeStateInfo xs blk - -> Injection WrapForgeStateUpdateError xs blk - -> ForgeStateUpdateInfo blk + Index xs blk + -> (Maybe :.: ForgeStateUpdateInfo) blk -> K (ForgeStateUpdateInfo (HardForkBlock xs)) blk - inj injInfo injUpdateError forgeStateUpdateInfo = + inj index (Comp mForgeStateUpdateInfo) = K $ ForgeStateUpdateInfo $ - case getForgeStateUpdateInfo forgeStateUpdateInfo of - Updated info -> Updated $ injInfo' info - Unchanged info -> Unchanged $ injInfo' info - UpdateFailed err -> UpdateFailed $ injUpdateError' err - where - injInfo' :: - ForgeStateInfo blk - -> OneEraForgeStateInfo xs - injInfo' = - OneEraForgeStateInfo - . unK - . apFn injInfo - . WrapForgeStateInfo - - injUpdateError' :: - ForgeStateUpdateError blk - -> OneEraForgeStateUpdateError xs - injUpdateError' = - OneEraForgeStateUpdateError - . unK - . apFn injUpdateError - . WrapForgeStateUpdateError - --- | PRECONDITION: the 'NS' of 'BlockForging's, the ticked 'ChainDepState', the --- 'HardForkIsLeader', and the 'HardForkStateInfo' are all from the same era. + case mForgeStateUpdateInfo of + Nothing -> Unchanged $ CurrentEraLacksBlockForging $ eraIndexFromIndex index + Just forgeStateUpdateInfo -> + case getForgeStateUpdateInfo forgeStateUpdateInfo of + Updated info -> Updated $ injInfo index info + Unchanged info -> Unchanged $ injInfo index info + UpdateFailed err -> UpdateFailed $ injUpdateError index err + +-- | PRECONDITION: the ticked 'ChainDepState', the 'HardForkIsLeader', and the +-- 'HardForkStateInfo' are all from the same era, and we must have a +-- 'BlockForging' for that era. -- -- This follows from the postconditions of 'check' and -- 'hardForkUpdateForgeState'. hardForkCheckCanForge :: - forall m xs. CanHardFork xs - => NS (BlockForging m) xs + forall m xs empty. CanHardFork xs + => OptNP empty (BlockForging m) xs -> TopLevelConfig (HardForkBlock xs) -> SlotNo -> Ticked (HardForkChainDepState xs) @@ -133,61 +213,75 @@ hardForkCheckCanForge blockForging (TickedHardForkChainDepState chainDepState ei) isLeader forgeStateInfo = - distrib - $ hzipWith - checkOne - (distribTopLevelConfig ei cfg) + distrib $ + hizipWith3 + checkOne + (distribTopLevelConfig ei cfg) + (OptNP.toNP blockForging) -- We know all three NSs must be from the same era, because they were -- all produced from the same 'BlockForging'. Unfortunately, we can't -- enforce it statically. - $ Match.mustMatchNS "ForgeStateInfo" (getOneEraForgeStateInfo forgeStateInfo) - $ Match.mustMatchNS "IsLeader" (getOneEraIsLeader isLeader) - $ Match.mustMatchNS "Ticked ChainDepState" (State.tip chainDepState) - $ blockForging + ( Match.mustMatchNS "ForgeStateInfo" forgeStateInfo' + $ Match.mustMatchNS "IsLeader" (getOneEraIsLeader isLeader) + $ State.tip chainDepState + ) where distrib :: NS (Maybe :.: WrapCannotForge) xs -> Either (HardForkCannotForge xs) () distrib = maybe (Right ()) (Left . OneEraCannotForge) . hsequence' + missingBlockForgingImpossible :: EraIndex xs -> String + missingBlockForgingImpossible eraIndex = + "impossible: current era lacks block forging but we have an IsLeader proof " + <> show eraIndex + + forgeStateInfo' :: NS WrapForgeStateInfo xs + forgeStateInfo' = case forgeStateInfo of + CurrentEraForgeStateUpdated info -> getOneEraForgeStateInfo info + CurrentEraLacksBlockForging eraIndex -> + error $ missingBlockForgingImpossible eraIndex + checkOne :: - TopLevelConfig blk + Index xs blk + -> TopLevelConfig blk + -> (Maybe :.: BlockForging m) blk -> Product WrapForgeStateInfo (Product WrapIsLeader - (Product - (Ticked :.: WrapChainDepState) - (BlockForging m))) + (Ticked :.: WrapChainDepState)) blk -> (Maybe :.: WrapCannotForge) blk -- ^ We use @Maybe x@ instead of @Either x ()@ because the former can -- be partially applied. - checkOne cfg' + checkOne index + cfg' + (Comp mBlockForging') (Pair - (WrapForgeStateInfo forgeStateInfo') + (WrapForgeStateInfo forgeStateInfo'') (Pair (WrapIsLeader isLeader') - (Pair - (Comp tickedChainDepState) - blockForging'))) = + (Comp tickedChainDepState))) = Comp $ either (Just . WrapCannotForge) (const Nothing) $ checkCanForge - blockForging' + (fromMaybe + (error (missingBlockForgingImpossible (eraIndexFromIndex index))) + mBlockForging') cfg' curSlot (unwrapTickedChainDepState tickedChainDepState) isLeader' - forgeStateInfo' + forgeStateInfo'' --- | PRECONDITION: the 'NS' of 'BlockForging's, the ticked 'LedgerState' and --- 'HardForkIsLeader' are from the same era. +-- | PRECONDITION: the ticked 'LedgerState' and 'HardForkIsLeader' are from the +-- same era, and we must have a 'BlockForging' for that era. -- -- This follows from the postcondition of 'check' and the fact that the ticked -- 'ChainDepState' and ticked 'LedgerState' are from the same era. hardForkForgeBlock :: - forall m xs. (CanHardFork xs, Monad m) - => NS (BlockForging m) xs + forall m xs empty. (CanHardFork xs, Monad m) + => OptNP empty (BlockForging m) xs -> TopLevelConfig (HardForkBlock xs) -> BlockNo -> SlotNo @@ -204,45 +298,49 @@ hardForkForgeBlock blockForging isLeader = fmap (HardForkBlock . OneEraBlock) $ hsequence - $ hzipWith3 + $ hizipWith4 forgeBlockOne (distribTopLevelConfig ei cfg) + (OptNP.toNP blockForging) -- Although we get a list with transactions that each could be from a -- different era, we know they have been validated against the -- 'LedgerState', which means they __must__ be from the same era. (partition_NS (map (getOneEraGenTx . getHardForkGenTx) txs)) - -- We know both NSs must be from the same era, because they were all - -- produced from the same 'BlockForging'. Unfortunately, we can't - -- enforce it statically. - $ Match.mustMatchNS "IsLeader" (getOneEraIsLeader isLeader) - $ Match.mustMatchNS "Ticked LedgerState" (State.tip ledgerState) - $ blockForging + -- We know both NSs must be from the same era, because they were all + -- produced from the same 'BlockForging'. Unfortunately, we can't + -- enforce it statically. + (Match.mustMatchNS + "IsLeader" + (getOneEraIsLeader isLeader) + (State.tip ledgerState)) where ei = State.epochInfoPrecomputedTransitionInfo (hardForkLedgerConfigShape (configLedger cfg)) transition ledgerState + missingBlockForgingImpossible :: EraIndex xs -> String + missingBlockForgingImpossible eraIndex = + "impossible: current era lacks block forging but we have an IsLeader proof " + <> show eraIndex + -- | Unwraps all the layers needed for SOP and call 'forgeBlock'. forgeBlockOne :: - TopLevelConfig blk + Index xs blk + -> TopLevelConfig blk + -> (Maybe :.: BlockForging m) blk -> ([] :.: GenTx) blk - -> Product - WrapIsLeader - (Product - (Ticked :.: LedgerState) - (BlockForging m)) - blk + -> Product WrapIsLeader (Ticked :.: LedgerState) blk -> m blk - forgeBlockOne cfg' + forgeBlockOne index + cfg' + (Comp mBlockForging') (Comp txs') - (Pair - (WrapIsLeader isLeader') - (Pair - (Comp ledgerState') - blockForging')) = + (Pair (WrapIsLeader isLeader') (Comp ledgerState')) = forgeBlock - blockForging' + (fromMaybe + (error (missingBlockForgingImpossible (eraIndexFromIndex index))) + mBlockForging') cfg' bno sno diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs index b8a1780fc82..a184917acb0 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs @@ -37,6 +37,7 @@ import Ouroboros.Consensus.Block import Ouroboros.Consensus.Protocol.Abstract import Ouroboros.Consensus.TypeFamilyWrappers import Ouroboros.Consensus.Util ((.:)) +import qualified Ouroboros.Consensus.Util.OptNP as OptNP import Ouroboros.Consensus.HardFork.Combinator.Abstract import Ouroboros.Consensus.HardFork.Combinator.AcrossEras @@ -193,7 +194,7 @@ type HardForkIsLeader xs = OneEraIsLeader xs -- | We have one or more 'BlockForging's, and thus 'CanBeLeader' proofs, for -- each era in which we can forge blocks. -type HardForkCanBeLeader xs = OneEraCanBeLeader xs +type HardForkCanBeLeader xs = SomeErasCanBeLeader xs -- | POSTCONDITION: if the result is @Just isLeader@, then 'HardForkCanBeLeader' -- and the ticked 'ChainDepState' must be in the same era. The returned @@ -205,33 +206,33 @@ check :: forall xs. (CanHardFork xs, HasCallStack) -> Ticked (ChainDepState (HardForkProtocol xs)) -> Maybe (HardForkIsLeader xs) check HardForkConsensusConfig{..} - (OneEraCanBeLeader canBeLeader) + (SomeErasCanBeLeader canBeLeader) slot (TickedHardForkChainDepState chainDepState ei) = - case State.match canBeLeader chainDepState of - -- Not a leader in this era - Left _mismatch -> Nothing - Right matched -> undistrib $ - hczipWith - proxySingle - checkOne - cfgs - (State.tip matched) + undistrib $ + hczipWith3 + proxySingle + checkOne + cfgs + (OptNP.toNP canBeLeader) + (State.tip chainDepState) where cfgs = getPerEraConsensusConfig hardForkConsensusConfigPerEra checkOne :: - SingleEraBlock blk - => WrapPartialConsensusConfig blk - -> Product WrapCanBeLeader (Ticked :.: WrapChainDepState) blk - -> (Maybe :.: WrapIsLeader) blk - checkOne cfg' (Pair canBeLeader' (Comp chainDepState')) = Comp $ - WrapIsLeader <$> - checkIsLeader - (completeConsensusConfig' ei cfg') - (unwrapCanBeLeader canBeLeader') - slot - (unwrapTickedChainDepState chainDepState') + SingleEraBlock blk + => WrapPartialConsensusConfig blk + -> (Maybe :.: WrapCanBeLeader) blk + -> (Ticked :.: WrapChainDepState) blk + -> (Maybe :.: WrapIsLeader) blk + checkOne cfg' (Comp mCanBeLeader) (Comp chainDepState') = Comp $ do + canBeLeader' <- mCanBeLeader + WrapIsLeader <$> + checkIsLeader + (completeConsensusConfig' ei cfg') + (unwrapCanBeLeader canBeLeader') + slot + (unwrapTickedChainDepState chainDepState') undistrib :: NS (Maybe :.: WrapIsLeader) xs -> Maybe (HardForkIsLeader xs) undistrib = hcollapse . hzipWith inj injections diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Unary.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Unary.hs index 6a266edc564..983c6e82130 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Unary.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Unary.hs @@ -57,6 +57,7 @@ import Ouroboros.Consensus.Node.ProtocolInfo import Ouroboros.Consensus.Protocol.Abstract import Ouroboros.Consensus.Storage.Serialisation import Ouroboros.Consensus.TypeFamilyWrappers +import qualified Ouroboros.Consensus.Util.OptNP as OptNP import Ouroboros.Consensus.Storage.ChainDB.Init (InitChainDB) @@ -64,7 +65,7 @@ import Ouroboros.Consensus.HardFork.Combinator.Abstract import Ouroboros.Consensus.HardFork.Combinator.AcrossEras import Ouroboros.Consensus.HardFork.Combinator.Basics import Ouroboros.Consensus.HardFork.Combinator.Block -import Ouroboros.Consensus.HardFork.Combinator.Forging () +import Ouroboros.Consensus.HardFork.Combinator.Forging import Ouroboros.Consensus.HardFork.Combinator.Ledger import Ouroboros.Consensus.HardFork.Combinator.Ledger.Query import Ouroboros.Consensus.HardFork.Combinator.Mempool @@ -200,10 +201,6 @@ instance Isomorphic LedgerState where project = defaultProjectSt inject = defaultInjectSt -instance Isomorphic WrapCanBeLeader where - project = defaultProjectNS - inject = defaultInjectNS - instance Isomorphic WrapCannotForge where project = defaultProjectNS inject = defaultInjectNS @@ -212,10 +209,6 @@ instance Isomorphic WrapChainDepState where project = defaultProjectSt inject = defaultInjectSt -instance Isomorphic WrapForgeStateInfo where - project = defaultProjectNS - inject = defaultInjectNS - instance Isomorphic WrapForgeStateUpdateError where project = defaultProjectNS inject = defaultInjectNS @@ -428,7 +421,14 @@ instance Functor m => Isomorphic (BlockForging m) where project BlockForging {..} = BlockForging { forgeLabel = forgeLabel , canBeLeader = project' (Proxy @(WrapCanBeLeader blk)) canBeLeader - , updateForgeState = \sno -> project <$> updateForgeState sno + , updateForgeState = \cfg sno tickedChainDepSt -> + project <$> + updateForgeState + (inject cfg) + sno + (injTickedChainDepSt + (noHardForksEpochInfo cfg) + tickedChainDepSt) , checkCanForge = \cfg sno tickedChainDepSt isLeader forgeStateInfo -> first (project' (Proxy @(WrapCannotForge blk))) $ checkCanForge @@ -468,7 +468,12 @@ instance Functor m => Isomorphic (BlockForging m) where inject BlockForging {..} = BlockForging { forgeLabel = forgeLabel , canBeLeader = inject' (Proxy @(WrapCanBeLeader blk)) canBeLeader - , updateForgeState = \sno -> inject <$> updateForgeState sno + , updateForgeState = \cfg sno tickedChainDepSt -> + inject <$> + updateForgeState + (project cfg) + sno + (projTickedChainDepSt tickedChainDepSt) , checkCanForge = \cfg sno tickedChainDepSt isLeader forgeStateInfo -> first (inject' (Proxy @(WrapCannotForge blk))) $ checkCanForge @@ -545,6 +550,20 @@ instance Isomorphic WrapEnvelopeErr where -> OtherHeaderEnvelopeError (HardForkBlock '[b]) aux = HardForkEnvelopeErrFromEra . OneEraEnvelopeErr . Z +instance Isomorphic WrapCanBeLeader where + project = OptNP.fromSingleton . getSomeErasCanBeLeader . unwrapCanBeLeader + inject = WrapCanBeLeader . SomeErasCanBeLeader . OptNP.singleton + +instance Isomorphic WrapForgeStateInfo where + project (WrapForgeStateInfo forgeStateInfo) = + case forgeStateInfo of + CurrentEraForgeStateUpdated info -> unZ $ getOneEraForgeStateInfo info + inject = + WrapForgeStateInfo + . CurrentEraForgeStateUpdated + . OneEraForgeStateInfo + . Z + instance Isomorphic WrapLedgerView where project = State.fromTZ . hardForkLedgerViewPerEra . unwrapLedgerView inject = WrapLedgerView diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/DerivingVia.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/DerivingVia.hs index 74455e341e1..8b36b3091b1 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/DerivingVia.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Util/DerivingVia.hs @@ -10,6 +10,7 @@ module Ouroboros.Consensus.HardFork.Combinator.Util.DerivingVia ( LiftNS(..) , LiftNP(..) + , LiftOptNP(..) , LiftTelescope(..) , LiftMismatch(..) , LiftNamedNS(..) @@ -26,6 +27,8 @@ import Data.Typeable import GHC.TypeLits import NoThunks.Class (NoThunks (..)) +import Ouroboros.Consensus.Util.OptNP (OptNP (..)) + import Ouroboros.Consensus.HardFork.Combinator.Abstract import Ouroboros.Consensus.HardFork.Combinator.Util.Match (Mismatch) import Ouroboros.Consensus.HardFork.Combinator.Util.Telescope @@ -104,6 +107,26 @@ instance (All SingleEraBlock xs, forall x. SingleEraBlock x => Show (f x)) show x } +{------------------------------------------------------------------------------- + LiftOptNP +-------------------------------------------------------------------------------} + +newtype LiftOptNP empty f xs = LiftOptNP (OptNP empty f xs) + +instance (All SingleEraBlock xs, forall x. SingleEraBlock x => Eq (f x)) + => Eq (LiftOptNP empty f xs) where + LiftOptNP x == LiftOptNP y = + case liftEras (Proxy @xs) (Proxy @Eq) (Proxy @f) of { Dict -> + x == y + } + +instance (All SingleEraBlock xs, forall x. SingleEraBlock x => Show (f x)) + => Show (LiftOptNP empty f xs) where + show (LiftOptNP x) = + case liftEras (Proxy @xs) (Proxy @Show) (Proxy @f) of { Dict -> + show x + } + {------------------------------------------------------------------------------- LiftTelescope -------------------------------------------------------------------------------} diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/Util/OptNP.hs b/ouroboros-consensus/src/Ouroboros/Consensus/Util/OptNP.hs new file mode 100644 index 00000000000..11e624d5559 --- /dev/null +++ b/ouroboros-consensus/src/Ouroboros/Consensus/Util/OptNP.hs @@ -0,0 +1,211 @@ +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE EmptyCase #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE UndecidableInstances #-} +-- | NP with optional values +-- +-- +-- Intended for qualified import +-- +-- > import Ouroboros.Consensus.Util.OptNP (OptNP (..), ViewOptNP (..)) +-- > import qualified Ouroboros.Consensus.Util.OptNP as OptNP +module Ouroboros.Consensus.Util.OptNP ( + OptNP(..) + , empty + , fromNonEmptyNP + , fromNP + , toNP + , at + , singleton + , fromSingleton + -- * View + , ViewOptNP(..) + , view + -- * Combining + , zipWith + , combine + , combineWith + ) where + +import Prelude hiding (zipWith) + +import Control.Monad (guard) +import Data.Functor.These (These1 (..)) +import Data.Kind (Type) +import Data.Maybe (isJust) +import Data.SOP.Strict hiding (And) +import Data.Type.Equality +import GHC.Stack (HasCallStack) + +import Ouroboros.Consensus.Util.SOP + +-- | Like an 'NP', but with optional values +data OptNP (empty :: Bool) (f :: k -> Type) (xs :: [k]) where + OptNil :: OptNP 'True f '[] + OptCons :: !(f x) -> !(OptNP empty f xs) -> OptNP 'False f (x ': xs) + OptSkip :: !(OptNP empty f xs) -> OptNP empty f (x ': xs) + +type instance AllN (OptNP empty) c = All c +type instance SListIN (OptNP empty) = SListI +type instance Prod (OptNP empty) = NP + +deriving instance All (Show `Compose` f) xs => Show (OptNP empty f xs) + +eq :: + All (Eq `Compose` f) xs + => OptNP empty f xs + -> OptNP empty' f xs -> Maybe (empty :~: empty') +eq OptNil OptNil = Just Refl +eq (OptSkip xs) (OptSkip ys) = eq xs ys +eq (OptCons x xs) (OptCons y ys) = do guard (x == y) + Refl <- eq xs ys + return Refl +eq _ _ = Nothing + +instance All (Eq `Compose` f) xs => Eq (OptNP empty f xs) where + xs == ys = isJust (eq xs ys) + +empty :: forall f xs. SListI xs => OptNP 'True f xs +empty = case sList @xs of + SNil -> OptNil + SCons -> OptSkip empty + +fromNonEmptyNP :: forall f xs. IsNonEmpty xs => NP f xs -> OptNP 'False f xs +fromNonEmptyNP xs = case isNonEmpty (Proxy @xs) of + ProofNonEmpty {} -> + case xs of + x :* xs' -> fromNP (OptCons x) xs' + +fromNP :: (forall empty. OptNP empty f xs -> r) -> NP f xs -> r +fromNP k Nil = k OptNil +fromNP k (x :* xs) = fromNP (k . OptCons x) xs + +toNP :: OptNP empty f xs -> NP (Maybe :.: f) xs +toNP = go + where + go :: OptNP empty f xs -> NP (Maybe :.: f) xs + go OptNil = Nil + go (OptCons x xs) = Comp (Just x) :* go xs + go (OptSkip xs) = Comp Nothing :* go xs + +at :: SListI xs => f x -> Index xs x -> OptNP 'False f xs +at x IZ = OptCons x empty +at x (IS index) = OptSkip (at x index) + +singleton :: f x -> OptNP 'False f '[x] +singleton x = OptCons x OptNil + +-- | If 'OptNP' is not empty, it must contain at least one value +fromSingleton :: OptNP 'False f '[x] -> f x +fromSingleton (OptCons x _) = x + +ap :: + NP (f -.-> g) xs + -> OptNP empty f xs + -> OptNP empty g xs +ap = go + where + go :: NP (f -.-> g) xs -> OptNP empty f xs -> OptNP empty g xs + go (f :* fs) (OptCons x xs) = OptCons (apFn f x) (go fs xs) + go (_ :* fs) (OptSkip xs) = OptSkip (go fs xs) + go Nil OptNil = OptNil + +ctraverse' :: + forall c proxy empty xs f f' g. (All c xs, Applicative g) + => proxy c + -> (forall a. c a => f a -> g (f' a)) + -> OptNP empty f xs -> g (OptNP empty f' xs) +ctraverse' _ f = go + where + go :: All c ys => OptNP empty' f ys -> g (OptNP empty' f' ys) + go (OptCons x xs) = OptCons <$> f x <*> go xs + go (OptSkip xs) = OptSkip <$> go xs + go OptNil = pure OptNil + +instance HAp (OptNP empty) where + hap = ap + +instance HSequence (OptNP empty) where + hctraverse' = ctraverse' + htraverse' = hctraverse' (Proxy @Top) + hsequence' = htraverse' unComp + +{------------------------------------------------------------------------------- + View +-------------------------------------------------------------------------------} + +data ViewOptNP f xs where + OptNP_ExactlyOne :: f x -> ViewOptNP f '[x] + OptNP_AtLeastTwo :: ViewOptNP f (x ': y ': zs) + +view :: forall f xs. OptNP 'False f xs -> ViewOptNP f xs +view = \case + OptCons x OptNil -> OptNP_ExactlyOne x + OptCons _ (OptCons _ _) -> OptNP_AtLeastTwo + OptCons _ (OptSkip _) -> OptNP_AtLeastTwo + OptSkip (OptCons _ _) -> OptNP_AtLeastTwo + OptSkip (OptSkip _) -> OptNP_AtLeastTwo + +{------------------------------------------------------------------------------- + Combining +-------------------------------------------------------------------------------} + +type family And (x :: Bool) (y :: Bool) :: Bool where + And 'True y = y + And 'False _ = 'False + And _ 'False = 'False + +zipWith :: + forall f g h empty1 empty2 xs. + (forall a. These1 f g a -> h a) + -> OptNP empty1 f xs + -> OptNP empty2 g xs + -> OptNP (And empty1 empty2) h xs +zipWith f = go + where + go :: OptNP empty1' f xs' + -> OptNP empty2' g xs' + -> OptNP (And empty1' empty2') h xs' + go OptNil OptNil = OptNil + go (OptCons x xs) (OptSkip ys) = OptCons (f (This1 x )) (go xs ys) + go (OptSkip xs) (OptCons y ys) = OptCons (f (That1 y)) (go xs ys) + go (OptCons x xs) (OptCons y ys) = OptCons (f (These1 x y)) (go xs ys) + go (OptSkip xs) (OptSkip ys) = OptSkip (go xs ys) + +combineWith :: + SListI xs + => (forall a. These1 f g a -> h a) + -> Maybe (OptNP 'False f xs) + -> Maybe (OptNP 'False g xs) + -> Maybe (OptNP 'False h xs) +combineWith _ Nothing Nothing = Nothing +combineWith f (Just xs) Nothing = Just $ zipWith f xs empty +combineWith f Nothing (Just ys) = Just $ zipWith f empty ys +combineWith f (Just xs) (Just ys) = Just $ zipWith f xs ys + +-- | Precondition: there is no overlap between the two given lists: if there is +-- a 'Just' at a given position in one, it must be 'Nothing' at the same +-- position in the other. +combine :: + forall (f :: Type -> Type) xs. + -- 'These1' is not kind-polymorphic + (SListI xs, HasCallStack) + => Maybe (OptNP 'False f xs) + -> Maybe (OptNP 'False f xs) + -> Maybe (OptNP 'False f xs) +combine = combineWith $ \case + This1 x -> x + That1 y -> y + These1 {} -> error "combine: precondition violated" From d362ec655516323f794e8eda381a6805ee235fc7 Mon Sep 17 00:00:00 2001 From: Thomas Winant Date: Thu, 19 Nov 2020 16:40:55 +0100 Subject: [PATCH 7/7] Use h(c)imap and h(c)izipWithX instead of injections --- .../Consensus/HardFork/Combinator/Block.hs | 8 ++--- .../Consensus/HardFork/Combinator/Ledger.hs | 36 ++++++++----------- .../Consensus/HardFork/Combinator/Mempool.hs | 34 +++++++++--------- .../Consensus/HardFork/Combinator/Protocol.hs | 27 +++++++------- .../Combinator/Serialisation/Common.hs | 13 ++++--- 5 files changed, 52 insertions(+), 66 deletions(-) diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Block.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Block.hs index 3381aa4e347..347cbb49634 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Block.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Block.hs @@ -210,15 +210,15 @@ distribAnnTip AnnTip{..} = AnnTip annTipSlotNo annTipBlockNo info undistribAnnTip :: SListI xs => NS AnnTip xs -> AnnTip (HardForkBlock xs) -undistribAnnTip = hcollapse . hzipWith undistrib injections +undistribAnnTip = hcollapse . himap undistrib where - undistrib :: (WrapTipInfo -.-> K (NS WrapTipInfo xs)) blk + undistrib :: Index xs blk -> AnnTip blk -> K (AnnTip (HardForkBlock xs)) blk - undistrib inj AnnTip{..} = K $ + undistrib index AnnTip{..} = K $ AnnTip annTipSlotNo annTipBlockNo - (OneEraTipInfo $ unK . apFn inj . WrapTipInfo $ annTipInfo) + (OneEraTipInfo . injectNS index . WrapTipInfo $ annTipInfo) {------------------------------------------------------------------------------- BasicEnvelopeValidation diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Ledger.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Ledger.hs index 4e597365323..f3b78db9f01 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Ledger.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Ledger.hs @@ -50,6 +50,7 @@ import Ouroboros.Consensus.Ledger.SupportsProtocol import Ouroboros.Consensus.TypeFamilyWrappers import Ouroboros.Consensus.Util.Condense import Ouroboros.Consensus.Util.Counting (getExactly) +import Ouroboros.Consensus.Util.SOP import Ouroboros.Consensus.HardFork.Combinator.Abstract import Ouroboros.Consensus.HardFork.Combinator.AcrossEras @@ -176,7 +177,7 @@ instance CanHardFork xs Match.bihcmap proxySingle singleEraInfo ledgerInfo mismatch Right matched -> fmap HardForkLedgerState $ hsequence' $ - hczipWith3 proxySingle apply cfgs errInjections matched + hcizipWith proxySingle apply cfgs matched where cfgs = distribLedgerConfig ei cfg ei = State.epochInfoPrecomputedTransitionInfo @@ -184,9 +185,6 @@ instance CanHardFork xs transition st - errInjections :: NP (Injection WrapLedgerErr xs) xs - errInjections = injections - reapplyLedgerBlock cfg (HardForkBlock (OneEraBlock block)) (TickedHardForkLedgerState transition st) = @@ -206,12 +204,12 @@ instance CanHardFork xs st apply :: SingleEraBlock blk - => WrapLedgerConfig blk - -> Injection WrapLedgerErr xs blk + => Index xs blk + -> WrapLedgerConfig blk -> Product I (Ticked :.: LedgerState) blk -> (Except (HardForkLedgerError xs) :.: LedgerState) blk -apply (WrapLedgerConfig cfg) injectErr (Pair (I block) (Comp st)) = Comp $ - withExcept (injectLedgerError injectErr) $ +apply index (WrapLedgerConfig cfg) (Pair (I block) (Comp st)) = Comp $ + withExcept (injectLedgerError index) $ applyLedgerBlock cfg block st reapply :: SingleEraBlock blk @@ -261,7 +259,7 @@ instance CanHardFork xs => ValidateEnvelope (HardForkBlock xs) where HardForkEnvelopeErrWrongEra . MismatchEraInfo $ Match.bihcmap proxySingle singleEraInfo ledgerViewInfo mismatch Right matched -> - hcollapse $ hczipWith3 proxySingle aux cfgs errInjections matched + hcollapse $ hcizipWith proxySingle aux cfgs matched where ei :: EpochInfo Identity ei = State.epochInfoPrecomputedTransitionInfo @@ -272,15 +270,12 @@ instance CanHardFork xs => ValidateEnvelope (HardForkBlock xs) where cfgs :: NP TopLevelConfig xs cfgs = distribTopLevelConfig ei tlc - errInjections :: NP (Injection WrapEnvelopeErr xs) xs - errInjections = injections - aux :: forall blk. SingleEraBlock blk - => TopLevelConfig blk - -> Injection WrapEnvelopeErr xs blk + => Index xs blk + -> TopLevelConfig blk -> Product Header (Ticked :.: WrapLedgerView) blk -> K (Except (HardForkEnvelopeErr xs) ()) blk - aux cfg injErr (Pair hdr (Comp view)) = K $ + aux index cfg (Pair hdr (Comp view)) = K $ withExcept injErr' $ additionalEnvelopeChecks cfg @@ -290,7 +285,7 @@ instance CanHardFork xs => ValidateEnvelope (HardForkBlock xs) where injErr' :: OtherHeaderEnvelopeError blk -> HardForkEnvelopeErr xs injErr' = HardForkEnvelopeErrFromEra . OneEraEnvelopeErr - . unK . apFn injErr + . injectNS index . WrapEnvelopeErr {------------------------------------------------------------------------------- @@ -743,12 +738,9 @@ ledgerViewInfo :: forall blk f. SingleEraBlock blk => (Ticked :.: f) blk -> LedgerEraInfo blk ledgerViewInfo _ = LedgerEraInfo $ singleEraInfo (Proxy @blk) -injectLedgerError :: Injection WrapLedgerErr xs blk - -> LedgerError blk - -> HardForkLedgerError xs -injectLedgerError inj = +injectLedgerError :: Index xs blk -> LedgerError blk -> HardForkLedgerError xs +injectLedgerError index = HardForkLedgerErrorFromEra . OneEraLedgerError - . unK - . apFn inj + . injectNS index . WrapLedgerErr diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Mempool.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Mempool.hs index 4d7328c33a6..0191bc5d7f2 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Mempool.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Mempool.hs @@ -36,6 +36,7 @@ import Ouroboros.Consensus.Ledger.Abstract import Ouroboros.Consensus.Ledger.SupportsMempool import Ouroboros.Consensus.TypeFamilyWrappers import Ouroboros.Consensus.Util (ShowProxy) +import Ouroboros.Consensus.Util.SOP import Ouroboros.Consensus.HardFork.Combinator.Abstract import Ouroboros.Consensus.HardFork.Combinator.AcrossEras @@ -138,7 +139,7 @@ applyHelper apply -- which we will remain to be) or we are forecasting, which is not -- applicable here. fmap (TickedHardForkLedgerState transition) $ hsequence' $ - hczipWith3 proxySingle applyCurrent cfgs errInjections matched + hcizipWith proxySingle applyCurrent cfgs matched where pcfgs = getPerEraLedgerConfig hardForkLedgerConfigPerEra cfgs = hcmap proxySingle (completeLedgerConfig'' ei) pcfgs @@ -150,17 +151,14 @@ applyHelper apply injectTxs :: InPairs InjectTx xs injectTxs = InPairs.requiringBoth cfgs hardForkInjectTxs - errInjections :: NP (Injection WrapApplyTxErr xs) xs - errInjections = injections - applyCurrent :: forall blk. SingleEraBlock blk - => WrapLedgerConfig blk - -> Injection WrapApplyTxErr xs blk + => Index xs blk + -> WrapLedgerConfig blk -> Product GenTx (Ticked :.: LedgerState) blk -> (Except (HardForkApplyTxErr xs) :.: (Ticked :.: LedgerState)) blk - applyCurrent cfg injectErr (Pair tx (Comp st)) = Comp $ fmap Comp $ - withExcept (injectApplyTxErr injectErr) $ + applyCurrent index cfg (Pair tx (Comp st)) = Comp $ fmap Comp $ + withExcept (injectApplyTxErr index) $ apply (unwrapLedgerConfig cfg) slot tx st newtype instance TxId (GenTx (HardForkBlock xs)) = HardForkGenTxId { @@ -184,13 +182,16 @@ instance CanHardFork xs => HasTxId (GenTx (HardForkBlock xs)) where instance All HasTxs xs => HasTxs (HardForkBlock xs) where extractTxs = hcollapse - . hzipWith (\inj -> K . map (mkTx inj) . unComp) injections - . hcmap (Proxy @HasTxs) (Comp . extractTxs . unI) + . hcimap (Proxy @HasTxs) aux . getOneEraBlock . getHardForkBlock where - mkTx :: Injection GenTx xs blk -> GenTx blk -> GenTx (HardForkBlock xs) - mkTx inj = HardForkGenTx . OneEraGenTx . unK . apFn inj + aux :: + HasTxs blk + => Index xs blk + -> I blk + -> K [GenTx (HardForkBlock xs)] blk + aux index = K . map (injectNS' (Proxy @GenTx) index) . extractTxs . unI {------------------------------------------------------------------------------- Auxiliary @@ -200,12 +201,9 @@ ledgerInfo :: forall blk. SingleEraBlock blk => State.Current (Ticked :.: LedgerState) blk -> LedgerEraInfo blk ledgerInfo _ = LedgerEraInfo $ singleEraInfo (Proxy @blk) -injectApplyTxErr :: Injection WrapApplyTxErr xs blk - -> ApplyTxErr blk - -> HardForkApplyTxErr xs -injectApplyTxErr inj = +injectApplyTxErr :: Index xs blk -> ApplyTxErr blk -> HardForkApplyTxErr xs +injectApplyTxErr index = HardForkApplyTxErrFromEra . OneEraApplyTxErr - . unK - . apFn inj + . injectNS index . WrapApplyTxErr diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs index a184917acb0..46bc3cc75df 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Protocol.hs @@ -38,6 +38,7 @@ import Ouroboros.Consensus.Protocol.Abstract import Ouroboros.Consensus.TypeFamilyWrappers import Ouroboros.Consensus.Util ((.:)) import qualified Ouroboros.Consensus.Util.OptNP as OptNP +import Ouroboros.Consensus.Util.SOP import Ouroboros.Consensus.HardFork.Combinator.Abstract import Ouroboros.Consensus.HardFork.Combinator.AcrossEras @@ -235,13 +236,13 @@ check HardForkConsensusConfig{..} (unwrapTickedChainDepState chainDepState') undistrib :: NS (Maybe :.: WrapIsLeader) xs -> Maybe (HardForkIsLeader xs) - undistrib = hcollapse . hzipWith inj injections + undistrib = hcollapse . himap inj where - inj :: Injection WrapIsLeader xs blk + inj :: Index xs blk -> (Maybe :.: WrapIsLeader) blk -> K (Maybe (HardForkIsLeader xs)) blk - inj injIsLeader (Comp mIsLeader) = K $ - OneEraIsLeader . unK . apFn injIsLeader <$> mIsLeader + inj index (Comp mIsLeader) = K $ + OneEraIsLeader . injectNS index <$> mIsLeader {------------------------------------------------------------------------------- Rolling forward and backward @@ -275,24 +276,21 @@ update HardForkConsensusConfig{..} mismatch Right matched -> hsequence' - . hczipWith3 proxySingle (updateEra ei slot) cfgs errInjections + . hcizipWith proxySingle (updateEra ei slot) cfgs $ matched where cfgs = getPerEraConsensusConfig hardForkConsensusConfigPerEra - errInjections :: NP (Injection WrapValidationErr xs) xs - errInjections = injections - updateEra :: forall xs blk. SingleEraBlock blk => EpochInfo Identity -> SlotNo + -> Index xs blk -> WrapPartialConsensusConfig blk - -> Injection WrapValidationErr xs blk -> Product WrapValidateView (Ticked :.: WrapChainDepState) blk -> (Except (HardForkValidationErr xs) :.: WrapChainDepState) blk -updateEra ei slot cfg injectErr +updateEra ei slot index cfg (Pair view (Comp chainDepState)) = Comp $ - withExcept (injectValidationErr injectErr) $ + withExcept (injectValidationErr index) $ fmap WrapChainDepState $ updateChainDepState (completeConsensusConfig' ei cfg) @@ -357,14 +355,13 @@ translateConsensus ei HardForkConsensusConfig{..} = pcfgs = getPerEraConsensusConfig hardForkConsensusConfigPerEra cfgs = hcmap proxySingle (completeConsensusConfig'' ei) pcfgs -injectValidationErr :: Injection WrapValidationErr xs blk +injectValidationErr :: Index xs blk -> ValidationErr (BlockProtocol blk) -> HardForkValidationErr xs -injectValidationErr inj = +injectValidationErr index = HardForkValidationErrFromEra . OneEraValidationErr - . unK - . apFn inj + . injectNS index . WrapValidationErr {------------------------------------------------------------------------------- diff --git a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Serialisation/Common.hs b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Serialisation/Common.hs index 9bd8faea658..000e7cb6538 100644 --- a/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Serialisation/Common.hs +++ b/ouroboros-consensus/src/Ouroboros/Consensus/HardFork/Combinator/Serialisation/Common.hs @@ -460,13 +460,13 @@ decodeNS ds = do i <- Dec.decodeWord8 case nsFromIndex i of Nothing -> fail $ "decodeNS: invalid index " ++ show i - Just ns -> hcollapse $ hzipWith3 aux injections ds ns + Just ns -> hcollapse $ hizipWith aux ds ns where - aux :: (f -.-> K (NS f xs)) blk + aux :: Index xs blk -> (Decoder s :.: f) blk -> K () blk -> K (Decoder s (NS f xs)) blk - aux inj (Comp dec) (K ()) = K $ (unK . apFn inj) <$> dec + aux index (Comp dec) (K ()) = K $ injectNS index <$> dec decodeAnnNS :: SListI xs => NP (AnnDecoder f) xs @@ -476,14 +476,13 @@ decodeAnnNS ds = do i <- Dec.decodeWord8 case nsFromIndex i of Nothing -> fail $ "decodeAnnNS: invalid index " ++ show i - Just ns -> hcollapse $ hzipWith3 aux injections ds ns + Just ns -> hcollapse $ hizipWith aux ds ns where - aux :: (f -.-> K (NS f xs)) blk + aux :: Index xs blk -> AnnDecoder f blk -> K () blk -> K (Decoder s (Lazy.ByteString -> NS f xs)) blk - aux inj (AnnDecoder dec) (K ()) = K $ - (\f -> unK . apFn inj . f ) <$> dec + aux index (AnnDecoder dec) (K ()) = K $ (injectNS index .) <$> dec {------------------------------------------------------------------------------- Dependent serialisation