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

build: upgrade Rust to v1.83 #789

Merged
merged 2 commits into from
Feb 5, 2025
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 changes: 1 addition & 1 deletion crates/edr_eth/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<'a> serde::Deserialize<'a> for SubscriptionType {
D: serde::Deserializer<'a>,
{
struct SubscriptionTypeVisitor;
impl<'a> serde::de::Visitor<'a> for SubscriptionTypeVisitor {
impl serde::de::Visitor<'_> for SubscriptionTypeVisitor {
type Value = SubscriptionType;

fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Expand Down
4 changes: 2 additions & 2 deletions crates/edr_eth/src/transaction/pooled/eip4844.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl Eip4844 {
#[repr(transparent)]
struct RlpBlob<'blob>(&'blob Blob);

impl<'blob> alloy_rlp::Encodable for RlpBlob<'blob> {
impl alloy_rlp::Encodable for RlpBlob<'_> {
fn encode(&self, out: &mut dyn alloy_rlp::BufMut) {
self.0.as_ref().encode(out);
}
Expand All @@ -192,7 +192,7 @@ impl<'blob> From<&'blob Blob> for RlpBlob<'blob> {
#[repr(transparent)]
struct RlpBytes48<'bytes>(&'bytes Bytes48);

impl<'bytes> alloy_rlp::Encodable for RlpBytes48<'bytes> {
impl alloy_rlp::Encodable for RlpBytes48<'_> {
fn encode(&self, out: &mut dyn alloy_rlp::BufMut) {
self.0.as_ref().encode(out);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_evm/src/blockchain/storage/contiguous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{chain_spec::ChainSpec, Block, LocalBlock};
#[derive(Clone, Default, Debug)]
pub struct ContiguousBlockchainStorage<BlockT, ChainSpecT>
where
BlockT: Block<ChainSpecT> + Clone + ?Sized,
BlockT: Block<ChainSpecT> + Clone,
ChainSpecT: ChainSpec,
{
blocks: Vec<BlockT>,
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_evm/src/blockchain/storage/reservable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct Reservation {
#[derive(Debug)]
pub struct ReservableSparseBlockchainStorage<BlockT, ChainSpecT>
where
BlockT: Block<ChainSpecT> + Clone + ?Sized,
BlockT: Block<ChainSpecT> + Clone,
ChainSpecT: ChainSpec,
{
reservations: RwLock<Vec<Reservation>>,
Expand Down
4 changes: 2 additions & 2 deletions crates/edr_evm/src/blockchain/storage/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{chain_spec::ChainSpec, hash_map::OccupiedError, Block};
#[derive(Debug)]
pub struct SparseBlockchainStorage<BlockT, ChainSpecT>
where
BlockT: Block<ChainSpecT> + Clone + ?Sized,
BlockT: Block<ChainSpecT> + Clone,
ChainSpecT: ChainSpec,
{
hash_to_block: HashMap<B256, BlockT>,
Expand All @@ -28,7 +28,7 @@ where

impl<BlockT, ChainSpecT> SparseBlockchainStorage<BlockT, ChainSpecT>
where
BlockT: Block<ChainSpecT> + Clone + ?Sized,
BlockT: Block<ChainSpecT> + Clone,
ChainSpecT: ChainSpec,
{
/// Constructs a new instance with the provided block.
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_evm/src/state/overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl<'overrides, StateT> StateRefOverrider<'overrides, StateT> {
}
}

impl<'state, StateT: StateRef> StateRef for StateRefOverrider<'state, StateT> {
impl<StateT: StateRef> StateRef for StateRefOverrider<'_, StateT> {
type Error = StateT::Error;

fn basic(&self, address: Address) -> Result<Option<AccountInfo>, Self::Error> {
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_evm/src/state/trie/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ struct AccountTrieMutation<'a> {
storage_tries: &'a mut StorageTries,
}

impl<'a> AccountTrieMutation<'a> {
impl AccountTrieMutation<'_> {
#[cfg_attr(feature = "tracing", tracing::instrument(skip(self)))]
pub fn init_account(&mut self, address: &Address, account_info: &AccountInfo) {
let storage_trie = StorageTrie::default();
Expand Down
4 changes: 2 additions & 2 deletions crates/edr_evm/src/state/trie/state_trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub(super) struct StateTrieMutation<'a> {
trie_query: TrieQuery,
}

impl<'a> StateTrieMutation<'a> {
impl StateTrieMutation<'_> {
pub fn account(&self, address: &Address) -> Option<BasicAccount> {
self.state_trie.account(address)
}
Expand All @@ -90,7 +90,7 @@ impl<'a> StateTrieMutation<'a> {
}
}

impl<'a> Drop for StateTrieMutation<'a> {
impl Drop for StateTrieMutation<'_> {
fn drop(&mut self) {
self.state_trie.root = self.trie_query.root();
}
Expand Down
4 changes: 2 additions & 2 deletions crates/edr_evm/src/state/trie/storage_trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub(super) struct StorageTrieMutation<'a> {
trie_query: TrieQuery,
}

impl<'a> StorageTrieMutation<'a> {
impl StorageTrieMutation<'_> {
#[cfg_attr(feature = "tracing", tracing::instrument(skip(self)))]
pub fn set_storage_slots(&mut self, storage: &revm::primitives::EvmStorage) {
storage.iter().for_each(|(index, value)| {
Expand Down Expand Up @@ -103,7 +103,7 @@ impl<'a> StorageTrieMutation<'a> {
}
}

impl<'a> Drop for StorageTrieMutation<'a> {
impl Drop for StorageTrieMutation<'_> {
fn drop(&mut self) {
self.storage_trie.root = self.trie_query.root();
}
Expand Down
22 changes: 9 additions & 13 deletions crates/edr_provider/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1551,24 +1551,22 @@ impl<LoggerErrorT: Debug, TimerT: Clone + TimeSinceEpoch> ProviderData<LoggerErr
None
};

let transaction_hash = self.add_pending_transaction(transaction).map_err(|error| {
if let Some(snapshot_id) = snapshot_id {
self.revert_to_snapshot(snapshot_id);
}

error
})?;
let transaction_hash = self
.add_pending_transaction(transaction)
.inspect_err(|_error| {
if let Some(snapshot_id) = snapshot_id {
self.revert_to_snapshot(snapshot_id);
}
})?;

let mut mining_results = Vec::new();
snapshot_id
.map(|snapshot_id| -> Result<(), ProviderError<LoggerErrorT>> {
loop {
let result = self
.mine_and_commit_block(BlockOptions::default())
.map_err(|error| {
.inspect_err(|_error| {
self.revert_to_snapshot(snapshot_id);

error
})?;

let mined_transaction = result.has_transaction(&transaction_hash);
Expand All @@ -1583,10 +1581,8 @@ impl<LoggerErrorT: Debug, TimerT: Clone + TimeSinceEpoch> ProviderData<LoggerErr
while self.mem_pool.has_pending_transactions() {
let result = self
.mine_and_commit_block(BlockOptions::default())
.map_err(|error| {
.inspect_err(|_error| {
self.revert_to_snapshot(snapshot_id);

error
})?;

mining_results.push(result);
Expand Down
4 changes: 2 additions & 2 deletions crates/edr_provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ impl<LoggerErrorT: Debug + Send + Sync + 'static, TimerT: Clone + TimeSinceEpoch
) => hardhat::handle_add_compilation_result(
data,
solc_version,
compiler_input,
compiler_output,
*compiler_input,
*compiler_output,
)
.and_then(to_json),
MethodInvocation::DropTransaction(transaction_hash) => {
Expand Down
6 changes: 3 additions & 3 deletions crates/edr_provider/src/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'blockchain> BlockchainWithPending<'blockchain> {
}
}

impl<'blockchain> Blockchain<L1ChainSpec> for BlockchainWithPending<'blockchain> {
impl Blockchain<L1ChainSpec> for BlockchainWithPending<'_> {
type BlockchainError = BlockchainError;

type StateError = StateError;
Expand Down Expand Up @@ -194,7 +194,7 @@ impl<'blockchain> Blockchain<L1ChainSpec> for BlockchainWithPending<'blockchain>
}
}

impl<'blockchain> BlockchainMut<L1ChainSpec> for BlockchainWithPending<'blockchain> {
impl BlockchainMut<L1ChainSpec> for BlockchainWithPending<'_> {
type Error = BlockchainError;

fn insert_block(
Expand All @@ -214,7 +214,7 @@ impl<'blockchain> BlockchainMut<L1ChainSpec> for BlockchainWithPending<'blockcha
}
}

impl<'blockchain> BlockHashRef for BlockchainWithPending<'blockchain> {
impl BlockHashRef for BlockchainWithPending<'_> {
type Error = BlockchainError;

fn block_hash(&self, number: u64) -> Result<B256, Self::Error> {
Expand Down
4 changes: 2 additions & 2 deletions crates/edr_provider/src/requests/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ pub enum MethodInvocation {
AddCompilationResult(
/// solc version:
String,
CompilerInput,
CompilerOutput,
Box<CompilerInput>,
Box<CompilerOutput>,
),
/// `hardhat_dropTransaction`
#[serde(rename = "hardhat_dropTransaction", with = "edr_eth::serde::sequence")]
Expand Down
5 changes: 4 additions & 1 deletion crates/edr_provider/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use edr_evm::{
};
use edr_rpc_eth::client::EthRpcClient;

use super::*;
use super::{
AccountConfig, Arc, Debug, MethodInvocation, Provider, ProviderConfig, ProviderData,
ProviderError, ProviderRequest, TimeSinceEpoch,
};
use crate::{config::MiningConfig, requests::hardhat::rpc_types::ForkConfig};

pub const TEST_SECRET_KEY: &str =
Expand Down
8 changes: 4 additions & 4 deletions crates/edr_provider/tests/hardhat_request_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ fn serde_hardhat_compiler() {

let call = MethodInvocation::AddCompilationResult(
String::from("0.8.0"),
serde_json::from_str::<CompilerInput>(compiler_input_json).unwrap(),
serde_json::from_str::<CompilerOutput>(compiler_output_json).unwrap(),
serde_json::from_str::<Box<CompilerInput>>(compiler_input_json).unwrap(),
serde_json::from_str::<Box<CompilerOutput>>(compiler_output_json).unwrap(),
);

help_test_method_invocation_serde(call.clone());
Expand All @@ -29,14 +29,14 @@ fn serde_hardhat_compiler() {
assert_eq!(
serde_json::to_value(input).unwrap(),
serde_json::to_value(
serde_json::from_str::<CompilerInput>(compiler_input_json).unwrap()
serde_json::from_str::<Box<CompilerInput>>(compiler_input_json).unwrap()
)
.unwrap(),
);
assert_eq!(
serde_json::to_value(output).unwrap(),
serde_json::to_value(
serde_json::from_str::<CompilerOutput>(compiler_output_json).unwrap()
serde_json::from_str::<Box<CompilerOutput>>(compiler_output_json).unwrap()
)
.unwrap(),
);
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_rpc_client/src/cache/block_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum CacheableBlockSpec<'a> {
Finalized,
}

impl<'a> CacheKeyVariant for CacheableBlockSpec<'a> {
impl CacheKeyVariant for CacheableBlockSpec<'_> {
fn cache_key_variant(&self) -> u8 {
match self {
CacheableBlockSpec::Number { .. } => 0,
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_rpc_client/src/cache/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub enum CacheableLogFilterRange<'a> {
},
}

impl<'a> CacheKeyVariant for CacheableLogFilterRange<'a> {
impl CacheKeyVariant for CacheableLogFilterRange<'_> {
fn cache_key_variant(&self) -> u8 {
match self {
CacheableLogFilterRange::Hash(_) => 0,
Expand Down
10 changes: 5 additions & 5 deletions crates/edr_rpc_client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub enum RpcClientError {
#[error("{error}. Request: {request}")]
JsonRpcError {
/// The JSON-RPC error
error: jsonrpc::Error,
error: Box<jsonrpc::Error>,
/// The request JSON
request: String,
},
Expand Down Expand Up @@ -239,7 +239,7 @@ impl<MethodT: RpcMethod + Serialize> RpcClient<MethodT> {
};

result.map_err(|error| RpcClientError::JsonRpcError {
error,
error: Box::new(error),
request: request.to_json_string(),
})
}
Expand Down Expand Up @@ -708,7 +708,7 @@ mod tests {
NetVersion,
}

impl<'method> CachedTestMethod<'method> {
impl CachedTestMethod<'_> {
fn key_hasher(&self) -> Result<cache::KeyHasher, UnresolvedBlockTagError> {
let hasher = KeyHasher::default().hash_u8(self.cache_key_variant());

Expand Down Expand Up @@ -770,7 +770,7 @@ mod tests {
}
}

impl<'method> CacheKeyVariant for CachedTestMethod<'method> {
impl CacheKeyVariant for CachedTestMethod<'_> {
fn cache_key_variant(&self) -> u8 {
match self {
Self::GetBlockByNumber { .. } => 0,
Expand All @@ -779,7 +779,7 @@ mod tests {
}
}

impl<'method> CacheableMethod for CachedTestMethod<'method> {
impl CacheableMethod for CachedTestMethod<'_> {
type MethodWithResolvableBlockTag = TestMethodWithResolvableBlockSpec;

fn resolve_block_tag(
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_rpc_client/src/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'a> Deserialize<'a> for Version {

struct VersionVisitor;

impl<'a> serde::de::Visitor<'a> for VersionVisitor {
impl serde::de::Visitor<'_> for VersionVisitor {
type Value = Version;

fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Expand Down
6 changes: 3 additions & 3 deletions crates/edr_rpc_eth/src/cacheable_method_invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub enum CachedRequestMethod<'a> {
NetVersion,
}

impl<'a> CachedRequestMethod<'a> {
impl CachedRequestMethod<'_> {
// Allow to keep same structure as other RequestMethod and other methods.
#[allow(clippy::match_same_arms)]
fn key_hasher(&self) -> Result<cache::KeyHasher, UnresolvedBlockTagError> {
Expand Down Expand Up @@ -266,7 +266,7 @@ impl RpcMethod for RequestMethod {
}
}

impl<'method> CacheableMethod for CachedRequestMethod<'method> {
impl CacheableMethod for CachedRequestMethod<'_> {
type MethodWithResolvableBlockTag = MethodWithResolvableBlockSpec;

fn resolve_block_tag(method: Self::MethodWithResolvableBlockTag, block_number: u64) -> Self {
Expand Down Expand Up @@ -337,7 +337,7 @@ impl<'method> CacheableMethod for CachedRequestMethod<'method> {
}
}

impl<'a> CacheKeyVariant for CachedRequestMethod<'a> {
impl CacheKeyVariant for CachedRequestMethod<'_> {
fn cache_key_variant(&self) -> u8 {
match self {
// The commented out methods have been removed as they're not currently in use by the
Expand Down
12 changes: 8 additions & 4 deletions crates/edr_solidity/benches/contracts_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
//! Steps to run:
//! 1. Check out <https://github.com/NomicFoundation/forge-std/tree/js-benchmark-config>
//! locally (note the branch).
//!
//! 2. In the `forge-std` repo root:
//! 2.1. `npm i`
//! 2.2. `npx hardhat compile`
//!
//! 2.1. `npm i`
//! 2.2. `npx hardhat compile`
//!
//! 3. In the `crates/edr_solidity` directory:
//! 3.1. `export EDR_FORGE_STD_ARTIFACTS_DIR=/path/to/forge-std/artifacts`
//! 3.2. `cargo bench contracts_identifier`
//!
//! 3.1. `export EDR_FORGE_STD_ARTIFACTS_DIR=/path/to/forge-std/artifacts`
//! 3.2. `cargo bench contracts_identifier`
use std::{fs, path::PathBuf, time::Duration};

use criterion::{black_box, criterion_group, criterion_main, Criterion};
Expand Down
7 changes: 3 additions & 4 deletions crates/edr_solidity/src/compiler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Processes the Solidity compiler standard JSON[^1] input and output AST and
//! creates the source model used to perform the stack trace decoding.

//!
//! [^1]: See <https://docs.soliditylang.org/en/latest/using-the-compiler.html#compiler-input-and-output-json-description>.
use std::{collections::HashMap, str::FromStr, sync::Arc};

use anyhow::{self, Context as _};
Expand All @@ -23,12 +24,10 @@ use crate::{
pub const FIRST_SOLC_VERSION_SUPPORTED: semver::Version = semver::Version::new(0, 5, 1);

/// For the Solidity compiler version and its standard JSON input and
/// output[^1], creates the source model, decodes the bytecode with source
/// output, creates the source model, decodes the bytecode with source
/// mapping and links them to the source files.
///
/// Returns the decoded bytecodes that reference the resolved source model.
///
/// [^1]: See <https://docs.soliditylang.org/en/latest/using-the-compiler.html#compiler-input-and-output-json-description>.
pub fn create_models_and_decode_bytecodes(
solc_version: String,
compiler_input: &CompilerInput,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.79
1.83