Skip to content

Commit

Permalink
upgrade ethers from 0.17.0 to 2.0.7 (scroll-tech#937)
Browse files Browse the repository at this point in the history
* upgrade ethers from 0.17.0 to 2.0.7

* upgrade scroll's fork of ethers-rs

* cargo update

* fix clippy

* fmt

* enable scroll feature
  • Loading branch information
kunxian-xia authored Sep 13, 2023
1 parent 68d18f9 commit 995790c
Show file tree
Hide file tree
Showing 23 changed files with 1,365 additions and 686 deletions.
1,973 changes: 1,323 additions & 650 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ members = [
]

[patch.crates-io]
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v0.17.0" }
ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v0.17.0" }
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "develop" }
[patch."https://github.com/privacy-scaling-explorations/poseidon.git"]
Expand Down
2 changes: 1 addition & 1 deletion aggregator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ zkevm-circuits = { path = "../zkevm-circuits" }

ark-std = "0.3.0"
env_logger = "0.10.0"
ethers-core = "0.17.0"
ethers-core = { version = "2.0.7", features = ["scroll"] }
hex = "0.4.3"
log = "0.4"
itertools = "0.10.3"
Expand Down
6 changes: 3 additions & 3 deletions bus-mapping/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ keccak256 = { path = "../keccak256" }
mpt-zktrie = {path = "../zktrie"}
mock = { path = "../mock", optional = true }

