Skip to content

Conversation

aganisgash
Copy link
Contributor

All other mock functions use make_acc_non_empty to etch a single byte onto empty accounts, which prevents Solidity's extcodesize check from failing when mocking calls to addresses without existing bytecode.

Makes mockCalls_1Call consistent with the other mock cheatcodes and ensures mocked calls work correctly in all scenarios.

@zerosnacks
Copy link
Member

This makes sense to me, I am not sure why this was treated as a special case

For context:

// Etches a single byte onto the account if it is empty to circumvent the `extcodesize`
// check Solidity might perform.
fn make_acc_non_empty(callee: &Address, ecx: &mut CheatsCtxt) -> Result {
let acc = ecx.journaled_state.load_account(*callee)?;
let empty_bytecode = acc.info.code.as_ref().is_none_or(Bytecode::is_empty);
if empty_bytecode {
let code = Bytecode::new_raw(Bytes::from_static(&[0u8]));
ecx.journaled_state.set_code(*callee, code);
}
Ok(Default::default())
}

@zerosnacks zerosnacks self-requested a review August 27, 2025 15:03
@aganisgash
Copy link
Contributor Author

This makes sense to me, I am not sure why this was treated as a special case

For context:

// Etches a single byte onto the account if it is empty to circumvent the `extcodesize`
// check Solidity might perform.
fn make_acc_non_empty(callee: &Address, ecx: &mut CheatsCtxt) -> Result {
let acc = ecx.journaled_state.load_account(*callee)?;
let empty_bytecode = acc.info.code.as_ref().is_none_or(Bytecode::is_empty);
if empty_bytecode {
let code = Bytecode::new_raw(Bytes::from_static(&[0u8]));
ecx.journaled_state.set_code(*callee, code);
}
Ok(Default::default())
}

Maybe just a copy-paste oversight. All the other mock functions follow the same pattern with make_acc_non_empty, so this one likely got missed when the code was initially written.

@grandizzy
Copy link
Collaborator

I think we want a sig to bypass that at some point but subject to discussion #10703 (comment)

zerosnacks
zerosnacks previously approved these changes Aug 27, 2025
@zerosnacks zerosnacks self-requested a review August 27, 2025 15:10
@zerosnacks zerosnacks dismissed their stale review August 27, 2025 15:11

pending discussion

@grandizzy
Copy link
Collaborator

grandizzy commented Aug 27, 2025

I think that's fine but could be breaking change for some projects assuming that will revert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants