added a new RPC call trace_replayBlockTransactions (#7366)

* intial add trace_replayBlockTransactions

* cleanup timing calls
add execution proof

* WIP implementing changes

* fix for trace_replayBlockTransactions rpc call

* cleanup comments

* cleanup, proof,
can't workout lifetime issues yet

* Fix lifetimes issue.

* naive rpc test

* updated docs
This commit is contained in:
tzapu
2018-01-10 12:34:34 +02:00
committed by Afri Schoedon
parent b685b7fae3
commit df5d27d516
7 changed files with 63 additions and 20 deletions

View File

@@ -61,4 +61,8 @@ impl Traces for TracesClient {
fn replay_transaction(&self, _transaction_hash: H256, _flags: TraceOptions) -> Result<TraceResults> {
Err(errors::light_unimplemented(None))
}
fn replay_block_transactions(&self, _block_number: BlockNumber, _flags: TraceOptions) -> Result<Vec<TraceResults>> {
Err(errors::light_unimplemented(None))
}
}

View File

@@ -122,4 +122,10 @@ impl<C> Traces for TracesClient<C> where C: MiningBlockChainClient + 'static {
.map(TraceResults::from)
.map_err(errors::call)
}
fn replay_block_transactions(&self, block_number: BlockNumber, flags: TraceOptions) -> Result<Vec<TraceResults>> {
self.client.replay_block_transactions(block_number.into(), to_call_analytics(flags))
.map(|results| results.into_iter().map(TraceResults::from).collect())
.map_err(errors::call)
}
}

View File

@@ -232,3 +232,13 @@ fn rpc_trace_replay_transaction_state_pruned() {
assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned()));
}
#[test]
fn rpc_trace_replay_block_transactions() {
let tester = io();
let request = r#"{"jsonrpc":"2.0","method":"trace_replayBlockTransactions","params":["0x10", ["trace", "stateDiff", "vmTrace"]],"id":1}"#;
let response = r#"{"jsonrpc":"2.0","result":[{"output":"0x010203","stateDiff":null,"trace":[],"vmTrace":null}],"id":1}"#;
assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned()));
}

View File

@@ -56,5 +56,9 @@ build_rpc_trait! {
/// Executes the transaction with the given hash and returns a number of possible traces for it.
#[rpc(name = "trace_replayTransaction")]
fn replay_transaction(&self, H256, TraceOptions) -> Result<TraceResults>;
/// Executes all the transactions at the given block and returns a number of possible traces for each transaction.
#[rpc(name = "trace_replayBlockTransactions")]
fn replay_block_transactions(&self, BlockNumber, TraceOptions) -> Result<Vec<TraceResults>>;
}
}