Skip to content

Commit

Permalink
get initial onchain balance for call receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
Raz0r committed Aug 27, 2024
1 parent 6b1c2d8 commit e46790f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/evm/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ use crate::{
mutator::AccessPattern,
onchain::{
abi_decompiler::fetch_abi_evmole,
flashloan::{register_borrow_txn, Flashloan},
flashloan::{register_borrow_txn, Flashloan}, OnChain,
},
types::{as_u64, generate_random_address, is_zero, EVMAddress, EVMU256},
vm::{is_reverted_or_control_leak, EVMState, SinglePostExecution, IN_DEPLOY, IS_FAST_CALL_STATIC},
Expand Down Expand Up @@ -1480,6 +1480,12 @@ where
if let Some(balance) = self.evmstate.get_balance(&receiver) {
self.evmstate.set_balance(receiver, *balance + value);
} else {
let on_chain_middleware = self.middlewares.read().unwrap().iter().find_map(|m| {
m.deref().borrow().as_any().downcast_ref::<OnChain>().cloned()
});
if let Some(mut on_chain_middleware) = on_chain_middleware {
self.next_slot = on_chain_middleware.endpoint.get_balance(receiver);
}
self.evmstate.set_balance(receiver, self.next_slot + value);
};
}
Expand Down

0 comments on commit e46790f

Please sign in to comment.