Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Fix #1451, option 1: Simply upgrade ethers #1452

Merged
merged 5 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2,271 changes: 1,160 additions & 1,111 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bus-mapping/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ eth-types = { path = "../eth-types" }
gadgets = { path = "../gadgets" }
mock = { path = "../mock", optional = true }

ethers-core = "0.17.0"
ethers-providers = "0.17.0"
ethers-core = "2.0.7"
ethers-providers = "2.0.7"
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", tag = "v2023_04_20" }
itertools = "0.10"
lazy_static = "1.4"
Expand Down
2 changes: 1 addition & 1 deletion bus-mapping/src/circuit_input_builder/input_state_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ impl<'a> CircuitInputStateRef<'a> {
let init_code = get_create_init_code(call_ctx, step)?.to_vec();
Ok(get_create2_address(
self.call()?.address,
salt.to_be_bytes().to_vec(),
salt.to_be_bytes(),
init_code,
))
}
Expand Down
2 changes: 1 addition & 1 deletion bus-mapping/src/evm/opcodes/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<const IS_CREATE2: bool> Opcode for Create<IS_CREATE2> {
address,
get_create2_address(
caller.address,
salt.to_be_bytes().to_vec(),
salt.to_be_bytes(),
initialization_code.clone(),
)
);
Expand Down
2 changes: 1 addition & 1 deletion bus-mapping/src/state_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl From<geth_types::Account> for Account {
nonce: account.nonce.as_u64(),
balance: account.balance,
storage: account.storage.clone(),
code_hash: CodeDB::hash(&account.code.to_vec()),
code_hash: CodeDB::hash(&account.code),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion circuit-benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rand = "0.8"
itertools = "0.10"
eth-types = { path = "../eth-types" }
env_logger = "0.9"
ethers-signers = "0.17.0"
ethers-signers = "2.0.7"
mock = { path="../mock" }
rand_chacha = "0.3"

Expand Down
4 changes: 2 additions & 2 deletions eth-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ authors = ["The appliedzkp team"]
license = "MIT OR Apache-2.0"

[dependencies]
ethers-core = "0.17.0"
ethers-signers = "0.17.0"
ethers-core = "2.0.7"
ethers-signers = "2.0.7"
hex = "0.4"
lazy_static = "1.4"
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", tag = "v2023_04_20" }
Expand Down
4 changes: 3 additions & 1 deletion eth-types/src/geth_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ impl GethData {
assert_eq!(Word::from(wallet.chain_id()), self.chain_id);
let geth_tx: Transaction = (&*tx).into();
let req: TransactionRequest = (&geth_tx).into();
let sig = wallet.sign_transaction_sync(&req.chain_id(self.chain_id.as_u64()).into());
let sig = wallet
.sign_transaction_sync(&req.chain_id(self.chain_id.as_u64()).into())
.unwrap();
tx.v = U64::from(sig.v);
tx.r = sig.r;
tx.s = sig.s;
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"

[dependencies]
lazy_static = "1.4"
ethers = { version = "0.17.0", features = ["ethers-solc"] }
ethers = { version = "2.0.7", features = ["ethers-solc"] }
serde_json = "1.0.66"
serde = { version = "1.0.130", features = ["derive"] }
bus-mapping = { path = "../bus-mapping" , features = ["test"] }
Expand Down
18 changes: 15 additions & 3 deletions integration-tests/src/bin/gen_blockchain_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use ethers::{
middleware::SignerMiddleware,
providers::{Middleware, PendingTransaction},
signers::Signer,
solc::Solc,
solc::{CompilerInput, EvmVersion, Solc},
};
use integration_tests::{
get_client, get_provider, get_wallet, log_init, CompiledContract, GenDataOutput, CONTRACTS,
Expand Down Expand Up @@ -75,11 +75,23 @@ async fn main() {

// Compile contracts
info!("Compiling contracts...");
let solc = Solc::default();
info!("Solc version {}", solc.version().expect("version works"));
let mut contracts = HashMap::new();
for (name, contract_path) in CONTRACTS {
let path_sol = Path::new(CONTRACTS_PATH).join(contract_path);
let compiled = Solc::default()
.compile_source(&path_sol)
let inputs = CompilerInput::new(&path_sol).expect("Compile success");
// ethers-solc: explicitly indicate the EvmVersion that corresponds to the zkevm circuit's
// supported Upgrade, e.g. `London/Shanghai/...` specifications.
let input = inputs
.clone()
.first_mut()
.expect("first exists")
.clone()
.evm_version(EvmVersion::London);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you have some comments to explain why we don't need to set evm version before but we need it now? Or we just have to set evm version here bcs it's part of rules of 2.0.7? Just would like to know what kind of situations we might need to upgrade the version in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point that we should add comments here. I added the comment in e118683

I checked ethers.rs and found it defaulted evm version to Shanghai, which is incompatible with my local 0.8.16 version.

I printed out the CI solidity version, which is 0.8.19. The Solidity doc for 0.8.19 says Paris is the latest supported EVM version. So if the ethers-solc selects Shanghai as EVM version, the Solidity compiler would not recognize it.


let compiled = solc
.compile(&input)
.unwrap_or_else(|_| panic!("solc compile error {:?}", path_sol));
if !compiled.errors.is_empty() {
panic!("Errors compiling {:?}:\n{:#?}", &path_sol, compiled.errors)
Expand Down
4 changes: 2 additions & 2 deletions mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ eth-types = { path = "../eth-types" }
external-tracer = { path = "../external-tracer" }
lazy_static = "1.4"
itertools = "0.10.3"
ethers-signers = "0.17.0"
ethers-core = "0.17.0"
ethers-signers = "2.0.7"
ethers-core = "2.0.7"
rand_chacha = "0.3"
rand = "0.8"
4 changes: 4 additions & 0 deletions mock/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ impl From<MockBlock> for Block<Transaction> {
.collect::<Vec<Transaction>>(),
size: Some(mock.size),
other: OtherFields::default(),
withdrawals_root: None,
withdrawals: None,
}
}
}
Expand Down Expand Up @@ -141,6 +143,8 @@ impl From<MockBlock> for Block<()> {
transactions: vec![],
size: Some(mock.size),
other: OtherFields::default(),
withdrawals_root: None,
withdrawals: None,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion mock/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ impl MockTransaction {
.from
.as_wallet()
.with_chain_id(self.chain_id.low_u64())
.sign_transaction_sync(&tx.into());
.sign_transaction_sync(&tx.into())
.unwrap();
// Set sig parameters
self.sig_data((sig.v, sig.r, sig.s));
}
Expand Down
4 changes: 2 additions & 2 deletions testool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ bus-mapping = { path = "../bus-mapping" }
clap = { version = "3.1", features = ["derive"] }
env_logger = "0.9"
eth-types = { path="../eth-types" }
ethers-core = "0.17.0"
ethers-signers = "0.17.0"
ethers-core = "2.0.7"
ethers-signers = "2.0.7"
external-tracer = { path="../external-tracer" }
glob = "0.3"
handlebars = "4.3"
Expand Down
4 changes: 2 additions & 2 deletions testool/src/statetest/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn into_traceconfig(st: StateTest) -> (String, TraceConfig, StateTestResult) {
}
let tx: TypedTransaction = tx.into();

let sig = wallet.sign_transaction_sync(&tx);
let sig = wallet.sign_transaction_sync(&tx).unwrap();

(
st.id,
Expand Down Expand Up @@ -229,7 +229,7 @@ pub fn run_test(
..eth_types::Block::default()
};

let wallet: LocalWallet = SigningKey::from_bytes(&st.secret_key).unwrap().into();
let wallet: LocalWallet = SigningKey::from_slice(&st.secret_key).unwrap().into();
let mut wallets = HashMap::new();
wallets.insert(
wallet.address(),
Expand Down
2 changes: 1 addition & 1 deletion testool/src/statetest/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<'a> JsonStateTestBuilder<'a> {

let to = parse::parse_to_address(&test.transaction.to)?;
let secret_key = parse::parse_bytes(&test.transaction.secret_key)?;
let from = secret_key_to_address(&SigningKey::from_bytes(&secret_key.to_vec())?);
let from = secret_key_to_address(&SigningKey::from_slice(&secret_key)?);
let nonce = parse::parse_u64(&test.transaction.nonce)?;
let gas_price = parse::parse_u256(&test.transaction.gas_price)?;

Expand Down
2 changes: 1 addition & 1 deletion testool/src/statetest/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl StateTest {
let value = parse_u256(tx.next().unwrap_or("0"))?;
let gas_limit = u64::from_str(tx.next().unwrap_or("10000000"))?;
let secret_key = Bytes::from(&[1u8; 32]);
let from = secret_key_to_address(&SigningKey::from_bytes(&secret_key.to_vec())?);
let from = secret_key_to_address(&SigningKey::from_slice(&secret_key)?);

let mut pre = HashMap::<Address, Account>::new();

Expand Down
2 changes: 1 addition & 1 deletion testool/src/statetest/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<'a> YamlStateTestBuilder<'a> {
let nonce = Self::parse_u64(&yaml_transaction["nonce"])?;
let to = Self::parse_to_address(&yaml_transaction["to"])?;
let secret_key = Self::parse_bytes(&yaml_transaction["secretKey"])?;
let from = secret_key_to_address(&SigningKey::from_bytes(&secret_key.to_vec())?);
let from = secret_key_to_address(&SigningKey::from_slice(&secret_key)?);

// parse expects (account states before executing the transaction)
let mut expects = Vec::new();
Expand Down
6 changes: 3 additions & 3 deletions zkevm-circuits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ array-init = "2.0.0"
bus-mapping = { path = "../bus-mapping" }
eth-types = { path = "../eth-types" }
gadgets = { path = "../gadgets" }
ethers-core = "0.17.0"
ethers-signers = { version = "0.17.0", optional = true }
ethers-core = "2.0.7"
ethers-signers = { version = "2.0.7", optional = true }
mock = { path = "../mock", optional = true }
strum = "0.24"
strum_macros = "0.24"
Expand All @@ -39,7 +39,7 @@ cli-table = { version = "0.4", optional = true }
[dev-dependencies]
bus-mapping = { path = "../bus-mapping", features = ["test"] }
ctor = "0.1.22"
ethers-signers = "0.17.0"
ethers-signers = "2.0.7"
hex = "0.4.3"
itertools = "0.10.1"
mock = { path = "../mock" }
Expand Down