Skip to content

perf(rpc): stop long blocking jobs once their request is dropped - #27462

Merged
mattsse merged 5 commits into
mainfrom
mattsse/cancel-dropped-blocking-jobs
Sep 30, 2026
Merged

mattsse merged 5 commits into
mainfrom
mattsse/cancel-dropped-blocking-jobs

Conversation

@mattsse

@mattsse mattsse commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Blocking tasks keep running when their request is dropped, for example because the client disconnected or timed out, and the long running ones only check for that before they start. spawn_blocking_io now runs the task inside CancelOnDrop::scope, which makes the request's cancellation state available to the blocking thread via reth_tasks::cancel::is_cancelled. This is checked between iterations of the eth_estimateGas binary search, between calls in eth_callMany, debug_traceCallMany and trace_callMany, between transactions of block traces and debug_intermediateRoots, and while replaying the transactions preceding a traced transaction.

The thread-local scope lives in reth-tasks next to CancelOnDrop so any spawned work can use it. Leaving a scope restores the previous state, also on unwind, and does not itself cancel.

Over WS and IPC this depends on calls being dropped when the connection closes, see #27458 and paritytech/jsonrpsee#1656.

Blocking tasks keep running after their request is dropped. Expose the
request's cancellation state to the blocking task and check it between
iterations of the longest running jobs.
@mattsse
mattsse requested a review from Rjected as a code owner September 26, 2026 06:14
@mattsse mattsse added the A-rpc Related to the RPC implementation label Sep 26, 2026
@mattsse mattsse added the M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity label Sep 30, 2026
The thread-local cancellation state and is_cancelled helper are generic over any spawned work, so they now live next to CancelOnDrop as CancelOnDrop::scope and reth_tasks::cancel::is_cancelled. The scope stores the shared flag rather than a CancelOnDrop clone, so leaving it does not cancel.
@mattsse

mattsse commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

cyclops audit fast

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

cc @mattsse

Cyclops audit event published. View workflow run

Config: config: default, iterations: 1, hours: default

@mattsse
mattsse enabled auto-merge September 30, 2026 11:29
@mattsse
mattsse disabled auto-merge September 30, 2026 11:30

@tempoxyz-bot tempoxyz-bot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👁️ Cyclops Review — No actionable findings.

@mattsse
mattsse merged commit 13a59de into main Sep 30, 2026
41 checks passed
@mattsse
mattsse deleted the mattsse/cancel-dropped-blocking-jobs branch September 30, 2026 13:39
Thegreatsura pushed a commit to Thegreatsura/tempo that referenced this pull request Oct 2, 2026
Automated nightly update of reth dependencies from `paradigmxyz/reth`
main branch.

## Upstream reth changes


[`5723a3f...5b68630`](paradigmxyz/reth@5723a3f...5b68630)

