diff --git a/crates/engine/tree/src/tree/payload_processor/mod.rs b/crates/engine/tree/src/tree/payload_processor/mod.rs index 1ed9b63215..9fde807865 100644 --- a/crates/engine/tree/src/tree/payload_processor/mod.rs +++ b/crates/engine/tree/src/tree/payload_processor/mod.rs @@ -377,8 +377,8 @@ where let _ = execute_tx.send(tx); next_for_execution += 1; - while let Some(entry) = queue.first_entry() - && *entry.key() == next_for_execution + while let Some(entry) = queue.first_entry() && + *entry.key() == next_for_execution { let _ = execute_tx.send(entry.remove()); next_for_execution += 1; diff --git a/crates/engine/tree/src/tree/payload_processor/multiproof.rs b/crates/engine/tree/src/tree/payload_processor/multiproof.rs index 12ce57693b..d3cd8b228a 100644 --- a/crates/engine/tree/src/tree/payload_processor/multiproof.rs +++ b/crates/engine/tree/src/tree/payload_processor/multiproof.rs @@ -896,8 +896,8 @@ impl MultiProofTask { ctx.accumulated_prefetch_targets.push(targets); // Batch consecutive prefetch messages up to limits. - while accumulated_count < PREFETCH_MAX_BATCH_TARGETS - && ctx.accumulated_prefetch_targets.len() < PREFETCH_MAX_BATCH_MESSAGES + while accumulated_count < PREFETCH_MAX_BATCH_TARGETS && + ctx.accumulated_prefetch_targets.len() < PREFETCH_MAX_BATCH_MESSAGES { match self.rx.try_recv() { Ok(MultiProofMessage::PrefetchProofs(next_targets)) => { @@ -1378,8 +1378,8 @@ fn get_proof_targets( .storage .keys() .filter(|slot| { - !fetched.is_some_and(|f| f.contains(*slot)) - || storage_added_removed_keys.is_some_and(|k| k.is_removed(slot)) + !fetched.is_some_and(|f| f.contains(*slot)) || + storage_added_removed_keys.is_some_and(|k| k.is_removed(slot)) }) .peekable(); @@ -1412,13 +1412,13 @@ fn dispatch_with_chunking( where I: IntoIterator, { - let should_chunk = chunking_len > max_targets_for_chunking - || available_account_workers > 1 - || available_storage_workers > 1; + let should_chunk = chunking_len > max_targets_for_chunking || + available_account_workers > 1 || + available_storage_workers > 1; - if should_chunk - && let Some(chunk_size) = chunk_size - && chunking_len > chunk_size + if should_chunk && + let Some(chunk_size) = chunk_size && + chunking_len > chunk_size { let mut num_chunks = 0usize; for chunk in chunker(items, chunk_size) { @@ -1451,8 +1451,8 @@ fn can_batch_state_update( ( Source::Evm(StateChangeSource::PreBlock(_)), Source::Evm(StateChangeSource::PreBlock(_)), - ) - | ( + ) | + ( Source::Evm(StateChangeSource::PostBlock(_)), Source::Evm(StateChangeSource::PostBlock(_)), ) => batch_update == next_update, @@ -2159,8 +2159,8 @@ mod tests { } match task.rx.try_recv() { Ok(MultiProofMessage::StateUpdate(next_source, next_update)) => { - if let Some((batch_source, batch_update)) = accumulated_updates.first() - && !can_batch_state_update( + if let Some((batch_source, batch_update)) = accumulated_updates.first() && + !can_batch_state_update( *batch_source, batch_update, next_source, @@ -2178,8 +2178,8 @@ mod tests { Some(MultiProofMessage::StateUpdate(next_source, next_update)); break; } - if accumulated_targets + next_estimate > STATE_UPDATE_MAX_BATCH_TARGETS - && !accumulated_updates.is_empty() + if accumulated_targets + next_estimate > STATE_UPDATE_MAX_BATCH_TARGETS && + !accumulated_updates.is_empty() { pending_msg = Some(MultiProofMessage::StateUpdate(next_source, next_update)); @@ -2283,8 +2283,8 @@ mod tests { } match task.rx.try_recv() { Ok(MultiProofMessage::StateUpdate(next_source, next_update)) => { - if let Some((batch_source, batch_update)) = accumulated_updates.first() - && !can_batch_state_update( + if let Some((batch_source, batch_update)) = accumulated_updates.first() && + !can_batch_state_update( *batch_source, batch_update, next_source, @@ -2302,8 +2302,8 @@ mod tests { Some(MultiProofMessage::StateUpdate(next_source, next_update)); break; } - if accumulated_targets + next_estimate > STATE_UPDATE_MAX_BATCH_TARGETS - && !accumulated_updates.is_empty() + if accumulated_targets + next_estimate > STATE_UPDATE_MAX_BATCH_TARGETS && + !accumulated_updates.is_empty() { pending_msg = Some(MultiProofMessage::StateUpdate(next_source, next_update)); diff --git a/crates/ethereum/payload/src/lib.rs b/crates/ethereum/payload/src/lib.rs index 7a21f0d3fd..fb6b2b0614 100644 --- a/crates/ethereum/payload/src/lib.rs +++ b/crates/ethereum/payload/src/lib.rs @@ -232,10 +232,10 @@ where // convert tx to a signed transaction let tx = pool_tx.to_consensus(); - let estimated_block_size_with_tx = block_transactions_rlp_length - + tx.inner().length() - + attributes.withdrawals().length() - + 1024; // 1Kb of overhead for the block header + let estimated_block_size_with_tx = block_transactions_rlp_length + + tx.inner().length() + + attributes.withdrawals().length() + + 1024; // 1Kb of overhead for the block header if is_osaka && estimated_block_size_with_tx > MAX_RLP_BLOCK_SIZE { best_txs.mark_invalid( diff --git a/crates/optimism/evm/src/lib.rs b/crates/optimism/evm/src/lib.rs index 1d0460ff72..67f856775c 100644 --- a/crates/optimism/evm/src/lib.rs +++ b/crates/optimism/evm/src/lib.rs @@ -230,7 +230,9 @@ where let spec = revm_spec_by_timestamp_after_bedrock(self.chain_spec(), timestamp); - let cfg_env = CfgEnv::new().with_chain_id(self.chain_spec().chain().id()).with_spec_and_mainnet_gas_params(spec); + let cfg_env = CfgEnv::new() + .with_chain_id(self.chain_spec().chain().id()) + .with_spec_and_mainnet_gas_params(spec); let blob_excess_gas_and_price = spec .into_eth_spec() @@ -361,7 +363,8 @@ mod tests { let db = CacheDB::>::default(); // Create a custom configuration environment with a chain ID of 111 - let cfg = CfgEnv::new().with_chain_id(111).with_spec_and_mainnet_gas_params(OpSpecId::default()); + let cfg = + CfgEnv::new().with_chain_id(111).with_spec_and_mainnet_gas_params(OpSpecId::default()); let evm_env = EvmEnv { cfg_env: cfg.clone(), ..Default::default() }; @@ -399,8 +402,10 @@ mod tests { let db = CacheDB::>::default(); - let evm_env = - EvmEnv { cfg_env: CfgEnv::new().with_spec_and_mainnet_gas_params(OpSpecId::ECOTONE), ..Default::default() }; + let evm_env = EvmEnv { + cfg_env: CfgEnv::new().with_spec_and_mainnet_gas_params(OpSpecId::ECOTONE), + ..Default::default() + }; let evm = evm_config.evm_with_env(db, evm_env.clone()); @@ -426,7 +431,8 @@ mod tests { let evm_config = test_evm_config(); let db = CacheDB::>::default(); - let cfg = CfgEnv::new().with_chain_id(111).with_spec_and_mainnet_gas_params(OpSpecId::default()); + let cfg = + CfgEnv::new().with_chain_id(111).with_spec_and_mainnet_gas_params(OpSpecId::default()); let block = BlockEnv::default(); let evm_env = EvmEnv { block_env: block, cfg_env: cfg.clone() }; @@ -462,8 +468,10 @@ mod tests { let evm_config = test_evm_config(); let db = CacheDB::>::default(); - let evm_env = - EvmEnv { cfg_env: CfgEnv::new().with_spec_and_mainnet_gas_params(OpSpecId::ECOTONE), ..Default::default() }; + let evm_env = EvmEnv { + cfg_env: CfgEnv::new().with_spec_and_mainnet_gas_params(OpSpecId::ECOTONE), + ..Default::default() + }; let evm = evm_config.evm_with_env_and_inspector(db, evm_env.clone(), NoOpInspector {}); diff --git a/crates/optimism/payload/src/builder.rs b/crates/optimism/payload/src/builder.rs index 0980a778cf..4ac2a611d6 100644 --- a/crates/optimism/payload/src/builder.rs +++ b/crates/optimism/payload/src/builder.rs @@ -729,8 +729,8 @@ where // We skip invalid cross chain txs, they would be removed on the next block update in // the maintenance job - if let Some(interop) = interop - && !is_valid_interop(interop, self.config.attributes.timestamp()) + if let Some(interop) = interop && + !is_valid_interop(interop, self.config.attributes.timestamp()) { best_txs.mark_invalid(tx.signer(), tx.nonce()); continue; diff --git a/crates/primitives-traits/src/account.rs b/crates/primitives-traits/src/account.rs index 56b4dc12a8..99c148ae2d 100644 --- a/crates/primitives-traits/src/account.rs +++ b/crates/primitives-traits/src/account.rs @@ -47,9 +47,9 @@ impl Account { /// After `SpuriousDragon` empty account is defined as account with nonce == 0 && balance == 0 /// && bytecode = None (or hash is [`KECCAK_EMPTY`]). pub fn is_empty(&self) -> bool { - self.nonce == 0 - && self.balance.is_zero() - && self.bytecode_hash.is_none_or(|hash| hash == KECCAK_EMPTY) + self.nonce == 0 && + self.balance.is_zero() && + self.bytecode_hash.is_none_or(|hash| hash == KECCAK_EMPTY) } /// Returns an account bytecode's hash. diff --git a/crates/rpc/rpc-eth-api/src/helpers/estimate.rs b/crates/rpc/rpc-eth-api/src/helpers/estimate.rs index aad32417b4..7e82def937 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/estimate.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/estimate.rs @@ -97,8 +97,8 @@ pub trait EstimateCall: Call { let mut tx_env = self.create_txn_env(&evm_env, request, &mut db)?; // Check if this is a basic transfer (no input data to account with no code) - let is_basic_transfer = if tx_env.input().is_empty() - && let TxKind::Call(to) = tx_env.kind() + let is_basic_transfer = if tx_env.input().is_empty() && + let TxKind::Call(to) = tx_env.kind() { match db.database.basic_account(&to) { Ok(Some(account)) => { @@ -136,8 +136,8 @@ pub trait EstimateCall: Call { min_tx_env.set_gas_limit(MIN_TRANSACTION_GAS); // Reuse the same EVM instance - if let Ok(res) = evm.transact(min_tx_env).map_err(Self::Error::from_evm_err) - && res.result.is_success() + if let Ok(res) = evm.transact(min_tx_env).map_err(Self::Error::from_evm_err) && + res.result.is_success() { return Ok(U256::from(MIN_TRANSACTION_GAS)); } @@ -152,8 +152,8 @@ pub trait EstimateCall: Call { // retry the transaction with the block's gas limit to determine if // the failure was due to insufficient gas. Err(err) - if err.is_gas_too_high() - && (tx_request_gas_limit.is_some() || tx_request_gas_price.is_some()) => + if err.is_gas_too_high() && + (tx_request_gas_limit.is_some() || tx_request_gas_price.is_some()) => { return Self::map_out_of_gas_err(&mut evm, tx_env, max_gas_limit); } diff --git a/crates/rpc/rpc-eth-types/src/error/mod.rs b/crates/rpc/rpc-eth-types/src/error/mod.rs index 83bc92a1fd..6063ed5f85 100644 --- a/crates/rpc/rpc-eth-types/src/error/mod.rs +++ b/crates/rpc/rpc-eth-types/src/error/mod.rs @@ -20,9 +20,12 @@ use reth_transaction_pool::error::{ Eip4844PoolTransactionError, Eip7702PoolTransactionError, InvalidPoolTransactionError, PoolError, PoolErrorKind, PoolTransactionError, }; -use revm::{context_interface::result::{ - EVMError, HaltReason, InvalidHeader, InvalidTransaction, OutOfGasError, -}, state::bal::BalError}; +use revm::{ + context_interface::result::{ + EVMError, HaltReason, InvalidHeader, InvalidTransaction, OutOfGasError, + }, + state::bal::BalError, +}; use revm_inspectors::tracing::{DebugInspectorError, MuxError}; use std::convert::Infallible; use tokio::sync::oneshot::error::RecvError; @@ -221,8 +224,8 @@ impl EthApiError { matches!( self, Self::InvalidTransaction( - RpcInvalidTransactionError::GasTooHigh - | RpcInvalidTransactionError::GasLimitTooHigh + RpcInvalidTransactionError::GasTooHigh | + RpcInvalidTransactionError::GasLimitTooHigh ) ) } @@ -265,25 +268,25 @@ impl EthApiError { impl From for jsonrpsee_types::error::ErrorObject<'static> { fn from(error: EthApiError) -> Self { match error { - EthApiError::FailedToDecodeSignedTransaction - | EthApiError::InvalidTransactionSignature - | EthApiError::EmptyRawTransactionData - | EthApiError::InvalidBlockRange - | EthApiError::ExceedsMaxProofWindow - | EthApiError::ConflictingFeeFieldsInRequest - | EthApiError::Signing(_) - | EthApiError::BothStateAndStateDiffInOverride(_) - | EthApiError::InvalidTracerConfig - | EthApiError::TransactionConversionError(_) - | EthApiError::InvalidRewardPercentiles - | EthApiError::InvalidBytecode(_) => invalid_params_rpc_err(error.to_string()), + EthApiError::FailedToDecodeSignedTransaction | + EthApiError::InvalidTransactionSignature | + EthApiError::EmptyRawTransactionData | + EthApiError::InvalidBlockRange | + EthApiError::ExceedsMaxProofWindow | + EthApiError::ConflictingFeeFieldsInRequest | + EthApiError::Signing(_) | + EthApiError::BothStateAndStateDiffInOverride(_) | + EthApiError::InvalidTracerConfig | + EthApiError::TransactionConversionError(_) | + EthApiError::InvalidRewardPercentiles | + EthApiError::InvalidBytecode(_) => invalid_params_rpc_err(error.to_string()), EthApiError::InvalidTransaction(err) => err.into(), EthApiError::PoolError(err) => err.into(), - EthApiError::PrevrandaoNotSet - | EthApiError::ExcessBlobGasNotSet - | EthApiError::InvalidBlockData(_) - | EthApiError::Internal(_) - | EthApiError::EvmCustom(_) => internal_rpc_err(error.to_string()), + EthApiError::PrevrandaoNotSet | + EthApiError::ExcessBlobGasNotSet | + EthApiError::InvalidBlockData(_) | + EthApiError::Internal(_) | + EthApiError::EvmCustom(_) => internal_rpc_err(error.to_string()), EthApiError::UnknownBlockOrTxIndex | EthApiError::TransactionNotFound => { rpc_error_with_code(EthRpcErrorCode::ResourceNotFound.code(), error.to_string()) } @@ -727,14 +730,14 @@ impl RpcInvalidTransactionError { /// Returns the rpc error code for this error. pub const fn error_code(&self) -> i32 { match self { - Self::InvalidChainId - | Self::GasTooLow - | Self::GasTooHigh - | Self::GasRequiredExceedsAllowance { .. } - | Self::NonceTooLow { .. } - | Self::NonceTooHigh { .. } - | Self::FeeCapTooLow - | Self::FeeCapVeryHigh => EthRpcErrorCode::InvalidInput.code(), + Self::InvalidChainId | + Self::GasTooLow | + Self::GasTooHigh | + Self::GasRequiredExceedsAllowance { .. } | + Self::NonceTooLow { .. } | + Self::NonceTooHigh { .. } | + Self::FeeCapTooLow | + Self::FeeCapVeryHigh => EthRpcErrorCode::InvalidInput.code(), Self::Revert(_) => EthRpcErrorCode::ExecutionError.code(), _ => EthRpcErrorCode::TransactionRejected.code(), } @@ -795,8 +798,8 @@ impl From for RpcInvalidTransactionError { } InvalidTransaction::PriorityFeeGreaterThanMaxFee => Self::TipAboveFeeCap, InvalidTransaction::GasPriceLessThanBasefee => Self::FeeCapTooLow, - InvalidTransaction::CallerGasLimitMoreThanBlock - | InvalidTransaction::TxGasLimitGreaterThanCap { .. } => { + InvalidTransaction::CallerGasLimitMoreThanBlock | + InvalidTransaction::TxGasLimitGreaterThanCap { .. } => { // tx.gas > block.gas_limit Self::GasTooHigh } @@ -833,13 +836,13 @@ impl From for RpcInvalidTransactionError { InvalidTransaction::AuthorizationListNotSupported => { Self::AuthorizationListNotSupported } - InvalidTransaction::AuthorizationListInvalidFields - | InvalidTransaction::EmptyAuthorizationList => Self::AuthorizationListInvalidFields, - InvalidTransaction::Eip2930NotSupported - | InvalidTransaction::Eip1559NotSupported - | InvalidTransaction::Eip4844NotSupported - | InvalidTransaction::Eip7702NotSupported - | InvalidTransaction::Eip7873NotSupported => Self::TxTypeNotSupported, + InvalidTransaction::AuthorizationListInvalidFields | + InvalidTransaction::EmptyAuthorizationList => Self::AuthorizationListInvalidFields, + InvalidTransaction::Eip2930NotSupported | + InvalidTransaction::Eip1559NotSupported | + InvalidTransaction::Eip4844NotSupported | + InvalidTransaction::Eip7702NotSupported | + InvalidTransaction::Eip7873NotSupported => Self::TxTypeNotSupported, InvalidTransaction::Eip7873MissingTarget => { Self::other(internal_rpc_err(err.to_string())) } @@ -865,11 +868,11 @@ impl From for RpcInvalidTransactionError { Self::OldLegacyChainId } InvalidTransactionError::ChainIdMismatch => Self::InvalidChainId, - InvalidTransactionError::Eip2930Disabled - | InvalidTransactionError::Eip1559Disabled - | InvalidTransactionError::Eip4844Disabled - | InvalidTransactionError::Eip7702Disabled - | InvalidTransactionError::TxTypeNotSupported => Self::TxTypeNotSupported, + InvalidTransactionError::Eip2930Disabled | + InvalidTransactionError::Eip1559Disabled | + InvalidTransactionError::Eip4844Disabled | + InvalidTransactionError::Eip7702Disabled | + InvalidTransactionError::TxTypeNotSupported => Self::TxTypeNotSupported, InvalidTransactionError::GasUintOverflow => Self::GasUintOverflow, InvalidTransactionError::GasTooLow => Self::GasTooLow, InvalidTransactionError::GasTooHigh => Self::GasTooHigh, @@ -1005,20 +1008,20 @@ impl From for jsonrpsee_types::error::ErrorObject<'static> { RpcPoolError::TxPoolOverflow => { rpc_error_with_code(EthRpcErrorCode::TransactionRejected.code(), error.to_string()) } - RpcPoolError::AlreadyKnown - | RpcPoolError::InvalidSender - | RpcPoolError::Underpriced - | RpcPoolError::ReplaceUnderpriced - | RpcPoolError::ExceedsGasLimit - | RpcPoolError::MaxTxGasLimitExceeded - | RpcPoolError::ExceedsFeeCap { .. } - | RpcPoolError::NegativeValue - | RpcPoolError::OversizedData { .. } - | RpcPoolError::ExceedsMaxInitCodeSize - | RpcPoolError::PoolTransactionError(_) - | RpcPoolError::Eip4844(_) - | RpcPoolError::Eip7702(_) - | RpcPoolError::AddressAlreadyReserved => { + RpcPoolError::AlreadyKnown | + RpcPoolError::InvalidSender | + RpcPoolError::Underpriced | + RpcPoolError::ReplaceUnderpriced | + RpcPoolError::ExceedsGasLimit | + RpcPoolError::MaxTxGasLimitExceeded | + RpcPoolError::ExceedsFeeCap { .. } | + RpcPoolError::NegativeValue | + RpcPoolError::OversizedData { .. } | + RpcPoolError::ExceedsMaxInitCodeSize | + RpcPoolError::PoolTransactionError(_) | + RpcPoolError::Eip4844(_) | + RpcPoolError::Eip7702(_) | + RpcPoolError::AddressAlreadyReserved => { rpc_error_with_code(EthRpcErrorCode::InvalidInput.code(), error.to_string()) } RpcPoolError::Other(other) => internal_rpc_err(other.to_string()), diff --git a/crates/trie/common/src/hashed_state.rs b/crates/trie/common/src/hashed_state.rs index f51282f7d0..80d99be1aa 100644 --- a/crates/trie/common/src/hashed_state.rs +++ b/crates/trie/common/src/hashed_state.rs @@ -224,8 +224,8 @@ impl HashedPostState { Some(storage_in_targets) => { let mut storage_not_in_targets = HashedStorage::default(); storage.storage.retain(|&slot, value| { - if storage_in_targets.contains(&slot) - && !storage_added_removed_keys.is_some_and(|k| k.is_removed(&slot)) + if storage_in_targets.contains(&slot) && + !storage_added_removed_keys.is_some_and(|k| k.is_removed(&slot)) { return true; } @@ -281,9 +281,8 @@ impl HashedPostState { /// Returns the number of items that will be considered during chunking in `[Self::chunks]`. pub fn chunking_length(&self) -> usize { - self.accounts.len() - + self - .storages + self.accounts.len() + + self.storages .values() .map(|storage| if storage.wiped { 1 } else { 0 } + storage.storage.len()) .sum::()