rust-ethereum / evm

Pure Rust implementation of Ethereum Virtual Machine
Apache License 2.0
1.17k stars 360 forks source link

refactor: introduce Interpreter trait and merge RuntimeState/GasometerState #250

Closed sorpaas closed 10 months ago

sorpaas commented 10 months ago

In Rust, the current best method of doing interpretation is not available -- to implement things like direct threading (to avoid extra jumps), we'll need either goto, or guaranteed tail optimization. It's therefore best if we make the actual execution code generic so that people can use what's best on their targets (for example, tail optimization works on x86 but not really on wasm). Eventually, we'd also want to have at least two different modes -- a baseline, and an analyzed, where the former try to use as little memory as possible, and the latter are allowed to use more, optimizing for speed.

When handling substate merging, we currently differentiate runtime vs. gasometer, which is unnecessary. So we merge them together -- gasometer is just a state in the machine's runtime.