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

Commit 35f94a8

Browse files
committed
Review fixes
1 parent 7e8b8f2 commit 35f94a8

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
@@ -212,7 +212,7 @@ impl Client {
212212
trace!("Cleanup journal: DB Earliest = {:?}, Latest = {:?}", state_db.journal_db().earliest_era(), state_db.journal_db().latest_era());
213213

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

ethcore/src/client/evm_test_client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ impl<'a> EvmTestClient<'a> {
9090
ForkSpec::EIP158 => Some(&*EIP161),
9191
ForkSpec::Byzantium => Some(&*BYZANTIUM),
9292
ForkSpec::EIP158ToByzantiumAt5 => Some(&BYZANTIUM_TRANSITION),
93+
ForkSpec::FrontierToHomesteadAt5 | ForkSpec::HomesteadToDaoAt5 | ForkSpec::HomesteadToEIP150At5 => None,
9394
_ => None,
9495
}
9596
}

ethcore/src/json_tests/executive.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ use tests::helpers::*;
3030
use ethjson;
3131
use trace::{Tracer, NoopTracer};
3232
use trace::{VMTracer, NoopVMTracer};
33+
use rlp::RlpStream;
34+
use hash::keccak;
3335

3436
#[derive(Debug, PartialEq, Clone)]
3537
struct CallCreate {
@@ -257,15 +259,22 @@ fn do_json_test_for(vm_type: &VMType, json_data: &[u8]) -> Vec<String> {
257259
(res.finalize(ex), callcreates)
258260
};
259261

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

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

ethcore/src/state/mod.rs

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

503503
/// Determine whether an account exists and has code or non-zero nonce.
504504
pub fn exists_and_has_code_or_nonce(&self, a: &Address) -> trie::Result<bool> {
505-
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())))
505+
self.ensure_cached(a, RequireCache::CodeSize, false,
506+
|a| a.map_or(false, |a| a.code_size().map_or(false,
507+
|size| size != 0 || *a.nonce() != self.account_start_nonce)))
506508
}
507509

508510
/// Get the balance of account `a`.
@@ -695,9 +697,9 @@ impl<B: Backend> State<B> {
695697
let e = self.execute(env_info, engine, t, options, false)?;
696698

697699
let eip658 = env_info.number >= engine.params().eip658_transition;
698-
let no_intermediate_commits = (env_info.number >= engine.params().eip98_transition
699-
&& env_info.number >= engine.params().validate_receipts_transition)
700-
|| eip658;
700+
let no_intermediate_commits =
701+
eip658 ||
702+
(env_info.number >= engine.params().eip98_transition && env_info.number >= engine.params().validate_receipts_transition);
701703

702704
let state_root = if no_intermediate_commits {
703705
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)