-
Notifications
You must be signed in to change notification settings - Fork 155
/
shelley.cddl
320 lines (246 loc) · 9.5 KB
/
shelley.cddl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
; This file was auto-generated from huddle. Please do not modify it directly!
; Pseudo-rule introduced by Cuddle to collect root elements
huddle_root_defs = [block, transaction, signkeyKES]
$hash28 = bytes .size 28
$hash32 = bytes .size 32
$kes_signature = bytes .size 448
$kes_vkey = bytes .size 32
$signature = bytes .size 64
$vkey = bytes .size 32
$vrf_cert = [bytes, bytes .size 80]
$vrf_vkey = bytes .size 32
addr_keyhash = $hash28
; address = bytes
;
; 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
;
; reward addresses:
; bits 7-5: 111
; bit 4: credential is keyhash/scripthash
; bits 3-0: network id
;
; 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
;
address = h'001000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000'
/ h'102000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000'
/ h'203000000000000000000000000000000000000000000000000000000033000000000000000000000000000000000000000000000000000000'
/ h'304000000000000000000000000000000000000000000000000000000044000000000000000000000000000000000000000000000000000000'
/ h'405000000000000000000000000000000000000000000000000000000087680203'
/ h'506000000000000000000000000000000000000000000000000000000087680203'
/ h'6070000000000000000000000000000000000000000000000000000000'
/ h'7080000000000000000000000000000000000000000000000000000000'
block = [header
, transaction_bodies : [* transaction_body]
, transaction_witness_sets : [* transaction_witness_set]
, transaction_metadata_set : {* transaction_index => transaction_metadata}]
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]
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
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]
ipv4 = bytes .size 4
ipv6 = bytes .size 16
major_protocol_version = 1 .. 3
metadata_hash = $hash32
; 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]
multisig_script = [multisig_pubkey
// multisig_all
// multisig_any
// multisig_n_of_k]
nonce = [0 // 1, bytes .size 32]
nonnegative_interval = #6.30([uint, positive_int])
pool_keyhash = $hash28
pool_metadata = [url, metadata_hash]
port = uint .le 65535
positive_int = 1 .. 18446744073709551615
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: 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 .size 2
, ? 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 = bytes
;
reward_account = h'E090000000000000000000000000000000000000000000000000000000'
/ h'F0A0000000000000000000000000000000000000000000000000000000'
; 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
signkeyKES = bytes .size 64
stake_credential = credential
transaction = [transaction_body
, transaction_witness_set
, transaction_metadata / nil]
transaction_body = {0 : set<transaction_input>
, 1 : [* transaction_output]
, 2 : coin
, 3 : uint
, ? 4 : [* certificate]
, ? 5 : withdrawals
, ? 6 : update
, ? 7 : metadata_hash}
transaction_index = uint .size 2
transaction_input = [transaction_id : $hash32, index : uint]
transaction_metadata = {* transaction_metadatum_label => transaction_metadatum}
transaction_metadatum = {* transaction_metadatum => transaction_metadatum}
/ [* transaction_metadatum]
/ int
/ bytes .size (0 .. 64)
/ text .size (0 .. 64)
transaction_metadatum_label = uint
transaction_output = [address, amount : coin]
transaction_witness_set = {? 0 : [* vkeywitness]
, ? 1 : [* multisig_script]
, ? 2 : [* bootstrap_witness]}
; The real unit_interval is: #6.30([uint, uint])
;
; A unit interval is a number in the range between 0 and 1, which
; means there are two extra constraints:
; 1. numerator <= denominator
; 2. denominator > 0
;
; The relation between numerator and denominator can be
; expressed in CDDL, but we have a limitation currently
; (see: https://github.com/input-output-hk/cuddle/issues/30)
; 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
;
unit_interval = #6.30([1, 2])
update = [proposed_protocol_parameter_updates, epoch]
url = text .size (0 .. 64)
vkeywitness = [$vkey, $signature]
vrf_keyhash = $hash32
withdrawals = {* reward_account => coin}
genesis_key_delegation = (5, genesis_hash, genesis_delegate_hash, vrf_keyhash)
move_instantaneous_rewards_cert = (6, move_instantaneous_reward)
; dns_name: An SRV DNS record
;
multi_host_name = (2, dns_name)
multisig_all = (1, [* multisig_script])
multisig_any = (2, [* multisig_script])
multisig_n_of_k = (3, uint, [* multisig_script])
multisig_pubkey = (0, addr_keyhash)
operational_cert = ($kes_vkey, uint, uint, $signature)
; pool_keyhash: operator
; coin: pledge
; coin: cost
; unit_interval: margin
; set<addr_keyhash>: pool_owners
;
pool_params = (pool_keyhash
, vrf_keyhash
, coin
, coin
, unit_interval
, reward_account
, set<addr_keyhash>
, [* relay]
, pool_metadata / nil)
pool_registration = (3, pool_params)
pool_retirement = (4, pool_keyhash, epoch)
protocol_version = (major_protocol_version, uint)
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)
; This will be deprecated in a future era
stake_deregistration = (1, stake_credential)
; This will be deprecated in a future era
stake_registration = (0, stake_credential)
set<a0> = [* a0]