Skip to content

Commit 9fa3747

Browse files
committed
Adapt CLI ledger-state JSON to current snapshot schema
1 parent 24713d8 commit 9fa3747

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

‎.changes/cip-160-receiving.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ description: |
1616
V4 evaluation, protected-change and body-signature binding tests.
1717
Preserve pool-query JSON fields while reporting the unavailable BLS registration
1818
epoch as null, instead of inventing registration history.
19+
Update ledger-state JSON encoding for the upstream six-field NewEpochState, preserving outer keys and reading currentStakeDistribution from the current set snapshot. Nested state JSON and CBOR follow the upstream ledger schema.

‎cabal.project‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ if impl(ghc >=9.14)
114114
source-repository-package
115115
type: git
116116
location: https://github.com/colll78/dns.git
117-
tag: 7bd4304298b38db3da0e72dec2b311f4cd785657
118-
--sha256: sha256-HRBHCYqk4Y63M81ry+qs7o6qtottda1RddK84lTSb/E=
117+
tag: df28303f5d07058388e40b3b9fa59509a11abdbb
118+
--sha256: sha256-2w9tP3bY7jOo+oyI4ozhyH/co+E1VEUpBqwKHpOY57Y=
119119

120120
-- Temporary public source prerequisites for the coordinated CIP-160 proposals.
121121
-- Proposed versions are unreleased; remove after official package delivery.
122122
source-repository-package
123123
type: git
124124
location: https://github.com/colll78/cardano-ledger.git
125-
tag: 4ab1c0df3373b962c641efb4935aca0e7e68967b
126-
--sha256: sha256-+EearRC1REi8n7pRvsR6AmTC/lyLYkxRdvkwUV1Ilk0=
125+
tag: 4b06e253c2fee5436d57cf56669c4e8a9358717b
126+
--sha256: sha256-PzoJjGuFq23OHvnDDwXnsCkxfywF41typfb7oCKefNw=
127127
subdir:
128128
eras/allegra/impl
129129
eras/alonzo/impl
@@ -134,6 +134,7 @@ source-repository-package
134134
eras/dijkstra/impl
135135
eras/mary/impl
136136
eras/shelley/impl
137+
eras/shelley/test-suite
137138
libs/cardano-data
138139
libs/cardano-ledger-api
139140
libs/cardano-ledger-binary
@@ -154,8 +155,8 @@ source-repository-package
154155
source-repository-package
155156
type: git
156157
location: https://github.com/colll78/ouroboros-consensus.git
157-
tag: 0c91555c0c0dfeef6cb0ac6facd42b471630f5b0
158-
--sha256: sha256-19A5YUoKnfUAc/KBPg3s25HaI+zwMGiIk4Vng3NJXH4=
158+
tag: bb55e647b1c1142948562c3702fe96ab2ee160f4
159+
--sha256: sha256-pqHyVyZfmTmU0UCgHZKjrpGvipR/3Mre7JohH8dilXk=
159160

160161
-- Exact public compatibility prerequisites; proposed versions are unreleased.
161162
source-repository-package
@@ -180,8 +181,8 @@ source-repository-package
180181
source-repository-package
181182
type: git
182183
location: https://github.com/colll78/cardano-api.git
183-
tag: a3966fb8dca37e796929ae870f0bc8edea521986
184-
--sha256: sha256-zhmSimpXLCW+NvoZWMX1HNnEpPOSSsngsXzSwbpx9pE=
184+
tag: 70415a82d7fbbc786aa646199c0cafe4063194fe
185+
--sha256: sha256-+F+j2njiPyKY1suO11uAL/fkxpB8/INDt/ifUzxBCvA=
185186
subdir:
186187
cardano-api
187188
cardano-api-gen

‎cardano-cli/src/Cardano/CLI/Orphan.hs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ import Cardano.Api.Ledger qualified as L
1616

1717
import Cardano.CLI.Type.Error.ScriptDecodeError
1818
import Cardano.Ledger.Conway.State qualified as L
19+
import Cardano.Ledger.Shelley.LedgerState (nesStakePoolDistrG)
1920

2021
import Control.Exception
2122
import Data.Aeson
2223
import Data.List qualified as List
2324
import Data.Typeable
2425
import Data.Word
26+
import Lens.Micro ((^.))
2527

2628
instance Error [Bech32DecodeError] where
2729
prettyError errs = vsep $ map prettyError errs
@@ -34,14 +36,14 @@ instance
3436
(L.EraTxOut ledgerera, L.EraGov ledgerera, L.EraCertState ledgerera, L.EraStake ledgerera)
3537
=> ToJSON (L.NewEpochState ledgerera)
3638
where
37-
toJSON (L.NewEpochState nesEL nesBprev nesBCur nesEs nesRu nesPd _stashedAvvm) =
39+
toJSON newEpochState =
3840
object
39-
[ "currentEpoch" .= nesEL
40-
, "priorBlocks" .= nesBprev
41-
, "currentEpochBlocks" .= nesBCur
42-
, "currentEpochState" .= nesEs
43-
, "rewardUpdate" .= nesRu
44-
, "currentStakeDistribution" .= nesPd
41+
[ "currentEpoch" .= L.nesEL newEpochState
42+
, "priorBlocks" .= L.nesBprev newEpochState
43+
, "currentEpochBlocks" .= L.nesBcur newEpochState
44+
, "currentEpochState" .= L.nesEs newEpochState
45+
, "rewardUpdate" .= L.nesRu newEpochState
46+
, "currentStakeDistribution" .= (newEpochState ^. nesStakePoolDistrG)
4547
]
4648

4749
instance ToJSON HashableScriptData where

0 commit comments

Comments
 (0)