Skip to content

Commit

Permalink
feat(forge): Paris & Shanghai support & add prevrandao cheatcode (f…
Browse files Browse the repository at this point in the history
…oundry-rs#4856)

* chore: upgrade default evm version to shanghai for optimizoors

* fix: make test runner actually respect evm_version

* chore: clippy?

* chore: add paris and shanghai to available evm versions but run london on tests

* chore: add missing post-merge block properties

* chore: poc on checking for shanghai compat per RPC

* chore: dedupe evm_spec fn

* feat: set default test runner config to shanghai

* feat: add prevrandao cheatcode

* chore: modify tests to use prevrandao

* chore: fmt

* chore: test out comp by setting solc 0.8.19

* chore: improve warning message

* chore: unpin solidity version, fmt

* chore: pin things to ethers default (merge) instead of shanghai

* chore: clippy

* chore: force forge tests to use at least 0.8.19

* feat: fix fixtures and other test-related compiler errors

* chore: add missing semicolons to failed compiler run msg

* chore: fix last complaining test

* chore: fix remaining tests

* chore: format warning as yellow, use Chain type instead of raw U256s

* chore: correct difficulty for prevrandao

* chore: make testconfig evm spec nicely configurable

* feat: add Shanghai compat test (thanks karmacoma and vex)

* chore: make own folder for evm spec tests

* chore: move shanghai compat test to its own spec folder

* chore: remove duplicated function

* Apply suggestions from code review

Co-authored-by: DaniPopes <[email protected]>

* feat: rewrite shanghai support check to be more efficient

* chore: use any

* chore: fmt

* chore: show chain IDs that are unsupported

* chore: point out unsupported chain IDs explicitly in message

---------

Co-authored-by: DaniPopes <[email protected]>
  • Loading branch information
Evalir and DaniPopes authored May 5, 2023
1 parent 326a889 commit e48db34
Show file tree
Hide file tree
Showing 153 changed files with 399 additions and 268 deletions.
112 changes: 65 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ panic = "abort"
codegen-units = 1

[workspace.dependencies]
ethers = { version = "2", default-features = false }
ethers = { version = "2.0.4", default-features = false }
ethers-addressbook = { version = "2", default-features = false }
ethers-core = { version = "2", default-features = false }
ethers-contract = { version = "2", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,7 @@ impl Backend {
nonce: Some(nonce),
base_fee_per_gas,
other: Default::default(),
..Default::default()
}
}

Expand Down
2 changes: 1 addition & 1 deletion chisel/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl SessionSource {
.with_config(env)
.with_chisel_state(final_pc)
.set_tracing(true)
.with_spec(foundry_cli::utils::evm_spec(&self.config.foundry_config.evm_version))
.with_spec(foundry_evm::utils::evm_spec(&self.config.foundry_config.evm_version))
.with_gas_limit(self.config.evm_opts.gas_limit())
.with_cheatcodes(CheatsConfig::new(&self.config.foundry_config, &self.config.evm_opts))
.build(backend);
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ foundry-utils = { path = "../utils" }
forge = { path = "../forge" }
foundry-config = { path = "../config" }
foundry-common = { path = "../common" }
foundry-evm = { path = "../evm" }
cast = { path = "../cast" }
ui = { path = "../ui" }

Expand Down
6 changes: 3 additions & 3 deletions cli/src/cmd/cast/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use forge::{
utils::h256_to_b256,
};
use foundry_config::{find_project_root_path, Config};
use foundry_evm::utils::evm_spec;
use std::{collections::BTreeMap, str::FromStr};
use tracing::trace;
use ui::{TUIExitReason, Tui, Ui};
Expand Down Expand Up @@ -92,9 +93,8 @@ impl RunArgs {

// configures a bare version of the evm executor: no cheatcode inspector is enabled,
// tracing will be enabled only for the targeted transaction
let builder = ExecutorBuilder::default()
.with_config(env)
.with_spec(crate::utils::evm_spec(&config.evm_version));
let builder =
ExecutorBuilder::default().with_config(env).with_spec(evm_spec(&config.evm_version));

let mut executor = builder.build(db);

Expand Down
5 changes: 3 additions & 2 deletions cli/src/cmd/forge/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
forge::{build::CoreBuildArgs, install, test::FilterArgs},
Cmd, LoadConfig,
},
utils::{self, p_println, STATIC_FUZZ_SEED},
utils::{p_println, STATIC_FUZZ_SEED},
};
use clap::{Parser, ValueEnum};
use ethers::{
Expand All @@ -29,6 +29,7 @@ use forge::{
};
use foundry_common::{compile::ProjectCompiler, evm::EvmArgs, fs};
use foundry_config::Config;
use foundry_evm::utils::evm_spec;
use semver::Version;
use std::{collections::HashMap, sync::mpsc::channel, thread};
use tracing::trace;
Expand Down Expand Up @@ -266,7 +267,7 @@ impl CoverageArgs {
let root = project.paths.root;

// Build the contract runner
let evm_spec = utils::evm_spec(&config.evm_version);
let evm_spec = evm_spec(&config.evm_version);
let env = evm_opts.evm_env_blocking()?;
let mut runner = MultiContractRunnerBuilder::default()
.initial_balance(evm_opts.initial_balance)
Expand Down
Loading

0 comments on commit e48db34

Please sign in to comment.