From ddb12eb976ae7409e41ee25ee41f5ec8636b3472 Mon Sep 17 00:00:00 2001 From: Wodann Date: Wed, 5 Feb 2025 19:17:54 +0000 Subject: [PATCH 1/2] build: upgrade Rust to v1.81 --- .../src/blockchain/storage/contiguous.rs | 2 +- .../src/blockchain/storage/reservable.rs | 2 +- .../edr_evm/src/blockchain/storage/sparse.rs | 4 ++-- crates/edr_provider/src/data.rs | 22 ++++++++----------- crates/edr_provider/src/test_utils.rs | 5 ++++- .../benches/contracts_identifier.rs | 12 ++++++---- rust-toolchain | 2 +- 7 files changed, 26 insertions(+), 23 deletions(-) diff --git a/crates/edr_evm/src/blockchain/storage/contiguous.rs b/crates/edr_evm/src/blockchain/storage/contiguous.rs index b6f7830e30..bfc0bfc8f8 100644 --- a/crates/edr_evm/src/blockchain/storage/contiguous.rs +++ b/crates/edr_evm/src/blockchain/storage/contiguous.rs @@ -18,7 +18,7 @@ use crate::{chain_spec::ChainSpec, Block, LocalBlock}; #[derive(Clone, Default, Debug)] pub struct ContiguousBlockchainStorage where - BlockT: Block + Clone + ?Sized, + BlockT: Block + Clone, ChainSpecT: ChainSpec, { blocks: Vec, diff --git a/crates/edr_evm/src/blockchain/storage/reservable.rs b/crates/edr_evm/src/blockchain/storage/reservable.rs index 185311e2a4..81c2445cac 100644 --- a/crates/edr_evm/src/blockchain/storage/reservable.rs +++ b/crates/edr_evm/src/blockchain/storage/reservable.rs @@ -26,7 +26,7 @@ struct Reservation { #[derive(Debug)] pub struct ReservableSparseBlockchainStorage where - BlockT: Block + Clone + ?Sized, + BlockT: Block + Clone, ChainSpecT: ChainSpec, { reservations: RwLock>, diff --git a/crates/edr_evm/src/blockchain/storage/sparse.rs b/crates/edr_evm/src/blockchain/storage/sparse.rs index 5e3b624ac2..dce52f2651 100644 --- a/crates/edr_evm/src/blockchain/storage/sparse.rs +++ b/crates/edr_evm/src/blockchain/storage/sparse.rs @@ -15,7 +15,7 @@ use crate::{chain_spec::ChainSpec, hash_map::OccupiedError, Block}; #[derive(Debug)] pub struct SparseBlockchainStorage where - BlockT: Block + Clone + ?Sized, + BlockT: Block + Clone, ChainSpecT: ChainSpec, { hash_to_block: HashMap, @@ -28,7 +28,7 @@ where impl SparseBlockchainStorage where - BlockT: Block + Clone + ?Sized, + BlockT: Block + Clone, ChainSpecT: ChainSpec, { /// Constructs a new instance with the provided block. diff --git a/crates/edr_provider/src/data.rs b/crates/edr_provider/src/data.rs index ac1432587c..e3a6451e90 100644 --- a/crates/edr_provider/src/data.rs +++ b/crates/edr_provider/src/data.rs @@ -1551,13 +1551,13 @@ impl ProviderData ProviderData ProviderData //! 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}; diff --git a/rust-toolchain b/rust-toolchain index 17420a571f..ea3769f296 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.79 +1.81 From ece2e6133c07cb9a275a0e75844a014b7799bb33 Mon Sep 17 00:00:00 2001 From: Wodann Date: Wed, 5 Feb 2025 20:23:14 +0000 Subject: [PATCH 2/2] build: upgrade to Rust v1.83 --- crates/edr_eth/src/filter.rs | 2 +- crates/edr_eth/src/transaction/pooled/eip4844.rs | 4 ++-- crates/edr_evm/src/state/overrides.rs | 2 +- crates/edr_evm/src/state/trie/account.rs | 2 +- crates/edr_evm/src/state/trie/state_trie.rs | 4 ++-- crates/edr_evm/src/state/trie/storage_trie.rs | 4 ++-- crates/edr_provider/src/lib.rs | 4 ++-- crates/edr_provider/src/pending.rs | 6 +++--- crates/edr_provider/src/requests/methods.rs | 4 ++-- .../tests/hardhat_request_serialization.rs | 8 ++++---- crates/edr_rpc_client/src/cache/block_spec.rs | 2 +- crates/edr_rpc_client/src/cache/filter.rs | 2 +- crates/edr_rpc_client/src/client.rs | 10 +++++----- crates/edr_rpc_client/src/jsonrpc.rs | 2 +- crates/edr_rpc_eth/src/cacheable_method_invocation.rs | 6 +++--- crates/edr_solidity/src/compiler.rs | 7 +++---- rust-toolchain | 2 +- 17 files changed, 35 insertions(+), 36 deletions(-) diff --git a/crates/edr_eth/src/filter.rs b/crates/edr_eth/src/filter.rs index d49fb32dc3..28f81ac4e0 100644 --- a/crates/edr_eth/src/filter.rs +++ b/crates/edr_eth/src/filter.rs @@ -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 { diff --git a/crates/edr_eth/src/transaction/pooled/eip4844.rs b/crates/edr_eth/src/transaction/pooled/eip4844.rs index e2a781a910..4a9d2348a5 100644 --- a/crates/edr_eth/src/transaction/pooled/eip4844.rs +++ b/crates/edr_eth/src/transaction/pooled/eip4844.rs @@ -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); } @@ -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); } diff --git a/crates/edr_evm/src/state/overrides.rs b/crates/edr_evm/src/state/overrides.rs index eccb821d23..c43dc24dc3 100644 --- a/crates/edr_evm/src/state/overrides.rs +++ b/crates/edr_evm/src/state/overrides.rs @@ -261,7 +261,7 @@ impl<'overrides, StateT> StateRefOverrider<'overrides, StateT> { } } -impl<'state, StateT: StateRef> StateRef for StateRefOverrider<'state, StateT> { +impl StateRef for StateRefOverrider<'_, StateT> { type Error = StateT::Error; fn basic(&self, address: Address) -> Result, Self::Error> { diff --git a/crates/edr_evm/src/state/trie/account.rs b/crates/edr_evm/src/state/trie/account.rs index df5e3a70a5..8321cba607 100644 --- a/crates/edr_evm/src/state/trie/account.rs +++ b/crates/edr_evm/src/state/trie/account.rs @@ -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(); diff --git a/crates/edr_evm/src/state/trie/state_trie.rs b/crates/edr_evm/src/state/trie/state_trie.rs index e0210e5ebf..4dd75225fb 100644 --- a/crates/edr_evm/src/state/trie/state_trie.rs +++ b/crates/edr_evm/src/state/trie/state_trie.rs @@ -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 { self.state_trie.account(address) } @@ -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(); } diff --git a/crates/edr_evm/src/state/trie/storage_trie.rs b/crates/edr_evm/src/state/trie/storage_trie.rs index cdd90d67c2..9421070fa7 100644 --- a/crates/edr_evm/src/state/trie/storage_trie.rs +++ b/crates/edr_evm/src/state/trie/storage_trie.rs @@ -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)| { @@ -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(); } diff --git a/crates/edr_provider/src/lib.rs b/crates/edr_provider/src/lib.rs index ad254882ee..ce2ac30710 100644 --- a/crates/edr_provider/src/lib.rs +++ b/crates/edr_provider/src/lib.rs @@ -395,8 +395,8 @@ impl hardhat::handle_add_compilation_result( data, solc_version, - compiler_input, - compiler_output, + *compiler_input, + *compiler_output, ) .and_then(to_json), MethodInvocation::DropTransaction(transaction_hash) => { diff --git a/crates/edr_provider/src/pending.rs b/crates/edr_provider/src/pending.rs index f7cfd420d9..4268626974 100644 --- a/crates/edr_provider/src/pending.rs +++ b/crates/edr_provider/src/pending.rs @@ -42,7 +42,7 @@ impl<'blockchain> BlockchainWithPending<'blockchain> { } } -impl<'blockchain> Blockchain for BlockchainWithPending<'blockchain> { +impl Blockchain for BlockchainWithPending<'_> { type BlockchainError = BlockchainError; type StateError = StateError; @@ -194,7 +194,7 @@ impl<'blockchain> Blockchain for BlockchainWithPending<'blockchain> } } -impl<'blockchain> BlockchainMut for BlockchainWithPending<'blockchain> { +impl BlockchainMut for BlockchainWithPending<'_> { type Error = BlockchainError; fn insert_block( @@ -214,7 +214,7 @@ impl<'blockchain> BlockchainMut for BlockchainWithPending<'blockcha } } -impl<'blockchain> BlockHashRef for BlockchainWithPending<'blockchain> { +impl BlockHashRef for BlockchainWithPending<'_> { type Error = BlockchainError; fn block_hash(&self, number: u64) -> Result { diff --git a/crates/edr_provider/src/requests/methods.rs b/crates/edr_provider/src/requests/methods.rs index 8409bc318b..8181045b75 100644 --- a/crates/edr_provider/src/requests/methods.rs +++ b/crates/edr_provider/src/requests/methods.rs @@ -300,8 +300,8 @@ pub enum MethodInvocation { AddCompilationResult( /// solc version: String, - CompilerInput, - CompilerOutput, + Box, + Box, ), /// `hardhat_dropTransaction` #[serde(rename = "hardhat_dropTransaction", with = "edr_eth::serde::sequence")] diff --git a/crates/edr_provider/tests/hardhat_request_serialization.rs b/crates/edr_provider/tests/hardhat_request_serialization.rs index 8eaba126cf..fdc9e6c664 100644 --- a/crates/edr_provider/tests/hardhat_request_serialization.rs +++ b/crates/edr_provider/tests/hardhat_request_serialization.rs @@ -18,8 +18,8 @@ fn serde_hardhat_compiler() { let call = MethodInvocation::AddCompilationResult( String::from("0.8.0"), - serde_json::from_str::(compiler_input_json).unwrap(), - serde_json::from_str::(compiler_output_json).unwrap(), + serde_json::from_str::>(compiler_input_json).unwrap(), + serde_json::from_str::>(compiler_output_json).unwrap(), ); help_test_method_invocation_serde(call.clone()); @@ -29,14 +29,14 @@ fn serde_hardhat_compiler() { assert_eq!( serde_json::to_value(input).unwrap(), serde_json::to_value( - serde_json::from_str::(compiler_input_json).unwrap() + serde_json::from_str::>(compiler_input_json).unwrap() ) .unwrap(), ); assert_eq!( serde_json::to_value(output).unwrap(), serde_json::to_value( - serde_json::from_str::(compiler_output_json).unwrap() + serde_json::from_str::>(compiler_output_json).unwrap() ) .unwrap(), ); diff --git a/crates/edr_rpc_client/src/cache/block_spec.rs b/crates/edr_rpc_client/src/cache/block_spec.rs index fb47e2de69..2c7a602dfb 100644 --- a/crates/edr_rpc_client/src/cache/block_spec.rs +++ b/crates/edr_rpc_client/src/cache/block_spec.rs @@ -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, diff --git a/crates/edr_rpc_client/src/cache/filter.rs b/crates/edr_rpc_client/src/cache/filter.rs index 969e0d0d18..3f10b494fe 100644 --- a/crates/edr_rpc_client/src/cache/filter.rs +++ b/crates/edr_rpc_client/src/cache/filter.rs @@ -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, diff --git a/crates/edr_rpc_client/src/client.rs b/crates/edr_rpc_client/src/client.rs index 178d48cf8b..b3602ecced 100644 --- a/crates/edr_rpc_client/src/client.rs +++ b/crates/edr_rpc_client/src/client.rs @@ -92,7 +92,7 @@ pub enum RpcClientError { #[error("{error}. Request: {request}")] JsonRpcError { /// The JSON-RPC error - error: jsonrpc::Error, + error: Box, /// The request JSON request: String, }, @@ -239,7 +239,7 @@ impl RpcClient { }; result.map_err(|error| RpcClientError::JsonRpcError { - error, + error: Box::new(error), request: request.to_json_string(), }) } @@ -708,7 +708,7 @@ mod tests { NetVersion, } - impl<'method> CachedTestMethod<'method> { + impl CachedTestMethod<'_> { fn key_hasher(&self) -> Result { let hasher = KeyHasher::default().hash_u8(self.cache_key_variant()); @@ -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, @@ -779,7 +779,7 @@ mod tests { } } - impl<'method> CacheableMethod for CachedTestMethod<'method> { + impl CacheableMethod for CachedTestMethod<'_> { type MethodWithResolvableBlockTag = TestMethodWithResolvableBlockSpec; fn resolve_block_tag( diff --git a/crates/edr_rpc_client/src/jsonrpc.rs b/crates/edr_rpc_client/src/jsonrpc.rs index 577d7c8171..6d8f488f6f 100644 --- a/crates/edr_rpc_client/src/jsonrpc.rs +++ b/crates/edr_rpc_client/src/jsonrpc.rs @@ -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 { diff --git a/crates/edr_rpc_eth/src/cacheable_method_invocation.rs b/crates/edr_rpc_eth/src/cacheable_method_invocation.rs index add86376d3..e724272220 100644 --- a/crates/edr_rpc_eth/src/cacheable_method_invocation.rs +++ b/crates/edr_rpc_eth/src/cacheable_method_invocation.rs @@ -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 { @@ -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 { @@ -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 diff --git a/crates/edr_solidity/src/compiler.rs b/crates/edr_solidity/src/compiler.rs index 9c9da700da..f7a498857d 100644 --- a/crates/edr_solidity/src/compiler.rs +++ b/crates/edr_solidity/src/compiler.rs @@ -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 . use std::{collections::HashMap, str::FromStr, sync::Arc}; use anyhow::{self, Context as _}; @@ -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 . pub fn create_models_and_decode_bytecodes( solc_version: String, compiler_input: &CompilerInput, diff --git a/rust-toolchain b/rust-toolchain index ea3769f296..74c280fb83 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.81 +1.83