Skip to content

Commit c726d92

Browse files
committed
Draft function call context schemas
1 parent a9dbbbb commit c726d92

File tree

4 files changed

+389
-0
lines changed

4 files changed

+389
-0
lines changed

schemas/program/context.schema.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ allOf:
5050
required: ["frame"]
5151
then:
5252
$ref: "schema:ethdebug/format/program/context/frame"
53+
- if:
54+
required: ["invoke"]
55+
then:
56+
$ref: "schema:ethdebug/format/program/context/invoke"
57+
- if:
58+
required: ["return"]
59+
then:
60+
$ref: "schema:ethdebug/format/program/context/return"
61+
- if:
62+
required: ["revert"]
63+
then:
64+
$ref: "schema:ethdebug/format/program/context/revert"
5365

5466
unevaluatedProperties: false
5567

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
$schema: "https://json-schema.org/draft/2020-12/schema"
2+
$id: "schema:ethdebug/format/program/context/invoke"
3+
4+
title: ethdebug/format/program/context/invoke
5+
description: |
6+
Schema for representing function invocation context at a specific point in
7+
program execution.
8+
9+
This context captures information about function calls, including both
10+
internal function calls (via JUMP) and external contract calls (via CALL,
11+
DELEGATECALL, STATICCALL, etc.). The schema distinguishes between these
12+
different invocation types through the use of `internal` and `external`
13+
boolean properties.
14+
15+
type: object
16+
properties:
17+
invoke:
18+
type: object
19+
title: Function invocation
20+
description: |
21+
Represents a function invocation, either internal (via JUMP) or external
22+
(via CALL opcodes). The schema enforces that exactly one of `internal`
23+
or `external` must be true.
24+
25+
For internal calls, only `target` and `arguments` are valid.
26+
For external calls, `gas`, `value`, `input`, `salt`, `delegate`,
27+
`static`, `create`, and `create2` may be used as appropriate.
28+
29+
properties:
30+
target:
31+
type: object
32+
title: Invocation target
33+
description: |
34+
Pointer to the target of the invocation. For internal calls, this
35+
typically points to a code location. For external calls, this points
36+
to the address being called.
37+
properties:
38+
pointer:
39+
$ref: "schema:ethdebug/format/pointer"
40+
required:
41+
- pointer
42+
additionalProperties: false
43+
44+
internal:
45+
type: boolean
46+
description: |
47+
Indicates this is an internal function call (JUMP/JUMPI).
48+
49+
external:
50+
type: boolean
51+
description: |
52+
Indicates this is an external contract call (CALL/DELEGATECALL/etc).
53+
54+
arguments:
55+
type: object
56+
title: Function arguments
57+
description: |
58+
Pointer to the arguments for an internal function call.
59+
Only valid for internal calls.
60+
properties:
61+
pointer:
62+
$ref: "schema:ethdebug/format/pointer"
63+
required:
64+
- pointer
65+
additionalProperties: false
66+
67+
gas:
68+
type: object
69+
title: Gas allocation
70+
description: |
71+
Pointer to the gas allocated for an external call.
72+
Only valid for external calls.
73+
properties:
74+
pointer:
75+
$ref: "schema:ethdebug/format/pointer"
76+
required:
77+
- pointer
78+
additionalProperties: false
79+
80+
value:
81+
type: object
82+
title: ETH value
83+
description: |
84+
Pointer to the amount of ETH being sent with an external call.
85+
Only valid for external calls.
86+
properties:
87+
pointer:
88+
$ref: "schema:ethdebug/format/pointer"
89+
required:
90+
- pointer
91+
additionalProperties: false
92+
93+
input:
94+
type: object
95+
title: Call input data
96+
description: |
97+
Pointer to the input data for an external call.
98+
Only valid for external calls.
99+
properties:
100+
pointer:
101+
$ref: "schema:ethdebug/format/pointer"
102+
required:
103+
- pointer
104+
additionalProperties: false
105+
106+
salt:
107+
type: object
108+
title: CREATE2 salt
109+
description: |
110+
Pointer to the salt value for CREATE2.
111+
Only valid when create2 is true.
112+
properties:
113+
pointer:
114+
$ref: "schema:ethdebug/format/pointer"
115+
required:
116+
- pointer
117+
additionalProperties: false
118+
119+
delegate:
120+
type: boolean
121+
description: |
122+
Indicates this external call is a DELEGATECALL.
123+
Only valid when external is true.
124+
125+
static:
126+
type: boolean
127+
description: |
128+
Indicates this external call is a STATICCALL.
129+
Only valid when external is true.
130+
131+
create:
132+
type: boolean
133+
description: |
134+
Indicates this external call creates a new contract (CREATE).
135+
Only valid when external is true.
136+
137+
create2:
138+
type: boolean
139+
description: |
140+
Indicates this external call creates a new contract (CREATE2).
141+
Only valid when external is true.
142+
143+
required:
144+
- target
145+
146+
oneOf:
147+
- properties:
148+
internal:
149+
const: true
150+
required:
151+
- internal
152+
- properties:
153+
external:
154+
const: true
155+
required:
156+
- external
157+
158+
required:
159+
- invoke
160+
161+
additionalProperties: false
162+
163+
examples:
164+
- invoke:
165+
target:
166+
pointer:
167+
location: code
168+
offset: 291
169+
length: 2
170+
internal: true
171+
arguments:
172+
pointer:
173+
location: stack
174+
slot: 0
175+
length: 3
176+
177+
- invoke:
178+
target:
179+
pointer:
180+
location: stack
181+
slot: 0
182+
external: true
183+
value:
184+
pointer:
185+
location: stack
186+
slot: 1
187+
gas:
188+
pointer:
189+
location: stack
190+
slot: 2
191+
input:
192+
pointer:
193+
location: memory
194+
offset: 128
195+
length: 68
196+
197+
- invoke:
198+
target:
199+
pointer:
200+
location: stack
201+
slot: 0
202+
external: true
203+
delegate: true
204+
gas:
205+
pointer:
206+
location: stack
207+
slot: 1
208+
input:
209+
pointer:
210+
location: calldata
211+
offset: 4
212+
length: 68
213+
214+
- invoke:
215+
target:
216+
pointer:
217+
location: stack
218+
slot: 0
219+
external: true
220+
create2: true
221+
salt:
222+
pointer:
223+
location: stack
224+
slot: 1
225+
value:
226+
pointer:
227+
location: stack
228+
slot: 2
229+
input:
230+
pointer:
231+
location: memory
232+
offset: 0
233+
length: 200
234+
235+
- invoke:
236+
target:
237+
pointer:
238+
location: stack
239+
slot: 0
240+
external: true
241+
static: true
242+
gas:
243+
pointer:
244+
location: stack
245+
slot: 1
246+
input:
247+
pointer:
248+
location: calldata
249+
offset: 4
250+
length: 36
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
$schema: "https://json-schema.org/draft/2020-12/schema"
2+
$id: "schema:ethdebug/format/program/context/return"
3+
4+
title: ethdebug/format/program/context/return
5+
description: |
6+
Schema for representing function return context at a specific point in
7+
program execution.
8+
9+
This context captures information about successful function returns,
10+
including the return data and, for external calls, the success status.
11+
12+
type: object
13+
properties:
14+
return:
15+
type: object
16+
properties:
17+
data:
18+
type: object
19+
title: Return data
20+
description: |
21+
Pointer to the data being returned from the function.
22+
properties:
23+
pointer:
24+
$ref: "schema:ethdebug/format/pointer"
25+
required:
26+
- pointer
27+
28+
success:
29+
type: object
30+
title: Call success status
31+
description: |
32+
Pointer to the success status of an external call.
33+
Typically points to a boolean value on the stack.
34+
properties:
35+
pointer:
36+
$ref: "schema:ethdebug/format/pointer"
37+
required:
38+
- pointer
39+
40+
required:
41+
- return
42+
43+
additionalProperties: false
44+
45+
examples:
46+
- return:
47+
data:
48+
pointer:
49+
location: memory
50+
offset: 0x40
51+
length: 0x20
52+
53+
- return:
54+
data:
55+
pointer:
56+
location: memory
57+
offset: 0x40
58+
length: 0x20
59+
success:
60+
pointer:
61+
location: stack
62+
slot: 0
63+
64+
- return:
65+
data:
66+
pointer:
67+
location: returndata
68+
offset: 0
69+
length: 32

0 commit comments

Comments
 (0)