-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitments-jsonrpc.yml
More file actions
514 lines (490 loc) · 15.8 KB
/
commitments-jsonrpc.yml
File metadata and controls
514 lines (490 loc) · 15.8 KB
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
openapi: 3.0.0
info:
title: "Commitments API"
description: |
JSON-RPC endpoints and schemas for issuing proposer commitments and relevant helper functions.
version: "v0.0.1 - Ethereum Commitments API Specification v0.0.1"
contact:
name: Ethereum Commitments Github
url: https://github.com/eth-fabric/commitments-specs/issues
license:
name: "MIT License and Apache 2.0 License"
url: "https://github.com/eth-fabric/commitments-specs/"
servers:
- url: "{server_url}"
variables:
server_url:
description: "Commitments API URL"
default: "http://localhost/"
tags:
- name: "Commitments API"
description: "JSON-RPC endpoints and schemas for issuing proposer commitments and relevant helper functions."
x-constants:
MAX_CONSTRAINTS_PER_SLOT: 32
x-envelope: "jsonrpc-2.0"
paths:
/commitmentRequest:
post:
operationId: "commitmentRequest"
tags:
- Commitments API
summary: "Request a new SignedCommitment"
description: |
JSON-RPC endpoint for requesting a new SignedCommitment.
A `CommitmentRequest` contains an opaque `payload` bytes input that can be decoded according to the `commitment_type`. By making a request, the user / app / wallet is asking for the Gateway to make a commitment that is enforceable via the specified `slasher` contract.
Each `commitment_type` has its own rules for how a Gateway maps a `CommitmentRequest.payload` to a `Commitment.payload`. The `Commitment.request_hash` field is used to bind the `Commitment` to a specific `CommitmentRequest`, however this is not required to correspond 1:1.
The `SignedCommitment` is the response to the `CommitmentRequest`. It contains the `Commitment` and the ECDSA signature over the `Commitment`.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CommitmentRequestInp'
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: '#/components/schemas/SignedCommitmentOut'
"400":
description: "Bad Request - Invalid commitment request"
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorOut'
"500":
description: "Internal Server Error"
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorOut'
/commitmentResult:
post:
operationId: "commitmentResult"
tags:
- Commitments API
summary: "Request an old SignedCommitment"
description: |
JSON-RPC endpoint for retrieving a previously signed commitment.
When supplied with a valid `request_hash`, this endpoint responds with the `SignedCommitment` object containing the same `SignedCommitment.Commitment.request_hash`.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CommitmentResultInp'
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: '#/components/schemas/SignedCommitmentOut'
"404":
description: "Not Found - No commitment found for the given request hash"
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorOut'
"500":
description: "Internal Server Error"
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorOut'
/slots:
post:
operationId: "slots"
tags:
- Commitments API
summary: "Get Gateway information for upcoming slots"
description: |
JSON-RPC endpoint for retrieving Gateway information for upcoming slots.
When called, the Gateway returns a `SlotInfo` for each upcoming L1 slot in the current or upcoming epoch.
Each `SlotInfo` contains a list of `Offering` objects which specify the types of commitments they offer for a given chain, e.g., inclusion preconfs for the L1.
It should be noted that this endpoint does not provide guarantees that the Gateway is actually capable of providing these.
For example, for proposer commitments that require delegations, the user should also consult the Constraints API to verify if the Gateway received delegations for the slot in question.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SlotsInp'
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: '#/components/schemas/SlotInfoResponseOut'
"500":
description: "Internal Server Error"
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorOut'
/fee:
post:
operationId: "fee"
tags:
- Commitments API
summary: "Get commitment fee information"
description: |
JSON-RPC endpoint for retrieving commitment fee information.
Since each proposer commitment protocol may have differing pricing mechanisms, i.e., per-request or subscription based,
this endpoint is intentionally left generic. Users submit a `CommitmentRequest` and receive a `FeeInfo` object containing
opaque `payload` bytes and a `commitment_type` to decode the `payload` into protocol-specific pricing information.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/FeeInp'
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: '#/components/schemas/FeeInfoOut'
"400":
description: "Bad Request - Invalid commitment request"
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorOut'
"500":
description: "Internal Server Error"
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorOut'
components:
schemas:
# Input schemas (for request params)
CommitmentRequestInp:
type: object
properties:
jsonrpc:
type: string
enum: ["2.0"]
description: JSON-RPC version
example: "2.0"
method:
type: string
enum: ["commitmentRequest"]
description: JSON-RPC method name
example: "commitmentRequest"
params:
type: object
properties:
commitment_type:
type: integer
format: uint64
description: Type of commitment being requested
example: 1
payload:
type: string
format: byte
description: Opaque input bytes used as part of the commitment
example: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
slasher:
type: string
description: Slasher contract for resolving commitment disputes
example: "0x1234567890123456789012345678901234567890"
required:
- commitment_type
- payload
- slasher
id:
oneOf:
- type: string
- type: integer
description: JSON-RPC request ID
example: 1
required:
- jsonrpc
- method
- params
- id
CommitmentResultInp:
type: object
properties:
jsonrpc:
type: string
enum: ["2.0"]
description: JSON-RPC version
example: "2.0"
method:
type: string
enum: ["commitmentResult"]
description: JSON-RPC method name
example: "commitmentResult"
params:
type: object
properties:
request_hash:
type: string
format: bytes32
description: Hash of the CommitmentRequest to retrieve
example: "0x1234567890123456789012345678901234567890000000000000000000000000"
required:
- request_hash
id:
oneOf:
- type: string
- type: integer
description: JSON-RPC request ID
example: 1
required:
- jsonrpc
- method
- params
- id
SlotsInp:
type: object
properties:
jsonrpc:
type: string
enum: ["2.0"]
description: JSON-RPC version
example: "2.0"
method:
type: string
enum: ["slots"]
description: JSON-RPC method name
example: "slots"
params:
type: object
description: No parameters required for this method
example: {}
id:
oneOf:
- type: string
- type: integer
description: JSON-RPC request ID
example: 1
required:
- jsonrpc
- method
- params
- id
FeeInp:
type: object
properties:
jsonrpc:
type: string
enum: ["2.0"]
description: JSON-RPC version
example: "2.0"
method:
type: string
enum: ["fee"]
description: JSON-RPC method name
example: "fee"
params:
type: object
properties:
commitment_type:
type: integer
format: uint64
description: Type of commitment being requested
example: 1
payload:
type: string
format: byte
description: Opaque input bytes used as part of the commitment
example: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
slasher:
type: string
description: Slasher contract for resolving commitment disputes
example: "0x1234567890123456789012345678901234567890"
required:
- commitment_type
- payload
- slasher
id:
oneOf:
- type: string
- type: integer
description: JSON-RPC request ID
example: 1
required:
- jsonrpc
- method
- params
- id
# Output schemas (for response results)
SignedCommitmentOut:
type: object
properties:
jsonrpc:
type: string
enum: ["2.0"]
description: JSON-RPC version
example: "2.0"
result:
type: object
properties:
commitment:
type: object
properties:
commitment_type:
type: integer
format: uint64
description: The type of commitment being made
example: 1
payload:
type: string
format: byte
description: Opaque payload bytes of the commitment
example: "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
request_hash:
type: string
format: bytes32
description: Hash of the CommitmentRequest this Commitment is for
example: "0x1234567890123456789012345678901234567890000000000000000000000000"
slasher:
type: string
description: Slasher contract for resolving commitment disputes
example: "0x1234567890123456789012345678901234567890"
required:
- commitment_type
- payload
- request_hash
- slasher
signature:
type: string
description: The ECDSA signature of the commitment message
example: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b"
required:
- commitment
- signature
id:
oneOf:
- type: string
- type: integer
description: JSON-RPC request ID
example: 1
required:
- jsonrpc
- result
- id
SlotInfoResponseOut:
type: object
properties:
jsonrpc:
type: string
enum: ["2.0"]
description: JSON-RPC version
example: "2.0"
result:
type: object
properties:
slots:
type: array
items:
type: object
properties:
slot:
type: integer
description: The L1 slot number
example: 1000
offerings:
type: array
items:
type: object
properties:
chain_id:
type: integer
format: uint64
description: The id of the target chain
example: 1
commitment_types:
type: array
items:
type: integer
format: uint64
description: The types of commitments offered for the target chain
example: [1, 2]
required:
- chain_id
- commitment_types
description: The list of chain offerings
description: A list of slot infos
required:
- slots
id:
oneOf:
- type: string
- type: integer
description: JSON-RPC request ID
example: 1
required:
- jsonrpc
- result
- id
FeeInfoOut:
type: object
properties:
jsonrpc:
type: string
enum: ["2.0"]
description: JSON-RPC version
example: "2.0"
result:
type: object
properties:
payload:
type: string
format: byte
description: Opaque bytes containing fee info related to the commitment type
example: "0xfee1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
commitment_type:
type: integer
format: uint64
description: Type of commitment being requested
example: 1
required:
- payload
- commitment_type
id:
oneOf:
- type: string
- type: integer
description: JSON-RPC request ID
example: 1
required:
- jsonrpc
- result
- id
ErrorOut:
type: object
properties:
jsonrpc:
type: string
enum: ["2.0"]
description: JSON-RPC version
example: "2.0"
error:
type: object
properties:
code:
type: integer
description: JSON-RPC error code
example: -32602
message:
type: string
description: JSON-RPC error message
example: "Invalid params"
id:
oneOf:
- type: string
- type: integer
description: JSON-RPC request ID
example: 1
required:
- jsonrpc
- error
- id