From c202abe09d5c0734bf431fead695e58cd6738e83 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 2 Jun 2016 13:14:49 +0200 Subject: [PATCH] Switch RPC namespace form ethcore_ to trace_ --- parity/rpc_apis.rs | 4 +- rpc/src/v1/impls/ethcore.rs | 156 ++-------------------------- rpc/src/v1/impls/traces.rs | 157 +++++++++++++++++++++++++++-- rpc/src/v1/tests/mocked/ethcore.rs | 61 ++++------- rpc/src/v1/traits/ethcore.rs | 9 -- rpc/src/v1/traits/traces.rs | 10 ++ 6 files changed, 188 insertions(+), 209 deletions(-) diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index 143d6b48f..b54693582 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -153,10 +153,10 @@ pub fn setup_rpc(server: T, deps: Arc, apis: ApiSet } }, Api::Ethcore => { - server.add_delegate(EthcoreClient::new(&deps.client, &deps.miner, deps.logger.clone(), deps.settings.clone()).to_delegate()) + server.add_delegate(EthcoreClient::new(&deps.miner, deps.logger.clone(), deps.settings.clone()).to_delegate()) }, Api::Traces => { - server.add_delegate(TracesClient::new(&deps.client).to_delegate()) + server.add_delegate(TracesClient::new(&deps.client, &deps.miner).to_delegate()) }, Api::Rpc => { let modules = to_modules(&apis); diff --git a/rpc/src/v1/impls/ethcore.rs b/rpc/src/v1/impls/ethcore.rs index 69d036500..d9d5859d2 100644 --- a/rpc/src/v1/impls/ethcore.rs +++ b/rpc/src/v1/impls/ethcore.rs @@ -15,151 +15,39 @@ // along with Parity. If not, see . //! Ethcore-specific rpc implementation. -use util::{U256, Address, RotatingLogger, FixedHash, Uint}; +use util::{U256, Address, RotatingLogger, FixedHash}; use util::network_settings::NetworkSettings; use util::misc::version_data; use std::sync::{Arc, Weak}; use std::ops::Deref; use std::collections::BTreeMap; use jsonrpc_core::*; -use serde; use ethcore::miner::MinerService; -use ethcore::state_diff::StateDiff; -use ethcore::account_diff::{Diff, Existance}; -use ethcore::transaction::{Transaction as EthTransaction, SignedTransaction, Action}; -use ethcore::client::{BlockChainClient, CallAnalytics}; -use ethcore::trace::VMTrace; +use ethcore::client::{BlockChainClient}; use v1::traits::Ethcore; -use v1::types::{Bytes, CallRequest}; +use v1::types::{Bytes}; /// Ethcore implementation. -pub struct EthcoreClient where - C: BlockChainClient, +pub struct EthcoreClient where M: MinerService { - client: Weak, miner: Weak, logger: Arc, settings: Arc, } -impl EthcoreClient where C: BlockChainClient, M: MinerService { +impl EthcoreClient where M: MinerService { /// Creates new `EthcoreClient`. - pub fn new(client: &Arc, miner: &Arc, logger: Arc, settings: Arc) -> Self { + pub fn new(miner: &Arc, logger: Arc, settings: Arc) -> Self { EthcoreClient { - client: Arc::downgrade(client), miner: Arc::downgrade(miner), logger: logger, settings: settings, } } - - // TODO: share with eth.rs - fn sign_call(&self, request: CallRequest) -> Result { - let client = take_weak!(self.client); - let miner = take_weak!(self.miner); - let from = request.from.unwrap_or(Address::zero()); - Ok(EthTransaction { - nonce: request.nonce.unwrap_or_else(|| client.latest_nonce(&from)), - action: request.to.map_or(Action::Create, Action::Call), - gas: request.gas.unwrap_or(U256::from(50_000_000)), - gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()), - value: request.value.unwrap_or_else(U256::zero), - data: request.data.map_or_else(Vec::new, |d| d.to_vec()) - }.fake_sign(from)) - } } -fn vm_trace_to_object(t: &VMTrace) -> Value { - let mut ret = BTreeMap::new(); - ret.insert("code".to_owned(), to_value(&t.code).unwrap()); - - let mut subs = t.subs.iter(); - let mut next_sub = subs.next(); - - let ops = t.operations - .iter() - .enumerate() - .map(|(i, op)| { - let mut m = map![ - "pc".to_owned() => to_value(&op.pc).unwrap(), - "cost".to_owned() => match op.gas_cost <= U256::from(!0u64) { - true => to_value(&op.gas_cost.low_u64()), - false => to_value(&op.gas_cost), - }.unwrap() - ]; - if let Some(ref ex) = op.executed { - let mut em = map![ - "used".to_owned() => to_value(&ex.gas_used.low_u64()).unwrap(), - "push".to_owned() => to_value(&ex.stack_push).unwrap() - ]; - if let Some(ref md) = ex.mem_diff { - em.insert("mem".to_owned(), Value::Object(map![ - "off".to_owned() => to_value(&md.offset).unwrap(), - "data".to_owned() => to_value(&md.data).unwrap() - ])); - } - if let Some(ref sd) = ex.store_diff { - em.insert("store".to_owned(), Value::Object(map![ - "key".to_owned() => to_value(&sd.location).unwrap(), - "val".to_owned() => to_value(&sd.value).unwrap() - ])); - } - m.insert("ex".to_owned(), Value::Object(em)); - } - if next_sub.is_some() && next_sub.unwrap().parent_step == i { - m.insert("sub".to_owned(), vm_trace_to_object(next_sub.unwrap())); - next_sub = subs.next(); - } - Value::Object(m) - }) - .collect::>(); - ret.insert("ops".to_owned(), Value::Array(ops)); - Value::Object(ret) -} - -fn diff_to_object(d: &Diff) -> Value where T: serde::Serialize + Eq { - let mut ret = BTreeMap::new(); - match *d { - Diff::Same => { - ret.insert("diff".to_owned(), Value::String("=".to_owned())); - } - Diff::Born(ref x) => { - ret.insert("diff".to_owned(), Value::String("+".to_owned())); - ret.insert("+".to_owned(), to_value(x).unwrap()); - } - Diff::Died(ref x) => { - ret.insert("diff".to_owned(), Value::String("-".to_owned())); - ret.insert("-".to_owned(), to_value(x).unwrap()); - } - Diff::Changed(ref from, ref to) => { - ret.insert("diff".to_owned(), Value::String("*".to_owned())); - ret.insert("-".to_owned(), to_value(from).unwrap()); - ret.insert("+".to_owned(), to_value(to).unwrap()); - } - }; - Value::Object(ret) -} - -fn state_diff_to_object(t: &StateDiff) -> Value { - Value::Object(t.iter().map(|(address, account)| { - (address.hex(), Value::Object(map![ - "existance".to_owned() => Value::String(match account.existance() { - Existance::Born => "+", - Existance::Alive => ".", - Existance::Died => "-", - }.to_owned()), - "balance".to_owned() => diff_to_object(&account.balance), - "nonce".to_owned() => diff_to_object(&account.nonce), - "code".to_owned() => diff_to_object(&account.code), - "storage".to_owned() => Value::Object(account.storage.iter().map(|(key, val)| { - (key.hex(), diff_to_object(&val)) - }).collect::>()) - ])) - }).collect::>()) -} - -impl Ethcore for EthcoreClient where C: BlockChainClient + 'static, M: MinerService + 'static { +impl Ethcore for EthcoreClient where M: MinerService + 'static { fn set_min_gas_price(&self, params: Params) -> Result { from_params::<(U256,)>(params).and_then(|(gas_price,)| { @@ -249,34 +137,4 @@ impl Ethcore for EthcoreClient where C: BlockChainClient + 'static, let version = version_data(); to_value(&Bytes::new(version)) } - - fn vm_trace_call(&self, params: Params) -> Result { - trace!(target: "jsonrpc", "vm_trace_call: {:?}", params); - from_params(params) - .and_then(|(request,)| { - let signed = try!(self.sign_call(request)); - let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: true, state_diffing: false }); - if let Ok(executed) = r { - if let Some(vm_trace) = executed.vm_trace { - return Ok(vm_trace_to_object(&vm_trace)); - } - } - Ok(Value::Null) - }) - } - - fn state_diff_call(&self, params: Params) -> Result { - trace!(target: "jsonrpc", "state_diff_call: {:?}", params); - from_params(params) - .and_then(|(request,)| { - let signed = try!(self.sign_call(request)); - let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: false, state_diffing: true }); - if let Ok(executed) = r { - if let Some(state_diff) = executed.state_diff { - return Ok(state_diff_to_object(&state_diff)); - } - } - Ok(Value::Null) - }) - } } diff --git a/rpc/src/v1/impls/traces.rs b/rpc/src/v1/impls/traces.rs index 0008d0dc1..b6015d498 100644 --- a/rpc/src/v1/impls/traces.rs +++ b/rpc/src/v1/impls/traces.rs @@ -18,26 +18,139 @@ use std::sync::{Weak, Arc}; use jsonrpc_core::*; -use util::H256; -use ethcore::client::{BlockChainClient, TransactionID, TraceId}; +use std::collections::BTreeMap; +use util::{H256, U256, FixedHash, Uint}; +use serde; +use ethcore::client::{BlockChainClient, CallAnalytics, TransactionID, TraceId}; +use ethcore::trace::VMTrace; +use ethcore::miner::MinerService; +use ethcore::state_diff::StateDiff; +use ethcore::account_diff::{Diff, Existance}; +use ethcore::transaction::{Transaction as EthTransaction, SignedTransaction, Action}; use v1::traits::Traces; -use v1::types::{TraceFilter, Trace, BlockNumber, Index}; +use v1::types::{TraceFilter, Trace, BlockNumber, Index, CallRequest}; /// Traces api implementation. -pub struct TracesClient where C: BlockChainClient { +pub struct TracesClient where C: BlockChainClient, M: MinerService { client: Weak, + miner: Weak, } -impl TracesClient where C: BlockChainClient { +impl TracesClient where C: BlockChainClient, M: MinerService { /// Creates new Traces client. - pub fn new(client: &Arc) -> Self { + pub fn new(client: &Arc, miner: &Arc) -> Self { TracesClient { client: Arc::downgrade(client), + miner: Arc::downgrade(miner), } } + + // TODO: share with eth.rs + fn sign_call(&self, request: CallRequest) -> Result { + let client = take_weak!(self.client); + let miner = take_weak!(self.miner); + let from = request.from.unwrap_or(0.into()); + Ok(EthTransaction { + nonce: request.nonce.unwrap_or_else(|| client.latest_nonce(&from)), + action: request.to.map_or(Action::Create, Action::Call), + gas: request.gas.unwrap_or(50_000_000.into()), + gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()), + value: request.value.unwrap_or(0.into()), + data: request.data.map_or_else(Vec::new, |d| d.to_vec()) + }.fake_sign(from)) + } } -impl Traces for TracesClient where C: BlockChainClient + 'static { +fn vm_trace_to_object(t: &VMTrace) -> Value { + let mut ret = BTreeMap::new(); + ret.insert("code".to_owned(), to_value(&t.code).unwrap()); + + let mut subs = t.subs.iter(); + let mut next_sub = subs.next(); + + let ops = t.operations + .iter() + .enumerate() + .map(|(i, op)| { + let mut m = map![ + "pc".to_owned() => to_value(&op.pc).unwrap(), + "cost".to_owned() => match op.gas_cost <= U256::from(!0u64) { + true => to_value(&op.gas_cost.low_u64()), + false => to_value(&op.gas_cost), + }.unwrap() + ]; + if let Some(ref ex) = op.executed { + let mut em = map![ + "used".to_owned() => to_value(&ex.gas_used.low_u64()).unwrap(), + "push".to_owned() => to_value(&ex.stack_push).unwrap() + ]; + if let Some(ref md) = ex.mem_diff { + em.insert("mem".to_owned(), Value::Object(map![ + "off".to_owned() => to_value(&md.offset).unwrap(), + "data".to_owned() => to_value(&md.data).unwrap() + ])); + } + if let Some(ref sd) = ex.store_diff { + em.insert("store".to_owned(), Value::Object(map![ + "key".to_owned() => to_value(&sd.location).unwrap(), + "val".to_owned() => to_value(&sd.value).unwrap() + ])); + } + m.insert("ex".to_owned(), Value::Object(em)); + } + if next_sub.is_some() && next_sub.unwrap().parent_step == i { + m.insert("sub".to_owned(), vm_trace_to_object(next_sub.unwrap())); + next_sub = subs.next(); + } + Value::Object(m) + }) + .collect::>(); + ret.insert("ops".to_owned(), Value::Array(ops)); + Value::Object(ret) +} + +fn diff_to_object(d: &Diff) -> Value where T: serde::Serialize + Eq { + let mut ret = BTreeMap::new(); + match *d { + Diff::Same => { + ret.insert("diff".to_owned(), Value::String("=".to_owned())); + } + Diff::Born(ref x) => { + ret.insert("diff".to_owned(), Value::String("+".to_owned())); + ret.insert("+".to_owned(), to_value(x).unwrap()); + } + Diff::Died(ref x) => { + ret.insert("diff".to_owned(), Value::String("-".to_owned())); + ret.insert("-".to_owned(), to_value(x).unwrap()); + } + Diff::Changed(ref from, ref to) => { + ret.insert("diff".to_owned(), Value::String("*".to_owned())); + ret.insert("-".to_owned(), to_value(from).unwrap()); + ret.insert("+".to_owned(), to_value(to).unwrap()); + } + }; + Value::Object(ret) +} + +fn state_diff_to_object(t: &StateDiff) -> Value { + Value::Object(t.iter().map(|(address, account)| { + (address.hex(), Value::Object(map![ + "existance".to_owned() => Value::String(match account.existance() { + Existance::Born => "+", + Existance::Alive => ".", + Existance::Died => "-", + }.to_owned()), + "balance".to_owned() => diff_to_object(&account.balance), + "nonce".to_owned() => diff_to_object(&account.nonce), + "code".to_owned() => diff_to_object(&account.code), + "storage".to_owned() => Value::Object(account.storage.iter().map(|(key, val)| { + (key.hex(), diff_to_object(&val)) + }).collect::>()) + ])) + }).collect::>()) +} + +impl Traces for TracesClient where C: BlockChainClient + 'static, M: MinerService + 'static { fn filter(&self, params: Params) -> Result { from_params::<(TraceFilter,)>(params) .and_then(|(filter, )| { @@ -81,4 +194,34 @@ impl Traces for TracesClient where C: BlockChainClient + 'static { to_value(&trace) }) } + + fn vm_trace_call(&self, params: Params) -> Result { + trace!(target: "jsonrpc", "vm_trace_call: {:?}", params); + from_params(params) + .and_then(|(request,)| { + let signed = try!(self.sign_call(request)); + let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: true, state_diffing: false }); + if let Ok(executed) = r { + if let Some(vm_trace) = executed.vm_trace { + return Ok(vm_trace_to_object(&vm_trace)); + } + } + Ok(Value::Null) + }) + } + + fn state_diff_call(&self, params: Params) -> Result { + trace!(target: "jsonrpc", "state_diff_call: {:?}", params); + from_params(params) + .and_then(|(request,)| { + let signed = try!(self.sign_call(request)); + let r = take_weak!(self.client).call(&signed, CallAnalytics{ vm_tracing: false, state_diffing: true }); + if let Ok(executed) = r { + if let Some(state_diff) = executed.state_diff { + return Ok(state_diff_to_object(&state_diff)); + } + } + Ok(Value::Null) + }) + } } diff --git a/rpc/src/v1/tests/mocked/ethcore.rs b/rpc/src/v1/tests/mocked/ethcore.rs index 3bed1f0f0..1685a598b 100644 --- a/rpc/src/v1/tests/mocked/ethcore.rs +++ b/rpc/src/v1/tests/mocked/ethcore.rs @@ -18,7 +18,6 @@ use std::sync::Arc; use std::str::FromStr; use jsonrpc_core::IoHandler; use v1::{Ethcore, EthcoreClient}; -use ethcore::client::{TestBlockChainClient}; use ethcore::miner::MinerService; use v1::tests::helpers::TestMinerService; use util::numbers::*; @@ -26,11 +25,6 @@ use rustc_serialize::hex::FromHex; use util::log::RotatingLogger; use util::network_settings::NetworkSettings; -fn blockchain_client() -> Arc { - let client = TestBlockChainClient::new(); - Arc::new(client) -} - fn miner_service() -> Arc { Arc::new(TestMinerService::default()) } @@ -51,15 +45,14 @@ fn settings() -> Arc { }) } -fn ethcore_client(client: &Arc, miner: &Arc) -> EthcoreClient { - EthcoreClient::new(&client, &miner, logger(), settings()) +fn ethcore_client(miner: &Arc) -> EthcoreClient { + EthcoreClient::new(&miner, logger(), settings()) } #[test] fn rpc_ethcore_extra_data() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -75,8 +68,7 @@ fn rpc_ethcore_default_extra_data() { use util::ToPretty; let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -89,8 +81,7 @@ fn rpc_ethcore_default_extra_data() { #[test] fn rpc_ethcore_gas_floor_target() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -103,8 +94,7 @@ fn rpc_ethcore_gas_floor_target() { #[test] fn rpc_ethcore_min_gas_price() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -117,8 +107,7 @@ fn rpc_ethcore_min_gas_price() { #[test] fn rpc_ethcore_set_min_gas_price() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -132,8 +121,7 @@ fn rpc_ethcore_set_min_gas_price() { #[test] fn rpc_ethcore_set_gas_floor_target() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -147,8 +135,7 @@ fn rpc_ethcore_set_gas_floor_target() { #[test] fn rpc_ethcore_set_extra_data() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -162,8 +149,7 @@ fn rpc_ethcore_set_extra_data() { #[test] fn rpc_ethcore_set_author() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -177,11 +163,10 @@ fn rpc_ethcore_set_author() { #[test] fn rpc_ethcore_dev_logs() { let miner = miner_service(); - let client = blockchain_client(); let logger = logger(); logger.append("a".to_owned()); logger.append("b".to_owned()); - let ethcore = EthcoreClient::new(&client, &miner, logger.clone(), settings()).to_delegate(); + let ethcore = EthcoreClient::new(&miner, logger.clone(), settings()).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -194,8 +179,7 @@ fn rpc_ethcore_dev_logs() { #[test] fn rpc_ethcore_dev_logs_levels() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -207,8 +191,7 @@ fn rpc_ethcore_dev_logs_levels() { #[test] fn rpc_ethcore_set_transactions_limit() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -222,8 +205,7 @@ fn rpc_ethcore_set_transactions_limit() { #[test] fn rpc_ethcore_transactions_limit() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -236,8 +218,7 @@ fn rpc_ethcore_transactions_limit() { #[test] fn rpc_ethcore_net_chain() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -250,8 +231,7 @@ fn rpc_ethcore_net_chain() { #[test] fn rpc_ethcore_net_max_peers() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -264,8 +244,7 @@ fn rpc_ethcore_net_max_peers() { #[test] fn rpc_ethcore_net_port() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -278,8 +257,7 @@ fn rpc_ethcore_net_port() { #[test] fn rpc_ethcore_rpc_settings() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); @@ -292,8 +270,7 @@ fn rpc_ethcore_rpc_settings() { #[test] fn rpc_ethcore_node_name() { let miner = miner_service(); - let client = blockchain_client(); - let ethcore = ethcore_client(&client, &miner).to_delegate(); + let ethcore = ethcore_client(&miner).to_delegate(); let io = IoHandler::new(); io.add_delegate(ethcore); diff --git a/rpc/src/v1/traits/ethcore.rs b/rpc/src/v1/traits/ethcore.rs index 116a4cd05..a0e12222a 100644 --- a/rpc/src/v1/traits/ethcore.rs +++ b/rpc/src/v1/traits/ethcore.rs @@ -72,12 +72,6 @@ pub trait Ethcore: Sized + Send + Sync + 'static { /// Returns default extra data fn default_extra_data(&self, _: Params) -> Result; - /// Executes the given call and returns the VM trace for it. - fn vm_trace_call(&self, _: Params) -> Result; - - /// Executes the given call and returns the diff for it. - fn state_diff_call(&self, params: Params) -> Result; - /// Should be used to convert object to io delegate. fn to_delegate(self) -> IoDelegate { let mut delegate = IoDelegate::new(Arc::new(self)); @@ -100,9 +94,6 @@ pub trait Ethcore: Sized + Send + Sync + 'static { delegate.add_method("ethcore_nodeName", Ethcore::node_name); delegate.add_method("ethcore_defaultExtraData", Ethcore::default_extra_data); - delegate.add_method("ethcore_vmTraceCall", Ethcore::vm_trace_call); - delegate.add_method("ethcore_stateDiffCall", Ethcore::state_diff_call); - delegate } } diff --git a/rpc/src/v1/traits/traces.rs b/rpc/src/v1/traits/traces.rs index 54d04b954..4b58b12ac 100644 --- a/rpc/src/v1/traits/traces.rs +++ b/rpc/src/v1/traits/traces.rs @@ -32,6 +32,12 @@ pub trait Traces: Sized + Send + Sync + 'static { /// Returns all traces produced at given block. fn block_traces(&self, _: Params) -> Result; + /// Executes the given call and returns the VM trace for it. + fn vm_trace_call(&self, _: Params) -> Result; + + /// Executes the given call and returns the diff for it. + fn state_diff_call(&self, params: Params) -> Result; + /// Should be used to convert object to io delegate. fn to_delegate(self) -> IoDelegate { let mut delegate = IoDelegate::new(Arc::new(self)); @@ -39,6 +45,10 @@ pub trait Traces: Sized + Send + Sync + 'static { delegate.add_method("trace_get", Traces::trace); delegate.add_method("trace_transaction", Traces::transaction_traces); delegate.add_method("trace_block", Traces::block_traces); + + delegate.add_method("trace_vmTraceCall", Traces::vm_trace_call); + delegate.add_method("trace_stateDiffCall", Traces::state_diff_call); + delegate } }