Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huddle for Alonzo #4778

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions eras/allegra/impl/cardano-ledger-allegra.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ library testlib
containers,
cuddle,
generic-random,
heredoc,
microlens,
mtl,
small-steps,
Expand Down
287 changes: 174 additions & 113 deletions eras/allegra/impl/cddl-files/allegra.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,39 @@ $vrf_vkey = bytes .size 32
addr_keyhash = $hash28

; address = bytes
; reward_account = bytes
; reward_account = bytes
;
; address format:
; [ 8 bit header | payload ];
; address format:
; [ 8 bit header | payload ];
;
; shelley payment addresses:
; bit 7: 0
; bit 6: base/other
; bit 5: pointer/enterprise [for base: stake cred is keyhash/scripthash]
; bit 4: payment cred is keyhash/scripthash
; bits 3-0: network id
; shelley payment addresses:
; bit 7: 0
; bit 6: base/other
; bit 5: pointer/enterprise [for base: stake cred is keyhash/scripthash]
; bit 4: payment cred is keyhash/scripthash
; bits 3-0: network id
;
; reward addresses:
; bits 7-5: 111
; bit 4: credential is keyhash/scripthash
; bits 3-0: network id
; reward addresses:
; bits 7-5: 111
; bit 4: credential is keyhash/scripthash
; bits 3-0: network id
;
; byron addresses:
; bits 7-4: 1000
; byron addresses:
; bits 7-4: 1000
;
; 0000: base address: keyhash28,keyhash28
; 0001: base address: scripthash28,keyhash28
; 0010: base address: keyhash28,scripthash28
; 0011: base address: scripthash28,scripthash28
; 0100: pointer address: keyhash28, 3 variable length uint
; 0101: pointer address: scripthash28, 3 variable length uint
; 0110: enterprise address: keyhash28
; 0111: enterprise address: scripthash28
; 1000: byron address
; 1110: reward account: keyhash28
; 1111: reward account: scripthash28
; 1001-1101: future formats
;
; 0000: base address: keyhash28,keyhash28
; 0001: base address: scripthash28,keyhash28
; 0010: base address: keyhash28,scripthash28
; 0011: base address: scripthash28,scripthash28
; 0100: pointer address: keyhash28, 3 variable length uint
; 0101: pointer address: scripthash28, 3 variable length uint
; 0110: enterprise address: keyhash28
; 0111: enterprise address: scripthash28
; 1000: byron address
; 1110: reward account: keyhash28
; 1111: reward account: scripthash28
; 1001 - 1101: future formats
address = h'001000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000'
/ h'102000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000'
/ h'203000000000000000000000000000000000000000000000000000000033000000000000000000000000000000000000000000000000000000'
Expand All @@ -62,51 +63,59 @@ address = h'00100000000000000000000000000000000000000000000000000000001100000000
/ h'6070000000000000000000000000000000000000000000000000000000'
/ h'7080000000000000000000000000000000000000000000000000000000'

auxiliary_data = {* transaction_metadatum_label => transaction_metadatum}
/ [transaction_metadata : {* transaction_metadatum_label => transaction_metadatum},
auxiliary_scripts : [* native_script]]
auxiliary_data = metadata
/ [transaction_metadata : metadata
, auxiliary_scripts : auxiliary_scripts]

auxiliary_scripts = [* native_script]

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

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

