feat(rpc): add admin_setBlockProcessingPaused to pause/resume block processing#12016
feat(rpc): add admin_setBlockProcessingPaused to pause/resume block processing#120160xDevNinja wants to merge 3 commits into
Conversation
…rocessing Adds the ability to pause and resume local block processing on a running node, which is useful for testing and diagnostics (e.g. letting blocks accumulate in the processing queue and then draining them on demand). - BlockchainProcessor gains PauseProcessing/ResumeProcessing and an IsProcessingPaused flag (exposed via IBlockProcessingQueue). While paused, the processing loop parks after a block becomes available but before it is dequeued, so suggested blocks keep accumulating in the queue until processing is resumed. StopAsync resumes first so shutdown cannot deadlock on a paused processor. - New admin_setBlockProcessingPaused(bool) JSON-RPC method toggles the state and returns whether processing is paused after the call. Closes NethermindEth#9914
|
Claude finished @svlachakis's task in 4m 35s —— View job Code Review
SummaryThe implementation is generally clean. The Two medium findings should be addressed before merge: FindingsMedium
Low
What looks good
|
- Per-block pause granularity: re-check pause before each dequeue in ProcessBlocks so a mid-drain pause takes effect at the next block boundary instead of after the whole batch drains. - Non-breaking interface change: default implementations on IBlockProcessingQueue (throw NotSupportedException / false) so external implementers keep compiling. - Suppress the "Block processing resumed." log when ResumeProcessing runs from StopAsync (internal shutdown unblock, not an operator action); the pause log now fires only on the real transition (idempotency). - Tests: replace the Thread.Sleep(500) negative assertion with a bounded wait on the new-head signal that must not fire; consolidate ThenBecomesNewHead/BecomesNewHead into a shared WaitForHead helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@claude review again |
|
Claude finished @svlachakis's task in 4m 53s —— View job Code Review (re-review)
Previous Findings — All Addressed ✅The fix commit
New-Pass FindingsNo new Critical, High, or Medium issues found. A few observations worth noting for completeness: DI wiring verified: Correctness of the per-block pause check: Shutdown deadlock prevention:
SummaryAll five findings from the first review have been addressed cleanly and correctly. The implementation is correct, the tests are sound, and the DI wiring is verified. This PR is ready to merge. |
|
I'm not sure that's correct and in the best shape possible, will dig a bit into it |

Closes #9914
Changes
BlockchainProcessornow exposesPauseProcessing(),ResumeProcessing()and anIsProcessingPausedflag viaIBlockProcessingQueue. While paused, the processing loop parks after a block becomes available but before it is dequeued, so suggested blocks keep accumulating in the queue until processing is resumed.StopAsyncresumes first so shutdown cannot deadlock on a paused processor.admin_setBlockProcessingPaused(bool paused)JSON-RPC method, which toggles the state and returns whether processing is paused after the call.This enables the scenario from the issue: keep the EL online and responding while paused, stack blocks in the processing queue, then resume to process the backlog.
Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
BlockchainProcessorTests.Can_pause_and_resume_block_processingdrives the real processor: after pausing, a fully-allowed block is enqueued and verified to remain unprocessed (the mock branch processor records a hash the moment it starts, so an empty entry proves the parked loop never dispatched it), then resuming processes it and it becomes the new head. Verified the test fails if the pause park is removed.AdminModuleTests.Admin_setBlockProcessingPaused_delegates_to_processing_queueverifies the RPC method delegates toPauseProcessing/ResumeProcessingand returns the resulting state.BlockchainProcessorTests(21) andAdminModuleTests(48) fixtures pass.Documentation
Requires documentation update
The new
admin_setBlockProcessingPausedmethod should be added to the admin JSON-RPC namespace docs. The[JsonRpcMethod]description/examples are included on the interface so the generated reference is populated.Requires explanation in Release Notes