Skip to content

Commit 9352bb7

Browse files
committed
fmt
1 parent d232ecb commit 9352bb7

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

crates/engine/tree/src/tree/payload_processor/multiproof.rs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,13 +1047,13 @@ impl MultiProofTask {
10471047
Vec::with_capacity(PREFETCH_MAX_BATCH_MESSAGES);
10481048
accumulated_targets.push(targets);
10491049

1050-
// Fast-path dispatch if the first message already fills the batch.
1051-
if accumulated_count < PREFETCH_MAX_BATCH_TARGETS
1052-
&& accumulated_targets.len() < PREFETCH_MAX_BATCH_MESSAGES
1050+
// Only attempt batching if below limits; otherwise skip straight to dispatch.
1051+
if accumulated_count < PREFETCH_MAX_BATCH_TARGETS &&
1052+
accumulated_targets.len() < PREFETCH_MAX_BATCH_MESSAGES
10531053
{
10541054
loop {
1055-
if accumulated_count >= PREFETCH_MAX_BATCH_TARGETS
1056-
|| accumulated_targets.len() >= PREFETCH_MAX_BATCH_MESSAGES
1055+
if accumulated_count >= PREFETCH_MAX_BATCH_TARGETS ||
1056+
accumulated_targets.len() >= PREFETCH_MAX_BATCH_MESSAGES
10571057
{
10581058
break;
10591059
}
@@ -1488,8 +1488,8 @@ fn get_proof_targets(
14881488
.storage
14891489
.keys()
14901490
.filter(|slot| {
1491-
!fetched.is_some_and(|f| f.contains(*slot))
1492-
|| storage_added_removed_keys.is_some_and(|k| k.is_removed(slot))
1491+
!fetched.is_some_and(|f| f.contains(*slot)) ||
1492+
storage_added_removed_keys.is_some_and(|k| k.is_removed(slot))
14931493
})
14941494
.peekable();
14951495

@@ -1522,20 +1522,20 @@ fn dispatch_with_chunking<T, I>(
15221522
where
15231523
I: IntoIterator<Item = T>,
15241524
{
1525-
let should_chunk = chunking_len > max_targets_for_chunking
1526-
|| available_account_workers > 1
1527-
|| available_storage_workers > 1;
1525+
let should_chunk = chunking_len > max_targets_for_chunking ||
1526+
available_account_workers > 1 ||
1527+
available_storage_workers > 1;
15281528

1529-
if should_chunk
1530-
&& let Some(chunk_size) = chunk_size
1531-
&& chunking_len > chunk_size
1529+
if should_chunk &&
1530+
let Some(chunk_size) = chunk_size &&
1531+
chunking_len > chunk_size
15321532
{
1533-
let mut dispatched = 0usize;
1533+
let mut num_chunks = 0usize;
15341534
for chunk in chunker(items, chunk_size) {
15351535
dispatch(chunk);
1536-
dispatched += 1;
1536+
num_chunks += 1;
15371537
}
1538-
return dispatched;
1538+
return num_chunks;
15391539
}
15401540

15411541
dispatch(items);
@@ -1544,8 +1544,9 @@ where
15441544

15451545
/// Checks whether two state updates can be merged in a batch.
15461546
///
1547-
/// Transaction updates that share the same `StateChangeSource::Transaction` are safe to merge
1548-
/// because they originate from one logical execution and can be coalesced to amortize proof work.
1547+
/// Transaction updates with the same transaction ID (`StateChangeSource::Transaction(id)`)
1548+
/// are safe to merge because they originate from the same logical execution and can be
1549+
/// coalesced to amortize proof work.
15491550
fn can_batch_state_update(
15501551
batch_source: StateChangeSource,
15511552
batch_update: &EvmState,
@@ -1557,8 +1558,8 @@ fn can_batch_state_update(
15571558
}
15581559

15591560
match (batch_source, next_source) {
1560-
(StateChangeSource::PreBlock(_), StateChangeSource::PreBlock(_))
1561-
| (StateChangeSource::PostBlock(_), StateChangeSource::PostBlock(_)) => {
1561+
(StateChangeSource::PreBlock(_), StateChangeSource::PreBlock(_)) |
1562+
(StateChangeSource::PostBlock(_), StateChangeSource::PostBlock(_)) => {
15621563
batch_update == next_update
15631564
}
15641565
_ => true,
@@ -2250,8 +2251,8 @@ mod tests {
22502251
}
22512252
match task.rx.try_recv() {
22522253
Ok(MultiProofMessage::StateUpdate(next_source, next_update)) => {
2253-
if let Some((batch_source, batch_update)) = accumulated_updates.first()
2254-
&& !can_batch_state_update(
2254+
if let Some((batch_source, batch_update)) = accumulated_updates.first() &&
2255+
!can_batch_state_update(
22552256
*batch_source,
22562257
batch_update,
22572258
next_source,
@@ -2269,8 +2270,8 @@ mod tests {
22692270
Some(MultiProofMessage::StateUpdate(next_source, next_update));
22702271
break;
22712272
}
2272-
if accumulated_targets + next_estimate > STATE_UPDATE_MAX_BATCH_TARGETS
2273-
&& !accumulated_updates.is_empty()
2273+
if accumulated_targets + next_estimate > STATE_UPDATE_MAX_BATCH_TARGETS &&
2274+
!accumulated_updates.is_empty()
22742275
{
22752276
pending_msg =
22762277
Some(MultiProofMessage::StateUpdate(next_source, next_update));
@@ -2372,8 +2373,8 @@ mod tests {
23722373
}
23732374
match task.rx.try_recv() {
23742375
Ok(MultiProofMessage::StateUpdate(next_source, next_update)) => {
2375-
if let Some((batch_source, batch_update)) = accumulated_updates.first()
2376-
&& !can_batch_state_update(
2376+
if let Some((batch_source, batch_update)) = accumulated_updates.first() &&
2377+
!can_batch_state_update(
23772378
*batch_source,
23782379
batch_update,
23792380
next_source,
@@ -2391,8 +2392,8 @@ mod tests {
23912392
Some(MultiProofMessage::StateUpdate(next_source, next_update));
23922393
break;
23932394
}
2394-
if accumulated_targets + next_estimate > STATE_UPDATE_MAX_BATCH_TARGETS
2395-
&& !accumulated_updates.is_empty()
2395+
if accumulated_targets + next_estimate > STATE_UPDATE_MAX_BATCH_TARGETS &&
2396+
!accumulated_updates.is_empty()
23962397
{
23972398
pending_msg =
23982399
Some(MultiProofMessage::StateUpdate(next_source, next_update));

0 commit comments

Comments
 (0)