Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 5929e1c

Browse files
committed
Review fixes
1 parent 09e201c commit 5929e1c

File tree

8 files changed

+27
-17
lines changed

8 files changed

+27
-17
lines changed

ethcore/evm/src/interpreter/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl<Cost: CostType> Interpreter<Cost> {
328328
let contract_code = self.mem.read_slice(init_off, init_size);
329329
let can_create = ext.balance(&params.address)? >= endowment && ext.depth() < ext.schedule().max_depth;
330330

331-
// clear return data buffer before crearing new call frame.
331+
// clear return data buffer before creating new call frame.
332332
self.return_data = ReturnData::empty();
333333

334334
if !can_create {
@@ -368,8 +368,7 @@ impl<Cost: CostType> Interpreter<Cost> {
368368
None
369369
} else if instruction == instructions::STATICCALL {
370370
Some(U256::zero())
371-
}
372-
else {
371+
} else {
373372
Some(stack.pop_back())
374373
};
375374

@@ -390,11 +389,11 @@ impl<Cost: CostType> Interpreter<Cost> {
390389
if ext.is_static() && value.map_or(false, |v| !v.is_zero()) {
391390
return Err(vm::Error::MutableCallInStaticContext);
392391
}
393-
let has_balance = ext.balance(&params.address)? >= value.expect("value set for all but delegate call and staticcall; qed");
392+
let has_balance = ext.balance(&params.address)? >= value.expect("value set for all but delegate call; qed");
394393
(&params.address, &code_address, has_balance, CallType::Call)
395394
},
396395
instructions::CALLCODE => {
397-
let has_balance = ext.balance(&params.address)? >= value.expect("value set for all but delegate call and staticcall; qed");
396+
let has_balance = ext.balance(&params.address)? >= value.expect("value set for all but delegate call; qed");
398397
(&params.address, &params.address, has_balance, CallType::CallCode)
399398
},
400399
instructions::DELEGATECALL => (&params.sender, &params.address, true, CallType::DelegateCall),
@@ -423,12 +422,12 @@ impl<Cost: CostType> Interpreter<Cost> {
423422
MessageCallResult::Success(gas_left, data) => {
424423
stack.push(U256::one());
425424
self.return_data = data;
426-
Ok(InstructionResult::UnusedGas(Cost::from_u256(gas_left).expect("Gas left cannot be greater then current one")))
425+
Ok(InstructionResult::UnusedGas(Cost::from_u256(gas_left).expect("Gas left cannot be greater than current one")))
427426
},
428427
MessageCallResult::Reverted(gas_left, data) => {
429428
stack.push(U256::zero());
430429
self.return_data = data;
431-
Ok(InstructionResult::UnusedGas(Cost::from_u256(gas_left).expect("Gas left cannot be greater then current one")))
430+
Ok(InstructionResult::UnusedGas(Cost::from_u256(gas_left).expect("Gas left cannot be greater than current one")))
432431
},
433432
MessageCallResult::Failed => {
434433
stack.push(U256::zero());

ethcore/res/ethereum/tests

Submodule tests updated 457 files

ethcore/src/client/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl Client {
211211
trace!("Cleanup journal: DB Earliest = {:?}, Latest = {:?}", state_db.journal_db().earliest_era(), state_db.journal_db().latest_era());
212212

213213
let history = if config.history < MIN_HISTORY_SIZE {
214-
debug!(target: "client", "Ignoring pruning history parameter of {}\
214+
info!(target: "client", "Ignoring pruning history parameter of {}\
215215
, falling back to minimum of {}",
216216
config.history, MIN_HISTORY_SIZE);
217217
MIN_HISTORY_SIZE

ethcore/src/client/evm_test_client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl<'a> EvmTestClient<'a> {
9292
ForkSpec::EIP158 => Some(&*EIP161),
9393
ForkSpec::Byzantium => Some(&*BYZANTIUM),
9494
ForkSpec::EIP158ToByzantiumAt5 => Some(&BYZANTIUM_TRANSITION),
95+
ForkSpec::FrontierToHomesteadAt5 | ForkSpec::HomesteadToDaoAt5 | ForkSpec::HomesteadToEIP150At5 => None,
9596
_ => None,
9697
}
9798
}

ethcore/src/json_tests/executive.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ use trace::{Tracer, NoopTracer};
3232
use trace::{VMTracer, NoopVMTracer};
3333
use bytes::{Bytes, BytesRef};
3434
use trie;
35+
use rlp::RlpStream;
36+
use hash::keccak;
3537

3638
#[derive(Debug, PartialEq, Clone)]
3739
struct CallCreate {
@@ -259,15 +261,22 @@ fn do_json_test_for(vm_type: &VMType, json_data: &[u8]) -> Vec<String> {
259261
(res.finalize(ex), callcreates)
260262
};
261263

264+
let log_hash = {
265+
let mut rlp = RlpStream::new_list(substate.logs.len());
266+
for l in &substate.logs {
267+
rlp.append(l);
268+
}
269+
keccak(&rlp.drain())
270+
};
271+
262272
match res {
263273
Err(_) => fail_unless(out_of_gas, "didn't expect to run out of gas."),
264274
Ok(res) => {
265275
fail_unless(!out_of_gas, "expected to run out of gas.");
266276
fail_unless(Some(res.gas_left) == vm.gas_left.map(Into::into), "gas_left is incorrect");
267277
let vm_output: Option<Vec<u8>> = vm.output.map(Into::into);
268278
fail_unless(Some(output) == vm_output, "output is incorrect");
269-
// TODO: verify logs
270-
//fail_unless(Some(res.logs) == vm.logs, "logs are incorrect");
279+
fail_unless(Some(log_hash) == vm.logs.map(|h| h.0), "logs are incorrect");
271280

272281
for (address, account) in vm.post_state.unwrap().into_iter() {
273282
let address = address.into();

ethcore/src/state/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,9 @@ impl<B: Backend> State<B> {
505505

506506
/// Determine whether an account exists and has code or non-zero nonce.
507507
pub fn exists_and_has_code_or_nonce(&self, a: &Address) -> trie::Result<bool> {
508-
self.ensure_cached(a, RequireCache::CodeSize, false, |a| a.map_or(false, |a| a.code_size().map_or(false, |size| size != 0 || !a.nonce().is_zero())))
508+
self.ensure_cached(a, RequireCache::CodeSize, false,
509+
|a| a.map_or(false, |a| a.code_size().map_or(false,
510+
|size| size != 0 || *a.nonce() != self.account_start_nonce)))
509511
}
510512

511513
/// Get the balance of account `a`.
@@ -698,9 +700,9 @@ impl<B: Backend> State<B> {
698700
let e = self.execute(env_info, engine, t, options, false)?;
699701

700702
let eip658 = env_info.number >= engine.params().eip658_transition;
701-
let no_intermediate_commits = (env_info.number >= engine.params().eip98_transition
702-
&& env_info.number >= engine.params().validate_receipts_transition)
703-
|| eip658;
703+
let no_intermediate_commits =
704+
eip658 ||
705+
(env_info.number >= engine.params().eip98_transition && env_info.number >= engine.params().validate_receipts_transition);
704706

705707
let state_root = if no_intermediate_commits {
706708
None

ethcore/vm/src/schedule.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ impl Schedule {
197197
schedule.have_revert = true;
198198
schedule.have_static_call = true;
199199
schedule.have_return_data = true;
200-
schedule.blockhash_gas = 800;
201200
schedule
202201
}
203202

json/src/vm/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ mod tests {
8686
"gas" : "0x013874",
8787
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
8888
"out" : "0x",
89-
"network" : "Fronier",
89+
"network" : "Frontier",
9090
"post" : {
9191
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
9292
"balance" : "0x0de0b6b3a7640000",

0 commit comments

Comments
 (0)