Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions eras/allegra/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

### `testlib`

* Rename `native_script` -> `allegra_native_script` in CDDL
* Add `auxiliary_data_array` to CDDL for simplification
* Remove `metadata` redefinition in CDDL
* Use fixed-sized `uint .size 8` for `slot` in CDDL for timelock validity intervals
* Add `impSatisfyMNativeScripts`
* Add `impSatisfySignature`
Expand Down
56 changes: 32 additions & 24 deletions eras/allegra/impl/cddl-files/allegra.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ transaction_body =
, ? 4 : [* certificate]
, ? 5 : withdrawals
, ? 6 : update
, ? 7 : metadata_hash
, ? 7 : auxiliary_data_hash
, ? 8 : slot
}

Expand Down Expand Up @@ -145,11 +145,12 @@ hash28 = bytes .size 28
; To compute a script hash, note that you must prepend
; a tag to the bytes of the script before hashing.
; The tag is determined by the language.
; The tags in the Conway era are:
; "\x00" for multisig scripts
; The tags are:
; "\x00" for multisig/native scripts
; "\x01" for Plutus V1 scripts
; "\x02" for Plutus V2 scripts
; "\x03" for Plutus V3 scripts
; "\x04" for Plutus V4 scripts
script_hash = hash28

; This will be deprecated in a future era
Expand Down Expand Up @@ -279,27 +280,29 @@ max_word64 = 18446744073709551615

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

metadata_hash = hash32
auxiliary_data_hash = hash32

transaction_witness_set =
{? 0 : [* vkeywitness], ? 1 : [* native_script], ? 2 : [* bootstrap_witness]}

vkeywitness = [vkey, signature]

; Timelock validity intervals are half-open intervals [a, b).
; Allegra introduces timelock support for native scripts.
; This is the 6-variant native script format used by
; Allegra, Mary, Alonzo, Babbage, and Conway.
;
; invalid_before:
; specifies the left (included) endpoint a.
; Timelock validity intervals are half-open intervals [a, b).
; script_invalid_before: specifies the left (included) endpoint a.
; script_invalid_hereafter: specifies the right (excluded) endpoint b.
;
; invalid_hereafter:
; specifies the right (excluded) endpoint b.
; Note: Allegra switched to int64 for script_n_of_k thresholds.
native_script =
[ script_pubkey
// script_all
// script_any
// script_n_of_k
// invalid_before
// invalid_hereafter
// script_invalid_before
// script_invalid_hereafter
]


Expand All @@ -317,9 +320,13 @@ min_int64 = -9223372036854775808

max_int64 = 9223372036854775807

invalid_before = (4, slot)
; Timelock validity intervals are half-open intervals [a, b).
; This field specifies the left (included) endpoint a.
script_invalid_before = (4, slot)

invalid_hereafter = (5, slot)
; Timelock validity intervals are half-open intervals [a, b).
; This field specifies the right (excluded) endpoint b.
script_invalid_hereafter = (5, slot)

bootstrap_witness =
[ public_key : vkey
Expand All @@ -331,20 +338,21 @@ bootstrap_witness =

transaction_index = uint .size 2

auxiliary_data =
metadata
/ [transaction_metadata : metadata, auxiliary_scripts : auxiliary_scripts]
auxiliary_data = metadata/ auxiliary_data_array

metadata = {* metadatum_label => metadatum}

metadata = {* transaction_metadatum_label => transaction_metadatum}
metadatum_label = uint .size 8

transaction_metadatum_label = uint
metadatum =
{* metadatum => metadatum}
/ [* metadatum]
/ int
/ bytes .size (0 .. 64)
/ text .size (0 .. 64)

transaction_metadatum =
{* transaction_metadatum => transaction_metadatum}
/ [* transaction_metadatum]
/ int
/ bytes .size (0 .. 64)
/ text .size (0 .. 64)
auxiliary_data_array =
[transaction_metadata : metadata, auxiliary_scripts : auxiliary_scripts]

auxiliary_scripts = [* native_script]

Expand Down
66 changes: 33 additions & 33 deletions eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/CDDL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ module Test.Cardano.Ledger.Allegra.CDDL (
allegraCDDL,
transaction_witness_set,
auxiliary_data,
metadata,
auxiliary_data_array,
auxiliary_scripts,
script_pubkey,
script_all,
script_any,
invalid_before,
invalid_hereafter,
allegra_native_script,
) where

import Cardano.Ledger.Allegra (AllegraEra)
Expand All @@ -38,57 +34,61 @@ allegraCDDL =
, HIRule $ transaction @AllegraEra
]

