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 CreateOutcome in create/create_end return (b…
…luealloy#980) * 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: create outcome * fix: createOutcome properties to pub and removed wrapper functions * review: fixed some review comments and added some improvement over instruction results * fix: removed unused is_revert method * review: adjusted comments, moved create_outcome to its own file * fix: no std check --------- Co-authored-by: rakita <[email protected]>
- Loading branch information
Showing
9 changed files
with
149 additions
and
38 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,68 @@ | ||
use crate::{Gas, InstructionResult, InterpreterResult}; | ||
use revm_primitives::{Address, Bytes}; | ||
|
||
/// Represents the outcome of a create operation in an interpreter. | ||
/// | ||
/// This struct holds the result of the operation along with an optional address. | ||
/// It provides methods to determine the next action based on the result of the operation. | ||
pub struct CreateOutcome { | ||
// The result of the interpreter operation. | ||
pub result: InterpreterResult, | ||
// An optional address associated with the create operation. | ||
pub address: Option<Address>, | ||
} | ||
|
||
impl CreateOutcome { | ||
/// Constructs a new `CreateOutcome`. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `result` - An `InterpreterResult` representing the result of the interpreter operation. | ||
/// * `address` - An optional `Address` associated with the create operation. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A new `CreateOutcome` instance. | ||
pub fn new(result: InterpreterResult, address: Option<Address>) -> Self { | ||
Self { result, address } | ||
} | ||
|
||
/// Retrieves a reference to the `InstructionResult` from the `InterpreterResult`. | ||
/// | ||
/// This method provides access to the `InstructionResult` which represents the | ||
/// outcome of the instruction execution. It encapsulates the result information | ||
/// such as whether the instruction was executed successfully, resulted in a revert, | ||
/// or encountered a fatal error. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A reference to the `InstructionResult`. | ||
pub fn instruction_result(&self) -> &InstructionResult { | ||
&self.result.result | ||
} | ||
|
||
/// Retrieves a reference to the output bytes from the `InterpreterResult`. | ||
/// | ||
/// This method returns the output of the interpreted operation. The output is | ||
/// typically used when the operation successfully completes and returns data. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A reference to the output `Bytes`. | ||
pub fn output(&self) -> &Bytes { | ||
&self.result.output | ||
} | ||
|
||
/// Retrieves a reference to the `Gas` details from the `InterpreterResult`. | ||
/// | ||
/// This method provides access to the gas details of the operation, which includes | ||
/// information about gas used, remaining, and refunded. It is essential for | ||
/// understanding the gas consumption of the operation. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A reference to the `Gas` details. | ||
pub fn gas(&self) -> &Gas { | ||
&self.result.gas | ||
} | ||
} |
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
Oops, something went wrong.