Skip to content

Commit

Permalink
Merge pull request #486 from fuzzland/fix-balance-create
Browse files Browse the repository at this point in the history
fix real_balance for create
  • Loading branch information
publicqi authored May 24, 2024
2 parents 2ffa214 + aaa023f commit 58f183b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/evm/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,20 @@ where
if unsafe { IN_DEPLOY } {
// todo: use nonce + hash instead
let r_addr = generate_random_address(state);

// update local balance
// for create we don't check sender balance
// todo: only disable checking in setUp
let value = EVMU256::from(inputs.value);
if cfg!(feature = "real_balance") && value != EVMU256::ZERO {
let receiver = r_addr;
if let Some(balance) = self.evmstate.get_balance(&receiver) {
self.evmstate.set_balance(receiver, *balance + value);
} else {
self.evmstate.set_balance(receiver, self.next_slot + value);
};
}

let mut interp = Interpreter::new_with_memory_limit(
Contract::new_with_context(
Bytes::new(),
Expand Down
6 changes: 5 additions & 1 deletion src/evm/middlewares/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ where
self.pc_coverage.entry(address).or_default().insert(pc);

if *interp.instruction_pointer == JUMPI {
let condition = if is_zero(interp.stack.peek(1).unwrap()) { false } else { true };
let condition = if is_zero(interp.stack.peek(1).unwrap()) {
false
} else {
true
};
self.jumpi_coverage.entry(address).or_default().insert((pc, condition));
}
}
Expand Down

0 comments on commit 58f183b

Please sign in to comment.