Skip to content

fix: resolve some p2p peer related issues#344

Merged
will-2012 merged 15 commits into
developfrom
debug-p2p
May 12, 2026
Merged

fix: resolve some p2p peer related issues#344
will-2012 merged 15 commits into
developfrom
debug-p2p

Conversation

@will-2012
Copy link
Copy Markdown
Contributor

@will-2012 will-2012 commented May 6, 2026

Description

Resolved p2p peer related issues to enhance stability.

Rationale

BSC network experiences frequent P2P peer disconnection issues that affect network stability. Main causes and solutions:

  1. Adjust P2P configs to align with geth-bsc - ensure ban/reputation mechanisms are compatible, avoid incorrect peer banning

  2. Optimize GetBlocksByRange logic - improve request success rate, avoid to be resetted by peer

  3. Fix vote pool memory leak - Add force pruning mechanism to prevent vote messages from becoming too large during stage sync and being rejected by peers

  4. Optimize logs and code - Lower warn log levels, clean up dead code, improve troubleshooting efficiency

These changes work together to solve reth-bsc's P2P stability issues and ensure good compatibility with the BSC network.

Changes

Notable changes:

  • P2P reputation alignment: Adjust ban/reputation mechanisms to match geth-bsc behavior, reduce false positive peer bans
  • GetBlocksByRange optimization: Improve peer selection logic - prefer v2 peers, avoid routing to incompatible peers
  • Vote pool memory fix: Add force pruning when pool exceeds 65536 votes to prevent oversized sync messages
  • Fork recovery improvements: Better error handling and cursor management for block discovery
  • Network protocol enhancements: Improved BSC protocol handler with better peer version tracking

Potential Impacts

  • Improved P2P network stability and reduced peer disconnections
  • Better compatibility with geth-bsc network behavior
  • Reduced memory usage during stage sync
  • Lower log noise and improved debugging experience

@will-2012 will-2012 requested a review from joey0612 as a code owner May 6, 2026 10:06
@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 6, 2026

Pull Request Review

This PR primarily updates the pinned reth dependency revision across the workspace (main crate and testing/bsc-ef-tests) from ed59a0... to 10a1e0..., likely to pick up upstream networking/debug behavior. It also adds richer P2P observability: a new peer_dump module that periodically logs peer state, ban/backoff snapshots, and recent network events, configurable via BSC_PEER_DIAG_PERIOD_SECS. Additionally, block import logging was enhanced to emit detailed debug/info context on new_payload errors and stale-block reputation penalties.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 7, 2026

Pull Request Review

This PR primarily updates the reth dependency revision across the workspace from ed59a0... to cf95f9... in both root and test Cargo manifests. It also adds substantial P2P diagnostics and observability: new peer diagnostic task (peer_dump.rs), additional handshake warning logs, and extra block import logging around stale blocks and payload errors. Overall, the changes are focused on debugging/operations visibility rather than functional protocol changes.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 7, 2026

Pull Request Review

This PR updates the project’s reth dependency set to a new git revision (cf95f9...) across both the main crate and the EF test crate, likely to pick up networking/debug-related upstream changes. It also adds substantial P2P observability improvements: richer handshake error logging, stale-block penalty visibility, far-ahead block routing diagnostics, and a new periodic peer diagnostic module (peer_dump.rs) that reports peers, bans/backoff state, and recent network events at INFO level. Overall, the change is primarily operational/debug instrumentation plus dependency revision alignment.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 9, 2026

Pull Request Review

This PR mainly updates the reth dependency pin across the workspace to a newer upstream commit and adds substantial P2P/debug-oriented networking changes in the BSC node stack. It refactors fork recovery to separate fetch start from FCU target (RecoverTarget), improves range-request peer selection to be version-aware (bsc/2 only), and adds announcer-aware failover logic plus extensive unit tests. It also introduces a new periodic peer diagnostics module (peer_dump.rs) and enhances handshake and block-import logging for troubleshooting peer churn and protocol issues.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 9, 2026

Pull Request Review

This PR is a Rust/web3 (BSC execution client networking) update focused on P2P stability and fork-recovery behavior. It refactors fork recovery to separate fetch start from FCU target (RecoverTarget), adds stricter FCU header resolution/validation, introduces bsc/1 vs bsc/2-aware peer selection for range requests, and adds announcer-based failover routing plus extensive unit tests. It also adjusts handshake/disconnect behavior, applies peer reputation/ban tuning overrides, adds periodic peer diagnostics logging, and bumps all reth git dependencies to a newer pinned revision.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 9, 2026

Pull Request Review

This PR primarily updates the reth dependency set to a newer pinned git revision across the workspace and test crate, while introducing substantial P2P/debug hardening in the BSC networking stack. It refactors fork recovery by introducing RecoverTarget (separating fetch start from FCU target), improves v2-only peer selection/failover for GetBlocksByRange, and adds announcer tracking plus extensive unit tests around these flows. It also adds a new periodic peer diagnostics module (peer_dump.rs), adjusts handshake/disconnect behavior for upgrade-status decode failures, and applies peer reputation/session stability overrides intended to reduce aggressive banning under BSC mainnet conditions.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 9, 2026

