Skip to content

fix(eth/bft): avoid broadcast send blocking during shutdown#2355

Open
gzliudan wants to merge 2 commits into
XinFinOrg:dev-upgradefrom
gzliudan:fix-node-stop
Open

fix(eth/bft): avoid broadcast send blocking during shutdown#2355
gzliudan wants to merge 2 commits into
XinFinOrg:dev-upgradefrom
gzliudan:fix-node-stop

Conversation

@gzliudan
Copy link
Copy Markdown
Collaborator

Proposed changes

Guard BFT broadcast enqueue with the quit channel so Vote/Timeout/SyncInfo exit cleanly once shutdown starts.

Add a regression test to ensure Vote returns after BFT loop stop and does not hang.

log messages when stop node without this PR:

INFO [05-21|13:01:19.273] [getTCEpochInfo] Init epochInfo          number=82,155,518 round=25893000   tcRound=25893274 tcEpoch=91913
INFO [05-21|13:01:19.273] [getTCEpochInfo] Final TC epochInfo      number=82,155,518 round=25893000   tcRound=25893274 tcEpoch=91913
INFO [05-21|13:01:19.273] Timeout pool threashold reached: true, number of items in the pool: 22
INFO [05-21|13:01:19.273] [setNewRound] new round and reset pools and workers round=25893275
INFO [05-21|13:01:19.273] [onTimeoutPoolThresholdReached] process TC successfully TcRound=25893274 NumberOfTcSig=22
INFO [05-21|13:01:19.348] [getTCEpochInfo] Init epochInfo          number=82,155,518 round=25893000   tcRound=25893275 tcEpoch=91913
INFO [05-21|13:01:19.349] [getTCEpochInfo] Final TC epochInfo      number=82,155,518 round=25893000   tcRound=25893275 tcEpoch=91913
INFO [05-21|13:01:19.353] Imported new chain segment               blocks=1   txs=0    mgas=0.000  elapsed=1.694ms       mgasps=0.000   number=82,155,770 hash=fa80d0..d8ffca dirty=0.00B
INFO [05-21|13:01:19.469] [voteHandler] Vote pool threashold reached: true, number of items in the pool: 22
INFO [05-21|13:01:19.470] [commitBlocks] Rounds not continuous(parent) found when committing block proposedBlockRound=25893275 decodedExtraField.Round=25893273 proposedBlockHeaderHash=fa80d0..d8ffca
INFO [05-21|13:01:19.470] [setNewRound] new round and reset pools and workers round=25893276
INFO [05-21|13:01:19.470] Successfully processed the vote and produced QC! QcRound=25893275 QcNumOfSig=22 QcHash=fa80d0..d8ffca QcNumber=82,155,770
INFO [05-21|13:01:19.470] [voteHandler] time cost from receive first vote under QC create elapsed=10.23727721s
INFO [05-21|13:01:19.821] Got interrupt, shutting down...
INFO [05-21|13:01:19.828] HTTP server stopped                      endpoint=[::]:8745
INFO [05-21|13:01:19.831] HTTP server stopped                      endpoint=[::]:9745
INFO [05-21|13:01:19.832] IPC endpoint closed                      url=/home/me/xdc_chain/testnet_1/XDC.ipc
INFO [05-21|13:01:19.833] Stopping Ethereum bloomIndexer start
INFO [05-21|13:01:19.833] Ethereum bloomIndexer stopped
INFO [05-21|13:01:19.833] Stopping Ethereum blockchain start
INFO [05-21|13:01:19.833] Blockchain manager stopped
INFO [05-21|13:01:19.833] Ethereum blockchain stopped
INFO [05-21|13:01:19.833] Stopping Ethereum protocolManager start
INFO [05-21|13:01:19.835] Stopping Ethereum protocol
WARN [05-21|13:01:19.839] BFT Loop Close
INFO [05-21|13:01:19.842] Ethereum protocol stopped
INFO [05-21|13:01:19.842] Ethereum protocolManager stopped
INFO [05-21|13:01:19.842] Stopping Ethereum txPool start
INFO [05-21|13:01:19.842] Transaction pool stopped
INFO [05-21|13:01:19.842] Ethereum txPool stopped
INFO [05-21|13:01:19.842] Stopping Ethereum shutdownChan start
INFO [05-21|13:01:19.842] Ethereum shutdownChan stopped
INFO [05-21|13:01:19.842] Stopping Ethereum miner start
INFO [05-21|13:01:19.842] Ethereum miner stopped
INFO [05-21|13:01:19.842] Stopping Ethereum eventMux start
INFO [05-21|13:01:19.842] Ethereum eventMux stopped
INFO [05-21|13:01:19.842] Stopping Ethereum chainDb start
INFO [05-21|13:01:20.308] Ethereum chainDb stopped
WARN [05-21|13:01:27.011] Propagated block verification failed     peer=386884ee0aa5383d number=82,154,346 hash=e14937..07a462 err="unknown ancestor"
WARN [05-21|13:02:43.000] Propagated block verification failed     peer=386884ee0aa5383d number=82,154,376 hash=11895e..23d420 err="unknown ancestor"
WARN [05-21|13:03:59.001] Propagated block verification failed     peer=386884ee0aa5383d number=82,154,406 hash=29cc51..857659 err="unknown ancestor"

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Changes that don't change source code or tests
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Revert something
  • style: Changes that do not affect the meaning of the code
  • test: Adding missing tests or correcting existing tests

Impacted Components

Which parts of the codebase does this PR touch?
Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Tested on a private network from the genesis block and monitored the chain operating correctly for multiple epochs.
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

gzliudan added 2 commits May 21, 2026 15:30
Guard BFT broadcast enqueue with the quit channel so Vote/Timeout/SyncInfo exit cleanly once shutdown starts.

Add a regression test to ensure Vote returns after BFT loop stop and does not hang.
Add regression tests to ensure Timeout and SyncInfo return promptly after BFT loop stop.

This complements the previous Vote shutdown regression and hardens shutdown race coverage.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cc40a980-abd2-47cf-a425-415d62e7e9ed

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant