Skip to content

Conversation

jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Jun 20, 2025

If Geth is engaged in a long-run block synchronization, such as a full syncing over a large number of blocks, invoking debug_setHead will cause downloader.Cancel to wait for all fetchers to stop first.
This can be time-consuming, particularly for the block processing thread.
To address this, we manually call blockchain.StopInsert to interrupt the blocking processing thread and allow it to exit immediately, and after that call blockchain.ResumeInsert to resume the block downloading process.

Additionally, we add a sanity check for the input block number of debug_setHead to ensure its validity.

@rjl493456442 rjl493456442 self-assigned this Jun 20, 2025
@rjl493456442 rjl493456442 added this to the 1.15.12 milestone Jun 23, 2025
@rjl493456442 rjl493456442 merged commit 78b6059 into ethereum:master Jun 23, 2025
3 of 4 checks passed
@jsvisa jsvisa deleted the debug-setHead branch June 23, 2025 12:11
howjmay pushed a commit to iotaledger/go-ethereum that referenced this pull request Aug 27, 2025
…thereum#32067)

If Geth is engaged in a long-run block synchronization, such as a full
syncing over a large number of blocks, invoking `debug_setHead` will
cause `downloader.Cancel` to wait for all fetchers to stop first.
This can be time-consuming, particularly for the block processing
thread.

To address this, we manually call `blockchain.StopInsert` to interrupt
the blocking processing thread and allow it to exit immediately, and
after that call `blockchain.ResumeInsert` to resume the block
downloading process.

Additionally, we add a sanity check for the input block number of
`debug_setHead` to ensure its validity.

---------

Signed-off-by: jsvisa <[email protected]>
Co-authored-by: Gary Rong <[email protected]>
gballet pushed a commit to gballet/go-ethereum that referenced this pull request Sep 11, 2025
…thereum#32067)

If Geth is engaged in a long-run block synchronization, such as a full
syncing over a large number of blocks, invoking `debug_setHead` will
cause `downloader.Cancel` to wait for all fetchers to stop first.
This can be time-consuming, particularly for the block processing
thread.

To address this, we manually call `blockchain.StopInsert` to interrupt
the blocking processing thread and allow it to exit immediately, and
after that call `blockchain.ResumeInsert` to resume the block
downloading process.

Additionally, we add a sanity check for the input block number of
`debug_setHead` to ensure its validity.

---------

Signed-off-by: jsvisa <[email protected]>
Co-authored-by: Gary Rong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants