mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 11:22:56 +00:00
Implement reliable range sync for PeerDAS
This commit is contained in:
@@ -59,6 +59,14 @@ pub struct BlobsByRangeRequestId {
|
||||
pub struct DataColumnsByRangeRequestId {
|
||||
/// Id to identify this attempt at a data_columns_by_range request for `parent_request_id`
|
||||
pub id: Id,
|
||||
/// The Id of the parent custody by range request that issued this data_columns_by_range request
|
||||
pub parent_request_id: CustodyByRangeRequestId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
pub struct CustodyByRangeRequestId {
|
||||
/// Id to identify this attempt at a meta custody by range request for `parent_request_id`
|
||||
pub id: Id,
|
||||
/// The Id of the overall By Range request for block components.
|
||||
pub parent_request_id: ComponentsByRangeRequestId,
|
||||
}
|
||||
@@ -221,6 +229,7 @@ macro_rules! impl_display {
|
||||
impl_display!(BlocksByRangeRequestId, "{}/{}", id, parent_request_id);
|
||||
impl_display!(BlobsByRangeRequestId, "{}/{}", id, parent_request_id);
|
||||
impl_display!(DataColumnsByRangeRequestId, "{}/{}", id, parent_request_id);
|
||||
impl_display!(CustodyByRangeRequestId, "{}/{}", id, parent_request_id);
|
||||
impl_display!(ComponentsByRangeRequestId, "{}/{}", id, requester);
|
||||
impl_display!(DataColumnsByRootRequestId, "{}/{}", id, requester);
|
||||
impl_display!(SingleLookupReqId, "{}/Lookup/{}", req_id, lookup_id);
|
||||
@@ -299,14 +308,17 @@ mod tests {
|
||||
fn display_id_data_columns_by_range() {
|
||||
let id = DataColumnsByRangeRequestId {
|
||||
id: 123,
|
||||
parent_request_id: ComponentsByRangeRequestId {
|
||||
parent_request_id: CustodyByRangeRequestId {
|
||||
id: 122,
|
||||
requester: RangeRequestId::RangeSync {
|
||||
chain_id: 54,
|
||||
batch_id: Epoch::new(0),
|
||||
parent_request_id: ComponentsByRangeRequestId {
|
||||
id: 121,
|
||||
requester: RangeRequestId::RangeSync {
|
||||
chain_id: 54,
|
||||
batch_id: Epoch::new(0),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
assert_eq!(format!("{id}"), "123/122/RangeSync/0/54");
|
||||
assert_eq!(format!("{id}"), "123/122/121/RangeSync/0/54");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,6 +245,25 @@ impl<E: EthSpec> NetworkGlobals<E> {
|
||||
Self::new_test_globals_with_metadata(trusted_peers, metadata, config, spec)
|
||||
}
|
||||
|
||||
pub fn new_test_globals_as_supernode(
|
||||
trusted_peers: Vec<PeerId>,
|
||||
config: Arc<NetworkConfig>,
|
||||
spec: Arc<ChainSpec>,
|
||||
is_supernode: bool,
|
||||
) -> NetworkGlobals<E> {
|
||||
let metadata = MetaData::V3(MetaDataV3 {
|
||||
seq_number: 0,
|
||||
attnets: Default::default(),
|
||||
syncnets: Default::default(),
|
||||
custody_group_count: if is_supernode {
|
||||
spec.number_of_custody_groups
|
||||
} else {
|
||||
spec.custody_requirement
|
||||
},
|
||||
});
|
||||
Self::new_test_globals_with_metadata(trusted_peers, metadata, config, spec)
|
||||
}
|
||||
|
||||
pub(crate) fn new_test_globals_with_metadata(
|
||||
trusted_peers: Vec<PeerId>,
|
||||
metadata: MetaData<E>,
|
||||
|
||||
Reference in New Issue
Block a user