Skip to content

Commit

Permalink
Update from upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <[email protected]>
  • Loading branch information
Deniallugo committed Dec 8, 2023
1 parent cf104db commit 739ec8b
Show file tree
Hide file tree
Showing 15 changed files with 618 additions and 612 deletions.
992 changes: 523 additions & 469 deletions Cargo.lock

Large diffs are not rendered by default.

65 changes: 26 additions & 39 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ trezor-client.opt-level = 1
[workspace.dependencies]
anvil = { path = "crates/anvil" }
cast = { path = "crates/cast" }
zkcast = { path = "crates/zkcast" }
chisel = { path = "crates/chisel" }
forge = { path = "crates/forge" }
zkforge = { path = "crates/zkforge" }

forge-doc = { path = "crates/doc" }
forge-fmt = { path = "crates/fmt" }
Expand All @@ -126,31 +124,24 @@ foundry-macros = { path = "crates/macros" }
foundry-test-utils = { path = "crates/test-utils" }

foundry-block-explorers = { version = "0.1.2", default-features = false }
foundry-compilers = { version = "0.1.1", default-features = false }

## revm
# no default features to avoid c-kzg
revm = { version = "3", default-features = false }
revm-primitives = { version = "1", default-features = false }
# Using a fork of revm as zksync-era requires the usage of sha3 0.10.6, and the latest revm uses 0.10.8
revm = { version = "3.5.0", default-features = false }
era_revm = { git="https://github.com/matter-labs/era-revm", rev = "2662bb19427a421662a7e463cf1ed6a15da361e5" }

# We use a fork of `ethers` to gain access to a previously private variable.
# This ensures that all artifact files, freshly compiled and saved in the `output` directory, are publicly accessible.
# For details on this modification, refer to:
# https://github.com/mm-zk/ethers-rs/commit/2b2c7312f328a431fa40a7b87a722eaf28e27061
ethers = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-addressbook = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-core = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-contract = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-contract-abigen = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-providers = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-signers = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-middleware = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-etherscan = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-solc = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }

## ethers
ethers = { version = "2.0", default-features = false }
ethers-core = { version = "2.0", default-features = false }
ethers-contract = { version = "2.0", default-features = false }
ethers-contract-abigen = { version = "2.0", default-features = false }
ethers-providers = { version = "2.0", default-features = false }
ethers-signers = { version = "2.0", default-features = false }
ethers-middleware = { version = "2.0", default-features = false }
ethers-solc = { version = "2.0", default-features = false }

foundry-compilers = { version = "0.1.1", default-features = false }
## alloy
alloy-primitives = "0.5.0"
alloy-dyn-abi = "0.5.0"
Expand Down Expand Up @@ -185,22 +176,18 @@ tower = "0.4"
tower-http = "0.4"

[patch.crates-io]
# We use a fork of `ethers` to gain access to a previously private variable.
# This ensures that all artifact files, freshly compiled and saved in the `output` directory, are publicly accessible.
# For details on this modification, refer to:
# https://github.com/mm-zk/ethers-rs/commit/2b2c7312f328a431fa40a7b87a722eaf28e27061
ethers = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-addressbook = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-core = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-contract = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-contract-abigen = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-providers = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-signers = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-middleware = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-etherscan = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
ethers-solc = { git = "https://github.com/mm-zk/ethers-rs", tag = "main_public_artifact", default-features = false }
revm = { git = "https://github.com/dutterbutter/revm", tag = "sha3_0.10" }
revm-interpreter = { git = "https://github.com/dutterbutter/revm", tag = "sha3_0.10" }
revm-precompile = { git = "https://github.com/dutterbutter/revm", tag = "sha3_0.10" }
revm-primitives = { git = "https://github.com/dutterbutter/revm", tag = "sha3_0.10" }

ethers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-core = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-contract = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-contract-abigen = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-providers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-signers = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }
ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "f0e5b194f09c533feb10d1a686ddb9e5946ec107" }

revm = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" }
revm-interpreter = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" }
revm-precompile = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" }
revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "reth_freeze" }

