Skip to content

PIBD peers fix#3823

Open
ardocrat wants to merge 12 commits into
mimblewimble:stagingfrom
ardocrat:pibd_peers_fix
Open

PIBD peers fix#3823
ardocrat wants to merge 12 commits into
mimblewimble:stagingfrom
ardocrat:pibd_peers_fix

Conversation

@ardocrat
Copy link
Copy Markdown
Contributor

@ardocrat ardocrat commented Mar 30, 2026

  • choose peers based on minimal height (minimal 2 blocks behind max tip)

  • temporary block peers for stale segments disconnecting only outbound:

    • 1st time for 1 min.,
    • 2nd time for 3 min.,
    • 3rd time for 10min.,

    (Actual only for inbound, outbound resetting counter after reconnect)

  • force request for output and rangeproof segments to avoid stuck

  • do not check for max cached segments on selecting next desired segment for request (stuck happened when peer got disconnected and we reached max segments cache size, so not tried to make another request).

@syntaxjak
Copy link
Copy Markdown

IMG_5687

@wiesche89 wiesche89 changed the base branch from master to staging May 12, 2026 17:58
Copy link
Copy Markdown
Contributor

@wiesche89 wiesche89 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. I found three points that I think should be checked before merging.

Comment thread chain/src/txhashset/desegmenter.rs Outdated
Comment thread p2p/src/peers.rs Outdated
Comment thread servers/src/grin/sync/state_sync.rs
Comment thread servers/src/grin/sync/state_sync.rs
Comment thread servers/src/grin/sync/state_sync.rs Outdated
Comment thread servers/src/grin/sync/state_sync.rs Outdated
Comment thread chain/src/types.rs
}

/// Drop all tracked PIBD requests, returning how many entries were removed.
pub fn clear_pibd_requests(&self) -> usize {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Currently, pending PIBD requests are cleared, which means the node loses the mapping of which segments are currently expected from which peers.

I have effectively fixed this in my branch: pending PIBD requests are no longer cleared globally. Instead, retryable segments are reconsidered via retryable_pibd_segments(), and when they are requested again, the existing request state is updated via refresh_pibd_segment().

So the question is whether we should wait for my change here, or handle this separately in a new PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

lets wait your change here I guess

let mut elems_added = 0;
if let Some(mut next_output_idx) = self.next_required_output_segment_index() {
while (next_output_idx as usize) < total_output_segments {
if elems_added == max_elements / 3 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I intentionally kept the max_cached_segments checks in place. This prevents creating additional normal requests for output, rangeproof, and kernel segments once the respective segment cache is full.
That avoids requesting too many extra segments under bad peer ordering or malicious peers, which would otherwise increase retry pressure.
Only the next required kernel is still explicitly forced, to avoid the known PIBD stall case.

wiesche89 added a commit to wiesche89/grin that referenced this pull request May 15, 2026
- force request of next required output/rangeproof/kernel segments
- add PIBD peer height slack filtering
- temporarily block peers after PIBD segment timeouts
- disconnect timed-out outbound PIBD peers
- use escalating temporary block durations
- keep existing retry/refresh logic instead of clearing pending requests
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.

3 participants