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: use foundry-cheatcodes implementations #6131

Merged
merged 65 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
b033269
feat: use `foundry-cheatcodes` in `foundry-evm`
DaniPopes Oct 26, 2023
e7df61c
fix: deps
DaniPopes Oct 26, 2023
8ac41c7
docs: retire `foundry-abi`
DaniPopes Oct 26, 2023
7183cf7
chore: refactor profiles
DaniPopes Oct 26, 2023
665ea5a
docs: obsolete -> deprecated
DaniPopes Oct 26, 2023
ee112b2
fix: fs tests
DaniPopes Oct 26, 2023
37b660a
fix: repro 5808
DaniPopes Oct 26, 2023
10211b4
fix: implement `rpc` and `eth_getLogs`
DaniPopes Oct 26, 2023
7ff109d
fix: int test
DaniPopes Oct 26, 2023
df9426a
chore: reorder EthGetLogs struct fields
DaniPopes Oct 26, 2023
55a8edb
chore: update JSON
DaniPopes Oct 26, 2023
1249038
docs: update dev docs and cheatcodes README
DaniPopes Oct 26, 2023
54a15e4
chore: rename magic bytes constants
DaniPopes Oct 26, 2023
709401c
fix: Error ABI encoding
DaniPopes Oct 27, 2023
91a7e48
fix: ABI-encode Error as `CheatCodeError(string)`
DaniPopes Oct 27, 2023
13c467d
chore: remove bad re-export
DaniPopes Oct 27, 2023
9a0aad8
test: update script panic message
DaniPopes Oct 27, 2023
f0eca5d
fix: broadcast origin and caller
DaniPopes Oct 27, 2023
2bba499
test: update some test messages
DaniPopes Oct 27, 2023
018580f
test: add more debug
DaniPopes Oct 27, 2023
74926a2
test: don't run commands twice...
DaniPopes Oct 27, 2023
a662a23
chore: clippy
DaniPopes Oct 27, 2023
d0c5b86
fix: tracing-subscriber features
DaniPopes Oct 27, 2023
e5defcf
fix: re-disable color
DaniPopes Oct 27, 2023
b30f49f
fixes
DaniPopes Oct 27, 2023
7be945a
chore: clippy
DaniPopes Oct 27, 2023
c7096a1
fix: error encoding
DaniPopes Oct 27, 2023
1b20006
feat: auto generate solidity interface
DaniPopes Oct 28, 2023
8df2988
opts
DaniPopes Oct 28, 2023
f03ff3b
ci: fix forge-fmt
DaniPopes Oct 30, 2023
96e1ef5
feat: re-implement `cool`
DaniPopes Oct 30, 2023
04caeac
fix: FfiResult exit_code->exitCode
DaniPopes Oct 30, 2023
e7bd8c7
chore: update
DaniPopes Oct 30, 2023
64eed10
Merge branch 'master' into alloy-cheatcodes4
DaniPopes Oct 30, 2023
2b679ff
fix: scripting expects
DaniPopes Oct 30, 2023
670c3f3
fix: rename test output methods
DaniPopes Oct 30, 2023
de21ea6
test: update expect msgs
DaniPopes Oct 30, 2023
d69e39b
chore: update broadcast staticcall error message
DaniPopes Oct 30, 2023
ed93c1f
chore: only expand `#[vm]` macro in `cfg(test)`
DaniPopes Oct 30, 2023
79975ff
test: update precompile error msg
DaniPopes Oct 30, 2023
07e265a
test: update env tests
DaniPopes Oct 30, 2023
42753fa
fix: expectCall value gt 0
DaniPopes Oct 30, 2023
1df33b5
fix: fs error messages
DaniPopes Oct 30, 2023
75a4127
fix: rm huff abi test
DaniPopes Oct 30, 2023
4e487e4
fix: forge fmt
DaniPopes Oct 30, 2023
a3d271a
fix: JSON coerce error msg
DaniPopes Oct 30, 2023
2c3fe89
fix: JSON non-object error message
DaniPopes Oct 30, 2023
f8ed465
chore: random stuff
DaniPopes Oct 30, 2023
85a66b4
tmp: comment out sleep fuzz test
DaniPopes Oct 30, 2023
54000c3
chore: mark generated files in .gitattributes
DaniPopes Oct 30, 2023
db99a1c
chore: uncapitalize an error msg
DaniPopes Oct 30, 2023
c765167
fix: use BTreeMap for serialized JSONs
DaniPopes Oct 30, 2023
362c22d
chore: better tracing
DaniPopes Oct 31, 2023
d06838b
fix: properly serialize JSON arrays
DaniPopes Oct 31, 2023
c855ed6
fix: missing rpc url error message
DaniPopes Oct 31, 2023
fba652c
fix: mock calls
DaniPopes Oct 31, 2023
126eaa3
chore: clippy
DaniPopes Oct 31, 2023
35a49ce
Merge branch 'master' into alloy-cheatcodes4
DaniPopes Oct 31, 2023
28a62fa
fix: update broadcast sender nonce, not CREATE2 deployer
DaniPopes Oct 31, 2023
3a4807b
chore: use trace! for verbose cheatcode logs
DaniPopes Oct 31, 2023
beaad60
feat: extend schema to include other items
DaniPopes Oct 31, 2023
cee8c7e
feat: generate Vm from expanded interface
DaniPopes Oct 31, 2023
fc3596c
chore: clippy
DaniPopes Oct 31, 2023
d250410
fix: use forge-std pr
DaniPopes Oct 31, 2023
d42cf07
fix: use forge-std master
DaniPopes Oct 31, 2023
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
18 changes: 6 additions & 12 deletions Cargo.lock

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

