rust-ethereum / evm

Pure Rust implementation of Ethereum Virtual Machine
Apache License 2.0
1.16k stars 355 forks source link

Support of far calls and CREATE #269

Closed hedgar2017 closed 7 months ago

hedgar2017 commented 8 months ago

Hi everyone!

We are eager to use your EVM interpreter for testing our LLVM-based compiler toolchain targeting EVM. The emulator works very well with single contracts, but we would also like to run some multi-contract project with external calls and CREATE sequences. I can see them stubbed with traps in the handlers.

Is there a planned support of such opcodes? Is it possible to contribute and how? I reviewed PRs and issues briefly and couldn't find relevant ones.

Thanks in advance!

sorpaas commented 8 months ago

Are you using the 0.x or 1.0-alpha version? In any case, yes the CREATE/CALL opcodes will trap on evm_core::Interpreter (for 0.x) or evm_interpreter::interpreter::EtableInterpreter (for 1.0-alpha). You are not supposed to use that directly unless you do something really customized.

CREATE/CALL requires a call stack, and that's implemented in evm. If you use 0.x, you can find StackExecutor which will be what you need. If you use 1.0-alpha, it allows much more customizibility, and the entrypoint is simply evm::transact. We'll add more docs soon!

hedgar2017 commented 8 months ago

@sorpaas thanks for your response! I will investigate the direct usage soon. Is it still possible to override the context values (e.g. chain_id) to make our test datasets work? Our testing infrastructure is quite minimal. We just submit code, context, and calldata, and check if the return data and events returned match the expected data.

hedgar2017 commented 7 months ago

@sorpaas are there any default implementations for Invoker for evm:transact?

sorpaas commented 7 months ago

The standard invoker! https://docs.rs/evm/1.0.0-alpha.2/evm/standard/struct.Invoker.html

hedgar2017 commented 7 months ago

The standard invoker! https://docs.rs/evm/1.0.0-alpha.2/evm/standard/struct.Invoker.html

Oh great, I'd overlooked it, thanks!