Skip to content

Conversation

@yascha
Copy link

@yascha yascha commented Mar 28, 2024

Add example of (unsafe) implementation of a handler that can be used to execute arbitrary EVM calls before a given evm instruction. Useful in the new REVM model.

Example usage in EVM builder:

let old_handle = handler.execution_loop.pre_run_interpreter.clone();
            handler.execution_loop.pre_run_interpreter = Arc::new(
                move |evm: &mut Evm<'_, IE, DB>,
                      table: &[Box<dyn Fn(&mut Interpreter, &mut Evm<'_, IE, DB>)>; 256],
                      frame: &mut Box<CallStackFrame>|
                      -> Option<InterpreterAction> {
                    let engine_evm = EngineEVM {
                        evm,
                        table,
                        current_stack_frame: frame,
                    };
                    if let Some(pre_run) = IE::on_pre_run_interpreter(engine_evm) {
                        return Some(pre_run);
                    }
                    old_handle(evm, table, frame)
                },
            );

…n be used to arbitrarily execute EVM calls before a given evm instruction.
@rakita
Copy link
Member

rakita commented Mar 29, 2024

Ty, will check it out

@gakonst
Copy link
Collaborator

gakonst commented Apr 2, 2024

@yascha interesting, how do you think about the use case for this?

@yascha
Copy link
Author

yascha commented Apr 3, 2024

@gakonst with the old implementation of revm, it was very easy to manipulate the evm (in a very custom manner) via rust code. The new model has some incredibly nice changes, but it makes the evm manipulation trickier.
I've been using a variant of this hook for some time to enable executing arbitrary evm code anywhere within a callstack.

@rakita
Copy link
Member

rakita commented May 4, 2024

Effort is moved to this PR: #1369

@rakita rakita closed this May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants