@@ -161,7 +161,47 @@ pub fn inspector_handle_register<DB: Database, EXT: GetInspector<DB>>(
161
161
} ,
162
162
) ;
163
163
164
- // TODO(EOF) EOF create call.
164
+ // Calls inspector `eofcreate` and `initialize_interp` functions. Queues the inputs for the `eofcreate_end`` function.
165
+ // Calls the old handler, and in case of inspector returning outcome,
166
+ // returns the outcome without executing eofcreate.
167
+ let eofcreate_input_stack_inner = eofcreate_input_stack. clone ( ) ;
168
+ let old_handle = handler. execution . eofcreate . clone ( ) ;
169
+ handler. execution . eofcreate = Arc :: new (
170
+ move |ctx, mut inputs| -> Result < FrameOrResult , EVMError < DB :: Error > > {
171
+ // Call inspector to change input or return outcome.
172
+ let outcome = ctx
173
+ . external
174
+ . get_inspector ( )
175
+ . eofcreate ( & mut ctx. evm , & mut inputs) ;
176
+ eofcreate_input_stack_inner
177
+ . borrow_mut ( )
178
+ . push ( inputs. clone ( ) ) ;
179
+ if let Some ( outcome) = outcome {
180
+ return Ok ( FrameOrResult :: Result ( FrameResult :: EOFCreate ( outcome) ) ) ;
181
+ }
182
+
183
+ let mut frame_or_result = old_handle ( ctx, inputs) ;
184
+ if let Ok ( FrameOrResult :: Frame ( frame) ) = & mut frame_or_result {
185
+ ctx. external
186
+ . get_inspector ( )
187
+ . initialize_interp ( frame. interpreter_mut ( ) , & mut ctx. evm )
188
+ }
189
+ frame_or_result
190
+ } ,
191
+ ) ;
192
+
193
+ // Pops eofcreate input from the stack and calls inspector `eofcreate_end` function.
194
+ // preserve the old handler and calls it with the outcome.
195
+ let eofcreate_input_stack_inner = eofcreate_input_stack. clone ( ) ;
196
+ let old_handle = handler. execution . insert_eofcreate_outcome . clone ( ) ;
197
+ handler. execution . insert_eofcreate_outcome = Arc :: new ( move |ctx, frame, mut outcome| {
198
+ let create_inputs = eofcreate_input_stack_inner. borrow_mut ( ) . pop ( ) . unwrap ( ) ;
199
+ outcome = ctx
200
+ . external
201
+ . get_inspector ( )
202
+ . eofcreate_end ( & mut ctx. evm , & create_inputs, outcome) ;
203
+ old_handle ( ctx, frame, outcome)
204
+ } ) ;
165
205
166
206
// call outcome
167
207
let call_input_stack_inner = call_input_stack. clone ( ) ;
@@ -188,8 +228,6 @@ pub fn inspector_handle_register<DB: Database, EXT: GetInspector<DB>>(
188
228
old_handle ( ctx, frame, outcome)
189
229
} ) ;
190
230
191
- // TODO(EOF) EOF create handle.
192
-
193
231
// last frame outcome
194
232
let old_handle = handler. execution . last_frame_return . clone ( ) ;
195
233
handler. execution . last_frame_return = Arc :: new ( move |ctx, frame_result| {
0 commit comments