-
Notifications
You must be signed in to change notification settings - Fork 745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custody by root request to sync #6275
Changes from all commits
f2abdd4
01e897b
cc92d31
6707b24
63555dc
5be3755
052845a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
//! A collection of variables that are accessible outside of the network thread itself. | ||
use crate::discovery::enr::Eth2Enr; | ||
use crate::peer_manager::peerdb::PeerDB; | ||
use crate::rpc::{MetaData, MetaDataV2}; | ||
use crate::types::{BackFillState, SyncState}; | ||
|
@@ -7,7 +8,9 @@ use crate::EnrExt; | |
use crate::{Enr, GossipTopic, Multiaddr, PeerId}; | ||
use parking_lot::RwLock; | ||
use std::collections::HashSet; | ||
use types::{ChainSpec, ColumnIndex, EthSpec}; | ||
use types::{ChainSpec, ColumnIndex, DataColumnSubnetId, EthSpec}; | ||
|
||
use super::Subnet; | ||
|
||
pub struct NetworkGlobals<E: EthSpec> { | ||
/// The current local ENR. | ||
|
@@ -111,10 +114,32 @@ impl<E: EthSpec> NetworkGlobals<E> { | |
} | ||
|
||
/// Compute custody data columns the node is assigned to custody. | ||
pub fn custody_columns(&self, _spec: &ChainSpec) -> Vec<ColumnIndex> { | ||
let _enr = self.local_enr(); | ||
//TODO(das): implement ENR changes | ||
vec![] | ||
pub fn custody_columns(&self, spec: &ChainSpec) -> Vec<ColumnIndex> { | ||
let enr = self.local_enr(); | ||
let node_id = enr.node_id().raw().into(); | ||
let custody_subnet_count = enr.custody_subnet_count::<E>(spec); | ||
DataColumnSubnetId::compute_custody_columns::<E>(node_id, custody_subnet_count, spec) | ||
.collect() | ||
} | ||
|
||
/// Returns a connected peer that: | ||
/// 1. is connected | ||
/// 2. assigned to custody the column based on it's `custody_subnet_count` from metadata (WIP) | ||
/// 3. has a good score | ||
/// 4. subscribed to the specified column - this condition can be removed later, so we can | ||
/// identify and penalise peers that are supposed to custody the column. | ||
pub fn custody_peers_for_column( | ||
&self, | ||
column_index: ColumnIndex, | ||
spec: &ChainSpec, | ||
) -> Vec<PeerId> { | ||
self.peers | ||
.read() | ||
.good_peers_on_subnet(Subnet::DataColumn( | ||
DataColumnSubnetId::from_column_index::<E>(column_index as usize, spec), | ||
)) | ||
.cloned() | ||
.collect::<Vec<_>>() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not take the latest change from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also happy if you'd like to change how it works on the |
||
} | ||
|
||
/// TESTING ONLY. Build a dummy NetworkGlobals instance. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is all this change required? Why not just take the latest change from
das
branch? The change in #6218 fixes the custody lookup tests.