From e4a08fbbf95e392641baba03bd75e5ba409e0ef8 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 7 Jun 2024 13:08:19 +0200 Subject: [PATCH] chore: misc stages docs (#8669) --- crates/stages/stages/src/stages/sender_recovery.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/stages/stages/src/stages/sender_recovery.rs b/crates/stages/stages/src/stages/sender_recovery.rs index 2551bce796..9f1500edfd 100644 --- a/crates/stages/stages/src/stages/sender_recovery.rs +++ b/crates/stages/stages/src/stages/sender_recovery.rs @@ -90,9 +90,9 @@ impl Stage for SenderRecoveryStage { // Acquire the cursor for inserting elements let mut senders_cursor = tx.cursor_write::()?; - // Iterate over transactions in chunks 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) .step_by(BATCH_SIZE) .map(|start| start..std::cmp::min(start + BATCH_SIZE as u64, tx_range.end)) @@ -155,8 +155,6 @@ fn recover_range( let static_file_provider = provider.static_file_provider().clone(); tokio::task::spawn_blocking(move || { for (chunk_range, recovered_senders_tx) in chunks { - let static_file_provider = static_file_provider.clone(); - // Read the raw value, and let the rayon worker to decompress & decode. let chunk = static_file_provider .fetch_range_with_predicate( @@ -229,11 +227,11 @@ fn recover_sender( (tx_id, tx): (TxNumber, TransactionSignedNoHash), rlp_buf: &mut Vec, ) -> Result<(u64, Address), Box> { - // We call [Signature::recover_signer_unchecked] because transactions run in the pipeline are - // known to be valid - this means that we do not need to check whether or not the `s` value is - // greater than `secp256k1n / 2` if past EIP-2. There are transactions pre-homestead which have - // large `s` values, so using [Signature::recover_signer] here would not be - // backwards-compatible. + // We call [Signature::encode_and_recover_unchecked] because transactions run in the pipeline + // are known to be valid - this means that we do not need to check whether or not the `s` + // value is greater than `secp256k1n / 2` if past EIP-2. There are transactions + // pre-homestead which have large `s` values, so using [Signature::recover_signer] here + // would not be backwards-compatible. let sender = tx .encode_and_recover_unchecked(rlp_buf) .ok_or(SenderRecoveryStageError::FailedRecovery(FailedSenderRecoveryError { tx: tx_id }))?;