ethers-core = "0.17.0"
ethers-signers = "0.17.0"
ethers-providers = "0.17.0"
ethers-core = { version = "2.0.7", features = ["scroll"] }
ethers-signers = "2.0.7"
ethers-providers = "2.0.7"
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", tag = "v2023_02_02" }
poseidon-circuit = { git = "https://github.com/scroll-tech/poseidon-circuit.git", branch = "scroll-dev-0901"}
itertools = "0.10"
Expand Down
3 changes: 1 addition & 2 deletions bus-mapping/src/circuit_input_builder/input_state_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,7 @@ impl<'a> CircuitInputStateRef<'a> {
let salt = step.stack.nth_last(3)?;
let call_ctx = self.call_ctx()?;
let init_code = get_create_init_code(call_ctx, step)?.to_vec();
let address =
get_create2_address(self.call()?.address, salt.to_be_bytes().to_vec(), init_code);
let address = get_create2_address(self.call()?.address, salt.to_be_bytes(), init_code);
log::trace!(
"create2_address {:?}, from {:?}, salt {:?}",
address,
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 @@ -302,7 +302,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
4 changes: 2 additions & 2 deletions bus-mapping/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ impl BlockData {
}

for account in geth_data.accounts {
let keccak_code_hash = H256(keccak256(account.code.to_vec()));
let keccak_code_hash = H256(keccak256(&account.code));
log::trace!(
"trace code {:?} {:?}",
keccak_code_hash,
hex::encode(account.code.to_vec())
hex::encode(&account.code)
);
let code_hash = code_db.insert(account.code.to_vec());
sdb.set_account(
Expand Down
4 changes: 2 additions & 2 deletions circuit-benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ eth-types = { path = "../eth-types" }
env_logger = "0.9"
log="0.4"
tokio = { version = "1.13", features = ["macros", "rt-multi-thread"] }
ethers-signers = "0.17.0"
ethers = { version = "0.17.0", features = ["ethers-solc"] }
ethers-signers = "2.0.7"
ethers = { version = "2.0.7", features = ["ethers-solc"] }
mock = { path="../mock" }
rand_chacha = "0.3"
url="2.2.2"
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 = { version = "2.0.7", features = ["scroll"] }
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_02_02" }
Expand Down
6 changes: 4 additions & 2 deletions eth-types/src/sign_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn get_dummy_tx() -> (TransactionRequest, Signature) {
let mut sk_be_scalar = [0u8; 32];
sk_be_scalar[31] = 1_u8;

let sk = SigningKey::from_bytes(&sk_be_scalar).expect("sign key = 1");
let sk = SigningKey::from_bytes((&sk_be_scalar).into()).expect("sign key = 1");
let wallet = ethers_signers::Wallet::from(sk);

let tx = TransactionRequest::new()
Expand All @@ -85,7 +85,9 @@ pub fn get_dummy_tx() -> (TransactionRequest, Signature) {
.data(Bytes::default());
let sighash: H256 = keccak256(tx.rlp_unsigned()).into();

let sig = wallet.sign_hash(sighash);
let sig = wallet
.sign_hash(sighash)
.expect("sign dummy tx using dummy sk");
assert_eq!(sig.v, 28);
assert_eq!(
sig.r,
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
4 changes: 2 additions & 2 deletions mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ 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 = { version = "2.0.7", features = ["scroll"] }
rand_chacha = "0.3"
rand = "0.8"
log = "0.4"
Expand Down
4 changes: 4 additions & 0 deletions mock/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ impl From<MockBlock> for Block<Transaction> {
nonce: Some(mock.nonce),
base_fee_per_gas: Some(mock.base_fee_per_gas),
other: OtherFields::default(),
withdrawals: None,
withdrawals_root: None,
}
}
}
Expand Down Expand Up @@ -137,6 +139,8 @@ impl From<MockBlock> for Block<()> {
nonce: Some(mock.nonce),
base_fee_per_gas: Some(mock.base_fee_per_gas),
other: OtherFields::default(),
withdrawals: None,
withdrawals_root: 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 @@ -355,7 +355,8 @@ impl MockTransaction {
.from
.as_wallet()
.with_chain_id(self.chain_id)
.sign_transaction_sync(&tx.into());
.sign_transaction_sync(&tx.into())
.expect("sign mock tx");
// Set sig parameters
self.sig_data((sig.v, sig.r, sig.s));
}
Expand Down
2 changes: 1 addition & 1 deletion prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ base64 = "0.13.0"
blake2 = "0.10.3"
chrono = "0.4.19"
dotenvy = "0.15.7"
ethers-core = "0.17.0"
ethers-core = { version = "2.0.7", features = ["scroll"] }
git-version = "0.3.5"
hex = "0.4.3"
itertools = "0.10.5"
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 = { version = "2.0.7", features = ["scroll"] }
ethers-signers = "2.0.7"
external-tracer = { path="../external-tracer" }
glob = "0.3"
handlebars = "4.3"
Expand Down
8 changes: 4 additions & 4 deletions testool/src/statetest/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn into_traceconfig(st: StateTest) -> (String, TraceConfig, StateTestResult) {
let rlp_unsigned = tx.rlp().to_vec();
let tx: TypedTransaction = tx.into();

let sig = wallet.sign_transaction_sync(&tx);
let sig = wallet.sign_transaction_sync(&tx).unwrap();
let rlp_signed = tx.rlp_signed(&sig).to_vec();
let tx_hash = keccak256(tx.rlp_signed(&sig));
let accounts = st.pre;
Expand Down Expand Up @@ -448,7 +448,7 @@ fn trace_config_to_witness_block_l1(
..eth_types::Block::default()
};

let wallet: LocalWallet = ethers_core::k256::ecdsa::SigningKey::from_bytes(&st.secret_key)
let wallet: LocalWallet = ethers_core::k256::ecdsa::SigningKey::from_slice(&st.secret_key)
.unwrap()
.into();
let mut wallets = HashMap::new();
Expand Down Expand Up @@ -739,8 +739,8 @@ pub fn run_test(
let (exist, acc_in_local_sdb) = builder.sdb.get_account_mut(&account.address);
if !exist {
// modified from bus-mapping/src/mock.rs
let keccak_code_hash = H256(keccak256(account.code.to_vec()));
let code_hash = CodeDB::hash(&account.code.to_vec());
let keccak_code_hash = H256(keccak256(&account.code));
let code_hash = CodeDB::hash(&account.code);
*acc_in_local_sdb = bus_mapping::state_db::Account {
nonce: account.nonce,
balance: account.balance,
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 @@ -122,7 +122,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_u256(&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 @@ -208,7 +208,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 = BTreeMap::<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 @@ -113,7 +113,7 @@ impl<'a> YamlStateTestBuilder<'a> {
let nonce = Self::parse_u256(&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 @@ -16,8 +16,8 @@ bus-mapping = { path = "../bus-mapping" }
either = "1.9"
eth-types = { path = "../eth-types" }
gadgets = { path = "../gadgets" }
ethers-core = "0.17.0"
ethers-signers = { version = "0.17.0", optional = true }
ethers-core = { version = "2.0.7", features = ["scroll"] }
ethers-signers = { version = "2.0.7", optional = true }
mock = { path = "../mock", optional = true }
strum = "0.24"
strum_macros = "0.24"
Expand Down Expand Up @@ -54,7 +54,7 @@ once_cell = "1.17.0"
bus-mapping = { path = "../bus-mapping", features = ["test"] }
criterion = "0.3"
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
2 changes: 1 addition & 1 deletion zkevm-circuits/src/rlp_circuit_fsm/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn get_tx(is_eip155: bool) -> Transaction {
(TxType::PreEip155, tx.rlp_unsigned().to_vec())
};
let typed_tx: TypedTransaction = tx.into();
let sig = from.sign_transaction_sync(&typed_tx);
let sig = from.sign_transaction_sync(&typed_tx).unwrap();
let signed_bytes = typed_tx.rlp_signed(&sig).to_vec();

log::debug!("num_unsigned_bytes: {}", unsigned_bytes.len());
Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/src/witness/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ mod tests {
Fr::from(eth_tx.gas.as_u64()),
eth_tx.to.unwrap().to_scalar().unwrap(),
rlc(&eth_tx.value.to_be_bytes(), evm_word),
rlc(&eth_tx.input.to_vec(), keccak_input),
rlc(&eth_tx.input, keccak_input),
];
if let Some(access_list) = eth_tx.access_list {
for item in access_list.0.iter() {
Expand Down

0 comments on commit 995790c

Please sign in to comment.