66 changes: 14 additions & 52 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ scrypt.opt-level = 3
# forking
axum.opt-level = 3

# Optimized release profile
[profile.release]
opt-level = "s"
lto = "fat"
# Local "release" mode, more optimized than dev but much faster to compile than release
[profile.local]
inherits = "dev"
opt-level = 1
strip = true
panic = "abort"
codegen-units = 1
codegen-units = 16

# Like release, but with full debug symbols and with stack unwinds. Useful for e.g. `perf`.
[profile.debug-fast]
Expand All @@ -84,13 +84,16 @@ strip = "none"
panic = "unwind"
incremental = false

[profile.release.package]
# Optimize all non-workspace packages for speed
"*".opt-level = 3

# Package overrides
foundry-evm.opt-level = 3
# Optimized release profile
[profile.release]
opt-level = 3
lto = "fat"
strip = true
panic = "abort"
codegen-units = 1

# Override packages which aren't perf-sensitive for faster compilation speed
[profile.release.package]
foundry-abi.opt-level = 1
mdbook.opt-level = 1
protobuf.opt-level = 1
Expand All @@ -100,47 +103,6 @@ rusoto_kms.opt-level = 1
toml_edit.opt-level = 1
trezor-client.opt-level = 1

# Given that the `"*"` above takes precedence over the defaults for build scripts and macros, we
# have to override all of them to reduce compile times
syn.opt-level = 0
prettyplease.opt-level = 0
lalrpop.opt-level = 0

ethers-contract-abigen.opt-level = 0
ethers-contract-derive.opt-level = 0
async-recursion.opt-level = 0
miette-derive.opt-level = 0
strum_macros.opt-level = 0
enumn.opt-level = 0
clap_derive.opt-level = 0
serde_derive.opt-level = 0
pear_codegen.opt-level = 0
num_enum_derive.opt-level = 0
scale-info-derive.opt-level = 0
parity-scale-codec-derive.opt-level = 0
time-macros.opt-level = 0
phf_macros.opt-level = 0
pin-project-internal.opt-level = 0
auto_impl.opt-level = 0
derive_more.opt-level = 0
rlp-derive.opt-level = 0
impl-trait-for-tuples.opt-level = 0
async-trait.opt-level = 0
tokio-macros.opt-level = 0
tracing-attributes.opt-level = 0
futures-macro.opt-level = 0
thiserror-impl.opt-level = 0
wasm-bindgen-macro-support.opt-level = 0
wasm-bindgen-backend.opt-level = 0

# Local "release" mode, more optimized than dev but much faster to compile than release
[profile.local]
inherits = "dev"
opt-level = 1
strip = true
panic = "abort"
codegen-units = 16

[workspace.dependencies]
anvil = { path = "crates/anvil" }
cast = { path = "crates/cast" }
Expand Down
4 changes: 4 additions & 0 deletions crates/abi/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# foundry-abi

> [!WARNING]
> This crate is deprecated and will be replaced with `foundry-cheatcodes` in the near future.
> Please avoid making any changes in this crate.

Contains automatically-generated Rust bindings from Solidity ABI.

Additional bindings can be generated by doing the following:
Expand Down
4 changes: 4 additions & 0 deletions crates/abi/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! **WARNING**
//! This crate is deprecated and will be replaced with `foundry-cheatcodes` in the near future.
//! Please avoid making any changes in this crate.

use ethers_contract_abigen::MultiAbigen;

/// Includes a JSON ABI as a string literal.
Expand Down
4 changes: 4 additions & 0 deletions crates/abi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
//! Foundry's Solidity ABI bindings.
//!
//! Automatically generated by [abigen](ethers_contract::abigen).
//!
//! **WARNING**
//! This crate is deprecated and will be replaced with `foundry-cheatcodes` in the near future.
//! Please avoid making any changes in this crate.

#![warn(unused_crate_dependencies)]

