Skip to content

Commit 1a03ad8

Browse files
committed
CDDL: Consolidate protocol_version definitions
1 parent 9ecddb1 commit 1a03ad8

File tree

10 files changed

+21
-18
lines changed

10 files changed

+21
-18
lines changed

eras/alonzo/impl/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### `testlib`
1010

1111
* Use named CDDL `slot` and `block_number` rules in header
12+
* Remove CDDL `protocol_version` redefinition
1213
* Add `NativeScript` parameter to `exampleTx`
1314

1415
## 1.14.0.0

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ transaction =
7575
, a (auxiliary_data / VNil)
7676
]
7777

78-
protocol_version :: Named Group
79-
protocol_version = "protocol_version" =:~ grp [a $ major_protocol_version @AlonzoEra, a VUInt]
80-
8178
transaction_body :: Rule
8279
transaction_body =
8380
comment
@@ -231,7 +228,7 @@ protocol_param_update =
231228
, opt (idx 11 ==> unit_interval)
232229
, opt (idx 12 ==> unit_interval)
233230
, opt (idx 13 ==> nonce)
234-
, opt (idx 14 ==> arr [a protocol_version])
231+
, opt (idx 14 ==> arr [a (protocol_version @AlonzoEra)])
235232
, opt (idx 16 ==> coin)
236233
, opt (idx 17 ==> coin)
237234
, opt (idx 18 ==> cost_models)
@@ -400,7 +397,7 @@ header_body =
400397
, "block_body_size" ==> VUInt
401398
, "block_body_hash" ==> hash32
402399
, a operational_cert
403-
, a protocol_version
400+
, a (protocol_version @AlonzoEra)
404401
]
405402

406403
native_script :: Rule

eras/babbage/impl/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
### `testlib`
88

9+
* Hide Shelley CDDL `protocol_version` and re-export a new one for Babbage
910
* Use named CDDL `slot` and `block_number` rules in header
1011
* Add `BabbageEraImp`
1112
* Removed `babbageEraSpecificSpec`

eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
{-# LANGUAGE AllowAmbiguousTypes #-}
12
{-# LANGUAGE ImportQualifiedPost #-}
23
{-# LANGUAGE OverloadedLists #-}
34
{-# LANGUAGE OverloadedStrings #-}
45
{-# LANGUAGE QuasiQuotes #-}
6+
{-# LANGUAGE RankNTypes #-}
7+
{-# LANGUAGE ScopedTypeVariables #-}
58
{-# LANGUAGE TypeApplications #-}
69
{-# LANGUAGE NoImplicitPrelude #-}
710

@@ -14,13 +17,16 @@ module Test.Cardano.Ledger.Babbage.CDDL (
1417
operational_cert,
1518
babbage_transaction_output,
1619
plutus_data,
20+
protocol_version,
1721
) where
1822

1923
import Cardano.Ledger.Babbage (BabbageEra)
24+
import Cardano.Ledger.Core (Era)
2025
import Codec.CBOR.Cuddle.Huddle
2126
import Data.Word (Word64)
2227
import Test.Cardano.Ledger.Alonzo.CDDL hiding (
2328
operational_cert,
29+
protocol_version,
2430
)
2531
import Text.Heredoc
2632
import Prelude hiding ((/))
@@ -83,7 +89,7 @@ header_body =
8389
, "block_body_size" ==> VUInt
8490
, "block_body_hash" ==> hash32
8591
, a operational_cert
86-
, a protocol_version
92+
, a (protocol_version @BabbageEra)
8793
]
8894

8995
operational_cert :: Rule
@@ -96,8 +102,8 @@ operational_cert =
96102
, "sigma" ==> signature
97103
]
98104

99-
protocol_version :: Rule
100-
protocol_version = "protocol_version" =:= arr [a $ major_protocol_version @BabbageEra, a VUInt]
105+
protocol_version :: forall era. Era era => Rule
106+
protocol_version = "protocol_version" =:= arr [a $ major_protocol_version @era, a VUInt]
101107

102108
transaction_body :: Rule
103109
transaction_body =
@@ -367,7 +373,7 @@ protocol_param_update =
367373
, opt (idx 9 ==> nonnegative_interval)
368374
, opt (idx 10 ==> unit_interval)
369375
, opt (idx 11 ==> unit_interval)
370-
, opt (idx 14 ==> protocol_version)
376+
, opt (idx 14 ==> protocol_version @BabbageEra)
371377
, opt (idx 16 ==> coin)
372378
, opt (idx 17 ==> coin)
373379
, opt (idx 18 ==> cost_models)

eras/conway/impl/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
* Rename `epoch_no` to `epoch` for consistency
1414
* Rename `slot_no` to `slot` and `block_no` to `block_number` for consistency
15+
* Remove CDDL `protocol_version` redefinition
1516
* Removed `regDelegToDRep`
1617
* Removed `registerRewardAccountWithDeposit`
1718
* Removed `registerPoolWithDeposit`

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,9 @@ header_body =
181181
, "block_body_size" ==> (VUInt `sized` (4 :: Word64))
182182
, "block_body_hash" ==> hash32
183183
, a operational_cert
184-
, a protocol_version
184+
, a (protocol_version @ConwayEra)
185185
]
186186

187-
protocol_version :: Rule
188-
protocol_version = "protocol_version" =:= arr [a $ major_protocol_version @ConwayEra, a VUInt]
189-
190187
transaction_body :: Rule
191188
transaction_body =
192189
"transaction_body"
@@ -264,7 +261,7 @@ parameter_change_action =
264261
hard_fork_initiation_action :: Named Group
265262
hard_fork_initiation_action =
266263
"hard_fork_initiation_action"
267-
=:~ grp [1, a $ gov_action_id / VNil, a protocol_version]
264+
=:~ grp [1, a $ gov_action_id / VNil, a (protocol_version @ConwayEra)]
268265

269266
treasury_withdrawals_action :: Named Group
270267
treasury_withdrawals_action =

eras/dijkstra/impl/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
### `testlib`
1414

1515
* Use Conway's renamed CDDL `slot` and `block_number` rules
16+
* Remove CDDL `protocol_version` redefinition
1617
* Add `impDijkstraSatisfyNativeScript`
1718
* Add `DijkstraEraTxBody` and `DijkstraEraScript` constraints to `DijkstraEraTest`
1819

eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/CDDL.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,9 @@ header_body =
105105
, "block_body_size" ==> (VUInt `sized` (4 :: Word64))
106106
, "block_body_hash" ==> hash32
107107
, a operational_cert
108-
, a protocol_version
108+
, a (protocol_version @DijkstraEra)
109109
]
110110

111-
protocol_version :: Rule
112-
protocol_version = "protocol_version" =:= arr [a $ major_protocol_version @DijkstraEra, a VUInt]
113-
114111
transaction_body :: Rule
115112
transaction_body =
116113
"transaction_body"

eras/shelley/impl/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
### `testlib`
1717

18+
* Export polymorphic CDDL definition for `protocol_version`
1819
* Add CDDL definitions for `slot` and `block_number`
1920
* Remove CDDL definition for `nonce`
2021
* Rename `examplePoolParams` to `exampleStakePoolParams`

eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module Test.Cardano.Ledger.Shelley.CDDL (
2727
bootstrap_witness,
2828
script_hash,
2929
major_protocol_version,
30+
protocol_version,
3031
epoch,
3132
slot,
3233
block_number,

0 commit comments

Comments
 (0)