-
Notifications
You must be signed in to change notification settings - Fork 64
/
inspect.yaml
144 lines (127 loc) · 4.43 KB
/
inspect.yaml
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
openapi: 3.0.0
info:
title: Inspect-state HTTP API for Cartesi Rollups
version: 0.6.0
license:
name: Apache-2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
description: |
API that allows the DApp frontend to make inspect-state requests to the DApp backend.
paths:
inspect/{payload}:
get:
operationId: inspect
summary: Inspect DApp state via GET
description: |
This method sends an inspect-state request to the DApp backend, passing the payload string in the URL.
The payload string should be URL-encoded; the inspect server will decode the string to UTF-8.
If the DApp frontend needs to pass a binary string to the backend then it is advised to use the POST method.
The response contains a status string and the reports generated by the DApp backend.
The status string can be either 'accept', 'reject', or 'exception'.
In case of exception, the field exception_payload will contain the exception payload;
Otherwise, this field will be null.
When running on machine mode, the whole Cartesi machine is rolled back after processing the inspect-state request.
On host mode, it is advised against changing the DApp backend state when processing an inspect-state request.
Notice that this method is synchronous, so it is not advised to be used for performing resource-intensive operations.
parameters:
- in: path
name: payload
required: true
schema:
type: string
responses:
"200":
description: Inspect state response.
content:
application/json:
schema:
$ref: "#/components/schemas/InspectResult"
default:
description: Error response.
content:
text/plain:
schema:
$ref: "#/components/schemas/Error"
inspect:
post:
operationId: inspect_post
summary: Inspect DApp state via POST
description: |
Differently from the GET method, the POST method sends an inspect-state request to the DApp backend by passing its payload in the request body.
The payload should be a binary.
Other than that, it behaves the same way as described in the GET method.
requestBody:
content:
application/octet-stream:
schema:
type: string
format: binary
responses:
"200":
description: Inspect state response.
content:
application/json:
schema:
$ref: "#/components/schemas/InspectResult"
default:
description: Error response.
content:
text/plain:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
InspectResult:
type: object
properties:
status:
$ref: "#/components/schemas/CompletionStatus"
exception_payload:
$ref: "#/components/schemas/Payload"
reports:
type: array
items:
$ref: "#/components/schemas/Report"
processed_input_count:
type: integer
description: Number of processed inputs since genesis
example: 0
required:
- status
- exception_payload
- reports
- processed_input_count
CompletionStatus:
type: string
description: Whether inspection completed or not (and why not)
enum:
[
Accepted,
Rejected,
Exception,
MachineHalted,
CycleLimitExceeded,
TimeLimitExceeded,
]
example: "Accepted"
Payload:
type: string
description: |
Payload in the Ethereum hex binary format.
The first two characters are '0x' followed by pairs of hexadecimal numbers that correspond to one byte.
For instance, '0xdeadbeef' corresponds to a payload with length 4 and bytes 222, 173, 190, 175.
An empty payload is represented by the string '0x'.
example: "0xdeadbeef"
pattern: "^0x([0-9a-fA-F]{2})*$"
format: hex
Report:
type: object
properties:
payload:
$ref: "#/components/schemas/Payload"
required:
- payload
Error:
type: string
description: Detailed error message.
example: "The request could not be understood by the server due to malformed syntax"