-
Notifications
You must be signed in to change notification settings - Fork 17
/
schema.asn
241 lines (189 loc) · 4.71 KB
/
schema.asn
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
TypesModule DEFINITIONS ::= BEGIN
-- Tiny Constants
validators-count INTEGER ::= 6
epoch-length INTEGER ::= 12
cores-count INTEGER ::= 2
-- (validators-count * 2/3 + 1)
validators-super-majority INTEGER ::= 5
-- (cores-count + 7) / 8
avail-bitfield-bytes INTEGER ::= 1
-- Generic Primitive Types
U8 ::= INTEGER (0..255)
U16 ::= INTEGER (0..65535)
U32 ::= INTEGER (0..4294967295)
U64 ::= INTEGER (0..18446744073709551615)
ByteSequence ::= OCTET STRING
ByteArray32 ::= OCTET STRING (SIZE(32))
-- Application Specific Primitive Types
OpaqueHash ::= ByteArray32
TimeSlot ::= U32
ServiceId ::= U32
Gas ::= U64
ValidatorIndex ::= U16
CoreIndex ::= U16
TicketAttempt ::= INTEGER (0..1)
BandersnatchKey ::= ByteArray32
Ed25519Key ::= ByteArray32
BandersnatchVrfSignature ::= OCTET STRING (SIZE(96))
BandersnatchRingSignature ::= OCTET STRING (SIZE(784))
Ed25519Signature ::= OCTET STRING (SIZE(64))
-- Refine Context
RefineContext ::= SEQUENCE {
anchor OpaqueHash,
state-root OpaqueHash,
beefy-root OpaqueHash,
lookup-anchor OpaqueHash,
lookup-anchor-slot TimeSlot,
prerequisite OpaqueHash OPTIONAL
}
-- Work Package
ImportSpec ::= SEQUENCE {
tree-root OpaqueHash,
index U16
}
ExtrinsicSpec ::= SEQUENCE {
hash OpaqueHash,
len U32
}
Authorizer ::= SEQUENCE {
code-hash OpaqueHash,
params ByteSequence
}
WorkItem ::= SEQUENCE {
service ServiceId,
code-hash OpaqueHash,
payload ByteSequence,
gas-limit Gas,
import-segments SEQUENCE OF ImportSpec,
extrinsic SEQUENCE OF ExtrinsicSpec,
export-count U16
}
WorkPackage ::= SEQUENCE {
authorization ByteSequence,
auth-code-host ServiceId,
authorizer Authorizer,
context RefineContext,
items SEQUENCE (SIZE(1..4)) OF WorkItem
}
-- Work Report
WorkExecResult ::= CHOICE {
ok [0] ByteSequence,
out-of-gas [1] NULL,
panic [2] NULL,
bad-code [3] NULL,
code-oversize [4] NULL
}
WorkResult ::= SEQUENCE {
service ServiceId,
code-hash OpaqueHash,
payload-hash OpaqueHash,
gas-ratio Gas,
result WorkExecResult
}
WorkPackageSpec ::= SEQUENCE {
hash OpaqueHash,
len U32,
erasure-root OpaqueHash,
exports-root OpaqueHash
}
WorkReport ::= SEQUENCE {
package-spec WorkPackageSpec,
context RefineContext,
core-index CoreIndex,
authorizer-hash OpaqueHash,
auth-output ByteSequence,
results SEQUENCE (SIZE(1..4)) OF WorkResult
}
-- Header
EpochMark ::= SEQUENCE {
entropy OpaqueHash,
validators SEQUENCE (SIZE(validators-count)) OF BandersnatchKey
}
TicketBody ::= SEQUENCE {
id OpaqueHash,
attempt TicketAttempt
}
TicketsMark ::= SEQUENCE (SIZE(epoch-length)) OF TicketBody
Header ::= SEQUENCE {
parent OpaqueHash,
parent-state-root OpaqueHash,
extrinsic-hash OpaqueHash,
slot TimeSlot,
epoch-mark EpochMark OPTIONAL,
tickets-mark TicketsMark OPTIONAL,
offenders-mark SEQUENCE OF Ed25519Key,
author-index ValidatorIndex,
entropy-source BandersnatchVrfSignature,
seal BandersnatchVrfSignature
}
-- Tickets
TicketEnvelope ::= SEQUENCE {
attempt TicketAttempt,
signature BandersnatchRingSignature
}
TicketsExtrinsic ::= SEQUENCE (SIZE(0..16)) OF TicketEnvelope
-- Disputes
Judgement ::= SEQUENCE {
vote BOOLEAN,
index ValidatorIndex,
signature Ed25519Signature
}
Verdict ::= SEQUENCE {
target OpaqueHash,
age U32,
votes SEQUENCE (SIZE(validators-super-majority)) OF Judgement
}
Culprit ::= SEQUENCE {
target OpaqueHash,
key Ed25519Key,
signature Ed25519Signature
}
Fault ::= SEQUENCE {
target OpaqueHash,
vote BOOLEAN,
key Ed25519Key,
signature Ed25519Signature
}
DisputesExtrinsic ::= SEQUENCE {
verdicts SEQUENCE OF Verdict,
culprits SEQUENCE OF Culprit,
faults SEQUENCE OF Fault
}
-- Preimages
Preimage ::= SEQUENCE {
requester ServiceId,
blob ByteSequence
}
PreimagesExtrinsic ::= SEQUENCE OF Preimage
-- Assurances
AvailAssurance ::= SEQUENCE {
anchor OpaqueHash,
bitfield OCTET STRING (SIZE(avail-bitfield-bytes)),
validator-index ValidatorIndex,
signature Ed25519Signature
}
AssurancesExtrinsic ::= SEQUENCE (SIZE(0..validators-count)) OF AvailAssurance
-- Guarantees
ValidatorSignature ::= SEQUENCE {
validator-index ValidatorIndex,
signature Ed25519Signature
}
ReportGuarantee ::= SEQUENCE {
report WorkReport,
slot TimeSlot,
signatures SEQUENCE OF ValidatorSignature
}
GuaranteesExtrinsic ::= SEQUENCE SIZE(0..cores-count) OF ReportGuarantee
-- Block
Extrinsic ::= SEQUENCE {
tickets TicketsExtrinsic,
disputes DisputesExtrinsic,
preimages PreimagesExtrinsic,
assurances AssurancesExtrinsic,
guarantees GuaranteesExtrinsic
}
Block ::= SEQUENCE {
header Header,
extrinsic Extrinsic
}
END