-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(l1,levm): remove coupling LEVM and REVM #2083
base: main
Are you sure you want to change the base?
Conversation
|
crates/blockchain/blockchain.rs
Outdated
|
||
// Validate the block pre-execution | ||
validate_block(block, &parent_header, &chain_config)?; | ||
let BlockExecutionResult { | ||
receipts, | ||
requests, | ||
account_updates, | ||
} = self.vm.execute_block(block, &mut state)?; | ||
} = self.vm.execute_block(block, self.storage.clone())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping that we could decouple the vm
from storage
. I think the vm
should not be aware of the storage
crate.
Instead, it would be ideal if vm
could define an interface for the state access it needs and blockchain
could implement that interface by calling methods from storage
.
So that our dependency tree can look more like this: https://www.mermaidchart.com/raw/4e4ac69d-5149-40e8-92f2-2466890c2893?theme=light&version=v0.1&format=svg
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can do something about it but maybe in a subsequent PR (or at least after making sure nothing breaks in the decoupling). I like the idea though!
…enum to EvmImplementation
Motivation
EvmState
whenever possible. (except for when we use REVM, of course)Description
EvmState
only in cases in which we use REVM, not for LEVM methods!get_state_transitions
, there is no need for using EvmState in it but remember that we can't useExecutionDB
with LEVM!EVM
struct that has anEvmImplementation
enum and aStore
.EVM
methods anything that can be accessed withStore
.Note: There are still functions that are both for LEVM and REVM and therefore they tend to have the parameters each EVM needs. In the case of REVM we need
state: EvmState
, and in the case of LEVM we needblock_cache: CacheDB
. We probably want to avoid passing these things as parameters.We also want to decouple our VMs from
Store
but maybe that's a change for a following PR.Note 2: We decided to keep EVM stateless because stateful had complexity attached to it. See #2096