foundry-compilers = { git = "https://github.com/Deniallugo/compilers.git", branch = "main", default-features = false }
45 changes: 22 additions & 23 deletions crates/chisel/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use foundry_evm::{
backend::Backend, decode::decode_console_logs, executors::ExecutorBuilder,
inspectors::CheatsConfig,
};
use foundry_utils::types::ToEthers;
use revm::primitives::SpecId;
use solang_parser::pt::{self, CodeLocation};
use std::str::FromStr;
Expand Down Expand Up @@ -149,7 +148,7 @@ impl SessionSource {
if self.config.foundry_config.verbosity >= 3 {
eprintln!("Could not inspect: {e}");
}
return Ok((true, None));
return Ok((true, None))
}
},
};
Expand All @@ -169,10 +168,10 @@ impl SessionSource {

if let Some(event_definition) = intermediate_contract.event_definitions.get(input) {
let formatted = format_event_definition(event_definition)?;
return Ok((false, Some(formatted)));
return Ok((false, Some(formatted)))
}

return Ok((false, None));
return Ok((false, None))
}

let Some((stack, memory, _)) = &res.state else {
Expand All @@ -188,7 +187,7 @@ impl SessionSource {
}
}

return Err(eyre::eyre!("Failed to inspect expression"));
return Err(eyre::eyre!("Failed to inspect expression"))
};

