From 76223d3d137a791d205c8d39a694c8d96a671fcb Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 15 Jan 2016 02:52:37 +0100 Subject: [PATCH] Receipt logging --- src/client.rs | 8 ++++---- src/receipt.rs | 1 + src/state.rs | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/client.rs b/src/client.rs index 2c87af249..59734b387 100644 --- a/src/client.rs +++ b/src/client.rs @@ -129,14 +129,14 @@ impl Client { let block = BlockView::new(&bytes); let header = block.header(); if let Err(e) = verify_block_family(&bytes, self.engine.deref().deref(), self.chain.read().unwrap().deref()) { - warn!(target: "client", "Stage 3 block verification failed for {}\nError: {:?}", header.hash(), e); + warn!(target: "client", "Stage 3 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); // TODO: mark as bad return; }; let parent = match self.chain.read().unwrap().block_header(&header.parent_hash) { Some(p) => p, None => { - warn!(target: "client", "Block import failed for {}: Parent not found ({}) ", header.hash(), header.parent_hash); + warn!(target: "client", "Block import failed for #{} ({}): Parent not found ({}) ", header.number(), header.hash(), header.parent_hash); return; }, }; @@ -157,12 +157,12 @@ impl Client { let result = match enact(&bytes, self.engine.deref().deref(), self.state_db.clone(), &parent, &last_hashes) { Ok(b) => b, Err(e) => { - warn!(target: "client", "Block import failed for {}\nError: {:?}", header.hash(), e); + warn!(target: "client", "Block import failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); return; } }; if let Err(e) = verify_block_final(&header, result.block().header()) { - warn!(target: "client", "Stage 4 block verification failed for {}\nError: {:?}", header.hash(), e); + warn!(target: "client", "Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); return; } diff --git a/src/receipt.rs b/src/receipt.rs index ef7e03cc8..21a66f5cf 100644 --- a/src/receipt.rs +++ b/src/receipt.rs @@ -3,6 +3,7 @@ use basic_types::LogBloom; use log_entry::LogEntry; /// Information describing execution of a transaction. +#[derive(Debug)] pub struct Receipt { pub state_root: H256, pub gas_used: U256, diff --git a/src/state.rs b/src/state.rs index fdf71a496..c6e5516e1 100644 --- a/src/state.rs +++ b/src/state.rs @@ -142,7 +142,9 @@ impl State { let e = try!(Executive::new(self, env_info, engine).transact(t)); //println!("Executed: {:?}", e); self.commit(); - Ok(Receipt::new(self.root().clone(), e.gas_used, e.logs)) + let receipt = Receipt::new(self.root().clone(), e.cumulative_gas_used, e.logs); + debug!("Transaction receipt: {:?}", receipt); + Ok(receipt) } pub fn revert(&mut self, backup: State) {