Sitelet https://github.com/init4tech/node-components/commit/5147c88bdb939c7ce13f800994bf2178eaa61d5e
Skip to content

Commit 5147c88

Browse files
prestwichclaude
andcommitted
fix: reward percentile off-by-one, remove dead code, use async spawn
- Fix off-by-one in calculate_reward_percentiles that could skip the last transaction or panic on index out of bounds - Remove unused parent_header SealedHeader conversion in block processor - Use spawn_with_ctx (async) instead of spawn_blocking_with_ctx for send_order which only does async work - Add clarifying comment on per-block hardfork construction in node Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6bdd02d commit 5147c88

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎crates/block-processor/src/v1/processor.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ where
165165
.get_header(ru_height.saturating_sub(1))?
166166
.wrap_err("parent ru block not present in DB")
167167
.inspect_err(|e| error!(%e))?;
168-
let parent_header = signet_types::primitives::SealedHeader::new(parent_header.into_inner());
169168

170169
let txns = match &block_extracts.submitted {
171170
Some(submitted) => {

‎crates/node/src/node.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ where
308308

309309
let mut processed = false;
310310
for block_extracts in extracts.iter().filter(|e| e.ru_height > last_height) {
311+
// Constructed per-block: hardforks must be rechecked each block,
312+
// and the remaining fields are cheap (Arcs / Copy types).
311313
let hardforks = EthereumHardfork::active_hardforks(
312314
&self.config.genesis().config,
313315
block_extracts.host_block.number(),

‎crates/rpc/src/eth/endpoints.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,16 @@ fn calculate_reward_percentiles(
289289
for &percentile in percentiles {
290290
let threshold = (gas_used as f64 * percentile / 100.0) as u64;
291291

292-
while tx_idx < tx_gas_and_tip.len() - 1 {
292+
while tx_idx < tx_gas_and_tip.len() {
293293
cumulative_gas += tx_gas_and_tip[tx_idx].0;
294294
if cumulative_gas >= threshold {
295295
break;
296296
}
297297
tx_idx += 1;
298298
}
299299

300-
result.push(tx_gas_and_tip[tx_idx].1);
300+
let (_, tip) = tx_gas_and_tip.get(tx_idx).unwrap_or(tx_gas_and_tip.last().unwrap());
301+
result.push(*tip);
301302
}
302303

303304
result

‎crates/rpc/src/signet/endpoints.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ where
4141
ResponsePayload(Ok(()))
4242
};
4343

44-
await_handler!(@response_option hctx.spawn_blocking_with_ctx(task))
44+
await_handler!(@response_option hctx.spawn_with_ctx(task))
4545
}
4646

4747
/// `signet_callBundle` handler.

0 commit comments

Comments
 (0)