Merge branch 'master' into itertools
This commit is contained in:
@@ -25,11 +25,9 @@ use engines::epoch::{Transition as EpochTransition};
|
||||
use header::BlockNumber;
|
||||
use receipt::Receipt;
|
||||
|
||||
use rlp::*;
|
||||
use util::*;
|
||||
use util::{HeapSizeOf, H256, H264, U256};
|
||||
use util::kvdb::PREFIX_LEN as DB_PREFIX_LEN;
|
||||
|
||||
|
||||
/// Represents index of extra data in database
|
||||
#[derive(Copy, Debug, Hash, Eq, PartialEq, Clone)]
|
||||
pub enum ExtrasIndex {
|
||||
@@ -184,7 +182,7 @@ impl Key<EpochTransitions> for u64 {
|
||||
}
|
||||
|
||||
/// Familial details concerning a block
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, RlpEncodable, RlpDecodable)]
|
||||
pub struct BlockDetails {
|
||||
/// Block number
|
||||
pub number: BlockNumber,
|
||||
@@ -202,30 +200,8 @@ impl HeapSizeOf for BlockDetails {
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for BlockDetails {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
let details = BlockDetails {
|
||||
number: rlp.val_at(0)?,
|
||||
total_difficulty: rlp.val_at(1)?,
|
||||
parent: rlp.val_at(2)?,
|
||||
children: rlp.list_at(3)?,
|
||||
};
|
||||
Ok(details)
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for BlockDetails {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(4);
|
||||
s.append(&self.number);
|
||||
s.append(&self.total_difficulty);
|
||||
s.append(&self.parent);
|
||||
s.append_list(&self.children);
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents address of certain transaction within block
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)]
|
||||
pub struct TransactionAddress {
|
||||
/// Block hash
|
||||
pub block_hash: H256,
|
||||
@@ -237,27 +213,8 @@ impl HeapSizeOf for TransactionAddress {
|
||||
fn heap_size_of_children(&self) -> usize { 0 }
|
||||
}
|
||||
|
||||
impl Decodable for TransactionAddress {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
let tx_address = TransactionAddress {
|
||||
block_hash: rlp.val_at(0)?,
|
||||
index: rlp.val_at(1)?,
|
||||
};
|
||||
|
||||
Ok(tx_address)
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for TransactionAddress {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(2);
|
||||
s.append(&self.block_hash);
|
||||
s.append(&self.index);
|
||||
}
|
||||
}
|
||||
|
||||
/// Contains all block receipts.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, RlpEncodableWrapper, RlpDecodableWrapper)]
|
||||
pub struct BlockReceipts {
|
||||
pub receipts: Vec<Receipt>,
|
||||
}
|
||||
@@ -270,20 +227,6 @@ impl BlockReceipts {
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for BlockReceipts {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
Ok(BlockReceipts {
|
||||
receipts: rlp.as_list()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for BlockReceipts {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.append_list(&self.receipts);
|
||||
}
|
||||
}
|
||||
|
||||
impl HeapSizeOf for BlockReceipts {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
self.receipts.heap_size_of_children()
|
||||
@@ -291,27 +234,12 @@ impl HeapSizeOf for BlockReceipts {
|
||||
}
|
||||
|
||||
/// Candidate transitions to an epoch with specific number.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, RlpEncodable, RlpDecodable)]
|
||||
pub struct EpochTransitions {
|
||||
pub number: u64,
|
||||
pub candidates: Vec<EpochTransition>,
|
||||
}
|
||||
|
||||
impl Encodable for EpochTransitions {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(2).append(&self.number).append_list(&self.candidates);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for EpochTransitions {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
Ok(EpochTransitions {
|
||||
number: rlp.val_at(0)?,
|
||||
candidates: rlp.list_at(1)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use rlp::*;
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use bloomchain as bc;
|
||||
use rlp::*;
|
||||
use util::HeapSizeOf;
|
||||
use basic_types::LogBloom;
|
||||
|
||||
/// Helper structure representing bloom of the trace.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, RlpEncodableWrapper, RlpDecodableWrapper)]
|
||||
pub struct Bloom(LogBloom);
|
||||
|
||||
impl From<LogBloom> for Bloom {
|
||||
@@ -43,18 +42,6 @@ impl Into<bc::Bloom> for Bloom {
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Bloom {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
LogBloom::decode(rlp).map(Bloom)
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for Bloom {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
Encodable::rlp_append(&self.0, s)
|
||||
}
|
||||
}
|
||||
|
||||
impl HeapSizeOf for Bloom {
|
||||
fn heap_size_of_children(&self) -> usize {
|
||||
0
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
|
||||
//! Epoch verifiers and transitions.
|
||||
|
||||
use util::H256;
|
||||
use error::Error;
|
||||
use header::Header;
|
||||
|
||||
use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp};
|
||||
use util::H256;
|
||||
|
||||
/// A full epoch transition.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, RlpEncodable, RlpDecodable)]
|
||||
pub struct Transition {
|
||||
/// Block hash at which the transition occurred.
|
||||
pub block_hash: H256,
|
||||
@@ -33,46 +31,14 @@ pub struct Transition {
|
||||
pub proof: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Encodable for Transition {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(3)
|
||||
.append(&self.block_hash)
|
||||
.append(&self.block_number)
|
||||
.append(&self.proof);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Transition {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
Ok(Transition {
|
||||
block_hash: rlp.val_at(0)?,
|
||||
block_number: rlp.val_at(1)?,
|
||||
proof: rlp.val_at(2)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// An epoch transition pending a finality proof.
|
||||
/// Not all transitions need one.
|
||||
#[derive(RlpEncodableWrapper, RlpDecodableWrapper)]
|
||||
pub struct PendingTransition {
|
||||
/// "transition/epoch" proof from the engine.
|
||||
pub proof: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Encodable for PendingTransition {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.append(&self.proof);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for PendingTransition {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
Ok(PendingTransition {
|
||||
proof: rlp.as_val()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Verifier for all blocks within an epoch with self-contained state.
|
||||
///
|
||||
/// See docs on `Engine` relating to proving functions for more details.
|
||||
|
||||
@@ -101,6 +101,9 @@ extern crate num;
|
||||
extern crate price_info;
|
||||
extern crate rand;
|
||||
extern crate rlp;
|
||||
|
||||
#[macro_use]
|
||||
extern crate rlp_derive;
|
||||
extern crate rustc_hex;
|
||||
extern crate semver;
|
||||
extern crate stats;
|
||||
|
||||
@@ -27,7 +27,7 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
use util::Bytes;
|
||||
use util::hash::H256;
|
||||
use rlp::{self, Encodable, RlpStream, UntrustedRlp};
|
||||
use rlp::{RlpStream, UntrustedRlp};
|
||||
|
||||
use super::ManifestData;
|
||||
|
||||
@@ -49,24 +49,9 @@ pub trait SnapshotWriter {
|
||||
}
|
||||
|
||||
// (hash, len, offset)
|
||||
#[derive(RlpEncodable, RlpDecodable)]
|
||||
struct ChunkInfo(H256, u64, u64);
|
||||
|
||||
impl Encodable for ChunkInfo {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(3);
|
||||
s.append(&self.0).append(&self.1).append(&self.2);
|
||||
}
|
||||
}
|
||||
|
||||
impl rlp::Decodable for ChunkInfo {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, rlp::DecoderError> {
|
||||
let hash = rlp.val_at(0)?;
|
||||
let len = rlp.val_at(1)?;
|
||||
let off = rlp.val_at(2)?;
|
||||
Ok(ChunkInfo(hash, len, off))
|
||||
}
|
||||
}
|
||||
|
||||
/// A packed snapshot writer. This writes snapshots to a single concatenated file.
|
||||
///
|
||||
/// The file format is very simple and consists of three parts:
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use bloomchain::Bloom;
|
||||
use bloomchain::group::{BloomGroup, GroupPosition};
|
||||
use rlp::*;
|
||||
use basic_types::LogBloom;
|
||||
|
||||
/// Helper structure representing bloom of the trace.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, RlpEncodableWrapper, RlpDecodableWrapper)]
|
||||
pub struct BlockTracesBloom(LogBloom);
|
||||
|
||||
impl From<LogBloom> for BlockTracesBloom {
|
||||
@@ -28,7 +27,7 @@ impl Into<Bloom> for BlockTracesBloom {
|
||||
}
|
||||
|
||||
/// Represents group of X consecutive blooms.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, RlpEncodableWrapper, RlpDecodableWrapper)]
|
||||
pub struct BlockTracesBloomGroup {
|
||||
blooms: Vec<BlockTracesBloom>,
|
||||
}
|
||||
@@ -59,34 +58,6 @@ impl Into<BloomGroup> for BlockTracesBloomGroup {
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for BlockTracesBloom {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
LogBloom::decode(rlp).map(BlockTracesBloom)
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for BlockTracesBloom {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
Encodable::rlp_append(&self.0, s)
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for BlockTracesBloomGroup {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
let blooms = rlp.as_list()?;
|
||||
let group = BlockTracesBloomGroup {
|
||||
blooms: blooms
|
||||
};
|
||||
Ok(group)
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for BlockTracesBloomGroup {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.append_list(&self.blooms);
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents `BloomGroup` position in database.
|
||||
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
|
||||
pub struct TraceGroupPosition {
|
||||
|
||||
@@ -77,7 +77,7 @@ impl Decodable for FlatTrace {
|
||||
}
|
||||
|
||||
/// Represents all traces produced by a single transaction.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone, RlpEncodableWrapper, RlpDecodableWrapper)]
|
||||
pub struct FlatTransactionTraces(Vec<FlatTrace>);
|
||||
|
||||
impl From<Vec<FlatTrace>> for FlatTransactionTraces {
|
||||
@@ -99,18 +99,6 @@ impl FlatTransactionTraces {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for FlatTransactionTraces {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.append_list(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for FlatTransactionTraces {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
Ok(FlatTransactionTraces(rlp.as_list()?))
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Vec<FlatTrace>> for FlatTransactionTraces {
|
||||
fn into(self) -> Vec<FlatTrace> {
|
||||
self.0
|
||||
@@ -118,7 +106,7 @@ impl Into<Vec<FlatTrace>> for FlatTransactionTraces {
|
||||
}
|
||||
|
||||
/// Represents all traces produced by transactions in a single block.
|
||||
#[derive(Debug, PartialEq, Clone, Default)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, RlpEncodableWrapper, RlpDecodableWrapper)]
|
||||
pub struct FlatBlockTraces(Vec<FlatTransactionTraces>);
|
||||
|
||||
impl HeapSizeOf for FlatBlockTraces {
|
||||
@@ -140,18 +128,6 @@ impl FlatBlockTraces {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for FlatBlockTraces {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.append_list(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for FlatBlockTraces {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
Ok(FlatBlockTraces(rlp.as_list()?))
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Vec<FlatTransactionTraces>> for FlatBlockTraces {
|
||||
fn into(self) -> Vec<FlatTransactionTraces> {
|
||||
self.0
|
||||
|
||||
@@ -27,7 +27,7 @@ use evm::CallType;
|
||||
use super::error::Error;
|
||||
|
||||
/// `Call` result.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
pub struct CallResult {
|
||||
/// Gas used by call.
|
||||
@@ -36,27 +36,8 @@ pub struct CallResult {
|
||||
pub output: Bytes,
|
||||
}
|
||||
|
||||
impl Encodable for CallResult {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(2);
|
||||
s.append(&self.gas_used);
|
||||
s.append(&self.output);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for CallResult {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
let res = CallResult {
|
||||
gas_used: rlp.val_at(0)?,
|
||||
output: rlp.val_at(1)?,
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
/// `Create` result.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
pub struct CreateResult {
|
||||
/// Gas used by create.
|
||||
@@ -67,27 +48,6 @@ pub struct CreateResult {
|
||||
pub address: Address,
|
||||
}
|
||||
|
||||
impl Encodable for CreateResult {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(3);
|
||||
s.append(&self.gas_used);
|
||||
s.append(&self.code);
|
||||
s.append(&self.address);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for CreateResult {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
let res = CreateResult {
|
||||
gas_used: rlp.val_at(0)?,
|
||||
code: rlp.val_at(1)?,
|
||||
address: rlp.val_at(2)?,
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
impl CreateResult {
|
||||
/// Returns bloom.
|
||||
pub fn bloom(&self) -> LogBloom {
|
||||
@@ -96,7 +56,7 @@ impl CreateResult {
|
||||
}
|
||||
|
||||
/// Description of a _call_ action, either a `CALL` operation or a message transction.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
pub struct Call {
|
||||
/// The sending account.
|
||||
@@ -126,33 +86,6 @@ impl From<ActionParams> for Call {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for Call {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(6);
|
||||
s.append(&self.from);
|
||||
s.append(&self.to);
|
||||
s.append(&self.value);
|
||||
s.append(&self.gas);
|
||||
s.append(&self.input);
|
||||
s.append(&self.call_type);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Call {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
let res = Call {
|
||||
from: rlp.val_at(0)?,
|
||||
to: rlp.val_at(1)?,
|
||||
value: rlp.val_at(2)?,
|
||||
gas: rlp.val_at(3)?,
|
||||
input: rlp.val_at(4)?,
|
||||
call_type: rlp.val_at(5)?,
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
impl Call {
|
||||
/// Returns call action bloom.
|
||||
/// The bloom contains from and to addresses.
|
||||
@@ -163,7 +96,7 @@ impl Call {
|
||||
}
|
||||
|
||||
/// Description of a _create_ action, either a `CREATE` operation or a create transction.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
pub struct Create {
|
||||
/// The address of the creator.
|
||||
@@ -187,29 +120,6 @@ impl From<ActionParams> for Create {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for Create {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(4);
|
||||
s.append(&self.from);
|
||||
s.append(&self.value);
|
||||
s.append(&self.gas);
|
||||
s.append(&self.init);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Create {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
let res = Create {
|
||||
from: rlp.val_at(0)?,
|
||||
value: rlp.val_at(1)?,
|
||||
gas: rlp.val_at(2)?,
|
||||
init: rlp.val_at(3)?,
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
impl Create {
|
||||
/// Returns bloom create action bloom.
|
||||
/// The bloom contains only from address.
|
||||
@@ -219,7 +129,7 @@ impl Create {
|
||||
}
|
||||
|
||||
/// Suicide action.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
pub struct Suicide {
|
||||
/// Suicided address.
|
||||
@@ -238,28 +148,6 @@ impl Suicide {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for Suicide {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(3);
|
||||
s.append(&self.address);
|
||||
s.append(&self.refund_address);
|
||||
s.append(&self.balance);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Suicide {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
let res = Suicide {
|
||||
address: rlp.val_at(0)?,
|
||||
refund_address: rlp.val_at(1)?,
|
||||
balance: rlp.val_at(2)?,
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Description of an action that we trace; will be either a call or a create.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
@@ -394,7 +282,7 @@ impl Res {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
/// A diff of some chunk of memory.
|
||||
pub struct MemoryDiff {
|
||||
@@ -404,24 +292,7 @@ pub struct MemoryDiff {
|
||||
pub data: Bytes,
|
||||
}
|
||||
|
||||
impl Encodable for MemoryDiff {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(2);
|
||||
s.append(&self.offset);
|
||||
s.append(&self.data);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for MemoryDiff {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
Ok(MemoryDiff {
|
||||
offset: rlp.val_at(0)?,
|
||||
data: rlp.val_at(1)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
/// A diff of some storage value.
|
||||
pub struct StorageDiff {
|
||||
@@ -431,24 +302,7 @@ pub struct StorageDiff {
|
||||
pub value: U256,
|
||||
}
|
||||
|
||||
impl Encodable for StorageDiff {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(2);
|
||||
s.append(&self.location);
|
||||
s.append(&self.value);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for StorageDiff {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
Ok(StorageDiff {
|
||||
location: rlp.val_at(0)?,
|
||||
value: rlp.val_at(1)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
/// A record of an executed VM operation.
|
||||
pub struct VMExecutedOperation {
|
||||
@@ -462,28 +316,7 @@ pub struct VMExecutedOperation {
|
||||
pub store_diff: Option<StorageDiff>,
|
||||
}
|
||||
|
||||
impl Encodable for VMExecutedOperation {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(4);
|
||||
s.append(&self.gas_used);
|
||||
s.append_list(&self.stack_push);
|
||||
s.append(&self.mem_diff);
|
||||
s.append(&self.store_diff);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for VMExecutedOperation {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
Ok(VMExecutedOperation {
|
||||
gas_used: rlp.val_at(0)?,
|
||||
stack_push: rlp.list_at(1)?,
|
||||
mem_diff: rlp.val_at(2)?,
|
||||
store_diff: rlp.val_at(3)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
/// A record of the execution of a single VM operation.
|
||||
pub struct VMOperation {
|
||||
@@ -497,30 +330,7 @@ pub struct VMOperation {
|
||||
pub executed: Option<VMExecutedOperation>,
|
||||
}
|
||||
|
||||
impl Encodable for VMOperation {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(4);
|
||||
s.append(&self.pc);
|
||||
s.append(&self.instruction);
|
||||
s.append(&self.gas_cost);
|
||||
s.append(&self.executed);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for VMOperation {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
let res = VMOperation {
|
||||
pc: rlp.val_at(0)?,
|
||||
instruction: rlp.val_at(1)?,
|
||||
gas_cost: rlp.val_at(2)?,
|
||||
executed: rlp.val_at(3)?,
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, RlpEncodable, RlpDecodable)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
/// A record of a full VM trace for a CALL/CREATE.
|
||||
pub struct VMTrace {
|
||||
@@ -534,26 +344,3 @@ pub struct VMTrace {
|
||||
/// Thre is a 1:1 correspondance between these and a CALL/CREATE/CALLCODE/DELEGATECALL instruction.
|
||||
pub subs: Vec<VMTrace>,
|
||||
}
|
||||
|
||||
impl Encodable for VMTrace {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.begin_list(4);
|
||||
s.append(&self.parent_step);
|
||||
s.append(&self.code);
|
||||
s.append_list(&self.operations);
|
||||
s.append_list(&self.subs);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for VMTrace {
|
||||
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
|
||||
let res = VMTrace {
|
||||
parent_step: rlp.val_at(0)?,
|
||||
code: rlp.val_at(1)?,
|
||||
operations: rlp.list_at(2)?,
|
||||
subs: rlp.list_at(3)?,
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,15 @@ impl Decodable for Action {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for Action {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
match *self {
|
||||
Action::Create => s.append_internal(&""),
|
||||
Action::Call(ref addr) => s.append_internal(addr),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Transaction activation condition.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Condition {
|
||||
@@ -90,10 +99,7 @@ impl Transaction {
|
||||
s.append(&self.nonce);
|
||||
s.append(&self.gas_price);
|
||||
s.append(&self.gas);
|
||||
match self.action {
|
||||
Action::Create => s.append_empty_data(),
|
||||
Action::Call(ref to) => s.append(to)
|
||||
};
|
||||
s.append(&self.action);
|
||||
s.append(&self.value);
|
||||
s.append(&self.data);
|
||||
if let Some(n) = network_id {
|
||||
@@ -308,10 +314,7 @@ impl UnverifiedTransaction {
|
||||
s.append(&self.nonce);
|
||||
s.append(&self.gas_price);
|
||||
s.append(&self.gas);
|
||||
match self.action {
|
||||
Action::Create => s.append_empty_data(),
|
||||
Action::Call(ref to) => s.append(to)
|
||||
};
|
||||
s.append(&self.action);
|
||||
s.append(&self.value);
|
||||
s.append(&self.data);
|
||||
s.append(&self.v);
|
||||
|
||||
Reference in New Issue
Block a user