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

Commit db0d403

Browse files
Upgrade rust version (#1769)
### Description We've been using the version one year ago. Let's get a new year vibe. ### Issue Link ### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [ ] Refactor (no updates to logic) ### Contents Major clippy fix - Clippy now detect useless vector. It is a little bit [buggy](rust-lang/rust-clippy#12101), and it sometimes complains without giving the exact line.
1 parent cd5edab commit db0d403

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+335
-343
lines changed

Cargo.lock

Lines changed: 127 additions & 115 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bus-mapping/src/circuit_input_builder/access.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl From<Vec<Access>> for AccessSet {
7272
for access in list {
7373
match access.value {
7474
AccessValue::Account { address } => {
75-
state.entry(address).or_insert_with(HashSet::new);
75+
state.entry(address).or_default();
7676
}
7777
AccessValue::Storage { address, key } => match state.entry(address) {
7878
Entry::Vacant(entry) => {
@@ -85,7 +85,7 @@ impl From<Vec<Access>> for AccessSet {
8585
}
8686
},
8787
AccessValue::Code { address } => {
88-
state.entry(address).or_insert_with(HashSet::new);
88+
state.entry(address).or_default();
8989
code.insert(address);
9090
}
9191
}

bus-mapping/src/circuit_input_builder/input_state_ref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ impl<'a> CircuitInputStateRef<'a> {
12251225
) -> Result<(), Error> {
12261226
let call = self.call()?.clone();
12271227
let geth_step = steps
1228-
.get(0)
1228+
.first()
12291229
.ok_or(Error::InternalError("invalid index 0"))?;
12301230
let is_revert_or_return_call_success = (geth_step.op == OpcodeId::REVERT
12311231
|| geth_step.op == OpcodeId::RETURN)
@@ -1419,7 +1419,7 @@ impl<'a> CircuitInputStateRef<'a> {
14191419

14201420
let call = self.call()?;
14211421

1422-
if matches!(next_step, None) {
1422+
if next_step.is_none() {
14231423
// enumerating call scope successful cases
14241424
// case 1: call with normal halt opcode termination
14251425
if matches!(

bus-mapping/src/precompile.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ pub(crate) fn execute_precompiled(
3636

3737
#[cfg(not(target_arch = "wasm32"))]
3838
{
39-
let Some(Precompile::Standard(precompile_fn)) = Precompiles::berlin()
40-
.get(address.as_fixed_bytes()) else {
39+
let Some(Precompile::Standard(precompile_fn)) =
40+
Precompiles::berlin().get(address.as_fixed_bytes())
41+
else {
4142
panic!("calling non-exist precompiled contract address")
4243
};
4344
let (return_data, gas_cost, is_oog, is_ok) = match precompile_fn(input, gas) {

eth-types/src/bytecode.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! EVM byte code generator
22
use crate::{evm_types::OpcodeId, keccak256, Bytes, Hash, ToBigEndian, ToWord, Word};
3-
use std::{collections::HashMap, iter, str::FromStr};
4-
3+
use std::{collections::HashMap, fmt::Display, iter, str::FromStr};
54
/// Error type for Bytecode related failures
65
#[derive(Debug)]
76
pub enum Error {
@@ -254,12 +253,13 @@ impl FromStr for OpcodeWithData {
254253
}
255254
}
256255

257-
impl ToString for OpcodeWithData {
258-
fn to_string(&self) -> String {
259-
match self {
256+
impl Display for OpcodeWithData {
257+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
258+
let str = match self {
260259
OpcodeWithData::Opcode(opcode) => format!("{:?}", opcode),
261260
OpcodeWithData::PushWithData(n, word) => format!("PUSH{}({})", n, word),
262-
}
261+
};
262+
f.write_str(&str)
263263
}
264264
}
265265

@@ -576,6 +576,6 @@ mod tests {
576576
POP
577577
STOP
578578
};
579-
assert_eq!(Bytecode::try_from(code.code()).unwrap(), code);
579+
assert_eq!(Bytecode::from(code.code()), code);
580580
}
581581
}

eth-types/src/evm_types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ mod gas_create {
3434
// [gasCreate2Eip3860](https://github.com/ethereum/go-ethereum/blob/eb83e7c54021573eaceb14236af3a7a8c64f6027/core/vm/gas_table.go#L321)
3535
// (similar for CREATE).
3636
// 1. size <= 49152 (MaxInitCodeSize)
37-
// 2. gasCost = memoryGasCost + (2 + 6) * ((size + 31) / 32) should not
38-
// overflow for Uint64.
37+
// 2. gasCost = memoryGasCost + (2 + 6) * ((size + 31) / 32) should not overflow for Uint64.
3938
// No need to constrain the second condition, since the maximum gas cost
4039
// cannot overflow for Uint64 (36028809887100925 calculated by
4140
// `memorySize = 0x1FFFFFFFE0` and `size = 49152`) if the first condition is

eth-types/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
#![deny(missing_docs)]
99
//#![deny(unsafe_code)] Allowed now until we find a
1010
// better way to handle downcasting from Operation into it's variants.
11-
#![allow(clippy::upper_case_acronyms)] // Too pedantic
11+
12+
// Too pedantic
13+
#![allow(clippy::upper_case_acronyms)]
14+
// Clippy is buggy on this one. Remove after https://github.com/rust-lang/rust-clippy/issues/12101 is resolved.
15+
#![allow(clippy::useless_vec)]
1216

1317
#[macro_use]
1418
pub mod macros;

eth-types/src/sign_types.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ pub fn ct_option_ok_or<T, E>(v: CtOption<T>, err: E) -> Result<T, E> {
135135
/// Return a copy of the serialized public key with swapped Endianness.
136136
pub fn pk_bytes_swap_endianness<T: Clone>(pk: &[T]) -> [T; 64] {
137137
assert_eq!(pk.len(), 64);
138-
let mut pk_swap = <&[T; 64]>::try_from(pk)
139-
.map(|r| r.clone())
140-
.expect("pk.len() != 64");
138+
let mut pk_swap = <&[T; 64]>::try_from(pk).cloned().expect("pk.len() != 64");
141139
pk_swap[..32].reverse();
142140
pk_swap[32..].reverse();
143141
pk_swap

geth-utils/src/mpt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub fn get_witness(block_no: u64, mods: &[TrieModification], node_url: &str) ->
8686

8787
let json = serde_json::to_string(&req).expect("Invalid request");
8888
let c_config = CString::new(json).expect("invalid config");
89-
let result = unsafe { go::GetMptWitness(c_config.as_ptr() as *const i8) };
89+
let result = unsafe { go::GetMptWitness(c_config.as_ptr()) };
9090
let c_str = unsafe { CStr::from_ptr(result) };
9191
let json = c_str
9292
.to_str()

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2023-04-24
1+
nightly-2024-02-14

0 commit comments

Comments
 (0)