Clean up logging.

This commit is contained in:
Gav Wood 2016-01-16 01:48:38 +01:00
parent 2f14b755f1
commit 5a2fab8b64
4 changed files with 21 additions and 28 deletions

View File

@ -268,7 +268,7 @@ pub fn enact<'x, 'y>(block_bytes: &[u8], engine: &'x Engine, db: OverlayDB, pare
{ {
let header = BlockView::new(block_bytes).header_view(); let header = BlockView::new(block_bytes).header_view();
let s = State::from_existing(db.clone(), parent.state_root().clone(), engine.account_start_nonce()); let s = State::from_existing(db.clone(), parent.state_root().clone(), engine.account_start_nonce());
// flush(format!("enact(): root={}, author={}, author_balance={}\n", s.root(), header.author(), s.balance(&header.author()))); trace!("enact(): root={}, author={}, author_balance={}\n", s.root(), header.author(), s.balance(&header.author()));
} }
let block = BlockView::new(block_bytes); let block = BlockView::new(block_bytes);

View File

@ -203,10 +203,10 @@ impl<'a> Executive<'a> {
evm.exec(&params, &mut ext) evm.exec(&params, &mut ext)
}; };
// flush(format!("exec: sstore-clears={}\n", unconfirmed_substate.refunds_count)); trace!("exec: sstore-clears={}\n", unconfirmed_substate.refunds_count);
// flush(format!("exec: substate={:?}; unconfirmed_substate={:?}\n", substate, unconfirmed_substate)); trace!("exec: substate={:?}; unconfirmed_substate={:?}\n", substate, unconfirmed_substate);
self.enact_result(&res, substate, unconfirmed_substate, backup); self.enact_result(&res, substate, unconfirmed_substate, backup);
// flush(format!("exec: new substate={:?}\n", substate)); trace!("exec: new substate={:?}\n", substate);
res res
} else { } else {
// otherwise, nothing // otherwise, nothing
@ -258,17 +258,17 @@ impl<'a> Executive<'a> {
let refund_value = gas_left * t.gas_price; let refund_value = gas_left * t.gas_price;
let fees_value = gas_used * t.gas_price; let fees_value = gas_used * t.gas_price;
// flush(format!("exec::finalize: t.gas={}, sstore_refunds={}, suicide_refunds={}, refunds_bound={}, gas_left_prerefund={}, refunded={}, gas_left={}, gas_used={}, refund_value={}, fees_value={}\n", trace!("exec::finalize: t.gas={}, sstore_refunds={}, suicide_refunds={}, refunds_bound={}, gas_left_prerefund={}, refunded={}, gas_left={}, gas_used={}, refund_value={}, fees_value={}\n",
// t.gas, sstore_refunds, suicide_refunds, refunds_bound, gas_left_prerefund, refunded, gas_left, gas_used, refund_value, fees_value)); t.gas, sstore_refunds, suicide_refunds, refunds_bound, gas_left_prerefund, refunded, gas_left, gas_used, refund_value, fees_value);
// flush(format!("exec::finalize: Refunding refund_value={}, sender={}\n", refund_value, t.sender().unwrap())); trace!("exec::finalize: Refunding refund_value={}, sender={}\n", refund_value, t.sender().unwrap());
self.state.add_balance(&t.sender().unwrap(), &refund_value); self.state.add_balance(&t.sender().unwrap(), &refund_value);
// flush(format!("exec::finalize: Compensating author: fees_value={}, author={}\n", fees_value, &self.info.author)); trace!("exec::finalize: Compensating author: fees_value={}, author={}\n", fees_value, &self.info.author);
self.state.add_balance(&self.info.author, &fees_value); self.state.add_balance(&self.info.author, &fees_value);
// perform suicides // perform suicides
for address in substate.suicides.iter() { for address in substate.suicides.iter() {
// trace!("Killing {}", address); trace!("Killing {}", address);
self.state.kill_account(address); self.state.kill_account(address);
} }

View File

@ -61,7 +61,7 @@ impl<'a> Externalities<'a> {
impl<'a> Ext for Externalities<'a> { impl<'a> Ext for Externalities<'a> {
fn storage_at(&self, key: &H256) -> H256 { fn storage_at(&self, key: &H256) -> H256 {
// flush(format!("ext: storage_at({}, {}) == {}\n", self.params.address, key, U256::from(self.state.storage_at(&self.params.address, key).as_slice()))); trace!("ext: storage_at({}, {}) == {}\n", self.params.address, key, U256::from(self.state.storage_at(&self.params.address, key).as_slice()));
self.state.storage_at(&self.params.address, key) self.state.storage_at(&self.params.address, key)
} }
@ -69,10 +69,10 @@ impl<'a> Ext for Externalities<'a> {
let old = self.state.storage_at(&self.params.address, &key); let old = self.state.storage_at(&self.params.address, &key);
// if SSTORE nonzero -> zero, increment refund count // if SSTORE nonzero -> zero, increment refund count
if value.is_zero() && !old.is_zero() { if value.is_zero() && !old.is_zero() {
// flush(format!("ext: additional refund. {} -> {}\n", self.substate.refunds_count, self.substate.refunds_count + x!(1))); trace!("ext: additional refund. {} -> {}\n", self.substate.refunds_count, self.substate.refunds_count + x!(1));
self.substate.refunds_count = self.substate.refunds_count + U256::one(); self.substate.refunds_count = self.substate.refunds_count + U256::one();
} }
// flush(format!("ext: set_storage_at({}, {}): {} -> {}\n", self.params.address, key, U256::from(old.as_slice()), U256::from(value.as_slice()))); trace!("ext: set_storage_at({}, {}): {} -> {}\n", self.params.address, key, U256::from(old.as_slice()), U256::from(value.as_slice()));
self.state.set_storage(&self.params.address, key, value) self.state.set_storage(&self.params.address, key, value)
} }
@ -85,11 +85,11 @@ impl<'a> Ext for Externalities<'a> {
true => { true => {
let index = self.info.number - number.low_u64() - 1; let index = self.info.number - number.low_u64() - 1;
let r = self.info.last_hashes[index as usize].clone(); let r = self.info.last_hashes[index as usize].clone();
// flush(format!("ext: blockhash({}) -> {} self.info.number={}\n", number, r, self.info.number)); trace!("ext: blockhash({}) -> {} self.info.number={}\n", number, r, self.info.number);
r r
}, },
false => { false => {
// flush(format!("ext: blockhash({}) -> null self.info.number={}\n", number, self.info.number)); trace!("ext: blockhash({}) -> null self.info.number={}\n", number, self.info.number);
H256::from(&U256::zero()) H256::from(&U256::zero())
}, },
} }
@ -176,10 +176,10 @@ impl<'a> Ext for Externalities<'a> {
}; };
// flush(format!("Externalities::call: BEFORE: bal({})={}, bal({})={}\n", params.sender, self.state.balance(&params.sender), params.address, self.state.balance(&params.address))); trace!("Externalities::call: BEFORE: bal({})={}, bal({})={}\n", params.sender, self.state.balance(&params.sender), params.address, self.state.balance(&params.address));
// flush(format!("Externalities::call: CALLING: params={:?}\n", params)); trace!("Externalities::call: CALLING: params={:?}\n", params);
let r = Executive::from_parent(self.state, self.info, self.engine, self.depth).call(&params, self.substate, BytesRef::Fixed(output)); let r = Executive::from_parent(self.state, self.info, self.engine, self.depth).call(&params, self.substate, BytesRef::Fixed(output));
// flush(format!("Externalities::call: AFTER: bal({})={}, bal({})={}\n", params.sender, self.state.balance(&params.sender), params.address, self.state.balance(&params.address))); trace!("Externalities::call: AFTER: bal({})={}, bal({})={}\n", params.sender, self.state.balance(&params.sender), params.address, self.state.balance(&params.address));
match r { match r {
Ok(gas_left) => Ok((gas + gas_left, true)), Ok(gas_left) => Ok((gas + gas_left, true)),

View File

@ -107,16 +107,16 @@ impl State {
/// Add `incr` to the balance of account `a`. /// Add `incr` to the balance of account `a`.
pub fn add_balance(&mut self, a: &Address, incr: &U256) { pub fn add_balance(&mut self, a: &Address, incr: &U256) {
// let old = self.balance(a); let old = self.balance(a);
self.require(a, false).add_balance(incr); self.require(a, false).add_balance(incr);
// flush(format!("state: add_balance({}, {}): {} -> {}\n", a, incr, old, self.balance(a))); trace!("state: add_balance({}, {}): {} -> {}\n", a, incr, old, self.balance(a));
} }
/// Subtract `decr` from the balance of account `a`. /// Subtract `decr` from the balance of account `a`.
pub fn sub_balance(&mut self, a: &Address, decr: &U256) { pub fn sub_balance(&mut self, a: &Address, decr: &U256) {
// let old = self.balance(a); let old = self.balance(a);
self.require(a, false).sub_balance(decr); self.require(a, false).sub_balance(decr);
// flush(format!("state: sub_balance({}, {}): {} -> {}\n", a, decr, old, self.balance(a))); trace!("state: sub_balance({}, {}): {} -> {}\n", a, decr, old, self.balance(a));
} }
/// Subtracts `by` from the balance of `from` and adds it to that of `to`. /// Subtracts `by` from the balance of `from` and adds it to that of `to`.
@ -230,13 +230,6 @@ impl State {
/// `require_code` requires that the code be cached, too. /// `require_code` requires that the code be cached, too.
fn get(&self, a: &Address, require_code: bool) -> Ref<Option<Account>> { fn get(&self, a: &Address, require_code: bool) -> Ref<Option<Account>> {
self.cache.borrow_mut().entry(a.clone()).or_insert_with(|| { self.cache.borrow_mut().entry(a.clone()).or_insert_with(|| {
/*{
let orlp = SecTrieDB::new(&self.db, &self.root).get(&a).map(|rlp| rlp.to_vec());
if let Some(rlp) = orlp {
let acc = Account::from_rlp(&rlp);
flush(format!("State::get({}) -> {} (bal={})\n", a, rlp.pretty(), acc.balance()));
}
}*/
SecTrieDB::new(&self.db, &self.root).get(&a).map(|rlp| Account::from_rlp(rlp)) SecTrieDB::new(&self.db, &self.root).get(&a).map(|rlp| Account::from_rlp(rlp))
}); });
if require_code { if require_code {