Extract the Engine trait (#10958)
* Add client-traits crate Move the BlockInfo trait to new crate * New crate `machine` Contains code extracted from ethcore that defines `Machine`, `Externalities` and other execution related code. * Use new machine and client-traits crates in ethcore * Use new crates machine and client-traits instead of ethcore where appropriate * Fix tests * Don't re-export so many types from ethcore::client * Fixing more fallout from removing re-export * fix test * More fallout from not re-exporting types * Add some docs * cleanup * import the macro edition style * Tweak docs * Add missing import * remove unused ethabi_derive imports * Use latest ethabi-contract * Move many traits from ethcore/client/traits to client-traits crate Initial version of extracted Engine trait * Move snapshot related traits to the engine crate (eew) * Move a few snapshot related types to common_types Cleanup Executed as exported from machine crate * fix warning * Gradually introduce new engine crate: snapshot * ethcore typechecks with new engine crate * Sort out types outside ethcore * Add an EpochVerifier to ethash and use that in Engine.epoch_verifier() Cleanup * Document pub members * Sort out tests Sort out default impls for EpochVerifier * Add test-helpers feature and move EngineSigner impl to the right place * Sort out tests * Sort out tests and refactor verification types * Fix missing traits * More missing traits Fix Histogram * Fix tests and cleanup * cleanup * Put back needed logger import * Don't rexport common_types from ethcore/src/client Don't export ethcore::client::* * Remove files no longer used Use types from the engine crate Explicit exports from engine::engine * Get rid of itertools * Move a few more traits from ethcore to client-traits: BlockChainReset, ScheduleInfo, StateClient * Move ProvingBlockChainClient to client-traits * Don't re-export ForkChoice and Transition from ethcore * Address grumbles: sort imports, remove commented out code * Fix merge resolution error * merge failure
This commit is contained in:
@@ -16,58 +16,14 @@
|
||||
|
||||
//! Transaction execution format module.
|
||||
|
||||
use ethereum_types::{U256, Address};
|
||||
use parity_bytes::Bytes;
|
||||
use vm;
|
||||
use trace::{VMTrace, FlatTrace};
|
||||
use common_types::{
|
||||
state_diff::StateDiff,
|
||||
log_entry::LogEntry,
|
||||
engines::machine,
|
||||
errors::ExecutionError,
|
||||
};
|
||||
|
||||
/// Transaction execution receipt.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct Executed<T = FlatTrace, V = VMTrace> {
|
||||
/// True if the outer call/create resulted in an exceptional exit.
|
||||
pub exception: Option<vm::Error>,
|
||||
|
||||
/// Gas paid up front for execution of transaction.
|
||||
pub gas: U256,
|
||||
|
||||
/// Gas used during execution of transaction.
|
||||
pub gas_used: U256,
|
||||
|
||||
/// Gas refunded after the execution of transaction.
|
||||
/// To get gas that was required up front, add `refunded` and `gas_used`.
|
||||
pub refunded: U256,
|
||||
|
||||
/// Cumulative gas used in current block so far.
|
||||
///
|
||||
/// `cumulative_gas_used = gas_used(t0) + gas_used(t1) + ... gas_used(tn)`
|
||||
///
|
||||
/// where `tn` is current transaction.
|
||||
pub cumulative_gas_used: U256,
|
||||
|
||||
/// Vector of logs generated by transaction.
|
||||
pub logs: Vec<LogEntry>,
|
||||
|
||||
/// Addresses of contracts created during execution of transaction.
|
||||
/// Ordered from earliest creation.
|
||||
///
|
||||
/// eg. sender creates contract A and A in constructor creates contract B
|
||||
///
|
||||
/// B creation ends first, and it will be the first element of the vector.
|
||||
pub contracts_created: Vec<Address>,
|
||||
/// Transaction output.
|
||||
pub output: Bytes,
|
||||
/// The trace of this transaction.
|
||||
pub trace: Vec<T>,
|
||||
/// The VM trace of this transaction.
|
||||
pub vm_trace: Option<V>,
|
||||
/// The state diff, if we traced it.
|
||||
pub state_diff: Option<StateDiff>,
|
||||
}
|
||||
/// /// Transaction execution receipt, parametrised with convenient defaults.
|
||||
pub type Executed = machine::Executed<FlatTrace, VMTrace>;
|
||||
|
||||
/// Transaction execution result.
|
||||
pub type ExecutionResult = Result<Box<Executed>, ExecutionError>;
|
||||
|
||||
@@ -36,14 +36,14 @@ use trace::{self, Tracer, VMTracer};
|
||||
use common_types::{
|
||||
errors::ExecutionError,
|
||||
transaction::{Action, SignedTransaction},
|
||||
engines::machine::Executed,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Machine,
|
||||
substate::Substate,
|
||||
externalities::{Externalities, OutputPolicy, OriginInfo}, // todo: make explicit
|
||||
externalities::{Externalities, OutputPolicy, OriginInfo},
|
||||
transaction_ext::Transaction,
|
||||
executed::Executed,
|
||||
};
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
|
||||
@@ -20,7 +20,6 @@ use common_types::engines::params::CommonParams;
|
||||
use ethjson;
|
||||
use crate::Machine;
|
||||
|
||||
|
||||
pub fn load_machine(reader: &[u8]) -> Machine {
|
||||
let spec = ethjson::spec::Spec::load(reader).expect("chain spec is invalid");
|
||||
|
||||
|
||||
@@ -153,12 +153,13 @@ mod test {
|
||||
use tempdir::TempDir;
|
||||
use ethereum_types::{U256, Address};
|
||||
|
||||
use client_traits::BlockChainClient;
|
||||
use common_types::{
|
||||
ids::BlockId,
|
||||
transaction::{Transaction, Action}
|
||||
};
|
||||
use ethcore::{
|
||||
client::{BlockChainClient, Client, ClientConfig},
|
||||
client::{Client, ClientConfig},
|
||||
spec::Spec,
|
||||
miner::Miner,
|
||||
test_helpers,
|
||||
|
||||
Reference in New Issue
Block a user