🔗 Amp thread:
https://ampcode.com/threads/T-01a0f577-22fa-769d-adda-29c049ad2fbd
**Engine**
- Fed early transactions to BAL execution first
([#27544](paradigmxyz/reth#27544)).
- Made sparse trie reuse fork-safe
([#27270](paradigmxyz/reth#27270)).
- Preserved tracing context across engine and worker tasks
([#27529](paradigmxyz/reth#27529)).
- Moved the precompile cache into `execution-cache`
([#27604](paradigmxyz/reth#27604)).

**RPC**
- Returned EIP-1186 account extensions in proofs. This adds the
`account-ext` feature and trie-side recovery, with test coverage
([#27501](paradigmxyz/reth#27501),
[#27524](paradigmxyz/reth#27524),
[#27574](paradigmxyz/reth#27574),
[#27575](paradigmxyz/reth#27575)).
- Timed out slow compressed requests and stopped long blocking jobs once
their request is dropped
([#27530](paradigmxyz/reth#27530),
[#27462](paradigmxyz/reth#27462)).
- Acquired tracing permits for Otterscan trace methods
([#27465](paradigmxyz/reth#27465)).
- Kept calls with omitted gas within the RPC gas cap
([#27586](paradigmxyz/reth#27586)).

**Storage / DB**
- Re-enabled BAL store activation
([#27472](paradigmxyz/reth#27472)).
- Added an overlay wait-time metric
([#27495](paradigmxyz/reth#27495)).
- Rejected snap sync on the legacy state layout
([#27540](paradigmxyz/reth#27540)).
- Pruned transaction row zero during recovery
([#27229](paradigmxyz/reth#27229)).

**Snap Sync**
- Repaired stale state at the pivot and logged peers that don't serve
the pivot ([#27457](paradigmxyz/reth#27457),
[#27536](paradigmxyz/reth#27536)).

**Stages / Pruning**
- Added `Pipeline::run_until`
([#27537](paradigmxyz/reth#27537)).
- Rebuilt pruned history from empty, and treated `Before(0)` as nothing
to prune ([#27602](paradigmxyz/reth#27602),
[#27603](paradigmxyz/reth#27603)).

**Networking**
- Explicitly added peers are now dialed right away
([#27499](paradigmxyz/reth#27499)).
- Simplified network test utils
([#27453](paradigmxyz/reth#27453)).

**Txpool**
- Capped intrinsic regular gas under EIP-8037
([#27587](paradigmxyz/reth#27587)).

**CLI**
- `download` now exits right after completion
([#27498](paradigmxyz/reth#27498)).

**Perf**
- Switched hash-keyed maps to `B256Map`
([#27558](paradigmxyz/reth#27558)).
- Updated keccak-asm to 0.1.9
([#27496](paradigmxyz/reth#27496)).

**Refactoring**
- Replaced hand-rolled logic with existing alloy and revm helpers across
chainspec, era, payload, engine, RPC, net, trie, and EVM
([#27454](paradigmxyz/reth#27454),
[#27505](paradigmxyz/reth#27505),
[#27506](paradigmxyz/reth#27506),
[#27507](paradigmxyz/reth#27507),
[#27509](paradigmxyz/reth#27509),
[#27510](paradigmxyz/reth#27510),
[#27511](paradigmxyz/reth#27511),
[#27512](paradigmxyz/reth#27512),
[#27513](paradigmxyz/reth#27513),
[#27514](paradigmxyz/reth#27514),
[#27519](paradigmxyz/reth#27519),
[#27520](paradigmxyz/reth#27520),
[#27521](paradigmxyz/reth#27521),
[#27522](paradigmxyz/reth#27522),
[#27504](paradigmxyz/reth#27504),
[#27545](paradigmxyz/reth#27545),
[#27549](paradigmxyz/reth#27549),
[#27550](paradigmxyz/reth#27550),
[#27551](paradigmxyz/reth#27551),
[#27552](paradigmxyz/reth#27552),
[#27553](paradigmxyz/reth#27553),
[#27554](paradigmxyz/reth#27554),
[#27556](paradigmxyz/reth#27556),
[#27557](paradigmxyz/reth#27557),
[#27559](paradigmxyz/reth#27559),
[#27562](paradigmxyz/reth#27562),
[#27563](paradigmxyz/reth#27563),
[#27564](paradigmxyz/reth#27564),
[#27565](paradigmxyz/reth#27565),
[#27567](paradigmxyz/reth#27567),
[#27568](paradigmxyz/reth#27568),
[#27516](paradigmxyz/reth#27516),
[#27517](paradigmxyz/reth#27517)).
- Dropped redundant RLP length checks
([#27547](paradigmxyz/reth#27547)).
- Replaced `cfg-if` with `cfg_select`
([#27577](paradigmxyz/reth#27577)).
- Made codec crates build standalone
([#27546](paradigmxyz/reth#27546)).

**Testing**
- Added e2e helpers:
- Control the next payload timestamp
([#27596](paradigmxyz/reth#27596)).
- Wait for the pool to process a new head
([#27597](paradigmxyz/reth#27597)).
- `import_payload`
([#27599](paradigmxyz/reth#27599)).
- Advance-until helpers
([#27598](paradigmxyz/reth#27598)).
- Made e2e tests less timing-dependent: fixed sleeps became pool waits,
stale notifications are skipped, and RocksDB pruning tests wait for the
pruner ([#27500](paradigmxyz/reth#27500),
[#27583](paradigmxyz/reth#27583),
[#27601](paradigmxyz/reth#27601)).
- ef-tests now run and validate Amsterdam block access list fixtures and
build the genesis trie before block 1
([#27607](paradigmxyz/reth#27607),
[#27571](paradigmxyz/reth#27571)).
- Covered a disk reorg with a partial state trie
([#27578](paradigmxyz/reth#27578)).
- Fixed flaky or nondeterministic tests in ethstats, bsc, txpool and net
([#27533](paradigmxyz/reth#27533),
[#27534](paradigmxyz/reth#27534),
[#27531](paradigmxyz/reth#27531),
[#27532](paradigmxyz/reth#27532),
[#27494](paradigmxyz/reth#27494)).
- Test code now uses existing helpers and constants instead of
hand-written equivalents
([#27508](paradigmxyz/reth#27508),
[#27515](paradigmxyz/reth#27515),
[#27518](paradigmxyz/reth#27518),
[#27548](paradigmxyz/reth#27548),
[#27555](paradigmxyz/reth#27555),
[#27560](paradigmxyz/reth#27560),
[#27561](paradigmxyz/reth#27561),
[#27572](paradigmxyz/reth#27572)).

**Release / Deps**
- Released 2.7.0
([#27489](paradigmxyz/reth#27489)).
- Bumped base64 to 0.23.1
([#27486](paradigmxyz/reth#27486)).
- Dependabot can now update indirect Cargo dependencies
([#27585](paradigmxyz/reth#27585)).

## Migrations

🔗 Amp thread:
https://ampcode.com/threads/T-01a0f577-c5c4-728b-aaa4-f65c61dd63a8
- Bumped all git-pinned `reth-*` dependencies in `Cargo.toml` from rev
`5723a3f` to `5b68630` to track a newer upstream reth commit.
- Updated `reth-revm` to the same rev. Its `std` and `optional-checks`
features stay the same.
- Left the crates.io-versioned `reth-codecs` and
`reth-primitives-traits` at `0.8.1`.
- Kept every crate's feature flags and `default-features = false`
settings as they were. The diff contains no source-code API migrations.

[GitHub
Workflow](https://github.com/tempoxyz/tempo/actions/runs/36809326198)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rpc Related to the RPC implementation M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants