Make stuff work.
This commit is contained in:
parent
4fde74c5e8
commit
2f14b755f1
@ -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, _) => {},
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -115,18 +115,18 @@ pub fn verify_block_family<BC>(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(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user