let generated_output = source
Expand Down Expand Up @@ -736,7 +735,7 @@ impl Type {
/// Handle special expressions like [global variables](https://docs.soliditylang.org/en/latest/cheatsheet.html#global-variables)
fn map_special(self) -> Self {
if !matches!(self, Self::Function(_, _, _) | Self::Access(_, _) | Self::Custom(_)) {
return self;
return self
}

let mut types = Vec::with_capacity(5);
Expand All @@ -745,7 +744,7 @@ impl Type {

let len = types.len();
if len == 0 {
return self;
return self
}

// Type members, like array, bytes etc
Expand Down Expand Up @@ -783,8 +782,8 @@ impl Type {
match name {
"block" => match access {
"coinbase" => Some(DynSolType::Address),
"basefee" | "chainid" | "difficulty" | "gaslimit" | "number"
| "timestamp" => Some(DynSolType::Uint(256)),
"basefee" | "chainid" | "difficulty" | "gaslimit" | "number" |
"timestamp" => Some(DynSolType::Uint(256)),
_ => None,
},
"msg" => match access {
Expand Down Expand Up @@ -903,7 +902,7 @@ impl Type {
custom_type.pop();
}
if custom_type.is_empty() {
return Ok(None);
return Ok(None)
}

// If a contract exists with the given name, check its definitions for a match.
Expand All @@ -918,7 +917,7 @@ impl Type {
if let Some(func) = intermediate_contract.function_definitions.get(cur_type) {
// Check if the custom type is a function pointer member access
if let res @ Some(_) = func_members(func, custom_type) {
return Ok(res);
return Ok(res)
}

// Because tuple types cannot be passed to `abi.encode`, we will only be
Expand All @@ -939,7 +938,7 @@ impl Type {
// struct, array, etc.
if let pt::Expression::Variable(ident) = return_ty {
custom_type.push(ident.name.clone());
return Self::infer_custom_type(intermediate, custom_type, Some(contract_name));
return Self::infer_custom_type(intermediate, custom_type, Some(contract_name))
}

// Check if our final function call alters the state. If it does, we bail so that it
Expand Down Expand Up @@ -978,7 +977,7 @@ impl Type {
// anything. If it is, we can stop here.
if let Ok(res) = Self::infer_custom_type(intermediate, custom_type, Some("REPL".into()))
{
return Ok(res);
return Ok(res)
}

// Check if the first element of the custom type is a known contract. If it is, begin
Expand All @@ -987,13 +986,13 @@ impl Type {
let contract = intermediate.intermediate_contracts.get(name);
if contract.is_some() {
let contract_name = custom_type.pop();
return Self::infer_custom_type(intermediate, custom_type, contract_name);
return Self::infer_custom_type(intermediate, custom_type, contract_name)
}

// See [`Type::infer_var_expr`]
let name = custom_type.last().unwrap();
if let Some(expr) = intermediate.repl_contract_expressions.get(name) {
return Self::infer_var_expr(expr, Some(intermediate), custom_type);
return Self::infer_var_expr(expr, Some(intermediate), custom_type)
}

// The first element of our custom type was neither a variable or a function within the
Expand Down Expand Up @@ -1121,7 +1120,7 @@ impl Type {
let pt::Expression::Variable(contract_name) =
intermediate.repl_contract_expressions.get(&contract_name.name)?
else {
return None;
return None
};

let contract = intermediate
Expand Down Expand Up @@ -1189,10 +1188,10 @@ impl Type {
fn is_array(&self) -> bool {
matches!(
self,
Self::Array(_)
| Self::FixedArray(_, _)
| Self::Builtin(DynSolType::Array(_))
| Self::Builtin(DynSolType::FixedArray(_, _))
Self::Array(_) |
Self::FixedArray(_, _) |
Self::Builtin(DynSolType::Array(_)) |
Self::Builtin(DynSolType::FixedArray(_, _))
)
}

Expand All @@ -1209,7 +1208,7 @@ impl Type {
#[inline]
fn func_members(func: &pt::FunctionDefinition, custom_type: &[String]) -> Option<DynSolType> {
if !matches!(func.ty, pt::FunctionTy::Function) {
return None;
return None
}

let vis = func.attributes.iter().find_map(|attr| match attr {
Expand Down Expand Up @@ -1647,15 +1646,15 @@ mod tests {
Ok((solc, v)) => {
// successfully installed
eprintln!("found installed Solc v{v} @ {}", solc.solc.display());
break;
break
}
Err(e) => {
// try reinstalling
eprintln!("error while trying to re-install Solc v{version}: {e}");
let solc = Solc::blocking_install(&version.parse().unwrap());
if solc.map_err(SolcError::from).and_then(|solc| solc.version()).is_ok() {
*is_preinstalled = true;
break;
break
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions crates/common/src/zk_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@
/// - Artifact Path Generation: The `build_artifacts_path` and `build_artifacts_file` methods
/// construct the path and file for saving the compiler output artifacts.
use crate::zksolc_manager::ZkSolcManager;
use alloy_json_abi::{Function, JsonAbi};
use alloy_primitives::Bytes;
use ansi_term::Colour::{Red, Yellow};
use ethers_core::types::Bytes;
use ethers_solc::{
use eyre::{Context, ContextCompat, Result};
use foundry_compilers::{
artifacts::{
output_selection::FileOutputSelection, CompactBytecode, CompactDeployedBytecode,
LosslessAbi, Source, StandardJsonCompilerInput,
output_selection::FileOutputSelection, CompactBytecode, CompactDeployedBytecode, Source,
StandardJsonCompilerInput,
},
remappings::RelativeRemapping,
ArtifactFile, Artifacts, ConfigurableContractArtifact, Graph, Project, ProjectCompileOutput,
Solc,
};
use eyre::{Context, ContextCompat, Result};
use regex::Regex;
use semver::Version;
use serde::Deserialize;
Expand Down Expand Up @@ -496,15 +497,15 @@ impl ZkSolc {

let mut art = ConfigurableContractArtifact {
bytecode: Some(CompactBytecode {
object: ethers_solc::artifacts::BytecodeObject::Bytecode(
object: foundry_compilers::artifacts::BytecodeObject::Bytecode(
packed_bytecode.clone(),
),
source_map: None,
link_references: Default::default(),
}),
deployed_bytecode: Some(CompactDeployedBytecode {
bytecode: Some(CompactBytecode {
object: ethers_solc::artifacts::BytecodeObject::Bytecode(
object: foundry_compilers::artifacts::BytecodeObject::Bytecode(
packed_bytecode,
),
source_map: None,
Expand Down Expand Up @@ -962,7 +963,7 @@ pub struct ZkContract {
#[serde(rename = "factoryDependencies", default)]
pub factory_dependencies: HashMap<String, String>,
pub evm: Evm,
pub abi: Option<LosslessAbi>,
pub abi: Option<JsonAbi>,
}
#[derive(Debug, Deserialize)]

Expand Down
Loading

0 comments on commit 739ec8b

Please sign in to comment.