Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3796bbe
add PIHD sync and harden PIBD segment handling
wiesche89 May 16, 2026
e087c97
Remove unrelated DNS seed changes
wiesche89 May 18, 2026
aa14276
Improve PIHD header sync peer failure handling
wiesche89 May 18, 2026
ac368d1
sync: reuse peer on legacy headers
ardocrat May 19, 2026
c8f3d44
fix pihd sync stalls and peer recovery
wiesche89 May 20, 2026
4e04a3a
detect interrupted PIBD by local MMR progress
wiesche89 May 22, 2026
d0a001b
avoid reusing disconnected header sync peer
wiesche89 May 22, 2026
df0290f
startup recovery after interrupted sync
wiesche89 May 25, 2026
932efa3
Remove early PIBD retry and keep sync active
wiesche89 May 25, 2026
939de57
Merge branch 'mimblewimble:staging' into staging
wiesche89 May 26, 2026
a69ee90
p2p: count enough outbound peers based on peers_allow, connect only t…
ardocrat May 27, 2026
e743447
sync: select single syncing peer for headers when only at non-pihd, c…
ardocrat May 28, 2026
8f2ffcb
Merge branch 'mimblewimble:staging' into staging
wiesche89 Jun 1, 2026
ef74708
Merge branch 'mimblewimble:staging' into staging
wiesche89 Jun 2, 2026
a00bc08
merge mw staging into staging
wiesche89 Jun 11, 2026
c9ac543
pibd: do not check for cache size at next desired segments to avoid s…
ardocrat Jun 11, 2026
efe1477
retry dropped queued segments immediately
wiesche89 Jun 11, 2026
dcfee2f
pibd: increase segment timeout to 30s
ardocrat Jun 11, 2026
da4a447
request timeout, remove_pibd_segment_from
wiesche89 Jun 11, 2026
fe2da7e
pibd: trace log for waiting segment
ardocrat Jun 11, 2026
9d515ea
improve segment retry and progress handling
wiesche89 Jun 11, 2026
4f679e7
cleanup and rm performance progress logging
wiesche89 Jun 11, 2026
eecfd8c
merge staging into PR branch
wiesche89 Jun 12, 2026
27212dc
merge mimblewimble staging into PR branch
wiesche89 Jun 12, 2026
2ff4fff
Merge branch 'mimblewimble:staging' into staging
wiesche89 Jun 13, 2026
3dc4b7d
cleanup pibd segment handling and pihd params
wiesche89 Jun 14, 2026
c755d9e
dedup pibd timeout peers
wiesche89 Jun 14, 2026
c2b162a
handle invalid PIHD header segments
wiesche89 Jun 15, 2026
cf6d559
block invalid pihd header segment peers
wiesche89 Jun 15, 2026
7d3bbd1
Merge mimblewimble staging into staging
wiesche89 Jun 19, 2026
1720dd4
Merge branch 'mimblewimble:staging' into staging
wiesche89 Jun 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions api/src/handlers/server_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use super::utils::w;
use crate::chain::{Chain, SyncState, SyncStatus};
use crate::chain::{Chain, HeaderSyncMode, SyncState, SyncStatus};
use crate::p2p;
use crate::rest::*;
use crate::router::{Handler, ResponseFuture};
Expand Down Expand Up @@ -81,11 +81,19 @@ fn sync_status_to_api(sync_status: SyncStatus) -> (String, Option<serde_json::Va
SyncStatus::AwaitingPeers(_) => ("awaiting_peers".to_string(), None),
SyncStatus::HeaderSync {
sync_head,
sync_mode,
highest_height,
..
} => (
"header_sync".to_string(),
Some(json!({ "current_height": sync_head.height, "highest_height": highest_height })),
Some(json!({
"current_height": sync_head.height,
"highest_height": highest_height,
"header_sync_type": match sync_mode {
HeaderSyncMode::Legacy => "legacy",
HeaderSyncMode::Pihd => "pihd",
}
})),
),
SyncStatus::TxHashsetPibd {
aborted,
Expand Down Expand Up @@ -149,7 +157,5 @@ fn sync_status_to_api(sync_status: SyncStatus) -> (String, Option<serde_json::Va
Some(json!({ "current_height": current_height, "highest_height": highest_height })),
),
SyncStatus::Shutdown => ("shutdown".to_string(), None),
// any other status is considered syncing (should be unreachable)
_ => ("syncing".to_string(), None),
}
}
8 changes: 8 additions & 0 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,9 +1739,17 @@ fn setup_head(
let head = batch.get_block_header(&head.last_block_h)?;
let pibd_tip = store.pibd_head()?;
let pibd_head = batch.get_block_header(&pibd_tip.last_block_h)?;
let pibd_mmr_in_progress = !resetting_pibd
&& pibd_head.height >= head.height
&& (txhashset.output_mmr_size() > head.output_mmr_size
|| txhashset.rangeproof_mmr_size() > head.output_mmr_size
|| txhashset.kernel_mmr_size() > head.kernel_mmr_size);
if pibd_head.height > head.height && !resetting_pibd {
pibd_in_progress = true;
pibd_head
} else if pibd_mmr_in_progress {
pibd_in_progress = true;
head
} else {
head
}
Expand Down
5 changes: 3 additions & 2 deletions chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ mod chain;
mod error;
pub mod linked_list;
pub mod pibd_params;
pub mod pihd_params;
pub mod pipe;
pub mod store;
pub mod txhashset;
Expand All @@ -50,6 +51,6 @@ pub use crate::chain::{Chain, MAX_ORPHAN_SIZE};
pub use crate::error::Error;
pub use crate::store::ChainStore;
pub use crate::types::{
BlockStatus, ChainAdapter, Options, SyncState, SyncStatus, Tip, TxHashsetDownloadStats,
TxHashsetWriteStatus,
BlockStatus, ChainAdapter, HeaderSyncMode, Options, SyncState, SyncStatus, Tip,
TxHashsetDownloadStats, TxHashsetWriteStatus,
};
12 changes: 6 additions & 6 deletions chain/src/pibd_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ pub const RANGEPROOF_SEGMENT_HEIGHT: u8 = 11;
/// Kernel segment height assumed for requests and segment calculation
pub const KERNEL_SEGMENT_HEIGHT: u8 = 11;

/// Maximum number of received segments to cache (across all trees) before we stop requesting others
pub const MAX_CACHED_SEGMENTS: usize = 15;
/// Maximum cached segment threshold used when dropping stale segment cache entries.
pub const MAX_CACHED_SEGMENTS: usize = 30;

/// Number of segments to apply in a single LMDB transaction
pub const SEGMENT_APPLY_BATCH_SIZE: usize = 4;
pub const SEGMENT_APPLY_BATCH_SIZE: usize = 12;

/// How long the state sync should wait after requesting a segment from a peer before
/// deciding the segment isn't going to arrive. The syncer will then re-request the segment
pub const SEGMENT_REQUEST_TIMEOUT_SECS: i64 = 20;
pub const SEGMENT_REQUEST_TIMEOUT_SECS: i64 = 30;

/// Number of simultaneous requests for segments we should make. Note this is currently
/// divisible by 3 to try and evenly spread requests amount the 3 main MMRs (Bitmap segments
/// will always be requested first)
pub const SEGMENT_REQUEST_COUNT: usize = 15;
pub const SEGMENT_REQUEST_COUNT: usize = 9;

/// How many blocks behind the tip a PIBD peer may be and still be considered usable.
pub const PIBD_PEER_HEIGHT_SLACK_BLOCKS: u64 = 2;
pub const SYNC_PEER_HEIGHT_SLACK_BLOCKS: u64 = 2;

/// If the syncer hasn't seen a max work peer that supports PIBD in this number of seconds
/// give up and revert back to the txhashset.zip download method
Expand Down
41 changes: 41 additions & 0 deletions chain/src/pihd_params.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2026 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Static definitions for PIHD sync parameters
//! Note these are for experimentation via compilation, not meant to be exposed as
//! configuration parameters anywhere

/// Maximum number of in-flight header segment requests.
pub const MAX_IN_FLIGHT_SEGMENTS: usize = 8;

/// Maximum number of header segment requests to send per sync tick.
pub const MAX_REQUESTS_PER_TICK: usize = 8;

/// Maximum number of in-flight header segment requests per peer.
pub const MAX_IN_FLIGHT_SEGMENTS_PER_PEER: usize = 2;

/// Number of seconds before treating a PIHD or legacy header request as timed out.
pub const HEADER_REQUEST_TIMEOUT_SECS: i64 = 10;

/// Number of timeouts before falling back temporarily.
pub const MAX_TIMED_OUT_SEGMENTS: usize = 3;

/// Number of seconds PIHD is disabled after repeated timeout stalls.
pub const DISABLE_SECS: i64 = 120;

/// Number of seconds before retrying a peer after a timed-out PIHD request.
pub const PEER_TIMEOUT_COOLDOWN_SECS: i64 = 30;

/// Number of seconds PIHD may stall before falling back to legacy header sync.
pub const STALL_FALLBACK_SECS: i64 = 120;
Loading
Loading