certificate = [stake_registration //
stake_deregistration //
stake_delegation //
pool_registration //
pool_retirement //
genesis_key_delegation //
move_instantaneous_rewards_cert]
certificate = [stake_registration
// stake_deregistration
// stake_delegation
// pool_registration
// pool_retirement
// genesis_key_delegation
// move_instantaneous_rewards_cert]

coin = uint

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

; This too has been introduced in Shelley as a backport from Alonzo.
;
delta_coin = int

dns_name = text .size (0 .. 64)

epoch = uint

genesis_delegate_hash = $hash28

genesishash = $hash28
genesis_hash = $hash28

header = [header_body, body_signature : $kes_signature]

header_body = [block_number : uint,
slot : uint,
prev_hash : $hash32 / 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,
operational_cert,
protocol_version]
header_body = [block_number : uint
, slot : uint
, prev_hash : $hash32 / 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
, operational_cert
, protocol_version]

int64 = -9223372036854775808 .. 9223372036854775807

Expand All @@ -116,20 +125,36 @@ ipv6 = bytes .size 16

major_protocol_version = 1 .. 3

metadata = {* transaction_metadatum_label => transaction_metadatum}

metadata_hash = $hash32

move_instantaneous_reward = [0 / 1, {* stake_credential => coin}]
; The first field determines where the funds are drawn from.
; 0 denotes the reserves,
; 1 denotes the treasury.
; If the second field is a map, funds are moved to stake credentials.
; Otherwise, the funds are given to the other accounting pot.
; NOTE:
; This has been safely backported to Shelley from Alonzo.
;
move_instantaneous_reward = [0 / 1, {* stake_credential => delta_coin} / coin]

; Timelock validity intervals are half-open intervals [a, b).
native_script = [script_pubkey //
script_all //
script_any //
script_n_of_k //
invalid_before //
invalid_hereafter]
;
; invalid_before:
; specifies the left (included) endpoint a.
;
; invalid_hereafter:
; specifies the right (excluded) endpoint b.
;
native_script = [script_pubkey
// script_all
// script_any
// script_n_of_k
// invalid_before
// invalid_hereafter]

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

nonnegative_interval = #6.30([uint, positive_int])

Expand All @@ -141,49 +166,73 @@ port = uint .le 65535

positive_int = 1 .. 18446744073709551615

proposed_protocol_parameter_updates = {* genesishash => protocol_param_update}

protocol_param_update = {? 0 : uint,
? 1 : uint,
? 2 : uint,
? 3 : uint,
? 4 : uint .size 2,
? 5 : coin,
? 6 : coin,
? 7 : epoch,
? 8 : uint,
? 9 : nonnegative_interval,
? 10 : unit_interval,
? 11 : unit_interval,
? 12 : unit_interval,
? 13 : nonce,
? 14 : [protocol_version],
? 15 : coin}

relay = [single_host_addr //
single_host_name //
multi_host_name]
proposed_protocol_parameter_updates = {* genesis_hash => protocol_param_update}

; 0: minfee A
; 1: minfee B
; 2: max block body size
; 3: max transaction size
; 4: max block header size
; 5: key deposit
; 6: pool deposit
; 7: maximum epoch
; 8: n_opt: desired number of stake pools
; 9: pool pledge influence
; 10: expansion rate
; 11: treasury growth rate
; 12: d. decentralization constant
; 13: extra entropy
; 14: protocol version
; 15: min utxo value
;
protocol_param_update = {? 0 : uint
, ? 1 : uint
, ? 2 : uint
, ? 3 : uint
, ? 4 : uint .size 2
, ? 5 : coin
, ? 6 : coin
, ? 7 : epoch
, ? 8 : uint
, ? 9 : nonnegative_interval
, ? 10 : unit_interval
, ? 11 : unit_interval
, ? 12 : unit_interval
, ? 13 : nonce
, ? 14 : [protocol_version]
, ? 15 : coin}

relay = [single_host_addr // single_host_name // multi_host_name]

reward_account = h'E090000000000000000000000000000000000000000000000000000000'
/ h'F0A0000000000000000000000000000000000000000000000000000000'

scripthash = $hash28
; 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
; "\\x01\" for Plutus V1 scripts
; "\\x02\" for Plutus V2 scripts
; "\\x03\" for Plutus V3 scripts
;
script_hash = $hash28

stake_credential = [0, addr_keyhash //
1, scripthash]
stake_credential = credential

transaction = [transaction_body, transaction_witness_set, auxiliary_data / nil]

; 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}
;
transaction_body = {0 : set<transaction_input>
, 1 : [* transaction_output]
, 2 : coin
, 3 : uint
, ? 4 : [* certificate]
, ? 5 : withdrawals
, ? 6 : update
, ? 7 : metadata_hash
, ? 8 : uint}

transaction_index = uint .size 2

Expand All @@ -199,9 +248,9 @@ transaction_metadatum_label = uint

transaction_output = [address, amount : coin]

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

unit_interval = #6.30([1, 2])

Expand All @@ -215,27 +264,37 @@ vrf_keyhash = $hash32

withdrawals = {* reward_account => coin}

genesis_key_delegation = (5, genesishash, genesis_delegate_hash, vrf_keyhash)
genesis_key_delegation = (5, genesis_hash, genesis_delegate_hash, vrf_keyhash)

invalid_before = (4, uint)

invalid_hereafter = (5, uint)

move_instantaneous_rewards_cert = (6, move_instantaneous_reward)

; dns_name: An SRV DNS record
;
multi_host_name = (2, dns_name)

operational_cert = ($kes_vkey, uint, uint, $signature)

pool_params = (pool_keyhash,
vrf_keyhash,
coin,
coin,
unit_interval,
reward_account,
set<addr_keyhash>,
[* relay],
pool_metadata / nil)
; pool_keyhash: operator
; coin: pledge
; coin: cost
; unit_interval: margin
; set<addr_keyhash>: pool_owners
; [* relay]: relays
; pool_metadata / null: pool_metadata
;
pool_params = (pool_keyhash
, vrf_keyhash
, coin
, coin
, unit_interval
, reward_account
, set<addr_keyhash>
, [* relay]
, pool_metadata / nil)

pool_registration = (3, pool_params)

Expand All @@ -253,6 +312,8 @@ script_pubkey = (0, addr_keyhash)

single_host_addr = (0, port / nil, ipv4 / nil, ipv6 / nil)

; dns_name: An A or AAAA DNS record
;
single_host_name = (1, port / nil, dns_name)

stake_delegation = (2, stake_credential, pool_keyhash)
Expand Down
Loading
Loading