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(Inspector): add CallOutcome to call/call_end (bluealloy#985)
* rename main Evm structs, introduce wip external type * tests * Split evm and external context * continue previous commit * wip inspector handle register * add few more handlers for frame and host * Add instruction handle * add instruction handler registration and Inspector wrap * Rm Spec generic, more handlers, start factory * move towards the builder, allow EVM modify * wip on EvmBuilder and modify functionality * EvmBuilder with stages wip * Add wip stages for builer * make handle register simple function, add raw instruction table, split external data from registers * wip on simple builder functions and handler registry * Examples and cleanup * fix lifetime and fmt * Add more handlers, deduct caller, validate tx agains state * All handlers counted, started on docs, some cleanup * renaming and docs * Support all Inspector functionality with Handler * Handler restructured. Documentation added * more docs on registers * integrate builder, fmt, move optimism l1block * add utility builder stage functions * add precompiles, fix bugs with journal spec * spec to generic, optimism build * fix optimism test * fuck macros * clippy and fmt * fix trace block example * ci fixes * Flatten builder stages to generic and handler stage * EvmBuilder doc and refactor fn access * ignore rust code in book * make revme compile, will refactor this in future * Rename handles to Pre/Post Execution and ExecutionLoop * fix optimism clippy * small rename * FrameData and docs * check links mdbook * comments and cleanup * comment * Add initialize interepreter to first frame * clippy * clippy2 * feat: add callOutcome and added to inspector.call * added meaningful rust docs
- Loading branch information
Showing
9 changed files
with
152 additions
and
44 deletions.
There are no files selected for viewing
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,89 @@ | ||
use crate::{Gas, InstructionResult, InterpreterResult}; | ||
use core::ops::Range; | ||
use revm_primitives::Bytes; | ||
|
||
/// Represents the outcome of a call operation in a virtual machine. | ||
/// | ||
/// This struct encapsulates the result of executing an instruction by an interpreter, including | ||
/// the result itself, gas usage information, and the memory offset where output data is stored. | ||
/// | ||
/// # Fields | ||
/// | ||
/// * `interpreter_result` - The result of the interpreter's execution, including output data and gas usage. | ||
/// * `memory_offset` - The range in memory where the output data is located. | ||
pub struct CallOutcome { | ||
pub interpreter_result: InterpreterResult, | ||
pub memory_offset: Range<usize>, | ||
} | ||
|
||
impl CallOutcome { | ||
/// Constructs a new `CallOutcome`. | ||
/// | ||
/// Creates an instance of `CallOutcome` with the given interpreter result and memory offset. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `interpreter_result` - The result of the interpreter's execution. | ||
/// * `memory_offset` - The range in memory indicating where the output data is stored. | ||
pub fn new(interpreter_result: InterpreterResult, memory_offset: Range<usize>) -> Self { | ||
Self { | ||
interpreter_result, | ||
memory_offset, | ||
} | ||
} | ||
|
||
/// Returns a reference to the instruction result. | ||
/// | ||
/// Provides access to the result of the executed instruction. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A reference to the `InstructionResult`. | ||
pub fn instruction_result(&self) -> &InstructionResult { | ||
&self.interpreter_result.result | ||
} | ||
|
||
/// Returns the gas usage information. | ||
/// | ||
/// Provides access to the gas usage details of the executed instruction. | ||
/// | ||
/// # Returns | ||
/// | ||
/// An instance of `Gas` representing the gas usage. | ||
pub fn gas(&self) -> Gas { | ||
self.interpreter_result.gas | ||
} | ||
|
||
/// Returns a reference to the output data. | ||
/// | ||
/// Provides access to the output data generated by the executed instruction. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A reference to the output data as `Bytes`. | ||
pub fn output(&self) -> &Bytes { | ||
&self.interpreter_result.output | ||
} | ||
|
||
/// Returns the start position of the memory offset. | ||
/// | ||
/// Provides the starting index of the memory range where the output data is stored. | ||
/// | ||
/// # Returns | ||
/// | ||
/// The starting index of the memory offset as `usize`. | ||
pub fn memory_start(&self) -> usize { | ||
self.memory_offset.start | ||
} | ||
|
||
/// Returns the length of the memory range. | ||
/// | ||
/// Provides the length of the memory range where the output data is stored. | ||
/// | ||
/// # Returns | ||
/// | ||
/// The length of the memory range as `usize`. | ||
pub fn memory_length(&self) -> usize { | ||
self.memory_offset.len() | ||
} | ||
} |
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