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: vm.blobhashes #7001

Merged
merged 13 commits into from
Apr 25, 2024
6 changes: 6 additions & 0 deletions crates/cheatcodes/spec/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ interface Vm {
#[cheatcode(group = Evm, safety = Unsafe)]
function prevrandao(bytes32 newPrevrandao) external;

/// Sets the blobhashes in the transaction.
/// Not available on EVM versions before Cancun.
/// If used on unsupported EVM versions it will revert.
#[cheatcode(group = Evm, safety = Unsafe)]
function blobhashes(bytes32[] blobhashes) external;

/// Sets `block.height`.
#[cheatcode(group = Evm, safety = Unsafe)]
function roll(uint256 newHeight) external;
Expand Down
13 changes: 13 additions & 0 deletions crates/cheatcodes/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,19 @@ impl Cheatcode for prevrandaoCall {
}
}

impl Cheatcode for blobhashesCall {
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
let Self { blobhashes } = self;
ensure!(
ccx.data.env.cfg.spec_id >= SpecId::CANCUN,
"`blobhash` is not supported before the Cancun hard fork; \
see EIP-4844: https://eips.ethereum.org/EIPS/eip-4844"
);
ccx.data.env.tx.blob_hashes = blobhashes.clone();
Ok(Default::default())
}
}

impl Cheatcode for rollCall {
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
let Self { newHeight } = self;
Expand Down
1 change: 0 additions & 1 deletion crates/cheatcodes/src/evm/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use foundry_evm_core::fork::CreateFork;

impl Cheatcode for activeForkCall {
fn apply_full<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
let Self {} = self;
onbjerg marked this conversation as resolved.
Show resolved Hide resolved
ccx.data
.db
.active_fork_id()
Expand Down
Loading