Expand Down
21 changes: 14 additions & 7 deletions crates/cheatcodes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ exclude.workspace = true

[dependencies]
foundry-macros.workspace = true

alloy-primitives.workspace = true
alloy-sol-types.workspace = true

serde.workspace = true
serde_json.workspace = true

Expand All @@ -23,38 +25,43 @@ schemars = { version = "0.8.15", optional = true }

# impls
foundry-common = { workspace = true, optional = true }
foundry-compilers = { workspace = true, optional = true }
foundry-config = { workspace = true, optional = true }
foundry-evm-core = { workspace = true, optional = true }
foundry-utils = { workspace = true, optional = true }

alloy-dyn-abi = { workspace = true, optional = true }
alloy-json-abi = { workspace = true, optional = true }
ethers = { workspace = true, optional = true, features = ["ethers-solc"] }
foundry-compilers = { workspace = true, optional = true, default-features = false }
ethers-core = { workspace = true, optional = true }
ethers-signers = { workspace = true, optional = true }
ethers-providers = { workspace = true, optional = true }

eyre = { workspace = true, optional = true }
futures = { version = "0.3", optional = true }
hex = { workspace = true, optional = true }
itertools = { workspace = true, optional = true }
jsonpath_lib = { workspace = true, optional = true }
revm = { workspace = true, optional = true }
thiserror = { version = "1", optional = true }
tracing = { workspace = true, optional = true }
walkdir = { version = "2", optional = true }

[features]
schema = ["dep:schemars"]
impls = [
"dep:foundry-common",
"dep:foundry-compilers",
"dep:foundry-config",
"dep:foundry-evm-core",
"dep:foundry-utils",
"dep:alloy-dyn-abi",
"dep:alloy-json-abi",
"dep:ethers",
"dep:ethers-core",
"dep:ethers-providers",
"dep:ethers-signers",
"dep:eyre",
"dep:futures",
"dep:hex",
"dep:itertools",
"dep:jsonpath_lib",
"dep:revm",
"dep:thiserror",
"dep:tracing",
"dep:walkdir",
]
36 changes: 36 additions & 0 deletions crates/cheatcodes/assets/cheatcodes.json

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

32 changes: 32 additions & 0 deletions crates/cheatcodes/src/defs/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,28 @@ interface Vm {
string url;
}

/// An RPC log object. Returned by `eth_getLogs`.
struct EthGetLogs {
/// The address of the log's emitter.
address emitter;
/// The topics of the log, including the signature, if any.
bytes32[] topics;
/// The raw data of the log.
bytes data;
/// The block hash.
bytes32 blockHash;
/// The block number.
uint64 blockNumber;
/// The transaction hash.
bytes32 transactionHash;
/// The transaction index in the block.
uint64 transactionIndex;
/// The log index.
uint256 logIndex;
/// Whether the log was removed.
bool removed;
}

/// A single entry in a directory listing. Returned by `readDir`.
struct DirEntry {
/// The error message, if any.
Expand Down Expand Up @@ -352,6 +374,16 @@ interface Vm {
#[cheatcode(group = Evm, safety = Unsafe)]
function transact(uint256 forkId, bytes32 txHash) external;

/// Performs an Ethereum JSON-RPC request to the current fork URL.
#[cheatcode(group = Evm, safety = Unsafe)]
function rpc(string calldata method, string calldata params) external returns (bytes memory data);

/// Gets all the logs according to specified filter.
#[cheatcode(group = Evm, safety = Unsafe)]
function eth_getLogs(uint256 fromBlock, uint256 toBlock, address addr, bytes32[] memory topics)
external
returns (EthGetLogs[] memory logs);

// --- Behavior ---

/// In forking mode, explicitly grant the given address cheatcode access.
Expand Down
24 changes: 1 addition & 23 deletions crates/cheatcodes/src/impls/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,9 @@ use foundry_config::{
cache::StorageCachingConfig, fs_permissions::FsAccessKind, Config, FsPermissions,
ResolvedRpcEndpoints,
};
use foundry_evm_core::opts::EvmOpts;
use std::path::{Path, PathBuf};

// TODO
#[derive(Clone, Debug, Default)]
pub struct EvmOpts {
pub ffi: bool,
pub fork_block_number: Option<u64>,
}

impl EvmOpts {
pub fn get_compute_units_per_second(&self) -> u64 {
unimplemented!()
}

pub async fn fork_evm_env(
&self,
_x: &str,
) -> Result<
(revm::primitives::Env, ethers::types::Block<ethers::types::H256>),
core::convert::Infallible,
> {
unimplemented!()
}
}

/// Additional, configurable context the `Cheatcodes` inspector has access to
///
/// This is essentially a subset of various `Config` settings `Cheatcodes` needs to know.
Expand Down
Loading
Loading