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): ensure vm.difficulty and vm.prevrandao fail if not using the correct EVM Version #4904

Merged
merged 2 commits into from
May 9, 2023
Merged
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
10 changes: 9 additions & 1 deletion evm/src/executor/inspector/cheatcodes/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use ethers::{
};
use foundry_config::Config;
use revm::{
primitives::{Bytecode, B256},
primitives::{Bytecode, SpecId, B256},
Database, EVMData,
};
use std::collections::BTreeMap;
Expand Down Expand Up @@ -204,10 +204,18 @@ pub fn apply<DB: DatabaseExt>(
Bytes::new()
}
HEVMCalls::Difficulty(inner) => {
ensure!(
data.env.cfg.spec_id < SpecId::MERGE,
"Difficulty is not supported after the merge. Please use vm.prevrandao instead."
mattsse marked this conversation as resolved.
Show resolved Hide resolved
);
data.env.block.difficulty = inner.0.into();
Bytes::new()
}
HEVMCalls::Prevrandao(inner) => {
ensure!(
data.env.cfg.spec_id >= SpecId::MERGE,
"Prevrandao is not supported before the merge. Please use vm.difficulty instead."
);
data.env.block.prevrandao = Some(B256::from(inner.0));
Bytes::new()
}
Expand Down