Skip to content

Commit

Permalink
Fix size of TxIx in CDDL
Browse files Browse the repository at this point in the history
Also improve the cddl generation script to not fail fast
  • Loading branch information
lehins committed Jan 12, 2025
1 parent d83dc54 commit 87ff626
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion eras/allegra/impl/cddl-files/allegra.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ transaction_body = {0 : set<transaction_input>

transaction_index = uint .size 2

transaction_input = [transaction_id : $hash32, index : uint]
transaction_input = [transaction_id : $hash32, index : uint .size 2]

transaction_metadatum = {* transaction_metadatum => transaction_metadatum}
/ [* transaction_metadatum]
Expand Down
2 changes: 1 addition & 1 deletion eras/alonzo/impl/cddl-files/alonzo.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ transaction_body = {0 : set<transaction_input>

transaction_index = uint .size 2

transaction_input = [transaction_id : $hash32, index : uint]
transaction_input = [transaction_id : $hash32, index : uint .size 2]

transaction_metadatum = {* transaction_metadatum => transaction_metadatum}
/ [* transaction_metadatum]
Expand Down
2 changes: 1 addition & 1 deletion eras/babbage/impl/cddl-files/babbage.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ transaction_body = {0 : set<transaction_input>

transaction_index = uint .size 2

transaction_input = [transaction_id : $hash32, index : uint]
transaction_input = [transaction_id : $hash32, index : uint .size 2]

transaction_metadatum = {* transaction_metadatum => transaction_metadatum}
/ [* transaction_metadatum]
Expand Down
18 changes: 9 additions & 9 deletions eras/mary/impl/cddl-files/mary.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ move_instantaneous_reward = [0 / 1, {* stake_credential => delta_coin} / coin]
;
; invalid_before:
; specifies the left (included) endpoint a.
;
;
; invalid_hereafter:
; specifies the right (excluded) endpoint b.
;
Expand Down Expand Up @@ -221,7 +221,7 @@ reward_account = h'E090000000000000000000000000000000000000000000000000000000'
; "\x00" for multisig scripts
; "\x01" for Plutus V1 scripts
; "\x02" for Plutus V2 scripts
; "\x03" for Plutus V3 scripts
; "\x03" for Plutus V3 scripts
;
script_hash = $hash28

Expand All @@ -242,7 +242,7 @@ transaction_body = {0 : set<transaction_input>

transaction_index = uint .size 2

transaction_input = [transaction_id : $hash32, index : uint]
transaction_input = [transaction_id : $hash32, index : uint .size 2]

transaction_metadatum = {* transaction_metadatum => transaction_metadatum}
/ [* transaction_metadatum]
Expand Down Expand Up @@ -271,7 +271,7 @@ transaction_witness_set = {? 0 : [* vkeywitness]
; which poses a problem for testing. We need to be able to
; generate random valid data for testing implementation of
; our encoders/decoders. Which means we cannot use the actual
; definition here and we hard code the value to 1/2
; definition here and we hard code the value to 1/2
;
unit_interval = #6.30([1, 2])

Expand Down Expand Up @@ -306,11 +306,11 @@ multi_host_name = (2, dns_name)
;
operational_cert = ($kes_vkey, uint, uint, $signature)

; pool_keyhash: operator
; coin: pledge
; coin: cost
; unit_interval: margin
; set<addr_keyhash>: pool_owners
; pool_keyhash: operator
; coin: pledge
; coin: cost
; unit_interval: margin
; set<addr_keyhash>: pool_owners
;
pool_params = (pool_keyhash
, vrf_keyhash
Expand Down
2 changes: 1 addition & 1 deletion eras/shelley/impl/cddl-files/shelley.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ transaction_body = {0 : set<transaction_input>

transaction_index = uint .size 2

transaction_input = [transaction_id : $hash32, index : uint]
transaction_input = [transaction_id : $hash32, index : uint .size 2]

transaction_metadata = {* transaction_metadatum_label => transaction_metadatum}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ transaction_body =
]

transaction_input :: Rule
transaction_input = "transaction_input" =:= arr ["transaction_id" ==> hash32, "index" ==> VUInt]
transaction_input =
"transaction_input"
=:= arr
[ "transaction_id" ==> hash32
, "index" ==> VUInt `sized` (2 :: Word64)
]

transaction_output :: Rule
transaction_output = "transaction_output" =:= arr [a address, "amount" ==> coin]
Expand Down
12 changes: 5 additions & 7 deletions scripts/gen-cddl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ eras=("shelley" "allegra" "mary" "alonzo" "babbage" "conway")

for era in ${eras[@]}; do

changed=$(git diff --name-only origin/master -- "eras/${era}/impl/testlib/Test/Cardano/Ledger/${era^}/CDDL.hs" | xargs)

if [[ -n "$changed" ]]; then
echo "Generating cddl for $era..."
cabal run cardano-ledger-$era:exe:huddle-cddl
echo "Regenerated ${era}.cddl"
fi
echo "Generating cddl for $era..."
cabal run cardano-ledger-$era:exe:huddle-cddl
echo "Regenerated ${era}.cddl"

done

git diff --exit-code

0 comments on commit 87ff626

Please sign in to comment.