diff --git a/src/account.rs b/src/account.rs index 597d49053..8c36c7cbd 100644 --- a/src/account.rs +++ b/src/account.rs @@ -205,7 +205,6 @@ impl Account { match (self.code_hash.is_none(), self.code_cache.is_empty()) { (true, true) => self.code_hash = Some(SHA3_EMPTY), (true, false) => { - println!("Writing into DB {:?}", self.code_cache); self.code_hash = Some(db.insert(&self.code_cache)); }, (false, _) => {}, diff --git a/src/executive.rs b/src/executive.rs index 9d2562029..01bed3fd7 100644 --- a/src/executive.rs +++ b/src/executive.rs @@ -171,6 +171,7 @@ impl<'a> Executive<'a> { // at first, transfer value to destination self.state.transfer_balance(¶ms.sender, ¶ms.address, ¶ms.value); + debug!("Executive::call(params={:?}) self.env_info={:?}", params, self.info); if self.engine.is_builtin(¶ms.code_address) { // if destination is builtin, try to execute it diff --git a/src/externalities.rs b/src/externalities.rs index 9c9b08040..654a27a05 100644 --- a/src/externalities.rs +++ b/src/externalities.rs @@ -133,6 +133,7 @@ impl<'a> Ext for Externalities<'a> { data: &[u8], code_address: &Address, output: &mut [u8]) -> Result<(U256, bool), evm::Error> { + let mut gas_cost = *call_gas; let mut call_gas = *call_gas; @@ -147,9 +148,10 @@ impl<'a> Ext for Externalities<'a> { call_gas = call_gas + U256::from(self.schedule.call_stipend); } -// flush(format!("Externalities::call(gas={}, call_gas={}, recv={}, value={}, data={}, code={})\n", gas, call_gas, receive_address, value, data.pretty(), code_address)); + debug!("Externalities::call(gas={}, call_gas={}, recv={}, value={}, data={}, code={})\n", gas, call_gas, receive_address, value, data.pretty(), code_address); if gas_cost > *gas { + debug!("Externalities::call: OutOfGas gas_cost={}, gas={}", gas_cost, gas); return Err(evm::Error::OutOfGas); } @@ -157,7 +159,8 @@ impl<'a> Ext for Externalities<'a> { // if balance is insufficient or we are too deep, return if self.state.balance(&self.params.address) < *value || self.depth >= self.schedule.max_depth { - return Ok((gas + call_gas, true)); + debug!("Externalities::call: OutOfCash bal({})={}, value={}", self.params.address, self.state.balance(&self.params.address), value); + return Ok((gas + call_gas, false)); } let params = ActionParams { diff --git a/src/state.rs b/src/state.rs index d9ad0dfac..98d1eacc3 100644 --- a/src/state.rs +++ b/src/state.rs @@ -150,7 +150,7 @@ impl State { let e = try!(Executive::new(self, env_info, engine).transact(t)); //println!("Executed: {:?}", e); -// flush(format!("Applied transaction. Diff:\n{}\n", StateDiff::diff_pod(&old, &self.to_pod()))); + debug!("Applied transaction. Diff:\n{}\n", StateDiff::diff_pod(&old, &self.to_pod())); self.commit(); let receipt = Receipt::new(self.root().clone(), e.cumulative_gas_used, e.logs); debug!("Transaction receipt: {:?}", receipt); diff --git a/src/verification.rs b/src/verification.rs index 4383f5a4a..bb7b912aa 100644 --- a/src/verification.rs +++ b/src/verification.rs @@ -115,18 +115,18 @@ pub fn verify_block_family(header: &Header, bytes: &[u8], engine: &Engine, b /// Phase 4 verification. Check block information against transaction enactment results, pub fn verify_block_final(expected: &Header, got: &Header) -> Result<(), Error> { - if expected.state_root != got.state_root { - return Err(From::from(BlockError::InvalidStateRoot(Mismatch { expected: expected.state_root.clone(), found: got.state_root.clone() }))) + if expected.gas_used != got.gas_used { + return Err(From::from(BlockError::InvalidGasUsed(Mismatch { expected: expected.gas_used, found: got.gas_used }))) } if expected.receipts_root != got.receipts_root { return Err(From::from(BlockError::InvalidReceiptsStateRoot(Mismatch { expected: expected.receipts_root.clone(), found: got.receipts_root.clone() }))) } + if expected.state_root != got.state_root { + return Err(From::from(BlockError::InvalidStateRoot(Mismatch { expected: expected.state_root.clone(), found: got.state_root.clone() }))) + } if expected.log_bloom != got.log_bloom { return Err(From::from(BlockError::InvalidLogBloom(Mismatch { expected: expected.log_bloom.clone(), found: got.log_bloom.clone() }))) } - if expected.gas_used != got.gas_used { - return Err(From::from(BlockError::InvalidGasUsed(Mismatch { expected: expected.gas_used, found: got.gas_used }))) - } Ok(()) }