Skip to content

Commit 237fed8

Browse files
authored
Merge pull request #5362 from IntersectMBO/aniketd/deduplicate-cddl-tmp
CDDL: Switch to explicit exports and consolidate a few fields
2 parents facad76 + 38f3b4b commit 237fed8

File tree

15 files changed

+377
-275
lines changed

15 files changed

+377
-275
lines changed

eras/allegra/impl/cddl-files/allegra.cddl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ protocol_param_update =
267267

268268
nonnegative_interval = #6.30([uint, positive_int])
269269

270-
positive_int = 1 .. maxWord64
270+
positive_int = 1 .. max_word64
271271

272-
maxWord64 = 18446744073709551615
272+
max_word64 = 18446744073709551615
273273

274274
nonce = [0// 1, bytes .size 32]
275275

@@ -305,7 +305,11 @@ script_any = (2, [* native_script])
305305

306306
script_n_of_k = (3, n : int64, [* native_script])
307307

308-
int64 = -9223372036854775808 .. 9223372036854775807
308+
int64 = min_int64 .. max_int64
309+
310+
min_int64 = -9223372036854775808
311+
312+
max_int64 = 9223372036854775807
309313

310314
invalid_before = (4, uint)
311315

eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/CDDL.hs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@
1212

1313
module Test.Cardano.Ledger.Allegra.CDDL (
1414
module Test.Cardano.Ledger.Shelley.CDDL,
15-
module Test.Cardano.Ledger.Allegra.CDDL,
15+
allegraCDDL,
16+
transaction_witness_set,
17+
auxiliary_data,
18+
metadata,
19+
auxiliary_scripts,
20+
script_pubkey,
21+
script_all,
22+
script_any,
23+
invalid_before,
24+
invalid_hereafter,
1625
) where
1726

1827
import Cardano.Ledger.Allegra (AllegraEra)
1928
import Cardano.Ledger.Core (Era)
2029
import Codec.CBOR.Cuddle.Huddle
2130
import Data.Function (($))
22-
import Test.Cardano.Ledger.Shelley.CDDL hiding (
23-
block,
24-
transaction,
25-
transaction_body,
26-
transaction_witness_set,
27-
)
31+
import Test.Cardano.Ledger.Shelley.CDDL
2832
import Text.Heredoc
2933

3034
allegraCDDL :: Huddle
@@ -93,7 +97,7 @@ transaction_body =
9397
|]
9498
$ "transaction_body"
9599
=:= mp
96-
[ idx 0 ==> set transaction_input
100+
[ idx 0 ==> untagged_set transaction_input
97101
, idx 1 ==> arr [0 <+ a transaction_output]
98102
, idx 2 ==> coin
99103
, opt (idx 3 ==> VUInt)

eras/alonzo/impl/cddl-files/alonzo.cddl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ protocol_param_update =
330330

331331
nonnegative_interval = #6.30([uint, positive_int])
332332

333-
positive_int = 1 .. maxWord64
333+
positive_int = 1 .. max_word64
334334

335-
maxWord64 = 18446744073709551615
335+
max_word64 = 18446744073709551615
336336

337337
nonce = [0// 1, bytes .size 32]
338338

@@ -349,7 +349,11 @@ language = 0
349349
; See Plutus' `ParamName` for parameter ordering
350350
cost_model = [166*166 int64]
351351

352-
int64 = -9223372036854775808 .. 9223372036854775807
352+
int64 = min_int64 .. max_int64
353+
354+
min_int64 = -9223372036854775808
355+
356+
max_int64 = 9223372036854775807
353357

354358
ex_unit_prices = [mem_price : positive_interval, step_price : positive_interval]
355359

@@ -558,5 +562,5 @@ auxiliary_scripts = [* native_script]
558562
transaction =
559563
[transaction_body, transaction_witness_set, bool, auxiliary_data/ nil]
560564

561-
signkeyKES = bytes .size 64
565+
signkey_kes = bytes .size 64
562566

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

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@
1010

1111
module Test.Cardano.Ledger.Alonzo.CDDL (
1212
module Test.Cardano.Ledger.Mary.CDDL,
13-
module Test.Cardano.Ledger.Alonzo.CDDL,
13+
alonzoCDDL,
14+
certificates,
15+
auxiliary_data_hash,
16+
required_signers,
17+
network_id,
18+
native_script,
19+
redeemers,
20+
constr,
21+
ex_unit_prices,
22+
ex_units,
23+
positive_interval,
1424
) where
1525

1626
import Cardano.Ledger.Alonzo (AlonzoEra)
@@ -19,21 +29,9 @@ import Data.Function (($))
1929
import Data.Word (Word64)
2030
import Test.Cardano.Ledger.Mary.CDDL hiding (
2131
auxiliary_data,
22-
block,
2332
header,
24-
header_body,
25-
mint,
26-
native_script,
27-
proposed_protocol_parameter_updates,
28-
protocol_param_update,
29-
protocol_version,
30-
script_n_of_k,
31-
transaction,
32-
transaction_body,
33-
transaction_output,
3433
transaction_witness_set,
3534
update,
36-
value,
3735
)
3836
import Text.Heredoc
3937

@@ -44,7 +42,7 @@ alonzoCDDL =
4442
, HIRule transaction
4543
, HIRule kes_signature
4644
, HIRule language
47-
, HIRule signkeyKES
45+
, HIRule signkey_kes
4846
]
4947

5048
block :: Rule
@@ -95,7 +93,7 @@ transaction_body =
9593
|]
9694
$ "transaction_body"
9795
=:= mp
98-
[ idx 0 ==> set transaction_input
96+
[ idx 0 ==> untagged_set transaction_input
9997
, idx 1 ==> arr [0 <+ a transaction_output]
10098
, idx 2 ==> coin
10199
, opt (idx 3 ==> VUInt)
@@ -106,13 +104,13 @@ transaction_body =
106104
, opt (idx 8 ==> VUInt)
107105
, opt (idx 9 ==> mint)
108106
, opt (idx 11 ==> script_data_hash)
109-
, opt (idx 13 ==> set transaction_input)
107+
, opt (idx 13 ==> untagged_set transaction_input)
110108
, opt (idx 14 ==> required_signers)
111109
, opt (idx 15 ==> network_id)
112110
]
113111

114112
required_signers :: Rule
115-
required_signers = "required_signers" =:= set addr_keyhash
113+
required_signers = "required_signers" =:= untagged_set addr_keyhash
116114

117115
transaction_output :: Rule
118116
transaction_output =
@@ -435,9 +433,3 @@ network_id = "network_id" =:= int 0 / int 1
435433

436434
auxiliary_data_hash :: Rule
437435
auxiliary_data_hash = "auxiliary_data_hash" =:= hash32
438-
439-
mint :: Rule
440-
mint = "mint" =:= multiasset int64
441-
442-
value :: Rule
443-
value = "value" =:= coin / sarr [a coin, a (multiasset VUInt)]

eras/babbage/impl/cddl-files/babbage.cddl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,15 +415,19 @@ protocol_param_update =
415415

416416
nonnegative_interval = #6.30([uint, positive_int])
417417

418-
positive_int = 1 .. maxWord64
418+
positive_int = 1 .. max_word64
419419

420-
maxWord64 = 18446744073709551615
420+
max_word64 = 18446744073709551615
421421

422422
; 0: Plutus v1
423423
; 1: Plutus v2
424424
cost_models = {? 0 : [166*166 int64], ? 1 : [175*175 int64]}
425425

426-
int64 = -9223372036854775808 .. 9223372036854775807
426+
int64 = min_int64 .. max_int64
427+
428+
min_int64 = -9223372036854775808
429+
430+
max_int64 = 9223372036854775807
427431

428432
ex_unit_prices = [mem_price : positive_interval, step_price : positive_interval]
429433

@@ -578,5 +582,5 @@ transaction =
578582
; 1: Plutus v2
579583
language = 0/ 1
580584

581-
signkeyKES = bytes .size 64
585+
signkey_kes = bytes .size 64
582586

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

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,17 @@
1010

1111
module Test.Cardano.Ledger.Babbage.CDDL (
1212
module Test.Cardano.Ledger.Alonzo.CDDL,
13-
module Test.Cardano.Ledger.Babbage.CDDL,
13+
babbageCDDL,
14+
operational_cert,
15+
babbage_transaction_output,
16+
plutus_data,
1417
) where
1518

1619
import Cardano.Ledger.Babbage (BabbageEra)
1720
import Codec.CBOR.Cuddle.Huddle
1821
import Data.Word (Word64)
1922
import Test.Cardano.Ledger.Alonzo.CDDL hiding (
20-
auxiliary_data,
21-
block,
22-
cost_models,
23-
header,
24-
header_body,
25-
language,
2623
operational_cert,
27-
plutus_data,
28-
plutus_script,
29-
proposed_protocol_parameter_updates,
30-
protocol_param_update,
31-
protocol_version,
32-
script_data_hash,
33-
script_n_of_k,
34-
transaction,
35-
transaction_body,
36-
transaction_output,
37-
transaction_witness_set,
38-
update,
3924
)
4025
import Text.Heredoc
4126
import Prelude hiding ((/))
@@ -47,7 +32,7 @@ babbageCDDL =
4732
, HIRule transaction
4833
, HIRule kes_signature
4934
, HIRule language
50-
, HIRule signkeyKES
35+
, HIRule signkey_kes
5136
]
5237

5338
block :: Rule
@@ -128,7 +113,7 @@ transaction_body =
128113
|]
129114
$ "transaction_body"
130115
=:= mp
131-
[ idx 0 ==> set transaction_input
116+
[ idx 0 ==> untagged_set transaction_input
132117
, idx 1 ==> arr [0 <+ a transaction_output]
133118
, idx 2 ==> coin
134119
, opt (idx 3 ==> VUInt)
@@ -139,12 +124,12 @@ transaction_body =
139124
, opt (idx 8 ==> VUInt)
140125
, opt (idx 9 ==> mint)
141126
, opt (idx 11 ==> script_data_hash)
142-
, opt (idx 13 ==> set transaction_input)
127+
, opt (idx 13 ==> untagged_set transaction_input)
143128
, opt (idx 14 ==> required_signers)
144129
, opt (idx 15 ==> network_id)
145130
, opt (idx 16 ==> transaction_output)
146131
, opt (idx 17 ==> coin)
147-
, opt (idx 18 ==> set transaction_input)
132+
, opt (idx 18 ==> untagged_set transaction_input)
148133
]
149134

150135
-- TODO: Allow for adding to the comments of a Rule in order to not have to

eras/conway/impl/cddl-files/conway.cddl

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ language = 0/ 1/ 2
2323

2424
potential_languages = 0 .. 255
2525

26-
signkeyKES = bytes .size 64
26+
signkey_kes = bytes .size 64
2727

2828
certificate =
2929
[ stake_registration
@@ -228,9 +228,9 @@ hash28 = bytes .size 28
228228

229229
asset_name = bytes .size (0 .. 32)
230230

231-
positive_coin = 1 .. maxWord64
231+
positive_coin = 1 .. max_word64
232232

233-
maxWord64 = 18446744073709551615
233+
max_word64 = 18446744073709551615
234234

235235
; NEW starting with babbage
236236
; datum_option
@@ -309,7 +309,11 @@ script_any = (2, [* native_script])
309309

310310
script_n_of_k = (3, n : int64, [* native_script])
311311

312-
int64 = -9223372036854775808 .. 9223372036854775807
312+
int64 = min_int64 .. max_int64
313+
314+
min_int64 = -9223372036854775808
315+
316+
max_int64 = 9223372036854775807
313317

314318
invalid_before = (4, slot_no)
315319

@@ -321,21 +325,21 @@ invalid_hereafter = (5, slot_no)
321325
; around for tests in order to avoid generating duplicates, since
322326
; the cddl tool we use for roundtrip testing doesn't generate
323327
; distinct collections.
324-
plutus_v1_script = distinct_VBytes
328+
plutus_v1_script = distinct_bytes
325329

326330
; A type for distinct values.
327331
; The type parameter must support .size, for example: bytes or uint
328-
distinct_VBytes =
332+
distinct_bytes =
329333
bytes .size 8
330334
/ bytes .size 16
331335
/ bytes .size 20
332336
/ bytes .size 24
333337
/ bytes .size 30
334338
/ bytes .size 32
335339

336-
plutus_v2_script = distinct_VBytes
340+
plutus_v2_script = distinct_bytes
337341

338-
plutus_v3_script = distinct_VBytes
342+
plutus_v3_script = distinct_bytes
339343

340344
certificates = nonempty_oset<certificate>
341345

@@ -425,13 +429,13 @@ withdrawals = {+ reward_account => coin}
425429

426430
auxiliary_data_hash = hash32
427431

428-
mint = {+ policy_id => {+ asset_name => nonZeroInt64}}
432+
mint = {+ policy_id => {+ asset_name => nonzero_int64}}
429433

430-
nonZeroInt64 = negInt64/ posInt64
434+
nonzero_int64 = negative_int64/ positive_int64
431435

432-
negInt64 = -9223372036854775808 .. -1
436+
negative_int64 = min_int64 .. -1
433437

434-
posInt64 = 1 .. 9223372036854775807
438+
positive_int64 = 1 .. max_int64
435439

436440
; This is a hash of data which may affect evaluation of a script.
437441
; This data consists of:
@@ -586,7 +590,7 @@ epoch_interval = uint .size 4
586590

587591
nonnegative_interval = #6.30([uint, positive_int])
588592

589-
positive_int = 1 .. maxWord64
593+
positive_int = 1 .. max_word64
590594

591595
; The format for cost_models is flexible enough to allow adding
592596
; Plutus built-ins and language versions in the future.

0 commit comments

Comments
 (0)