Pull Request Review

This PR primarily updates the project to a newer pinned reth revision (cf95f...) across root and test manifests, while adding substantial BSC P2P/debug and fork-recovery robustness changes. It introduces version-aware BSC peer registry logic (distinguishing bsc/1 vs bsc/2), announcer-aware failover for GetBlocksByRange, and a new periodic peer diagnostics task that logs connection/reputation/ban/backoff state. It also refactors fork recovery to separate fetch-start vs FCU target (RecoverTarget), improves handshake/disconnect behavior and observability, and adds extensive unit tests around these paths.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 9, 2026

Pull Request Review

This PR primarily upgrades the pinned bnb-chain/reth dependency revision across the workspace and test crate, while introducing substantial BSC P2P/debug/stability changes in networking, fork recovery, and vote handling. It refactors fork recovery to separate fetch-start and FCU-target semantics (RecoverTarget), adds bsc/1 vs bsc/2-aware peer registry/failover routing, and introduces periodic peer diagnostics logging with new runtime tuning overrides for peer reputation/session behavior. It also moves vote-pool pruning to lazy prune-on-ingest and adds multiple tests around failover/versioning and FCU header resolution paths.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 12, 2026

Pull Request Review

This PR is a Rust (web3 client/networking) maintenance and stability update that primarily refactors BSC P2P behavior, fork recovery flow, and vote-pool pruning while also bumping a large set of dependencies in Cargo.lock. It introduces version-aware BSC peer registry handling (bsc/1 vs bsc/2), announcer-aware failover for GetBlocksByRange, and a new RecoverTarget model to separate recovery fetch start from FCU target to mitigate broadcast-before-commit race conditions. It also moves vote pruning to lazy, head-advance-triggered pruning in put_vote, adds extensive tests, and relaxes handshake/disconnect behavior and peer reputation/session tuning for improved network resilience.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 12, 2026

Pull Request Review

This PR primarily introduces P2P robustness and fork-recovery hardening for a Rust-based BSC node, while also updating a large set of dependencies in Cargo.lock. It refactors fork recovery to separate fetch-start and FCU-target semantics (RecoverTarget), adds bsc protocol version-awareness (v1/v2) with safer GetBlocksByRange peer selection/failover, and moves vote-pool pruning to lazy in-band pruning on vote ingest. It also adjusts handshake/disconnect behavior and peer stability settings to reduce overly aggressive penalties and improve network resilience under mainnet conditions.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 12, 2026

Pull Request Review

This PR is a Rust/BSC node networking and consensus maintenance update that primarily improves p2p resiliency, fork-recovery behavior, and vote-pool memory safety while also refreshing a large set of dependencies in Cargo.lock. It introduces version-aware BSC peer registry logic (bsc/1 vs bsc/2), announcer-aware failover selection for GetBlocksByRange, and a new RecoverTarget flow to decouple fork-discovery start point from FCU target to better handle broadcast-before-commit races. It also adds lazy/forced vote-pool pruning to prevent oversized vote sync packets and tunes network reputation/timeout settings to reduce aggressive peer bans under BSC mainnet conditions.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@will-2012 will-2012 changed the title chore: add more for debug p2p fix: resolve p2p peer related issues May 12, 2026
@will-2012 will-2012 changed the title fix: resolve p2p peer related issues fix: resolve some p2p peer related issues May 12, 2026
@will-2012 will-2012 marked this pull request as ready for review May 12, 2026 02:24
@will-2012 will-2012 added the R4R label May 12, 2026
joey0612
joey0612 previously approved these changes May 12, 2026
@hashdit-bot
Copy link
Copy Markdown

hashdit-bot Bot commented May 12, 2026

Pull Request Review

This PR focuses on BSC P2P stability and compatibility by refactoring peer/version handling, improving fork recovery flow, and hardening vote-pool memory behavior. It introduces version-aware BSC peer registry logic (bsc/1 vs bsc/2), announcer-aware failover for GetBlocksByRange, and a new RecoverTarget model that separates recovery fetch start from FCU target to better handle broadcast-before-commit races. It also removes explicit miner-triggered vote pruning in favor of lazy/forced pruning during vote ingestion, alongside broad dependency updates in Cargo.lock.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@will-2012 will-2012 merged commit a133c6c into develop May 12, 2026
8 checks passed
chee-chyuan pushed a commit that referenced this pull request May 21, 2026
* chore: add more for debug p2p

* chore: add more logs

* chore: avoid fetch newest block by newblock which result in failed fetch and p2p reset

* chore: avoid fetch unnecessary newest block

* chore: request_blocks_by_range only by v2 peer

* chore: fetch block prefer announce peer

* chore: make reth-bsc peer-manager similar to geth-bsc

* chore: try some p2p config

* chore: update peer config

* fix: fix forward vote bug which too large msg

* chore: restore reth deps

* chore: remove temp peer dump

* chore: remove useless codes

* chore: add force prune vote when stage sync

* chore: update some trivals
@sysvm sysvm deleted the debug-p2p branch May 22, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants