Skip to content

Commit 4962396

Browse files
authored
Merge pull request #4995 from IntersectMBO/td/pv-encoding-in-pparams
Stop encoding/decoding protocol version as a CBOR group in `PParams`
2 parents cd56d4b + 1722bfa commit 4962396

File tree

5 files changed

+17
-24
lines changed

5 files changed

+17
-24
lines changed

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/PParams.hs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,13 @@ import Cardano.Ledger.Binary (
7777
Encoding,
7878
FromCBOR (..),
7979
ToCBOR (..),
80-
decCBORGroup,
8180
decodeRecordNamed,
82-
encCBORGroup,
8381
encodeFoldableAsDefLenList,
8482
encodeFoldableAsIndefLenList,
8583
encodeListLen,
8684
encodeMapLen,
8785
encodeNull,
8886
encodePreEncoded,
89-
listLen,
9087
serialize',
9188
)
9289
import Cardano.Ledger.Binary.Coders (
@@ -389,7 +386,7 @@ instance EraGov AlonzoEra where
389386

390387
instance Era era => EncCBOR (AlonzoPParams Identity era) where
391388
encCBOR AlonzoPParams {..} =
392-
encodeListLen (23 + listLen appProtocolVersion)
389+
encodeListLen 24
393390
<> encCBOR appMinFeeA
394391
<> encCBOR appMinFeeB
395392
<> encCBOR appMaxBBSize
@@ -404,7 +401,7 @@ instance Era era => EncCBOR (AlonzoPParams Identity era) where
404401
<> encCBOR appTau
405402
<> encCBOR appD
406403
<> encCBOR appExtraEntropy
407-
<> encCBORGroup appProtocolVersion
404+
<> encCBOR appProtocolVersion
408405
<> encCBOR appMinPoolCost
409406
-- new/updated for alonzo
410407
<> encCBOR appCoinsPerUTxOWord
@@ -418,7 +415,7 @@ instance Era era => EncCBOR (AlonzoPParams Identity era) where
418415

419416
instance Era era => DecCBOR (AlonzoPParams Identity era) where
420417
decCBOR =
421-
decodeRecordNamed "PParams" (\pp -> 23 + fromIntegral (listLen (appProtocolVersion pp))) $ do
418+
decodeRecordNamed "PParams" (const 24) $ do
422419
appMinFeeA <- decCBOR
423420
appMinFeeB <- decCBOR
424421
appMaxBBSize <- decCBOR
@@ -433,7 +430,7 @@ instance Era era => DecCBOR (AlonzoPParams Identity era) where
433430
appTau <- decCBOR
434431
appD <- decCBOR
435432
appExtraEntropy <- decCBOR
436-
appProtocolVersion <- decCBORGroup
433+
appProtocolVersion <- decCBOR
437434
appMinPoolCost <- decCBOR
438435
-- new/updated for alonzo
439436
appCoinsPerUTxOWord <- decCBOR

eras/babbage/impl/src/Cardano/Ledger/Babbage/PParams.hs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,8 @@ import Cardano.Ledger.Binary (
7373
Encoding,
7474
FromCBOR (..),
7575
ToCBOR (..),
76-
decCBORGroup,
7776
decodeRecordNamed,
78-
encCBORGroup,
7977
encodeListLen,
80-
listLen,
8178
)
8279
import Cardano.Ledger.Binary.Coders (
8380
Decode (..),
@@ -274,7 +271,7 @@ instance EraGov BabbageEra where
274271

275272
instance Era era => EncCBOR (BabbagePParams Identity era) where
276273
encCBOR BabbagePParams {..} =
277-
encodeListLen (21 + listLen bppProtocolVersion)
274+
encodeListLen 22
278275
<> encCBOR bppMinFeeA
279276
<> encCBOR bppMinFeeB
280277
<> encCBOR bppMaxBBSize
@@ -287,7 +284,7 @@ instance Era era => EncCBOR (BabbagePParams Identity era) where
287284
<> encCBOR bppA0
288285
<> encCBOR bppRho
289286
<> encCBOR bppTau
290-
<> encCBORGroup bppProtocolVersion
287+
<> encCBOR bppProtocolVersion
291288
<> encCBOR bppMinPoolCost
292289
<> encCBOR bppCoinsPerUTxOByte
293290
<> encCBOR bppCostModels
@@ -303,7 +300,7 @@ instance Era era => ToCBOR (BabbagePParams Identity era) where
303300

304301
instance Era era => DecCBOR (BabbagePParams Identity era) where
305302
decCBOR =
306-
decodeRecordNamed "PParams" (\pp -> 21 + fromIntegral (listLen (bppProtocolVersion pp))) $ do
303+
decodeRecordNamed "PParams" (const 22) $ do
307304
bppMinFeeA <- decCBOR
308305
bppMinFeeB <- decCBOR
309306
bppMaxBBSize <- decCBOR
@@ -316,7 +313,7 @@ instance Era era => DecCBOR (BabbagePParams Identity era) where
316313
bppA0 <- decCBOR
317314
bppRho <- decCBOR
318315
bppTau <- decCBOR
319-
bppProtocolVersion <- decCBORGroup
316+
bppProtocolVersion <- decCBOR
320317
bppMinPoolCost <- decCBOR
321318
bppCoinsPerUTxOByte <- decCBOR
322319
bppCostModels <- decCBOR

eras/shelley/impl/src/Cardano/Ledger/Shelley/PParams.hs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ import Cardano.Ledger.BaseTypes (
5050
)
5151
import Cardano.Ledger.Binary (
5252
DecCBOR (..),
53-
DecCBORGroup (..),
5453
EncCBOR (..),
55-
EncCBORGroup (..),
5654
FromCBOR (..),
5755
ToCBOR (..),
5856
decodeMapContents,
@@ -195,7 +193,7 @@ instance EraPParams ShelleyEra where
195193
instance Era era => EncCBOR (ShelleyPParams Identity era) where
196194
encCBOR
197195
ShelleyPParams {..} =
198-
encodeListLen 18
196+
encodeListLen 17
199197
<> encCBOR sppMinFeeA
200198
<> encCBOR sppMinFeeB
201199
<> encCBOR sppMaxBBSize
@@ -210,13 +208,13 @@ instance Era era => EncCBOR (ShelleyPParams Identity era) where
210208
<> encCBOR sppTau
211209
<> encCBOR sppD
212210
<> encCBOR sppExtraEntropy
213-
<> encCBORGroup sppProtocolVersion
211+
<> encCBOR sppProtocolVersion
214212
<> encCBOR sppMinUTxOValue
215213
<> encCBOR sppMinPoolCost
216214

217215
instance Era era => DecCBOR (ShelleyPParams Identity era) where
218216
decCBOR = do
219-
decodeRecordNamed "ShelleyPParams" (const 18) $
217+
decodeRecordNamed "ShelleyPParams" (const 17) $
220218
ShelleyPParams @Identity
221219
<$> decCBOR -- sppMinFeeA :: Integer
222220
<*> decCBOR -- sppMinFeeB :: Natural
@@ -232,7 +230,7 @@ instance Era era => DecCBOR (ShelleyPParams Identity era) where
232230
<*> decCBOR -- sppTau :: UnitInterval
233231
<*> decCBOR -- sppD :: UnitInterval
234232
<*> decCBOR -- sppExtraEntropy :: Nonce
235-
<*> decCBORGroup -- sppProtocolVersion :: ProtVer
233+
<*> decCBOR -- sppProtocolVersion :: ProtVer
236234
<*> decCBOR -- sppMinUTxOValue :: Natural
237235
<*> decCBOR -- sppMinPoolCost :: Natural
238236

eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/Serialisation/Golden/Encoding.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,9 +1104,9 @@ tests =
11041104
, "03e8828284a0a0a0a08482a0a0a0a084a0a0000086a15822ee155ace9c40292074cb6aff"
11051105
, "8c9ccdd273c81648ff1149ef36bcea6ebb8a3e250000583d003900cb9358529df4729c32"
11061106
, "46a2a033cb9821abbfd16de4888005904abc410d6a577e9441ad8ed9663931906e4d43ec"
1107-
, "e8f82c712b1d0235affb06000a1903e80185a0a092000000190800000000001864d81e82"
1108-
, "0001d81e820001d81e820001d81e82000181000200010092000000190800000000001864"
1109-
, "d81e820001d81e820001d81e820001d81e820001810002000000810082a0a0008483a0a0"
1107+
, "e8f82c712b1d0235affb06000a1903e80185a0a091000000190800000000001864d81e82"
1108+
, "0001d81e820001d81e820001d81e8200018100820200010091000000190800000000001864"
1109+
, "d81e820001d81e820001d81e820001d81e82000181008202000000810082a0a0008483a0a0"
11101110
, "a083a0a0a083a0a0a00082a000818300880082020082a000000000a0a0840185a0800082"
11111111
, "0200a0a082a0a082a1581ce0a714319812c3f773ba04ec5d6b3ffcd5aad85006805b047b"
11121112
, "08254183820101015820c5e21ab1c9f6022d81c3b25e3436cb7f1df77f9652ae3e1310c2"

eras/shelley/test-suite/test/Test/Cardano/Ledger/Shelley/Serialisation/Golden/Genesis.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ golden_cbor_ShelleyGenesis =
9494
. TkInt 8000000 -- sgSlotLength
9595
. TkInt 16991 -- sgUpdateQuorum
9696
. TkInt 71 -- sgMaxLovelaceSupply
97-
. TkListLen 18 -- sgProtocolParams
97+
. TkListLen 17 -- sgProtocolParams
9898
. TkInt 0
9999
. TkInt 0
100100
. TkInt 239857
@@ -122,6 +122,7 @@ golden_cbor_ShelleyGenesis =
122122
. TkInt 1000
123123
. TkListLen 1
124124
. TkInt 0
125+
. TkListLen 2
125126
. TkInt 2
126127
. TkInt 0
127128
. TkInt 0

0 commit comments

Comments
 (0)