native_script :: Rule
native_script =
allegra_native_script :: Rule
allegra_native_script =
comment
[str|Timelock validity intervals are half-open intervals [a, b).
[str|Allegra introduces timelock support for native scripts.
|This is the 6-variant native script format used by
|Allegra, Mary, Alonzo, Babbage, and Conway.
|
| invalid_before:
| specifies the left (included) endpoint a.
|Timelock validity intervals are half-open intervals [a, b).
| script_invalid_before: specifies the left (included) endpoint a.
| script_invalid_hereafter: specifies the right (excluded) endpoint b.
|
| invalid_hereafter:
| specifies the right (excluded) endpoint b.
|Note: Allegra switched to int64 for script_n_of_k thresholds.
|]
$ "native_script"
=:= arr [a script_pubkey]
/ arr [a script_all]
/ arr [a script_any]
/ arr [a script_n_of_k]
/ arr [a invalid_before]
/ arr [a invalid_hereafter]
/ arr [a script_invalid_before]
/ arr [a script_invalid_hereafter]

script_pubkey :: Named Group
script_pubkey = "script_pubkey" =:~ grp [0, a addr_keyhash]
script_pubkey = mkScriptPubkey

script_all :: Named Group
script_all = "script_all" =:~ grp [1, a (arr [0 <+ a native_script])]
script_all = mkScriptAll allegra_native_script

script_any :: Named Group
script_any = "script_any" =:~ grp [2, a (arr [0 <+ a native_script])]
script_any = mkScriptAny allegra_native_script

script_n_of_k :: Named Group
script_n_of_k = "script_n_of_k" =:~ grp [3, "n" ==> int64, a (arr [0 <+ a native_script])]
script_n_of_k = mkScriptNOfK int64 allegra_native_script

invalid_before :: Named Group
invalid_before = "invalid_before" =:~ grp [4, a slot]
script_invalid_before :: Named Group
script_invalid_before = mkScriptInvalidBefore

invalid_hereafter :: Named Group
invalid_hereafter = "invalid_hereafter" =:~ grp [5, a slot]

metadata :: Rule
metadata = "metadata" =:= mp [0 <+ asKey transaction_metadatum_label ==> transaction_metadatum]
script_invalid_hereafter :: Named Group
script_invalid_hereafter = mkScriptInvalidHereafter

auxiliary_scripts :: Rule
auxiliary_scripts = "auxiliary_scripts" =:= arr [0 <+ a native_script]
auxiliary_scripts = "auxiliary_scripts" =:= arr [0 <+ a allegra_native_script]

auxiliary_data_array :: Rule
auxiliary_data_array =
"auxiliary_data_array"
=:= arr
[ "transaction_metadata" ==> metadata
, "auxiliary_scripts" ==> auxiliary_scripts
]

auxiliary_data :: Rule
auxiliary_data =
"auxiliary_data"
=:= metadata
/ sarr
[ "transaction_metadata" ==> metadata
, "auxiliary_scripts" ==> auxiliary_scripts
]
/ auxiliary_data_array

transaction_body :: forall era. Era era => Rule
transaction_body =
Expand All @@ -104,7 +104,7 @@ transaction_body =
, opt (idx 4 ==> arr [0 <+ a certificate])
, opt (idx 5 ==> withdrawals)
, opt (idx 6 ==> update @era)
, opt (idx 7 ==> metadata_hash)
, opt (idx 7 ==> auxiliary_data_hash)
, opt (idx 8 ==> slot)
]

Expand Down Expand Up @@ -132,6 +132,6 @@ transaction_witness_set =
"transaction_witness_set"
=:= mp
[ opt $ idx 0 ==> arr [0 <+ a vkeywitness]
, opt $ idx 1 ==> arr [0 <+ a native_script]
, opt $ idx 1 ==> arr [0 <+ a allegra_native_script]
, opt $ idx 2 ==> arr [0 <+ a bootstrap_witness]
]
4 changes: 4 additions & 0 deletions eras/alonzo/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@

### `testlib`

* Rename `plutus_script` -> `plutus_v1_script` in CDDL
* Add `plutus_v1_script` to CDDL exports
* Add `auxiliary_data_map` to CDDL for simplification
* Remove redefinition of `auxiliary_data_hash` from CDDL
* Remove deprecated function `mkPlutusScript'`
* Use fixed-sized `uint .size 8` for `slot` and `block_number` in CDDL for header
* Remove CDDL `protocol_version` redefinition
Expand Down
Loading