Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cheatcodes): add vm.setBlockhash #8258

Merged
merged 21 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/cheatcodes/spec/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,10 @@ interface Vm {
/// Returns a random `address`.
#[cheatcode(group = Utilities)]
function randomAddress() external returns (address);

/// Set blockhash for the current block.
#[cheatcode(group = Utilities)]
function setBlockhash(uint256 blockNumber, bytes32 blockHash) external;
DaniPopes marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
8 changes: 8 additions & 0 deletions crates/cheatcodes/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,14 @@ impl Cheatcode for stopAndReturnStateDiffCall {
}
}


impl Cheatcode for setBlockhashCall{
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
todo!()
mattsse marked this conversation as resolved.
Show resolved Hide resolved
TropicalDog17 marked this conversation as resolved.
Show resolved Hide resolved
}

}

pub(super) fn get_nonce<DB: DatabaseExt>(ccx: &mut CheatsCtxt<DB>, address: &Address) -> Result {
let (account, _) = ccx.ecx.journaled_state.load_account(*address, &mut ccx.ecx.db)?;
Ok(account.info.nonce.abi_encode())
Expand Down