From acfaee00680c7c52fd525f6448793ee6abe5adb2 Mon Sep 17 00:00:00 2001 From: Alexander Esgen Date: Mon, 17 Jun 2024 20:20:10 +0200 Subject: [PATCH] Vendor `PoolDistr` for query backwards-compatibility --- ...02003_alexander.esgen_cardano_node_8_12.md | 5 ++ .../Result_Allegra_StakeDistribution | 2 +- .../Result_Alonzo_StakeDistribution | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../Result_Shelley_StakeDistribution | 2 +- .../Result_Allegra_StakeDistribution | 2 +- .../Result_Alonzo_StakeDistribution | 2 +- .../Result_Babbage_StakeDistribution | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../Result_Shelley_StakeDistribution | 2 +- .../Result_Allegra_StakeDistribution | 2 +- .../Result_Alonzo_StakeDistribution | 2 +- .../Result_Babbage_StakeDistribution | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../Result_Shelley_StakeDistribution | 2 +- .../Result_Allegra_StakeDistribution | 2 +- .../Result_Alonzo_StakeDistribution | 2 +- .../Result_Babbage_StakeDistribution | 2 +- .../Result_Conway_StakeDistribution | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../Result_Shelley_StakeDistribution | 2 +- .../Result_Allegra_StakeDistribution | 2 +- .../Result_Alonzo_StakeDistribution | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../Result_Shelley_StakeDistribution | 2 +- .../Result_Allegra_StakeDistribution | 2 +- .../Result_Alonzo_StakeDistribution | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../Result_Shelley_StakeDistribution | 2 +- .../Result_Allegra_StakeDistribution | 2 +- .../Result_Alonzo_StakeDistribution | 2 +- .../Result_Babbage_StakeDistribution | 2 +- .../Result_Mary_StakeDistribution | 2 +- .../Result_Shelley_StakeDistribution | 2 +- .../Result_StakeDistribution | 2 +- .../Result_StakeDistribution | 2 +- .../Result_StakeDistribution | 2 +- .../Result_StakeDistribution | 2 +- .../Result_StakeDistribution | 2 +- .../ouroboros-consensus-cardano.cabal | 1 + .../Consensus/Shelley/Ledger/Query.hs | 10 +-- .../Consensus/Shelley/Ledger/Query/Types.hs | 71 +++++++++++++++++++ .../Test/Consensus/Shelley/Examples.hs | 5 +- .../Test/Consensus/Shelley/Generators.hs | 3 +- 44 files changed, 126 insertions(+), 45 deletions(-) create mode 100644 ouroboros-consensus-cardano/changelog.d/20240617_202003_alexander.esgen_cardano_node_8_12.md create mode 100644 ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/Types.hs diff --git a/ouroboros-consensus-cardano/changelog.d/20240617_202003_alexander.esgen_cardano_node_8_12.md b/ouroboros-consensus-cardano/changelog.d/20240617_202003_alexander.esgen_cardano_node_8_12.md new file mode 100644 index 0000000000..31686475c0 --- /dev/null +++ b/ouroboros-consensus-cardano/changelog.d/20240617_202003_alexander.esgen_cardano_node_8_12.md @@ -0,0 +1,5 @@ +### Breaking + +- Changed `GetStakeDistribution` and `GetPoolDistr` queries to return a + Consensus-vendored version of `PoolDistr` (instead of using the one from + Ledger, as it changed in a backwards-incompatible manner). diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Allegra_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Allegra_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Allegra_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Allegra_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Alonzo_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Alonzo_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Alonzo_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Alonzo_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Mary_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Mary_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Shelley_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Shelley_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Shelley_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion1/CardanoNodeToClientVersion7/Result_Shelley_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Allegra_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Allegra_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Allegra_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Allegra_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Alonzo_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Alonzo_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Alonzo_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Alonzo_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Babbage_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Babbage_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Babbage_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Babbage_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Mary_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Mary_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Shelley_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Shelley_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Shelley_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion10/Result_Shelley_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Allegra_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Allegra_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Allegra_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Allegra_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Alonzo_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Alonzo_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Alonzo_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Alonzo_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Babbage_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Babbage_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Babbage_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Babbage_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Mary_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Mary_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Shelley_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Shelley_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Shelley_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion11/Result_Shelley_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Allegra_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Allegra_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Allegra_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Allegra_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Alonzo_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Alonzo_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Alonzo_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Alonzo_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Babbage_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Babbage_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Babbage_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Babbage_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Conway_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Conway_StakeDistribution index 4f8aa309f9..967baf0b47 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Conway_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Conway_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Mary_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Mary_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Shelley_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Shelley_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Shelley_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion12/Result_Shelley_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Allegra_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Allegra_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Allegra_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Allegra_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Alonzo_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Alonzo_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Alonzo_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Alonzo_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Mary_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Mary_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Shelley_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Shelley_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Shelley_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion7/Result_Shelley_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Allegra_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Allegra_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Allegra_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Allegra_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Alonzo_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Alonzo_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Alonzo_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Alonzo_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Mary_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Mary_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Shelley_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Shelley_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Shelley_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion8/Result_Shelley_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Allegra_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Allegra_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Allegra_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Allegra_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Alonzo_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Alonzo_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Alonzo_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Alonzo_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Babbage_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Babbage_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Babbage_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Babbage_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Mary_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Mary_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Mary_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Mary_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Shelley_StakeDistribution b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Shelley_StakeDistribution index 016c85886a..968f15663d 100644 --- a/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Shelley_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/cardano/QueryVersion2/CardanoNodeToClientVersion9/Result_Shelley_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/shelley/QueryVersion1/ShelleyNodeToClientVersion5/Result_StakeDistribution b/ouroboros-consensus-cardano/golden/shelley/QueryVersion1/ShelleyNodeToClientVersion5/Result_StakeDistribution index e57082c051..12f9add46f 100644 --- a/ouroboros-consensus-cardano/golden/shelley/QueryVersion1/ShelleyNodeToClientVersion5/Result_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/shelley/QueryVersion1/ShelleyNodeToClientVersion5/Result_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion5/Result_StakeDistribution b/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion5/Result_StakeDistribution index e57082c051..12f9add46f 100644 --- a/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion5/Result_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion5/Result_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion6/Result_StakeDistribution b/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion6/Result_StakeDistribution index e57082c051..12f9add46f 100644 --- a/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion6/Result_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion6/Result_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion7/Result_StakeDistribution b/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion7/Result_StakeDistribution index e57082c051..12f9add46f 100644 --- a/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion7/Result_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion7/Result_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion8/Result_StakeDistribution b/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion8/Result_StakeDistribution index e57082c051..12f9add46f 100644 --- a/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion8/Result_StakeDistribution +++ b/ouroboros-consensus-cardano/golden/shelley/QueryVersion2/ShelleyNodeToClientVersion8/Result_StakeDistribution @@ -1 +1 @@ -X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file +X1s]k?ժP[{%AX -ò^46R>Žb{L \ No newline at end of file diff --git a/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal b/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal index 4196bc063a..11f1cb99fd 100644 --- a/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal +++ b/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal @@ -110,6 +110,7 @@ library Ouroboros.Consensus.Shelley.Ledger.PeerSelection Ouroboros.Consensus.Shelley.Ledger.Protocol Ouroboros.Consensus.Shelley.Ledger.Query + Ouroboros.Consensus.Shelley.Ledger.Query.Types Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol Ouroboros.Consensus.Shelley.Node Ouroboros.Consensus.Shelley.Node.Common diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs index 66d6bcd5f1..6e6775617b 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs @@ -83,6 +83,7 @@ import Ouroboros.Consensus.Shelley.Ledger.Ledger import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion (ShelleyNodeToClientVersion (..)) import Ouroboros.Consensus.Shelley.Ledger.Query.PParamsLegacyEncoder +import Ouroboros.Consensus.Shelley.Ledger.Query.Types import Ouroboros.Consensus.Shelley.Protocol.Abstract (ProtoCrypto) import Ouroboros.Consensus.Util (ShowProxy (..)) import Ouroboros.Network.Block (Serialised (..), decodePoint, @@ -127,7 +128,7 @@ data instance BlockQuery (ShelleyBlock proto era) :: Type -> Type where -- an endpoint that provides all the information that the wallet wants about -- pools, in an extensible fashion. GetStakeDistribution - :: BlockQuery (ShelleyBlock proto era) (SL.PoolDistr (EraCrypto era)) + :: BlockQuery (ShelleyBlock proto era) (PoolDistr (EraCrypto era)) -- | Get a subset of the UTxO, filtered by address. Although this will -- typically return a lot less data than 'GetUTxOWhole', it requires a linear @@ -224,7 +225,7 @@ data instance BlockQuery (ShelleyBlock proto era) :: Type -> Type where GetPoolDistr :: Maybe (Set (SL.KeyHash 'SL.StakePool (EraCrypto era))) -> BlockQuery (ShelleyBlock proto era) - (SL.PoolDistr (EraCrypto era)) + (PoolDistr (EraCrypto era)) GetStakeDelegDeposits :: Set (StakeCredential (EraCrypto era)) @@ -319,7 +320,7 @@ instance (ShelleyCompatible proto era, ProtoCrypto proto ~ crypto) GetProposedPParamsUpdates -> getProposedPPUpdates st GetStakeDistribution -> - SL.poolsByTotalStakeFraction globals st + fromLedgerPoolDistr $ SL.poolsByTotalStakeFraction globals st GetUTxOByAddress addrs -> SL.getFilteredUTxO st addrs GetUTxOWhole -> @@ -416,7 +417,8 @@ instance (ShelleyCompatible proto era, ProtoCrypto proto ~ crypto) GetPoolDistr mPoolIds -> let stakeSet = SL.ssStakeSet . SL.esSnapshots $ getEpochState st in - SL.calculatePoolDistr' (maybe (const True) (flip Set.member) mPoolIds) stakeSet + fromLedgerPoolDistr $ + SL.calculatePoolDistr' (maybe (const True) (flip Set.member) mPoolIds) stakeSet GetStakeDelegDeposits stakeCreds -> let lookupDeposit = lookupDepositDState (SL.certDState $ SL.lsCertState $ SL.esLState $ SL.nesEs st) diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/Types.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/Types.hs new file mode 100644 index 0000000000..3e7d61532d --- /dev/null +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query/Types.hs @@ -0,0 +1,71 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE OverloadedStrings #-} + +-- | This module contains copies of older versions of types from Ledger in order +-- to retain backwards-compatibility. Eventually, types likes this should be +-- defined in Ledger instead of here, see +-- . +module Ouroboros.Consensus.Shelley.Ledger.Query.Types ( + IndividualPoolStake (..) + , PoolDistr (..) + , fromLedgerIndividualPoolStake + , fromLedgerPoolDistr + ) where + +import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..), + decodeRecordNamed, encodeListLen) +import Cardano.Ledger.Crypto (Crypto) +import Cardano.Ledger.Keys (Hash) +import qualified Cardano.Ledger.PoolDistr as SL +import qualified Cardano.Ledger.Shelley.API as SL +import Data.Map.Strict (Map) +import qualified Data.Map.Strict as Map +import GHC.Generics (Generic) +import NoThunks.Class + +-- | Copy of 'SL.IndividualPoolStake' before +-- . +data IndividualPoolStake c = IndividualPoolStake { + individualPoolStake :: !Rational + , individualPoolStakeVrf :: !(Hash c (SL.VerKeyVRF c)) + } + deriving stock (Show, Eq, Generic) + deriving anyclass (NoThunks) + +fromLedgerIndividualPoolStake :: SL.IndividualPoolStake c -> IndividualPoolStake c +fromLedgerIndividualPoolStake ips = IndividualPoolStake { + individualPoolStake = SL.individualPoolStake ips + , individualPoolStakeVrf = SL.individualPoolStakeVrf ips + } + +instance Crypto c => EncCBOR (IndividualPoolStake c) where + encCBOR (IndividualPoolStake stake vrf) = + mconcat + [ encodeListLen 2 + , encCBOR stake + , encCBOR vrf + ] + +instance Crypto c => DecCBOR (IndividualPoolStake c) where + decCBOR = + decodeRecordNamed "IndividualPoolStake" (const 2) $ + IndividualPoolStake + <$> decCBOR + <*> decCBOR + +-- | Copy of 'SL.PoolDistr' before +-- . +newtype PoolDistr c = PoolDistr { + unPoolDistr :: Map (SL.KeyHash SL.StakePool c) (IndividualPoolStake c) + } + deriving stock (Show, Eq, Generic) + deriving newtype (EncCBOR, DecCBOR) + +fromLedgerPoolDistr :: SL.PoolDistr c -> PoolDistr c +fromLedgerPoolDistr pd = PoolDistr { + unPoolDistr = Map.map fromLedgerIndividualPoolStake $ SL.unPoolDistr pd + } diff --git a/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Examples.hs b/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Examples.hs index 7d4689a02b..2c4fdcfd59 100644 --- a/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Examples.hs +++ b/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Examples.hs @@ -39,6 +39,7 @@ import Ouroboros.Consensus.Protocol.TPraos (TPraos, import Ouroboros.Consensus.Shelley.Eras import Ouroboros.Consensus.Shelley.HFEras import Ouroboros.Consensus.Shelley.Ledger +import Ouroboros.Consensus.Shelley.Ledger.Query.Types import Ouroboros.Consensus.Shelley.Protocol.TPraos () import Ouroboros.Consensus.Storage.Serialisation import Ouroboros.Network.Block (Serialised (..)) @@ -114,7 +115,7 @@ fromShelleyLedgerExamples ShelleyLedgerExamples { , ("EpochNo", SomeResult GetEpochNo 10) , ("EmptyPParams", SomeResult GetCurrentPParams srePParams) , ("ProposedPParamsUpdates", SomeResult GetProposedPParamsUpdates sreProposedPPUpdates) - , ("StakeDistribution", SomeResult GetStakeDistribution srePoolDistr) + , ("StakeDistribution", SomeResult GetStakeDistribution $ fromLedgerPoolDistr srePoolDistr) , ("NonMyopicMemberRewards", SomeResult (GetNonMyopicMemberRewards Set.empty) (NonMyopicMemberRewards $ sreNonMyopicRewards)) , ("GenesisConfig", SomeResult GetGenesisConfig (compactGenesis sreShelleyGenesis)) @@ -207,7 +208,7 @@ fromShelleyLedgerExamplesPraos ShelleyLedgerExamples { , ("EpochNo", SomeResult GetEpochNo 10) , ("EmptyPParams", SomeResult GetCurrentPParams srePParams) , ("ProposedPParamsUpdates", SomeResult GetProposedPParamsUpdates sreProposedPPUpdates) - , ("StakeDistribution", SomeResult GetStakeDistribution srePoolDistr) + , ("StakeDistribution", SomeResult GetStakeDistribution $ fromLedgerPoolDistr srePoolDistr) , ("NonMyopicMemberRewards", SomeResult (GetNonMyopicMemberRewards Set.empty) (NonMyopicMemberRewards $ sreNonMyopicRewards)) , ("GenesisConfig", SomeResult GetGenesisConfig (compactGenesis sreShelleyGenesis)) diff --git a/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Generators.hs b/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Generators.hs index c3cacbd521..14f033761c 100644 --- a/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Generators.hs +++ b/ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Generators.hs @@ -30,6 +30,7 @@ import Ouroboros.Consensus.Protocol.TPraos (PraosCrypto, TPraos, TPraosState (..)) import Ouroboros.Consensus.Shelley.Eras import Ouroboros.Consensus.Shelley.Ledger +import Ouroboros.Consensus.Shelley.Ledger.Query.Types import Ouroboros.Consensus.Shelley.Protocol.Praos () import Ouroboros.Consensus.Shelley.Protocol.TPraos () import Ouroboros.Network.Block (mkSerialised) @@ -152,7 +153,7 @@ instance CanMock proto era => Arbitrary (SomeResult (ShelleyBlock proto era)) wh , SomeResult <$> (GetNonMyopicMemberRewards <$> arbitrary) <*> arbitrary , SomeResult GetCurrentPParams <$> arbitrary , SomeResult GetProposedPParamsUpdates <$> arbitrary - , SomeResult GetStakeDistribution <$> arbitrary + , SomeResult GetStakeDistribution . fromLedgerPoolDistr <$> arbitrary , SomeResult DebugEpochState <$> arbitrary , (\(SomeResult q r) -> SomeResult (GetCBOR q) (mkSerialised (encodeShelleyResult maxBound q) r)) <$>