From 0b5dbe4c120edae5157e95a69286110e1252c9f2 Mon Sep 17 00:00:00 2001 From: Aniket Deshpande Date: Wed, 29 Oct 2025 19:08:52 +0530 Subject: [PATCH 1/3] CDDL: Consolidate nonce, slot, epoch & block_number Remove all wrong definitions from later eras and add the correct definitions to core. --- eras/allegra/impl/CHANGELOG.md | 1 + eras/allegra/impl/cddl-files/allegra.cddl | 18 ++++++----- .../Test/Cardano/Ledger/Allegra/CDDL.hs | 8 ++--- eras/alonzo/impl/CHANGELOG.md | 1 + eras/alonzo/impl/cddl-files/alonzo.cddl | 18 ++++++----- .../Test/Cardano/Ledger/Alonzo/CDDL.hs | 8 ++--- eras/babbage/impl/CHANGELOG.md | 1 + eras/babbage/impl/cddl-files/babbage.cddl | 18 ++++++----- .../Test/Cardano/Ledger/Babbage/CDDL.hs | 8 ++--- eras/conway/impl/CHANGELOG.md | 1 + eras/conway/impl/cddl-files/conway.cddl | 30 +++++++++---------- .../Test/Cardano/Ledger/Conway/CDDL.hs | 27 +++++------------ eras/dijkstra/impl/cddl-files/dijkstra.cddl | 30 +++++++++---------- .../Test/Cardano/Ledger/Dijkstra/CDDL.hs | 8 ++--- eras/mary/impl/CHANGELOG.md | 4 +++ eras/mary/impl/cddl-files/mary.cddl | 18 ++++++----- .../testlib/Test/Cardano/Ledger/Mary/CDDL.hs | 4 +-- eras/shelley/impl/CHANGELOG.md | 1 + eras/shelley/impl/cddl-files/shelley.cddl | 12 +++++--- .../Test/Cardano/Ledger/Shelley/CDDL.hs | 14 ++------- libs/cardano-ledger-core/CHANGELOG.md | 1 + .../Test/Cardano/Ledger/Core/Binary/CDDL.hs | 16 ++++++++++ 22 files changed, 137 insertions(+), 110 deletions(-) diff --git a/eras/allegra/impl/CHANGELOG.md b/eras/allegra/impl/CHANGELOG.md index c39c5e47121..b8a14a9b808 100644 --- a/eras/allegra/impl/CHANGELOG.md +++ b/eras/allegra/impl/CHANGELOG.md @@ -11,6 +11,7 @@ ### `testlib` +* Use fixed-sized `uint .size 8` for `slot` in CDDL for timelock validity intervals * Add `impSatisfyMNativeScripts` * Add `impSatisfySignature` diff --git a/eras/allegra/impl/cddl-files/allegra.cddl b/eras/allegra/impl/cddl-files/allegra.cddl index 13bea52c9fb..186d44c1de8 100644 --- a/eras/allegra/impl/cddl-files/allegra.cddl +++ b/eras/allegra/impl/cddl-files/allegra.cddl @@ -11,8 +11,8 @@ block = header = [header_body, body_signature : kes_signature] header_body = - [ block_number : uint - , slot : uint + [ block_number : block_number + , slot : slot , prev_hash : hash32/ nil , issuer_vkey : vkey , vrf_vkey : vrf_vkey @@ -25,6 +25,10 @@ header_body = ] +block_number = uint .size 8 + +slot = uint .size 8 + hash32 = bytes .size 32 vkey = bytes .size 32 @@ -55,12 +59,12 @@ transaction_body = { 0 : set , 1 : [* transaction_output] , 2 : coin - , ? 3 : uint + , ? 3 : slot , ? 4 : [* certificate] , ? 5 : withdrawals , ? 6 : update , ? 7 : metadata_hash - , ? 8 : uint + , ? 8 : slot } @@ -216,7 +220,7 @@ url = text .size (0 .. 64) pool_retirement = (4, pool_keyhash, epoch) -epoch = uint +epoch = uint .size 8 genesis_key_delegation = (5, genesis_hash, genesis_delegate_hash, vrf_keyhash) @@ -311,9 +315,9 @@ min_int64 = -9223372036854775808 max_int64 = 9223372036854775807 -invalid_before = (4, uint) +invalid_before = (4, slot) -invalid_hereafter = (5, uint) +invalid_hereafter = (5, slot) bootstrap_witness = [ public_key : vkey diff --git a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/CDDL.hs b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/CDDL.hs index c3b15a8f51b..3debc13fb72 100644 --- a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/CDDL.hs +++ b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/CDDL.hs @@ -70,10 +70,10 @@ script_n_of_k :: Named Group script_n_of_k = "script_n_of_k" =:~ grp [3, "n" ==> int64, a (arr [0 <+ a native_script])] invalid_before :: Named Group -invalid_before = "invalid_before" =:~ grp [4, a VUInt] +invalid_before = "invalid_before" =:~ grp [4, a slot] invalid_hereafter :: Named Group -invalid_hereafter = "invalid_hereafter" =:~ grp [5, a VUInt] +invalid_hereafter = "invalid_hereafter" =:~ grp [5, a slot] metadata :: Rule metadata = "metadata" =:= mp [0 <+ asKey transaction_metadatum_label ==> transaction_metadatum] @@ -100,12 +100,12 @@ transaction_body = [ idx 0 ==> untagged_set transaction_input , idx 1 ==> arr [0 <+ a transaction_output] , idx 2 ==> coin - , opt (idx 3 ==> VUInt) + , opt (idx 3 ==> slot) , opt (idx 4 ==> arr [0 <+ a certificate]) , opt (idx 5 ==> withdrawals) , opt (idx 6 ==> update @era) , opt (idx 7 ==> metadata_hash) - , opt (idx 8 ==> VUInt) + , opt (idx 8 ==> slot) ] block :: forall era. Era era => Rule diff --git a/eras/alonzo/impl/CHANGELOG.md b/eras/alonzo/impl/CHANGELOG.md index f42c26074c9..8985801257d 100644 --- a/eras/alonzo/impl/CHANGELOG.md +++ b/eras/alonzo/impl/CHANGELOG.md @@ -25,6 +25,7 @@ ### `testlib` +* Use fixed-sized `uint .size 8` for `slot` and `block_number` in CDDL for header * Add `NativeScript` parameter to `exampleTx` ## 1.14.0.0 diff --git a/eras/alonzo/impl/cddl-files/alonzo.cddl b/eras/alonzo/impl/cddl-files/alonzo.cddl index 5ff9d2ca5db..980ab86bbbb 100644 --- a/eras/alonzo/impl/cddl-files/alonzo.cddl +++ b/eras/alonzo/impl/cddl-files/alonzo.cddl @@ -20,8 +20,8 @@ header = [header_body, body_signature : kes_signature] ; block_body_size: merkle triple root header_body = - [ block_number : uint - , slot : uint + [ block_number : block_number + , slot : slot , prev_hash : hash32/ nil , issuer_vkey : vkey , vrf_vkey : vrf_vkey @@ -34,6 +34,10 @@ header_body = ] +block_number = uint .size 8 + +slot = uint .size 8 + hash32 = bytes .size 32 vkey = bytes .size 32 @@ -72,12 +76,12 @@ transaction_body = { 0 : set , 1 : [* transaction_output] , 2 : coin - , ? 3 : uint + , ? 3 : slot , ? 4 : [* certificate] , ? 5 : withdrawals , ? 6 : update , ? 7 : auxiliary_data_hash - , ? 8 : uint + , ? 8 : slot , ? 9 : mint , ? 11 : script_data_hash , ? 13 : set @@ -248,7 +252,7 @@ url = text .size (0 .. 64) pool_retirement = (4, pool_keyhash, epoch) -epoch = uint +epoch = uint .size 8 genesis_key_delegation = (5, genesis_hash, genesis_delegate_hash, vrf_keyhash) @@ -470,9 +474,9 @@ script_any = (2, [* native_script]) script_n_of_k = (3, n : uint, [* native_script]) -invalid_before = (4, uint) +invalid_before = (4, slot) -invalid_hereafter = (5, uint) +invalid_hereafter = (5, slot) bootstrap_witness = [ public_key : vkey diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs index 712ce89d5d6..0bb337f1cb3 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs @@ -96,12 +96,12 @@ transaction_body = [ idx 0 ==> untagged_set transaction_input , idx 1 ==> arr [0 <+ a transaction_output] , idx 2 ==> coin - , opt (idx 3 ==> VUInt) + , opt (idx 3 ==> slot) , opt (idx 4 ==> arr [0 <+ a certificate]) , opt (idx 5 ==> withdrawals) , opt (idx 6 ==> update) , opt (idx 7 ==> auxiliary_data_hash) - , opt (idx 8 ==> VUInt) + , opt (idx 8 ==> slot) , opt (idx 9 ==> mint) , opt (idx 11 ==> script_data_hash) , opt (idx 13 ==> untagged_set transaction_input) @@ -390,8 +390,8 @@ header_body = |] $ "header_body" =:= arr - [ "block_number" ==> VUInt - , "slot" ==> VUInt + [ "block_number" ==> block_number + , "slot" ==> slot , "prev_hash" ==> (hash32 / VNil) , "issuer_vkey" ==> vkey , "vrf_vkey" ==> vrf_vkey diff --git a/eras/babbage/impl/CHANGELOG.md b/eras/babbage/impl/CHANGELOG.md index df1bf511f03..a28295dd08a 100644 --- a/eras/babbage/impl/CHANGELOG.md +++ b/eras/babbage/impl/CHANGELOG.md @@ -26,6 +26,7 @@ ### `testlib` +* Use fixed-sized `uint .size 8` for `slot` and `block_number` in CDDL for header * Add `BabbageEraImp` * Removed `babbageEraSpecificSpec` diff --git a/eras/babbage/impl/cddl-files/babbage.cddl b/eras/babbage/impl/cddl-files/babbage.cddl index 84bddf2f93b..46155015fae 100644 --- a/eras/babbage/impl/cddl-files/babbage.cddl +++ b/eras/babbage/impl/cddl-files/babbage.cddl @@ -19,8 +19,8 @@ header = [header_body, body_signature : kes_signature] ; block_body_size: merkle triple root ; vrf_result: NEW, replaces nonce_vrf and leader_vrf header_body = - [ block_number : uint - , slot : uint + [ block_number : block_number + , slot : slot , prev_hash : hash32/ nil , issuer_vkey : vkey , vrf_vkey : vrf_vkey @@ -32,6 +32,10 @@ header_body = ] +block_number = uint .size 8 + +slot = uint .size 8 + hash32 = bytes .size 32 vkey = bytes .size 32 @@ -70,12 +74,12 @@ transaction_body = { 0 : set , 1 : [* transaction_output] , 2 : coin - , ? 3 : uint + , ? 3 : slot , ? 4 : [* certificate] , ? 5 : withdrawals , ? 6 : update , ? 7 : auxiliary_data_hash - , ? 8 : uint + , ? 8 : slot , ? 9 : mint , ? 11 : script_data_hash , ? 13 : set @@ -243,9 +247,9 @@ script_any = (2, [* native_script]) script_n_of_k = (3, n : uint, [* native_script]) -invalid_before = (4, uint) +invalid_before = (4, slot) -invalid_hereafter = (5, uint) +invalid_hereafter = (5, slot) plutus_v1_script = bytes @@ -337,7 +341,7 @@ url = text .size (0 .. 64) pool_retirement = (4, pool_keyhash, epoch) -epoch = uint +epoch = uint .size 8 genesis_key_delegation = (5, genesis_hash, genesis_delegate_hash, vrf_keyhash) diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs index 4df9899b185..fce9f8b357e 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs @@ -74,8 +74,8 @@ header_body = |] $ "header_body" =:= arr - [ "block_number" ==> VUInt - , "slot" ==> VUInt + [ "block_number" ==> block_number + , "slot" ==> slot , "prev_hash" ==> (hash32 / VNil) , "issuer_vkey" ==> vkey , "vrf_vkey" ==> vrf_vkey @@ -116,12 +116,12 @@ transaction_body = [ idx 0 ==> untagged_set transaction_input , idx 1 ==> arr [0 <+ a transaction_output] , idx 2 ==> coin - , opt (idx 3 ==> VUInt) + , opt (idx 3 ==> slot) , opt (idx 4 ==> arr [0 <+ a certificate]) , opt (idx 5 ==> withdrawals) , opt (idx 6 ==> update) , opt (idx 7 ==> auxiliary_data_hash) - , opt (idx 8 ==> VUInt) + , opt (idx 8 ==> slot) , opt (idx 9 ==> mint) , opt (idx 11 ==> script_data_hash) , opt (idx 13 ==> untagged_set transaction_input) diff --git a/eras/conway/impl/CHANGELOG.md b/eras/conway/impl/CHANGELOG.md index b0890c1fb66..410b8db8865 100644 --- a/eras/conway/impl/CHANGELOG.md +++ b/eras/conway/impl/CHANGELOG.md @@ -15,6 +15,7 @@ ### `testlib` +* Remove `epoch_no`, `slot_no` and `block_no` reuse definitions from core * Removed `regDelegToDRep` * Removed `registerRewardAccountWithDeposit` * Removed `registerPoolWithDeposit` diff --git a/eras/conway/impl/cddl-files/conway.cddl b/eras/conway/impl/cddl-files/conway.cddl index 5161784f36c..d4c78b46226 100644 --- a/eras/conway/impl/cddl-files/conway.cddl +++ b/eras/conway/impl/cddl-files/conway.cddl @@ -56,7 +56,7 @@ stake_delegation = (2, stake_credential, pool_keyhash) pool_registration = (3, pool_params) -pool_retirement = (4, pool_keyhash, epoch_no) +pool_retirement = (4, pool_keyhash, epoch) reg_cert = (7, stake_credential, coin) @@ -86,8 +86,8 @@ update_drep_cert = (18, drep_credential, anchor/ nil) header = [header_body, body_signature : kes_signature] header_body = - [ block_number : block_no - , slot : slot_no + [ block_number : block_number + , slot : slot , prev_hash : hash32/ nil , issuer_vkey : vkey , vrf_vkey : vrf_vkey @@ -99,9 +99,9 @@ header_body = ] -block_no = uint .size 8 +block_number = uint .size 8 -slot_no = uint .size 8 +slot = uint .size 8 hash32 = bytes .size 32 @@ -131,11 +131,11 @@ transaction_body = { 0 : set , 1 : [* transaction_output] , 2 : coin - , ? 3 : slot_no + , ? 3 : slot , ? 4 : certificates , ? 5 : withdrawals , ? 7 : auxiliary_data_hash - , ? 8 : slot_no + , ? 8 : slot , ? 9 : mint , ? 11 : script_data_hash , ? 13 : nonempty_set @@ -315,9 +315,9 @@ min_int64 = -9223372036854775808 max_int64 = 9223372036854775807 -invalid_before = (4, slot_no) +invalid_before = (4, slot) -invalid_hereafter = (5, slot_no) +invalid_hereafter = (5, slot) ; The real type of plutus_v1_script, plutus_v2_script and ; plutus_v3_script is bytes. However, because we enforce @@ -413,7 +413,7 @@ pool_metadata = [url, bytes] url = text .size (0 .. 128) -epoch_no = uint .size 8 +epoch = uint .size 8 drep = [0, addr_keyhash// 1, script_hash// 2// 3] @@ -640,11 +640,11 @@ treasury_withdrawals_action = (2, {* reward_account => coin}, policy_hash/ nil) no_confidence = (3, gov_action_id/ nil) update_committee = - ( 4 - , gov_action_id/ nil - , set - , {* committee_cold_credential => epoch_no} - , unit_interval + ( 4 + , gov_action_id/ nil + , set + , {* committee_cold_credential => epoch} + , unit_interval ) new_constitution = (5, gov_action_id/ nil, constitution) diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs index bdab50c292f..29aca46cb31 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs @@ -26,8 +26,6 @@ module Test.Cardano.Ledger.Conway.CDDL ( reg_drep_cert, unreg_drep_cert, update_drep_cert, - block_no, - slot_no, transaction_input, withdrawals, mint, @@ -168,8 +166,8 @@ header_body :: Rule header_body = "header_body" =:= arr - [ "block_number" ==> block_no - , "slot" ==> slot_no + [ "block_number" ==> block_number + , "slot" ==> slot , "prev_hash" ==> (hash32 / VNil) , "issuer_vkey" ==> vkey , "vrf_vkey" ==> vrf_vkey @@ -190,11 +188,11 @@ transaction_body = [ idx 0 ==> maybe_tagged_set transaction_input , idx 1 ==> arr [0 <+ a transaction_output] , idx 2 ==> coin - , opt (idx 3 ==> slot_no) + , opt (idx 3 ==> slot) , opt (idx 4 ==> certificates) , opt (idx 5 ==> withdrawals) , opt (idx 7 ==> auxiliary_data_hash) - , opt (idx 8 ==> slot_no) -- Validity interval start + , opt (idx 8 ==> slot) -- Validity interval start , opt (idx 9 ==> mint) , opt (idx 11 ==> script_data_hash) , opt (idx 13 ==> maybe_tagged_nonempty_set transaction_input) @@ -277,7 +275,7 @@ update_committee = [ 4 , a $ gov_action_id / VNil , a (maybe_tagged_set committee_cold_credential) - , a (mp [0 <+ asKey committee_cold_credential ==> epoch_no]) + , a (mp [0 <+ asKey committee_cold_credential ==> epoch]) , a unit_interval ] @@ -452,7 +450,7 @@ pool_registration :: Named Group pool_registration = "pool_registration" =:~ grp [3, a pool_params] pool_retirement :: Named Group -pool_retirement = "pool_retirement" =:~ grp [4, a pool_keyhash, a epoch_no] +pool_retirement = "pool_retirement" =:~ grp [4, a pool_keyhash, a epoch] -- numbers 5 and 6 used to be the Genesis and MIR certificates respectively, -- which were deprecated in Conway @@ -828,10 +826,10 @@ script_n_of_k = =:~ grp [3, "n" ==> int64, a (arr [0 <+ a native_script])] invalid_before :: Named Group -invalid_before = "invalid_before" =:~ grp [4, a slot_no] +invalid_before = "invalid_before" =:~ grp [4, a slot] invalid_hereafter :: Named Group -invalid_hereafter = "invalid_hereafter" =:~ grp [5, a slot_no] +invalid_hereafter = "invalid_hereafter" =:~ grp [5, a slot] multiasset :: IsType0 a => a -> GRuleCall multiasset = binding $ \x -> @@ -844,18 +842,9 @@ value = "value" =:= coin / sarr [a coin, a (multiasset positive_coin)] mint :: Rule mint = "mint" =:= mp [1 <+ asKey policy_id ==> mp [1 <+ asKey asset_name ==> nonzero_int64]] -epoch_no :: Rule -epoch_no = "epoch_no" =:= VUInt `sized` (8 :: Word64) - epoch_interval :: Rule epoch_interval = "epoch_interval" =:= VUInt `sized` (4 :: Word64) -slot_no :: Rule -slot_no = "slot_no" =:= VUInt `sized` (8 :: Word64) - -block_no :: Rule -block_no = "block_no" =:= VUInt `sized` (8 :: Word64) - conway_script :: Rule conway_script = "script" diff --git a/eras/dijkstra/impl/cddl-files/dijkstra.cddl b/eras/dijkstra/impl/cddl-files/dijkstra.cddl index 2a6b7ae6c98..18ac9d14414 100644 --- a/eras/dijkstra/impl/cddl-files/dijkstra.cddl +++ b/eras/dijkstra/impl/cddl-files/dijkstra.cddl @@ -56,7 +56,7 @@ stake_delegation = (2, stake_credential, pool_keyhash) pool_registration = (3, pool_params) -pool_retirement = (4, pool_keyhash, epoch_no) +pool_retirement = (4, pool_keyhash, epoch) reg_cert = (7, stake_credential, coin) @@ -86,8 +86,8 @@ update_drep_cert = (18, drep_credential, anchor/ nil) header = [header_body, body_signature : kes_signature] header_body = - [ block_number : block_no - , slot : slot_no + [ block_number : block_number + , slot : slot , prev_hash : hash32/ nil , issuer_vkey : vkey , vrf_vkey : vrf_vkey @@ -99,9 +99,9 @@ header_body = ] -block_no = uint .size 8 +block_number = uint .size 8 -slot_no = uint .size 8 +slot = uint .size 8 hash32 = bytes .size 32 @@ -131,11 +131,11 @@ transaction_body = { 0 : set , 1 : [* transaction_output] , 2 : coin - , ? 3 : slot_no + , ? 3 : slot , ? 4 : certificates , ? 5 : withdrawals , ? 7 : auxiliary_data_hash - , ? 8 : slot_no + , ? 8 : slot , ? 9 : mint , ? 11 : script_data_hash , ? 13 : nonempty_set @@ -317,9 +317,9 @@ min_int64 = -9223372036854775808 max_int64 = 9223372036854775807 -invalid_before = (4, slot_no) +invalid_before = (4, slot) -invalid_hereafter = (5, slot_no) +invalid_hereafter = (5, slot) script_require_guard = (6, credential) @@ -419,7 +419,7 @@ pool_metadata = [url, bytes] url = text .size (0 .. 128) -epoch_no = uint .size 8 +epoch = uint .size 8 drep = [0, addr_keyhash// 1, script_hash// 2// 3] @@ -656,11 +656,11 @@ treasury_withdrawals_action = (2, {* reward_account => coin}, policy_hash/ nil) no_confidence = (3, gov_action_id/ nil) update_committee = - ( 4 - , gov_action_id/ nil - , set - , {* committee_cold_credential => epoch_no} - , unit_interval + ( 4 + , gov_action_id/ nil + , set + , {* committee_cold_credential => epoch} + , unit_interval ) new_constitution = (5, gov_action_id/ nil, constitution) diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/CDDL.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/CDDL.hs index c715ea797a1..98f507ae169 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/CDDL.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/CDDL.hs @@ -96,8 +96,8 @@ header_body :: Rule header_body = "header_body" =:= arr - [ "block_number" ==> block_no - , "slot" ==> slot_no + [ "block_number" ==> block_number + , "slot" ==> slot , "prev_hash" ==> (hash32 / VNil) , "issuer_vkey" ==> vkey , "vrf_vkey" ==> vrf_vkey @@ -118,11 +118,11 @@ transaction_body = [ idx 0 ==> maybe_tagged_set transaction_input , idx 1 ==> arr [0 <+ a transaction_output] , idx 2 ==> coin - , opt (idx 3 ==> slot_no) + , opt (idx 3 ==> slot) , opt (idx 4 ==> certificates) , opt (idx 5 ==> withdrawals) , opt (idx 7 ==> auxiliary_data_hash) - , opt (idx 8 ==> slot_no) -- Validity interval start + , opt (idx 8 ==> slot) -- Validity interval start , opt (idx 9 ==> mint) , opt (idx 11 ==> script_data_hash) , opt (idx 13 ==> maybe_tagged_nonempty_set transaction_input) diff --git a/eras/mary/impl/CHANGELOG.md b/eras/mary/impl/CHANGELOG.md index e99ffc98d92..5a376e5bd70 100644 --- a/eras/mary/impl/CHANGELOG.md +++ b/eras/mary/impl/CHANGELOG.md @@ -7,6 +7,10 @@ * Add `HasEraTxLevel` instances for `Tx` and `TxBody` * Add `EraTxLevel` instance +### `testlib` + +* Use fixed-sized `uint .size 8` for `slot` in CDDL for transaction validity intervals + ## 1.9.0.0 * Hide `Cardano.Ledger.Mary.Translation` module diff --git a/eras/mary/impl/cddl-files/mary.cddl b/eras/mary/impl/cddl-files/mary.cddl index 2830c7aff64..e2c7ea0a692 100644 --- a/eras/mary/impl/cddl-files/mary.cddl +++ b/eras/mary/impl/cddl-files/mary.cddl @@ -11,8 +11,8 @@ block = header = [header_body, body_signature : kes_signature] header_body = - [ block_number : uint - , slot : uint + [ block_number : block_number + , slot : slot , prev_hash : hash32/ nil , issuer_vkey : vkey , vrf_vkey : vrf_vkey @@ -25,6 +25,10 @@ header_body = ] +block_number = uint .size 8 + +slot = uint .size 8 + hash32 = bytes .size 32 vkey = bytes .size 32 @@ -54,12 +58,12 @@ transaction_body = { 0 : set , 1 : [* transaction_output] , 2 : coin - , ? 3 : uint + , ? 3 : slot , ? 4 : [* certificate] , ? 5 : withdrawals , ? 6 : update , ? 7 : metadata_hash - , ? 8 : uint + , ? 8 : slot , ? 9 : mint } @@ -224,7 +228,7 @@ url = text .size (0 .. 64) pool_retirement = (4, pool_keyhash, epoch) -epoch = uint +epoch = uint .size 8 genesis_key_delegation = (5, genesis_hash, genesis_delegate_hash, vrf_keyhash) @@ -321,9 +325,9 @@ script_any = (2, [* native_script]) script_n_of_k = (3, n : int64, [* native_script]) -invalid_before = (4, uint) +invalid_before = (4, slot) -invalid_hereafter = (5, uint) +invalid_hereafter = (5, slot) bootstrap_witness = [ public_key : vkey diff --git a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/CDDL.hs b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/CDDL.hs index 10ad0a3587e..634968a4773 100644 --- a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/CDDL.hs +++ b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/CDDL.hs @@ -58,12 +58,12 @@ transaction_body = [ idx 0 ==> untagged_set transaction_input , idx 1 ==> arr [0 <+ a transaction_output] , idx 2 ==> coin - , opt (idx 3 ==> VUInt) + , opt (idx 3 ==> slot) , opt (idx 4 ==> arr [0 <+ a certificate]) , opt (idx 5 ==> withdrawals) , opt (idx 6 ==> update @era) , opt (idx 7 ==> metadata_hash) - , opt (idx 8 ==> VUInt) + , opt (idx 8 ==> slot) , opt (idx 9 ==> mint) ] diff --git a/eras/shelley/impl/CHANGELOG.md b/eras/shelley/impl/CHANGELOG.md index 7f6227ae75a..9868b99da9e 100644 --- a/eras/shelley/impl/CHANGELOG.md +++ b/eras/shelley/impl/CHANGELOG.md @@ -20,6 +20,7 @@ ### `testlib` +* Move CDDL definition for `nonce`, `epoch`, `slot` and `block_number` to core * Rename `examplePoolParams` to `exampleStakePoolParams` * Removed `shelleyEraSpecificSpec` * Added `shelleyGenUnRegTxCert` diff --git a/eras/shelley/impl/cddl-files/shelley.cddl b/eras/shelley/impl/cddl-files/shelley.cddl index 3ec98f95e80..04087669b38 100644 --- a/eras/shelley/impl/cddl-files/shelley.cddl +++ b/eras/shelley/impl/cddl-files/shelley.cddl @@ -11,8 +11,8 @@ block = header = [header_body, body_signature : kes_signature] header_body = - [ block_number : uint - , slot : uint + [ block_number : block_number + , slot : slot , prev_hash : hash32/ nil , issuer_vkey : vkey , vrf_vkey : vrf_vkey @@ -25,6 +25,10 @@ header_body = ] +block_number = uint .size 8 + +slot = uint .size 8 + hash32 = bytes .size 32 vkey = bytes .size 32 @@ -54,7 +58,7 @@ transaction_body = { 0 : set , 1 : [* transaction_output] , 2 : coin - , 3 : uint + , 3 : slot , ? 4 : [* certificate] , ? 5 : withdrawals , ? 6 : update @@ -214,7 +218,7 @@ url = text .size (0 .. 64) pool_retirement = (4, pool_keyhash, epoch) -epoch = uint +epoch = uint .size 8 genesis_key_delegation = (5, genesis_hash, genesis_delegate_hash, vrf_keyhash) diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs index c9c5080fe60..a3f1670fbc1 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs @@ -27,8 +27,6 @@ module Test.Cardano.Ledger.Shelley.CDDL ( bootstrap_witness, script_hash, major_protocol_version, - epoch, - nonce, genesis_hash, operational_cert, stake_registration, @@ -83,8 +81,8 @@ header_body :: forall era. Era era => Rule header_body = "header_body" =:= arr - [ "block_number" ==> VUInt - , "slot" ==> VUInt + [ "block_number" ==> block_number + , "slot" ==> slot , "prev_hash" ==> (hash32 / VNil) , "issuer_vkey" ==> vkey , "vrf_vkey" ==> vrf_vkey @@ -121,7 +119,7 @@ transaction_body = [ idx 0 ==> untagged_set transaction_input , idx 1 ==> arr [0 <+ a transaction_output] , idx 2 ==> coin - , idx 3 ==> VUInt + , idx 3 ==> slot , opt (idx 4 ==> arr [0 <+ a certificate]) , opt (idx 5 ==> withdrawals) , opt (idx 6 ==> update @era) @@ -364,9 +362,6 @@ multisig_any = "multisig_any" =:~ grp [2, a (arr [0 <+ a multisig_script])] multisig_n_of_k :: Named Group multisig_n_of_k = "multisig_n_of_k" =:~ grp [3, "n" ==> VUInt, a (arr [0 <+ a multisig_script])] -epoch :: Rule -epoch = "epoch" =:= VUInt - genesis_delegate_hash :: Rule genesis_delegate_hash = "genesis_delegate_hash" =:= hash28 @@ -389,6 +384,3 @@ script_hash = metadata_hash :: Rule metadata_hash = "metadata_hash" =:= hash32 - -nonce :: Rule -nonce = "nonce" =:= arr [0] / arr [1, a (VBytes `sized` (32 :: Word64))] diff --git a/libs/cardano-ledger-core/CHANGELOG.md b/libs/cardano-ledger-core/CHANGELOG.md index ca88f2fc94e..fb1ff9fd7f1 100644 --- a/libs/cardano-ledger-core/CHANGELOG.md +++ b/libs/cardano-ledger-core/CHANGELOG.md @@ -26,6 +26,7 @@ ### `testlib` +* Add CDDL definition for `nonce`, `epoch`, `slot` and `block_number` * Remove `Test.Cardano.Ledger.Plutus.ExUnits` * Remove the `accountsToUMap` member function from the `EraTest` class. - Also remove the related `accountsFromUMap` function. diff --git a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Binary/CDDL.hs b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Binary/CDDL.hs index bd689167150..9157b4bf3f1 100644 --- a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Binary/CDDL.hs +++ b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Binary/CDDL.hs @@ -44,6 +44,10 @@ module Test.Cardano.Ledger.Core.Binary.CDDL ( untagged_nonempty_set, -- * Network + nonce, + epoch, + slot, + block_number, -- * Hashes, keys and certificates addr_keyhash, @@ -318,3 +322,15 @@ _tagged_oset = mkTaggedSet "oset" 0 _tagged_nonempty_oset :: IsType0 a => a -> GRuleCall _tagged_nonempty_oset = mkTaggedSet "nonempty_oset" 1 + +nonce :: Rule +nonce = "nonce" =:= arr [0] / arr [1, a (VBytes `sized` (32 :: Word64))] + +epoch :: Rule +epoch = "epoch" =:= VUInt `sized` (8 :: Word64) + +slot :: Rule +slot = "slot" =:= VUInt `sized` (8 :: Word64) + +block_number :: Rule +block_number = "block_number" =:= VUInt `sized` (8 :: Word64) From 6944dfb0ffdce20868bd2ae7a619e703e7f654d4 Mon Sep 17 00:00:00 2001 From: Aniket Deshpande Date: Wed, 29 Oct 2025 21:45:45 +0530 Subject: [PATCH 2/3] CDDL: Consolidate protocol_version definitions. Retroactively, correct the definition for sequence_number in the operational_cert. --- eras/allegra/impl/cddl-files/allegra.cddl | 8 +++--- eras/alonzo/impl/CHANGELOG.md | 1 + eras/alonzo/impl/cddl-files/alonzo.cddl | 8 +++--- .../Test/Cardano/Ledger/Alonzo/CDDL.hs | 7 ++--- eras/babbage/impl/CHANGELOG.md | 1 + .../Test/Cardano/Ledger/Babbage/CDDL.hs | 27 ++++++++++++++++--- eras/conway/impl/CHANGELOG.md | 1 + .../Test/Cardano/Ledger/Conway/CDDL.hs | 7 ++--- eras/dijkstra/impl/CHANGELOG.md | 1 + .../Test/Cardano/Ledger/Dijkstra/CDDL.hs | 5 +--- eras/mary/impl/cddl-files/mary.cddl | 8 +++--- eras/shelley/impl/CHANGELOG.md | 2 ++ eras/shelley/impl/cddl-files/shelley.cddl | 8 +++--- .../Test/Cardano/Ledger/Shelley/CDDL.hs | 3 ++- 14 files changed, 52 insertions(+), 35 deletions(-) diff --git a/eras/allegra/impl/cddl-files/allegra.cddl b/eras/allegra/impl/cddl-files/allegra.cddl index 186d44c1de8..14c55d8597b 100644 --- a/eras/allegra/impl/cddl-files/allegra.cddl +++ b/eras/allegra/impl/cddl-files/allegra.cddl @@ -38,10 +38,10 @@ vrf_vkey = bytes .size 32 vrf_cert = [bytes, bytes .size 80] operational_cert = - ( hot_vkey : kes_vkey - , sequence_number : uint - , kes_period : uint - , sigma : signature + ( hot_vkey : kes_vkey + , sequence_number : uint .size 8 + , kes_period : uint + , sigma : signature ) kes_vkey = bytes .size 32 diff --git a/eras/alonzo/impl/CHANGELOG.md b/eras/alonzo/impl/CHANGELOG.md index 8985801257d..41b8c8b97b1 100644 --- a/eras/alonzo/impl/CHANGELOG.md +++ b/eras/alonzo/impl/CHANGELOG.md @@ -26,6 +26,7 @@ ### `testlib` * Use fixed-sized `uint .size 8` for `slot` and `block_number` in CDDL for header +* Remove CDDL `protocol_version` redefinition * Add `NativeScript` parameter to `exampleTx` ## 1.14.0.0 diff --git a/eras/alonzo/impl/cddl-files/alonzo.cddl b/eras/alonzo/impl/cddl-files/alonzo.cddl index 980ab86bbbb..4810114158e 100644 --- a/eras/alonzo/impl/cddl-files/alonzo.cddl +++ b/eras/alonzo/impl/cddl-files/alonzo.cddl @@ -47,10 +47,10 @@ vrf_vkey = bytes .size 32 vrf_cert = [bytes, bytes .size 80] operational_cert = - ( hot_vkey : kes_vkey - , sequence_number : uint - , kes_period : uint - , sigma : signature + ( hot_vkey : kes_vkey + , sequence_number : uint .size 8 + , kes_period : uint + , sigma : signature ) kes_vkey = bytes .size 32 diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs index 0bb337f1cb3..43e9a8f9703 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs @@ -75,9 +75,6 @@ transaction = , a (auxiliary_data / VNil) ] -protocol_version :: Named Group -protocol_version = "protocol_version" =:~ grp [a $ major_protocol_version @AlonzoEra, a VUInt] - transaction_body :: Rule transaction_body = comment @@ -231,7 +228,7 @@ protocol_param_update = , opt (idx 11 ==> unit_interval) , opt (idx 12 ==> unit_interval) , opt (idx 13 ==> nonce) - , opt (idx 14 ==> arr [a protocol_version]) + , opt (idx 14 ==> arr [a (protocol_version @AlonzoEra)]) , opt (idx 16 ==> coin) , opt (idx 17 ==> coin) , opt (idx 18 ==> cost_models) @@ -400,7 +397,7 @@ header_body = , "block_body_size" ==> VUInt , "block_body_hash" ==> hash32 , a operational_cert - , a protocol_version + , a (protocol_version @AlonzoEra) ] native_script :: Rule diff --git a/eras/babbage/impl/CHANGELOG.md b/eras/babbage/impl/CHANGELOG.md index a28295dd08a..c7945e544e3 100644 --- a/eras/babbage/impl/CHANGELOG.md +++ b/eras/babbage/impl/CHANGELOG.md @@ -26,6 +26,7 @@ ### `testlib` +* Hide Shelley CDDL `protocol_version` and re-export a new one for Babbage * Use fixed-sized `uint .size 8` for `slot` and `block_number` in CDDL for header * Add `BabbageEraImp` * Removed `babbageEraSpecificSpec` diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs index fce9f8b357e..b3206700735 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs @@ -1,7 +1,10 @@ +{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ImportQualifiedPost #-} {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE NoImplicitPrelude #-} @@ -14,13 +17,16 @@ module Test.Cardano.Ledger.Babbage.CDDL ( operational_cert, babbage_transaction_output, plutus_data, + protocol_version, ) where import Cardano.Ledger.Babbage (BabbageEra) +import Cardano.Ledger.Core (Era) import Codec.CBOR.Cuddle.Huddle import Data.Word (Word64) import Test.Cardano.Ledger.Alonzo.CDDL hiding ( operational_cert, + protocol_version, ) import Text.Heredoc import Prelude hiding ((/)) @@ -83,7 +89,7 @@ header_body = , "block_body_size" ==> VUInt , "block_body_hash" ==> hash32 , a operational_cert - , a protocol_version + , a (protocol_version @BabbageEra) ] operational_cert :: Rule @@ -96,8 +102,21 @@ operational_cert = , "sigma" ==> signature ] -protocol_version :: Rule -protocol_version = "protocol_version" =:= arr [a $ major_protocol_version @BabbageEra, a VUInt] +-- IMPORTANT: Babbage changed operational_cert and protocol_version from 'grp' +-- to 'arr' to match actual block serialization (see PR #3762, issue #3559). +-- +-- Semantic difference: +-- grp (Named Group): +-- fields are inlined directly into parent array +-- -> header_body becomes 14-element flat array +-- arr (Rule): +-- fields are nested as separate sub-arrays +-- -> header_body becomes 10-element array with nested structures +-- +-- Pre-Babbage eras used 'grp' but actual Babbage+ blocks serialize with 'arr'. +-- This change corrects the CDDL spec to match reality. +protocol_version :: forall era. Era era => Rule +protocol_version = "protocol_version" =:= arr [a $ major_protocol_version @era, a VUInt] transaction_body :: Rule transaction_body = @@ -367,7 +386,7 @@ protocol_param_update = , opt (idx 9 ==> nonnegative_interval) , opt (idx 10 ==> unit_interval) , opt (idx 11 ==> unit_interval) - , opt (idx 14 ==> protocol_version) + , opt (idx 14 ==> protocol_version @BabbageEra) , opt (idx 16 ==> coin) , opt (idx 17 ==> coin) , opt (idx 18 ==> cost_models) diff --git a/eras/conway/impl/CHANGELOG.md b/eras/conway/impl/CHANGELOG.md index 410b8db8865..988ecb0f47c 100644 --- a/eras/conway/impl/CHANGELOG.md +++ b/eras/conway/impl/CHANGELOG.md @@ -15,6 +15,7 @@ ### `testlib` +* Remove CDDL `protocol_version` redefinition * Remove `epoch_no`, `slot_no` and `block_no` reuse definitions from core * Removed `regDelegToDRep` * Removed `registerRewardAccountWithDeposit` diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs index 29aca46cb31..e407fd6015a 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs @@ -175,12 +175,9 @@ header_body = , "block_body_size" ==> (VUInt `sized` (4 :: Word64)) , "block_body_hash" ==> hash32 , a operational_cert - , a protocol_version + , a (protocol_version @ConwayEra) ] -protocol_version :: Rule -protocol_version = "protocol_version" =:= arr [a $ major_protocol_version @ConwayEra, a VUInt] - transaction_body :: Rule transaction_body = "transaction_body" @@ -258,7 +255,7 @@ parameter_change_action = hard_fork_initiation_action :: Named Group hard_fork_initiation_action = "hard_fork_initiation_action" - =:~ grp [1, a $ gov_action_id / VNil, a protocol_version] + =:~ grp [1, a $ gov_action_id / VNil, a (protocol_version @ConwayEra)] treasury_withdrawals_action :: Named Group treasury_withdrawals_action = diff --git a/eras/dijkstra/impl/CHANGELOG.md b/eras/dijkstra/impl/CHANGELOG.md index 415564bad23..2144addb960 100644 --- a/eras/dijkstra/impl/CHANGELOG.md +++ b/eras/dijkstra/impl/CHANGELOG.md @@ -17,6 +17,7 @@ ### `testlib` +* Remove CDDL `protocol_version` redefinition * Add `impDijkstraSatisfyNativeScript` * Add `DijkstraEraTxBody` and `DijkstraEraScript` constraints to `DijkstraEraTest` diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/CDDL.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/CDDL.hs index 98f507ae169..cbf197626f6 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/CDDL.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/CDDL.hs @@ -105,12 +105,9 @@ header_body = , "block_body_size" ==> (VUInt `sized` (4 :: Word64)) , "block_body_hash" ==> hash32 , a operational_cert - , a protocol_version + , a (protocol_version @DijkstraEra) ] -protocol_version :: Rule -protocol_version = "protocol_version" =:= arr [a $ major_protocol_version @DijkstraEra, a VUInt] - transaction_body :: Rule transaction_body = "transaction_body" diff --git a/eras/mary/impl/cddl-files/mary.cddl b/eras/mary/impl/cddl-files/mary.cddl index e2c7ea0a692..d50aadc75e1 100644 --- a/eras/mary/impl/cddl-files/mary.cddl +++ b/eras/mary/impl/cddl-files/mary.cddl @@ -38,10 +38,10 @@ vrf_vkey = bytes .size 32 vrf_cert = [bytes, bytes .size 80] operational_cert = - ( hot_vkey : kes_vkey - , sequence_number : uint - , kes_period : uint - , sigma : signature + ( hot_vkey : kes_vkey + , sequence_number : uint .size 8 + , kes_period : uint + , sigma : signature ) kes_vkey = bytes .size 32 diff --git a/eras/shelley/impl/CHANGELOG.md b/eras/shelley/impl/CHANGELOG.md index 9868b99da9e..25ec82f027c 100644 --- a/eras/shelley/impl/CHANGELOG.md +++ b/eras/shelley/impl/CHANGELOG.md @@ -20,6 +20,8 @@ ### `testlib` +* Correct the CDDL definition of the `sequence_number` to be sized +* Export polymorphic CDDL definition for `protocol_version` * Move CDDL definition for `nonce`, `epoch`, `slot` and `block_number` to core * Rename `examplePoolParams` to `exampleStakePoolParams` * Removed `shelleyEraSpecificSpec` diff --git a/eras/shelley/impl/cddl-files/shelley.cddl b/eras/shelley/impl/cddl-files/shelley.cddl index 04087669b38..8905c096780 100644 --- a/eras/shelley/impl/cddl-files/shelley.cddl +++ b/eras/shelley/impl/cddl-files/shelley.cddl @@ -38,10 +38,10 @@ vrf_vkey = bytes .size 32 vrf_cert = [bytes, bytes .size 80] operational_cert = - ( hot_vkey : kes_vkey - , sequence_number : uint - , kes_period : uint - , sigma : signature + ( hot_vkey : kes_vkey + , sequence_number : uint .size 8 + , kes_period : uint + , sigma : signature ) kes_vkey = bytes .size 32 diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs index a3f1670fbc1..b45e682a989 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs @@ -27,6 +27,7 @@ module Test.Cardano.Ledger.Shelley.CDDL ( bootstrap_witness, script_hash, major_protocol_version, + protocol_version, genesis_hash, operational_cert, stake_registration, @@ -99,7 +100,7 @@ operational_cert = "operational_cert" =:~ grp [ "hot_vkey" ==> kes_vkey - , "sequence_number" ==> VUInt + , "sequence_number" ==> (VUInt `sized` (8 :: Word64)) , "kes_period" ==> VUInt , "sigma" ==> signature ] From c7c025f6bab7d86b0ac919eeb250c00eb6d69f16 Mon Sep 17 00:00:00 2001 From: Aniket Deshpande Date: Fri, 31 Oct 2025 17:22:56 +0530 Subject: [PATCH 3/3] CDDL: Retroactively fix EMax to use epoch_interval * Move epoch_interval definition to core * Correct field#7 in protocol_param_update with it --- eras/allegra/impl/cddl-files/allegra.cddl | 4 +++- eras/alonzo/impl/cddl-files/alonzo.cddl | 4 +++- eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs | 2 +- eras/babbage/impl/cddl-files/babbage.cddl | 4 +++- eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs | 2 +- eras/conway/impl/CHANGELOG.md | 2 +- eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs | 4 ---- eras/mary/impl/cddl-files/mary.cddl | 4 +++- eras/shelley/impl/cddl-files/shelley.cddl | 4 +++- eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs | 2 +- libs/cardano-ledger-core/CHANGELOG.md | 2 +- .../testlib/Test/Cardano/Ledger/Core/Binary/CDDL.hs | 4 ++++ 12 files changed, 24 insertions(+), 14 deletions(-) diff --git a/eras/allegra/impl/cddl-files/allegra.cddl b/eras/allegra/impl/cddl-files/allegra.cddl index 14c55d8597b..7ba0d119c68 100644 --- a/eras/allegra/impl/cddl-files/allegra.cddl +++ b/eras/allegra/impl/cddl-files/allegra.cddl @@ -256,7 +256,7 @@ protocol_param_update = , ? 4 : uint .size 2 ; max block header size , ? 5 : coin ; key deposit , ? 6 : coin ; pool deposit - , ? 7 : epoch ; maximum epoch + , ? 7 : epoch_interval ; maximum epoch , ? 8 : uint .size 2 ; n_opt: desired number of stake pools , ? 9 : nonnegative_interval ; pool pledge influence , ? 10 : unit_interval ; expansion rate @@ -269,6 +269,8 @@ protocol_param_update = } +epoch_interval = uint .size 4 + nonnegative_interval = #6.30([uint, positive_int]) positive_int = 1 .. max_word64 diff --git a/eras/alonzo/impl/cddl-files/alonzo.cddl b/eras/alonzo/impl/cddl-files/alonzo.cddl index 4810114158e..ecc55b25919 100644 --- a/eras/alonzo/impl/cddl-files/alonzo.cddl +++ b/eras/alonzo/impl/cddl-files/alonzo.cddl @@ -312,7 +312,7 @@ protocol_param_update = , ? 4 : uint .size 2 , ? 5 : coin , ? 6 : coin - , ? 7 : epoch + , ? 7 : epoch_interval , ? 8 : uint .size 2 , ? 9 : nonnegative_interval , ? 10 : unit_interval @@ -332,6 +332,8 @@ protocol_param_update = } +epoch_interval = uint .size 4 + nonnegative_interval = #6.30([uint, positive_int]) positive_int = 1 .. max_word64 diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs index 43e9a8f9703..937967f432b 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/CDDL.hs @@ -221,7 +221,7 @@ protocol_param_update = , opt (idx 4 ==> (VUInt `sized` (2 :: Word64))) , opt (idx 5 ==> coin) , opt (idx 6 ==> coin) - , opt (idx 7 ==> epoch) + , opt (idx 7 ==> epoch_interval) , opt (idx 8 ==> VUInt `sized` (2 :: Word64)) , opt (idx 9 ==> nonnegative_interval) , opt (idx 10 ==> unit_interval) diff --git a/eras/babbage/impl/cddl-files/babbage.cddl b/eras/babbage/impl/cddl-files/babbage.cddl index 46155015fae..2eeed29ac2d 100644 --- a/eras/babbage/impl/cddl-files/babbage.cddl +++ b/eras/babbage/impl/cddl-files/babbage.cddl @@ -399,7 +399,7 @@ protocol_param_update = , ? 4 : uint .size 2 , ? 5 : coin , ? 6 : coin - , ? 7 : epoch + , ? 7 : epoch_interval , ? 8 : uint .size 2 , ? 9 : nonnegative_interval , ? 10 : unit_interval @@ -417,6 +417,8 @@ protocol_param_update = } +epoch_interval = uint .size 4 + nonnegative_interval = #6.30([uint, positive_int]) positive_int = 1 .. max_word64 diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs index b3206700735..1f508a0bae2 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/CDDL.hs @@ -381,7 +381,7 @@ protocol_param_update = , opt (idx 4 ==> (VUInt `sized` (2 :: Word64))) , opt (idx 5 ==> coin) , opt (idx 6 ==> coin) - , opt (idx 7 ==> epoch) + , opt (idx 7 ==> epoch_interval) , opt (idx 8 ==> VUInt `sized` (2 :: Word64)) , opt (idx 9 ==> nonnegative_interval) , opt (idx 10 ==> unit_interval) diff --git a/eras/conway/impl/CHANGELOG.md b/eras/conway/impl/CHANGELOG.md index 988ecb0f47c..5c518cb0100 100644 --- a/eras/conway/impl/CHANGELOG.md +++ b/eras/conway/impl/CHANGELOG.md @@ -16,7 +16,7 @@ ### `testlib` * Remove CDDL `protocol_version` redefinition -* Remove `epoch_no`, `slot_no` and `block_no` reuse definitions from core +* Remove `epoch_no`, `epoch_interval`, `slot_no` and `block_no`. Reuse definitions from core * Removed `regDelegToDRep` * Removed `registerRewardAccountWithDeposit` * Removed `registerPoolWithDeposit` diff --git a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs index e407fd6015a..ee294e95ae5 100644 --- a/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs +++ b/eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/CDDL.hs @@ -40,7 +40,6 @@ module Test.Cardano.Ledger.Conway.CDDL ( gov_action_id, policy_hash, shelley_transaction_output, - epoch_interval, ex_unit_prices, pool_voting_thresholds, drep_voting_thresholds, @@ -839,9 +838,6 @@ value = "value" =:= coin / sarr [a coin, a (multiasset positive_coin)] mint :: Rule mint = "mint" =:= mp [1 <+ asKey policy_id ==> mp [1 <+ asKey asset_name ==> nonzero_int64]] -epoch_interval :: Rule -epoch_interval = "epoch_interval" =:= VUInt `sized` (4 :: Word64) - conway_script :: Rule conway_script = "script" diff --git a/eras/mary/impl/cddl-files/mary.cddl b/eras/mary/impl/cddl-files/mary.cddl index d50aadc75e1..19b32806893 100644 --- a/eras/mary/impl/cddl-files/mary.cddl +++ b/eras/mary/impl/cddl-files/mary.cddl @@ -264,7 +264,7 @@ protocol_param_update = , ? 4 : uint .size 2 ; max block header size , ? 5 : coin ; key deposit , ? 6 : coin ; pool deposit - , ? 7 : epoch ; maximum epoch + , ? 7 : epoch_interval ; maximum epoch , ? 8 : uint .size 2 ; n_opt: desired number of stake pools , ? 9 : nonnegative_interval ; pool pledge influence , ? 10 : unit_interval ; expansion rate @@ -277,6 +277,8 @@ protocol_param_update = } +epoch_interval = uint .size 4 + nonnegative_interval = #6.30([uint, positive_int]) positive_int = 1 .. max_word64 diff --git a/eras/shelley/impl/cddl-files/shelley.cddl b/eras/shelley/impl/cddl-files/shelley.cddl index 8905c096780..919db574ddc 100644 --- a/eras/shelley/impl/cddl-files/shelley.cddl +++ b/eras/shelley/impl/cddl-files/shelley.cddl @@ -254,7 +254,7 @@ protocol_param_update = , ? 4 : uint .size 2 ; max block header size , ? 5 : coin ; key deposit , ? 6 : coin ; pool deposit - , ? 7 : epoch ; maximum epoch + , ? 7 : epoch_interval ; maximum epoch , ? 8 : uint .size 2 ; n_opt: desired number of stake pools , ? 9 : nonnegative_interval ; pool pledge influence , ? 10 : unit_interval ; expansion rate @@ -267,6 +267,8 @@ protocol_param_update = } +epoch_interval = uint .size 4 + nonnegative_interval = #6.30([uint, positive_int]) positive_int = 1 .. max_word64 diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs index b45e682a989..e2bf731699d 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/CDDL.hs @@ -292,7 +292,7 @@ protocol_param_update = , opt (idx 4 ==> (VUInt `sized` (2 :: Word64))) //- "max block header size" , opt (idx 5 ==> coin) //- "key deposit" , opt (idx 6 ==> coin) //- "pool deposit" - , opt (idx 7 ==> epoch) //- "maximum epoch" + , opt (idx 7 ==> epoch_interval) //- "maximum epoch" , opt (idx 8 ==> VUInt `sized` (2 :: Word64)) //- "n_opt: desired number of stake pools" , opt (idx 9 ==> nonnegative_interval) //- "pool pledge influence" , opt (idx 10 ==> unit_interval) //- "expansion rate" diff --git a/libs/cardano-ledger-core/CHANGELOG.md b/libs/cardano-ledger-core/CHANGELOG.md index fb1ff9fd7f1..47a55f3a391 100644 --- a/libs/cardano-ledger-core/CHANGELOG.md +++ b/libs/cardano-ledger-core/CHANGELOG.md @@ -26,7 +26,7 @@ ### `testlib` -* Add CDDL definition for `nonce`, `epoch`, `slot` and `block_number` +* Add CDDL definition for `nonce`, `epoch`, `epoch_interval`, `slot` and `block_number` * Remove `Test.Cardano.Ledger.Plutus.ExUnits` * Remove the `accountsToUMap` member function from the `EraTest` class. - Also remove the related `accountsFromUMap` function. diff --git a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Binary/CDDL.hs b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Binary/CDDL.hs index 9157b4bf3f1..ce136508cff 100644 --- a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Binary/CDDL.hs +++ b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Core/Binary/CDDL.hs @@ -46,6 +46,7 @@ module Test.Cardano.Ledger.Core.Binary.CDDL ( -- * Network nonce, epoch, + epoch_interval, slot, block_number, @@ -329,6 +330,9 @@ nonce = "nonce" =:= arr [0] / arr [1, a (VBytes `sized` (32 :: Word64))] epoch :: Rule epoch = "epoch" =:= VUInt `sized` (8 :: Word64) +epoch_interval :: Rule +epoch_interval = "epoch_interval" =:= VUInt `sized` (4 :: Word64) + slot :: Rule slot = "slot" =:= VUInt `sized` (8 :: Word64)