forked from bluealloy/revm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: re-export all crates from
revm
(bluealloy#2088)
* refactor: re-export all crates from revm * fix * interface
- Loading branch information
Showing
19 changed files
with
202 additions
and
194 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use crate::{instructions::EthInstructions, EthFrame, Handler, MainnetHandler, PrecompileProvider}; | ||
use context::{ | ||
result::{EVMError, ExecutionResult, HaltReason, InvalidTransaction, ResultAndState}, | ||
setters::ContextSetters, | ||
ContextTr, Database, Evm, Journal, | ||
}; | ||
use database_interface::DatabaseCommit; | ||
use interpreter::{interpreter::EthInterpreter, InterpreterResult}; | ||
use primitives::Log; | ||
use state::EvmState; | ||
use std::vec::Vec; | ||
|
||
/// Execute EVM transactions. | ||
pub trait ExecuteEvm: ContextSetters { | ||
type Output; | ||
|
||
fn transact_previous(&mut self) -> Self::Output; | ||
|
||
fn transact(&mut self, tx: Self::Tx) -> Self::Output { | ||
self.set_tx(tx); | ||
self.transact_previous() | ||
} | ||
} | ||
|
||
/// Execute EVM transactions and commit to the state. | ||
/// TODO this trait can be implemented for all ExecuteEvm for specific Output/CommitOutput | ||
pub trait ExecuteCommitEvm: ExecuteEvm { | ||
type CommitOutput; | ||
|
||
fn transact_commit_previous(&mut self) -> Self::CommitOutput; | ||
|
||
fn transact_commit(&mut self, tx: Self::Tx) -> Self::CommitOutput { | ||
self.set_tx(tx); | ||
self.transact_commit_previous() | ||
} | ||
} | ||
|
||
impl<CTX, INSP, PRECOMPILES> ExecuteEvm | ||
for Evm<CTX, INSP, EthInstructions<EthInterpreter, CTX>, PRECOMPILES> | ||
where | ||
CTX: ContextSetters + ContextTr<Journal: Journal<FinalOutput = (EvmState, Vec<Log>)>>, | ||
PRECOMPILES: PrecompileProvider<Context = CTX, Output = InterpreterResult>, | ||
{ | ||
type Output = Result< | ||
ResultAndState<HaltReason>, | ||
EVMError<<CTX::Db as Database>::Error, InvalidTransaction>, | ||
>; | ||
|
||
fn transact_previous(&mut self) -> Self::Output { | ||
let mut t = MainnetHandler::<_, _, EthFrame<_, _, _>>::default(); | ||
t.run(self) | ||
} | ||
} | ||
|
||
impl<CTX, INSP, PRECOMPILES> ExecuteCommitEvm | ||
for Evm<CTX, INSP, EthInstructions<EthInterpreter, CTX>, PRECOMPILES> | ||
where | ||
CTX: ContextSetters | ||
+ ContextTr<Journal: Journal<FinalOutput = (EvmState, Vec<Log>)>, Db: DatabaseCommit>, | ||
PRECOMPILES: PrecompileProvider<Context = CTX, Output = InterpreterResult>, | ||
{ | ||
type CommitOutput = Result< | ||
ExecutionResult<HaltReason>, | ||
EVMError<<CTX::Db as Database>::Error, InvalidTransaction>, | ||
>; | ||
|
||
fn transact_commit_previous(&mut self) -> Self::CommitOutput { | ||
self.transact_previous().map(|r| { | ||
self.db().commit(r.state); | ||
r.result | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.