executed & trace moved
This commit is contained in:
parent
2a721b4eda
commit
25c88b7529
@ -20,47 +20,7 @@ use util::*;
|
||||
use header::BlockNumber;
|
||||
use basic_types::LogBloom;
|
||||
|
||||
/// Result of executing the transaction.
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub enum ExecutionError {
|
||||
/// Returned when there gas paid for transaction execution is
|
||||
/// lower than base gas required.
|
||||
NotEnoughBaseGas {
|
||||
/// Absolute minimum gas required.
|
||||
required: U256,
|
||||
/// Gas provided.
|
||||
got: U256
|
||||
},
|
||||
/// Returned when block (gas_used + gas) > gas_limit.
|
||||
///
|
||||
/// If gas =< gas_limit, upstream may try to execute the transaction
|
||||
/// in next block.
|
||||
BlockGasLimitReached {
|
||||
/// Gas limit of block for transaction.
|
||||
gas_limit: U256,
|
||||
/// Gas used in block prior to transaction.
|
||||
gas_used: U256,
|
||||
/// Amount of gas in block.
|
||||
gas: U256
|
||||
},
|
||||
/// Returned when transaction nonce does not match state nonce.
|
||||
InvalidNonce {
|
||||
/// Nonce expected.
|
||||
expected: U256,
|
||||
/// Nonce found.
|
||||
got: U256
|
||||
},
|
||||
/// Returned when cost of transaction (value + gas_price * gas) exceeds
|
||||
/// current sender balance.
|
||||
NotEnoughCash {
|
||||
/// Minimum required balance.
|
||||
required: U512,
|
||||
/// Actual balance.
|
||||
got: U512
|
||||
},
|
||||
/// Returned when internal evm error occurs.
|
||||
Internal
|
||||
}
|
||||
pub use types::executed::ExecutionError;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// Errors concerning transaction processing.
|
||||
|
@ -24,6 +24,8 @@ use substate::*;
|
||||
use trace::{Trace, Tracer, NoopTracer, ExecutiveTracer};
|
||||
use crossbeam;
|
||||
|
||||
pub use types::executed::{Executed, ExecutionResult};
|
||||
|
||||
/// Max depth to avoid stack overflow (when it's reached we start a new thread with VM)
|
||||
/// TODO [todr] We probably need some more sophisticated calculations here (limit on my machine 132)
|
||||
/// Maybe something like here: `https://github.com/ethereum/libethereum/blob/4db169b8504f2b87f7d5a481819cfb959fc65f6c/libethereum/ExtVM.cpp`
|
||||
@ -45,45 +47,6 @@ pub struct TransactOptions {
|
||||
pub check_nonce: bool,
|
||||
}
|
||||
|
||||
/// Transaction execution receipt.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct Executed {
|
||||
/// 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: Option<Trace>,
|
||||
}
|
||||
|
||||
/// Transaction execution result.
|
||||
pub type ExecutionResult = Result<Executed, ExecutionError>;
|
||||
|
||||
/// Transaction executor.
|
||||
pub struct Executive<'a> {
|
||||
state: &'a mut State,
|
||||
|
@ -25,12 +25,12 @@ pub mod flat;
|
||||
mod import;
|
||||
mod localized;
|
||||
mod noop_tracer;
|
||||
pub mod trace;
|
||||
|
||||
pub use types::trace_types::*;
|
||||
pub use self::block::BlockTraces;
|
||||
pub use self::config::{Config, Switch};
|
||||
pub use self::db::TraceDB;
|
||||
pub use self::trace::Trace;
|
||||
pub use types::trace_types::trace::Trace;
|
||||
pub use self::noop_tracer::NoopTracer;
|
||||
pub use self::executive_tracer::ExecutiveTracer;
|
||||
pub use types::trace_types::filter::{Filter, AddressesFilter};
|
||||
|
105
ethcore/src/types/executed.rs
Normal file
105
ethcore/src/types/executed.rs
Normal file
@ -0,0 +1,105 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Transaction execution format module.
|
||||
|
||||
use util::*;
|
||||
use trace::Trace;
|
||||
use types::log_entry::LogEntry;
|
||||
|
||||
|
||||
|
||||
/// Transaction execution receipt.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct Executed {
|
||||
/// 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: Option<Trace>,
|
||||
}
|
||||
|
||||
/// Result of executing the transaction.
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub enum ExecutionError {
|
||||
/// Returned when there gas paid for transaction execution is
|
||||
/// lower than base gas required.
|
||||
NotEnoughBaseGas {
|
||||
/// Absolute minimum gas required.
|
||||
required: U256,
|
||||
/// Gas provided.
|
||||
got: U256
|
||||
},
|
||||
/// Returned when block (gas_used + gas) > gas_limit.
|
||||
///
|
||||
/// If gas =< gas_limit, upstream may try to execute the transaction
|
||||
/// in next block.
|
||||
BlockGasLimitReached {
|
||||
/// Gas limit of block for transaction.
|
||||
gas_limit: U256,
|
||||
/// Gas used in block prior to transaction.
|
||||
gas_used: U256,
|
||||
/// Amount of gas in block.
|
||||
gas: U256
|
||||
},
|
||||
/// Returned when transaction nonce does not match state nonce.
|
||||
InvalidNonce {
|
||||
/// Nonce expected.
|
||||
expected: U256,
|
||||
/// Nonce found.
|
||||
got: U256
|
||||
},
|
||||
/// Returned when cost of transaction (value + gas_price * gas) exceeds
|
||||
/// current sender balance.
|
||||
NotEnoughCash {
|
||||
/// Minimum required balance.
|
||||
required: U512,
|
||||
/// Actual balance.
|
||||
got: U512
|
||||
},
|
||||
/// Returned when internal evm error occurs.
|
||||
Internal
|
||||
}
|
||||
|
||||
|
||||
/// Transaction execution result.
|
||||
pub type ExecutionResult = Result<Executed, ExecutionError>;
|
@ -23,3 +23,4 @@ pub mod tree_route;
|
||||
pub mod blockchain_info;
|
||||
pub mod log_entry;
|
||||
pub mod trace_types;
|
||||
pub mod executed;
|
||||
|
@ -20,7 +20,7 @@ use util::{Address, FixedHash};
|
||||
use util::sha3::Hashable;
|
||||
use basic_types::LogBloom;
|
||||
use trace::flat::FlatTrace;
|
||||
use trace::trace::Action;
|
||||
use types::trace_types::trace::Action;
|
||||
|
||||
/// Addresses filter.
|
||||
///
|
||||
|
@ -17,3 +17,4 @@
|
||||
//! Types used in the public api
|
||||
|
||||
pub mod filter;
|
||||
pub mod trace;
|
||||
|
Loading…
Reference in New Issue
Block a user