mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: fix clippy errors (#9845)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -172,13 +172,13 @@ impl Command {
|
||||
debug!(target: "reth::cli", bytes = ?tx_bytes, "Decoding transaction");
|
||||
let transaction = TransactionSigned::decode(&mut &Bytes::from_str(tx_bytes)?[..])?
|
||||
.into_ecrecovered()
|
||||
.ok_or(eyre::eyre!("failed to recover tx"))?;
|
||||
.ok_or_else(|| eyre::eyre!("failed to recover tx"))?;
|
||||
|
||||
let encoded_length = match &transaction.transaction {
|
||||
Transaction::Eip4844(TxEip4844 { blob_versioned_hashes, .. }) => {
|
||||
let blobs_bundle = blobs_bundle.as_mut().ok_or(eyre::eyre!(
|
||||
"encountered a blob tx. `--blobs-bundle-path` must be provided"
|
||||
))?;
|
||||
let blobs_bundle = blobs_bundle.as_mut().ok_or_else(|| {
|
||||
eyre::eyre!("encountered a blob tx. `--blobs-bundle-path` must be provided")
|
||||
})?;
|
||||
|
||||
let sidecar: BlobTransactionSidecar =
|
||||
blobs_bundle.pop_sidecar(blob_versioned_hashes.len());
|
||||
|
||||
@ -156,7 +156,9 @@ impl Command {
|
||||
storage_writer.write_to_storage(execution_outcome, OriginalValuesKnown::Yes)?;
|
||||
|
||||
let checkpoint = Some(StageCheckpoint::new(
|
||||
block_number.checked_sub(1).ok_or(eyre::eyre!("GenesisBlockHasNoParent"))?,
|
||||
block_number
|
||||
.checked_sub(1)
|
||||
.ok_or_else(|| eyre::eyre!("GenesisBlockHasNoParent"))?,
|
||||
));
|
||||
|
||||
let mut account_hashing_done = false;
|
||||
|
||||
@ -154,12 +154,12 @@ impl TreeState {
|
||||
|
||||
/// Returns the maximum block number stored.
|
||||
pub(crate) fn max_block_number(&self) -> BlockNumber {
|
||||
*self.blocks_by_number.last_key_value().unwrap_or((&BlockNumber::default(), &vec![])).0
|
||||
self.blocks_by_number.last_key_value().map(|e| *e.0).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Returns the minimum block number stored.
|
||||
pub(crate) fn min_block_number(&self) -> BlockNumber {
|
||||
*self.blocks_by_number.first_key_value().unwrap_or((&BlockNumber::default(), &vec![])).0
|
||||
self.blocks_by_number.first_key_value().map(|e| *e.0).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Returns the block number of the pending block: `head + 1`
|
||||
|
||||
@ -262,10 +262,10 @@ pub async fn test_exex_context_with_chain_spec(
|
||||
|
||||
let genesis = provider_factory
|
||||
.block_by_hash(genesis_hash)?
|
||||
.ok_or(eyre::eyre!("genesis block not found"))?
|
||||
.ok_or_else(|| eyre::eyre!("genesis block not found"))?
|
||||
.seal_slow()
|
||||
.seal_with_senders()
|
||||
.ok_or(eyre::eyre!("failed to recover senders"))?;
|
||||
.ok_or_else(|| eyre::eyre!("failed to recover senders"))?;
|
||||
|
||||
let head = Head {
|
||||
number: genesis.number,
|
||||
|
||||
@ -505,7 +505,7 @@ impl NetworkConfigBuilder {
|
||||
hello_message.unwrap_or_else(|| HelloMessage::builder(peer_id).build());
|
||||
hello_message.port = listener_addr.port();
|
||||
|
||||
let head = head.unwrap_or(Head {
|
||||
let head = head.unwrap_or_else(|| Head {
|
||||
hash: chain_spec.genesis_hash(),
|
||||
number: 0,
|
||||
timestamp: chain_spec.genesis.timestamp,
|
||||
|
||||
@ -69,7 +69,7 @@ impl ImportOpCommand {
|
||||
"Importing chain file chunk"
|
||||
);
|
||||
|
||||
let tip = file_client.tip().ok_or(eyre::eyre!("file client has no tip"))?;
|
||||
let tip = file_client.tip().ok_or_else(|| eyre::eyre!("file client has no tip"))?;
|
||||
info!(target: "reth::cli", "Chain file chunk read");
|
||||
|
||||
total_decoded_blocks += file_client.headers_len();
|
||||
|
||||
@ -32,7 +32,7 @@ pub fn extract_l1_info(block: &Block) -> Result<L1BlockInfo, OptimismBlockExecut
|
||||
let l1_info_tx_data = block
|
||||
.body
|
||||
.first()
|
||||
.ok_or(OptimismBlockExecutionError::L1BlockInfoError {
|
||||
.ok_or_else(|| OptimismBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not find l1 block info tx in the L2 block".to_string(),
|
||||
})
|
||||
.map(|tx| tx.input())?;
|
||||
@ -71,21 +71,21 @@ pub fn parse_l1_info_tx_bedrock(data: &[u8]) -> Result<L1BlockInfo, OptimismBloc
|
||||
})
|
||||
}
|
||||
|
||||
let l1_base_fee = U256::try_from_be_slice(&data[64..96]).ok_or(
|
||||
let l1_base_fee = U256::try_from_be_slice(&data[64..96]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 base fee".to_string(),
|
||||
},
|
||||
)?;
|
||||
let l1_fee_overhead = U256::try_from_be_slice(&data[192..224]).ok_or(
|
||||
}
|
||||
})?;
|
||||
let l1_fee_overhead = U256::try_from_be_slice(&data[192..224]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 fee overhead".to_string(),
|
||||
},
|
||||
)?;
|
||||
let l1_fee_scalar = U256::try_from_be_slice(&data[224..256]).ok_or(
|
||||
}
|
||||
})?;
|
||||
let l1_fee_scalar = U256::try_from_be_slice(&data[224..256]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 fee scalar".to_string(),
|
||||
},
|
||||
)?;
|
||||
}
|
||||
})?;
|
||||
|
||||
let mut l1block = L1BlockInfo::default();
|
||||
l1block.l1_base_fee = l1_base_fee;
|
||||
@ -117,26 +117,26 @@ pub fn parse_l1_info_tx_ecotone(data: &[u8]) -> Result<L1BlockInfo, OptimismBloc
|
||||
})
|
||||
}
|
||||
|
||||
let l1_blob_base_fee_scalar = U256::try_from_be_slice(&data[8..12]).ok_or(
|
||||
let l1_blob_base_fee_scalar = U256::try_from_be_slice(&data[8..12]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 blob base fee scalar".to_string(),
|
||||
},
|
||||
)?;
|
||||
let l1_base_fee_scalar = U256::try_from_be_slice(&data[12..16]).ok_or(
|
||||
}
|
||||
})?;
|
||||
let l1_base_fee_scalar = U256::try_from_be_slice(&data[12..16]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 base fee scalar".to_string(),
|
||||
},
|
||||
)?;
|
||||
let l1_base_fee = U256::try_from_be_slice(&data[32..64]).ok_or(
|
||||
}
|
||||
})?;
|
||||
let l1_base_fee = U256::try_from_be_slice(&data[32..64]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 blob base fee".to_string(),
|
||||
},
|
||||
)?;
|
||||
let l1_blob_base_fee = U256::try_from_be_slice(&data[64..96]).ok_or(
|
||||
}
|
||||
})?;
|
||||
let l1_blob_base_fee = U256::try_from_be_slice(&data[64..96]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 blob base fee".to_string(),
|
||||
},
|
||||
)?;
|
||||
}
|
||||
})?;
|
||||
|
||||
let mut l1block = L1BlockInfo::default();
|
||||
l1block.l1_base_fee = l1_base_fee;
|
||||
|
||||
@ -90,7 +90,8 @@ impl<DB: Database> Stage<DB> for SenderRecoveryStage {
|
||||
info!(target: "sync::stages::sender_recovery", ?tx_range, "Recovering senders");
|
||||
|
||||
// Iterate over transactions in batches, recover the senders and append them
|
||||
let batch = (tx_range.start..tx_range.end)
|
||||
let batch = tx_range
|
||||
.clone()
|
||||
.step_by(BATCH_SIZE)
|
||||
.map(|start| start..std::cmp::min(start + BATCH_SIZE as u64, tx_range.end))
|
||||
.collect::<Vec<Range<u64>>>();
|
||||
@ -140,7 +141,8 @@ where
|
||||
debug!(target: "sync::stages::sender_recovery", ?tx_range, "Recovering senders batch");
|
||||
|
||||
// Preallocate channels
|
||||
let (chunks, receivers): (Vec<_>, Vec<_>) = (tx_range.start..tx_range.end)
|
||||
let (chunks, receivers): (Vec<_>, Vec<_>) = tx_range
|
||||
.clone()
|
||||
.step_by(WORKER_CHUNK_SIZE)
|
||||
.map(|start| {
|
||||
let range = start..std::cmp::min(start + WORKER_CHUNK_SIZE as u64, tx_range.end);
|
||||
|
||||
@ -105,7 +105,7 @@ impl<'a> HeaderProvider for StaticFileJarProvider<'a> {
|
||||
let mut cursor = self.cursor()?;
|
||||
let mut headers = Vec::with_capacity((range.end - range.start) as usize);
|
||||
|
||||
for num in range.start..range.end {
|
||||
for num in range {
|
||||
if let Some(header) = cursor.get_one::<HeaderMask<Header>>(num.into())? {
|
||||
headers.push(header);
|
||||
}
|
||||
@ -131,7 +131,7 @@ impl<'a> HeaderProvider for StaticFileJarProvider<'a> {
|
||||
let mut cursor = self.cursor()?;
|
||||
let mut headers = Vec::with_capacity((range.end - range.start) as usize);
|
||||
|
||||
for number in range.start..range.end {
|
||||
for number in range {
|
||||
if let Some((header, hash)) =
|
||||
cursor.get_two::<HeaderMask<Header, BlockHash>>(number.into())?
|
||||
{
|
||||
|
||||
@ -1249,7 +1249,8 @@ impl TransactionsProviderExt for StaticFileProvider {
|
||||
let mut channels = Vec::new();
|
||||
|
||||
// iterator over the chunks
|
||||
let chunks = (tx_range.start..tx_range.end)
|
||||
let chunks = tx_range
|
||||
.clone()
|
||||
.step_by(chunk_size)
|
||||
.map(|start| start..std::cmp::min(start + chunk_size as u64, tx_range.end));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user