Skip to content

Commit e74f56f

Browse files
authored
Merge pull request #5217 from IntersectMBO/aniketd/oset-cddl
Conway/Dijkstra CDDL: OSet for certs and proposals
2 parents a00bc60 + b38a758 commit e74f56f

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ plutus_v2_script = distinct_VBytes
337337

338338
plutus_v3_script = distinct_VBytes
339339

340-
certificates = nonempty_set<certificate>
340+
certificates = nonempty_oset<certificate>
341341

342-
nonempty_set<a0> = #6.258([+ a0])/ [+ a0]
342+
nonempty_oset<a0> = #6.258([+ a0])/ [+ a0]
343343

344344
stake_credential = credential
345345

@@ -501,6 +501,8 @@ posInt64 = 1 .. 9223372036854775807
501501
; representation for empty redeemers.
502502
script_data_hash = hash32
503503

504+
nonempty_set<a0> = #6.258([+ a0])/ [+ a0]
505+
504506
required_signers = nonempty_set<addr_keyhash>
505507

506508
network_id = 0/ 1
@@ -528,7 +530,7 @@ voting_procedure = [vote, anchor/ nil]
528530

529531
vote = 0 .. 2
530532

531-
proposal_procedures = nonempty_set<proposal_procedure>
533+
proposal_procedures = nonempty_oset<proposal_procedure>
532534

533535
proposal_procedure = [deposit : coin, reward_account, gov_action, anchor]
534536

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Cardano.Ledger.Conway (ConwayEra)
1717
import Codec.CBOR.Cuddle.Comments ((//-))
1818
import Codec.CBOR.Cuddle.Huddle
1919
import Data.Function (($))
20+
import Data.Text (Text)
2021
import Data.Word (Word64)
2122
import GHC.Num (Integer)
2223
import Test.Cardano.Ledger.Babbage.CDDL hiding (
@@ -201,10 +202,10 @@ proposal_procedure =
201202
]
202203

203204
proposal_procedures :: Rule
204-
proposal_procedures = "proposal_procedures" =:= nonempty_set proposal_procedure
205+
proposal_procedures = "proposal_procedures" =:= nonempty_oset proposal_procedure
205206

206207
certificates :: Rule
207-
certificates = "certificates" =:= nonempty_set certificate
208+
certificates = "certificates" =:= nonempty_oset certificate
208209

209210
gov_action :: Rule
210211
gov_action =
@@ -842,14 +843,22 @@ conway_script =
842843
-- tooling to account for this future breaking change sooner rather than
843844
-- later, in order to provide a smooth transition for their users.
844845
set :: IsType0 t0 => t0 -> GRuleCall
845-
set = binding $ \x -> "set" =:= tag 258 (arr [0 <+ a x]) / sarr [0 <+ a x]
846+
set = set_len_spec "set" 0
846847

847848
-- | Conway era introduces an optional 258 tag for sets, which will
848849
-- become mandatory in the second era after Conway. We recommend all the
849850
-- tooling to account for this future breaking change sooner rather than
850851
-- later, in order to provide a smooth transition for their users.
851852
nonempty_set :: IsType0 t0 => t0 -> GRuleCall
852-
nonempty_set = binding $ \x ->
853-
"nonempty_set"
854-
=:= tag 258 (arr [1 <+ a x])
855-
/ sarr [1 <+ a x]
853+
nonempty_set = set_len_spec "nonempty_set" 1
854+
855+
-- | An OSet is a Set that preserves the order of its elements.
856+
oset :: IsType0 t0 => t0 -> GRuleCall
857+
oset = set_len_spec "oset" 0
858+
859+
-- | An NonEmpty OSet is a NonEmpty Set that preserves the order of its elements.
860+
nonempty_oset :: IsType0 t0 => t0 -> GRuleCall
861+
nonempty_oset = set_len_spec "nonempty_oset" 1
862+
863+
set_len_spec :: IsType0 t0 => Text -> Word64 -> t0 -> GRuleCall
864+
set_len_spec label n = binding $ \x -> label =:= tag 258 (arr [n <+ a x]) / sarr [n <+ a x]

eras/dijkstra/cddl-files/dijkstra.cddl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ plutus_v2_script = distinct_VBytes
337337

338338
plutus_v3_script = distinct_VBytes
339339

340-
certificates = nonempty_set<certificate>
340+
certificates = nonempty_oset<certificate>
341341

342-
nonempty_set<a0> = #6.258([+ a0])/ [+ a0]
342+
nonempty_oset<a0> = #6.258([+ a0])/ [+ a0]
343343

344344
stake_credential = credential
345345

@@ -501,6 +501,8 @@ posInt64 = 1 .. 9223372036854775807
501501
; representation for empty redeemers.
502502
script_data_hash = hash32
503503

504+
nonempty_set<a0> = #6.258([+ a0])/ [+ a0]
505+
504506
required_signers = nonempty_set<addr_keyhash>
505507

506508
network_id = 0/ 1
@@ -528,7 +530,7 @@ voting_procedure = [vote, anchor/ nil]
528530

529531
vote = 0 .. 2
530532

531-
proposal_procedures = nonempty_set<proposal_procedure>
533+
proposal_procedures = nonempty_oset<proposal_procedure>
532534

533535
proposal_procedure = [deposit : coin, reward_account, gov_action, anchor]
534536

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ proposal_procedure =
169169
]
170170

171171
proposal_procedures :: Rule
172-
proposal_procedures = "proposal_procedures" =:= nonempty_set proposal_procedure
172+
proposal_procedures = "proposal_procedures" =:= nonempty_oset proposal_procedure
173173

174174
certificates :: Rule
175-
certificates = "certificates" =:= nonempty_set certificate
175+
certificates = "certificates" =:= nonempty_oset certificate
176176

177177
gov_action :: Rule
178178
gov_action =

0 commit comments

Comments
 (0)