Skip to content
Open
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
110 changes: 61 additions & 49 deletions eras/allegra/impl/cddl-files/allegra.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

block =
[ header
, transaction_bodies : [* transaction_body]
, transaction_witness_sets : [* transaction_witness_set]
, auxiliary_data_set : {* transaction_index => auxiliary_data}
, transaction_bodies : [* transaction_body]
, transaction_witness_sets : [* transaction_witness_set]
, auxiliary_data_set : {* transaction_ix => auxiliary_data}
]


Expand All @@ -13,25 +13,27 @@ header = [header_body, body_signature : kes_signature]
header_body =
[ block_number : uint
, slot : uint
, prev_hash : hash32/ nil
, prev_hash : bytes32/ nil
, issuer_vkey : vkey
, vrf_vkey : vrf_vkey
, nonce_vrf : vrf_cert
, leader_vrf : vrf_cert
, block_body_size : uint .size 4
, block_body_hash : hash32
, block_body_hash : bytes32
, operational_cert
, protocol_version
]


hash32 = bytes .size 32
bytes32 = bytes .size 32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was hash switched to bytes? It is really good to indicate that it is not some bytes but a hash


vkey = bytes .size 32
vkey = bytes32

vrf_vkey = bytes .size 32
vrf_vkey = bytes32

vrf_cert = [bytes, bytes .size 80]
vrf_cert = [bytes, bytes80]

bytes80 = bytes .size 80

operational_cert =
( hot_vkey : kes_vkey
Expand All @@ -40,37 +42,41 @@ operational_cert =
, sigma : signature
)

kes_vkey = bytes .size 32
kes_vkey = bytes32

signature = bytes64

signature = bytes .size 64
bytes64 = bytes .size 64

protocol_version = (major_protocol_version, uint)
protocol_version = [major_protocol_version, uint]
Comment on lines -47 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change from group to array seems significant. However, I don't see any change in the .hs that matches this. I wonder where it's coming from?

I saw the same difference in some of the other eras.


major_protocol_version = 0 .. 4

kes_signature = bytes .size 448
kes_signature = bytes448

bytes448 = bytes .size 448

; Allegra transaction body adds the validity interval start at index 8
transaction_body =
{ 0 : set<transaction_input>
, 1 : [* transaction_output]
, 2 : coin
, ? 3 : uint
, ? 4 : [* certificate]
, ? 5 : withdrawals
, ? 6 : update
, ? 7 : metadata_hash
, ? 8 : uint
{ 0 : set<transaction_input>
, 1 : [* shelley_transaction_output]
, 2 : coin
, ? 3 : uint
, ? 4 : [* certificate]
, ? 5 : withdrawals
, ? 6 : [protocol_param_updates, epoch]
, ? 7 : auxiliary_data_hash
, ? 8 : uint
}


set<a0> = [* a0]

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

transaction_id = hash32
transaction_id = bytes32

transaction_output = [address, amount : coin]
shelley_transaction_output = [address, amount : coin]

; address = bytes
;
Expand Down Expand Up @@ -134,9 +140,9 @@ stake_credential = credential

credential = [0, addr_keyhash// 1, script_hash]

addr_keyhash = hash28
addr_keyhash = bytes28

hash28 = bytes .size 28
bytes28 = bytes .size 28

; To compute a script hash, note that you must prepend
; a tag to the bytes of the script before hashing.
Expand All @@ -146,14 +152,15 @@ hash28 = bytes .size 28
; "\x01" for Plutus V1 scripts
; "\x02" for Plutus V2 scripts
; "\x03" for Plutus V3 scripts
script_hash = hash28
; "\x04" for Plutus V4 scripts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is something definitely wrong with this comment. Tags for plutus scripts should not be relevant for Allegra CDDL

script_hash = bytes28

; This will be deprecated in a future era
stake_deregistration = (1, stake_credential)

stake_delegation = (2, stake_credential, pool_keyhash)

pool_keyhash = hash28
pool_keyhash = bytes28

pool_registration = (3, pool_params)

Expand All @@ -169,7 +176,7 @@ pool_params =
, pool_metadata : pool_metadata/ nil
)

vrf_keyhash = hash32
vrf_keyhash = bytes32

; The real unit_interval is: #6.30([uint, uint])
;
Expand Down Expand Up @@ -220,9 +227,9 @@ epoch = uint

genesis_key_delegation = (5, genesis_hash, genesis_delegate_hash, vrf_keyhash)

genesis_hash = hash28
genesis_hash = bytes28

genesis_delegate_hash = hash28
genesis_delegate_hash = bytes28

move_instantaneous_rewards_cert = (6, move_instantaneous_reward)

Expand All @@ -240,9 +247,7 @@ delta_coin = int

withdrawals = {* reward_account => coin}

update = [proposed_protocol_parameter_updates, epoch]

proposed_protocol_parameter_updates = {* genesis_hash => protocol_param_update}
protocol_param_updates = {* genesis_hash => protocol_param_update}

protocol_param_update =
{ ? 0 : uint ; minfee A
Expand All @@ -265,20 +270,20 @@ protocol_param_update =
}


nonnegative_interval = #6.30([uint, positive_int])
nonnegative_interval = #6.30([uint, pint])

positive_int = 1 .. maxWord64
pint = 1 .. max_word64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

positive_ is a much better prefix than p. Otherwise someone might think it is a definition for a pint of beer or something 🤣

Suggested change
pint = 1 .. max_word64
positive_int = 1 .. max_word64


maxWord64 = 18446744073709551615
max_word64 = 18446744073709551615

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

metadata_hash = hash32
auxiliary_data_hash = bytes32

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

vkeywitness = [vkey, signature]
vkey_witness = [vkey, signature]

; Timelock validity intervals are half-open intervals [a, b).
;
Expand All @@ -305,27 +310,34 @@ script_any = (2, [* native_script])

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

int64 = -9223372036854775808 .. 9223372036854775807
int64 = min_int64 .. max_int64

min_int64 = -9223372036854775808

max_int64 = 9223372036854775807

invalid_before = (4, uint)

invalid_hereafter = (5, uint)

bootstrap_witness =
[ public_key : vkey
, signature : signature
, chain_code : bytes .size 32
, attributes : bytes
[ public_key : vkey
, signature : signature
, chain_code : bytes32
, attributes : bytes
]


transaction_index = uint .size 2
transaction_ix = uint .size 2

auxiliary_data =
metadata
/ [transaction_metadata : metadata, auxiliary_scripts : auxiliary_scripts]
shelley_auxiliary_data
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. It just so happens that in Shelley auxiliary_data is set to just metadata. But metadata is it own concept: Map Word64 Metadatum

Suggested change
shelley_auxiliary_data
metadata

/ [ transaction_metadata : shelley_auxiliary_data
, auxiliary_scripts : auxiliary_scripts
]

metadata = {* transaction_metadatum_label => transaction_metadatum}
shelley_auxiliary_data =
{* transaction_metadatum_label => transaction_metadatum}

transaction_metadatum_label = uint

Expand Down
Loading
Loading