mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
Resolve todo
This commit is contained in:
@@ -107,6 +107,8 @@ impl<E: EthSpec> NetworkGlobals<E> {
|
|||||||
*self.peer_id.read()
|
*self.peer_id.read()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Must keep consistency between the persisted `local_enr` and the return of this
|
||||||
|
// function. Otherwise peers may downscore us and the network will have issues.
|
||||||
pub fn local_metadata(&self) -> MetaData<E> {
|
pub fn local_metadata(&self) -> MetaData<E> {
|
||||||
let enr = self.local_enr();
|
let enr = self.local_enr();
|
||||||
let attnets = enr
|
let attnets = enr
|
||||||
@@ -155,7 +157,9 @@ impl<E: EthSpec> NetworkGlobals<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn public_custody_group_count(&self) -> u64 {
|
fn public_custody_group_count(&self) -> u64 {
|
||||||
todo!();
|
// TODO(das): delay announcing the public custody count for the duration of the pruning
|
||||||
|
// period
|
||||||
|
self.cgc_updates.read().at_slot(Slot::new(u64::MAX))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the custody group count (CGC)
|
/// Returns the custody group count (CGC)
|
||||||
@@ -253,19 +257,13 @@ impl<E: EthSpec> NetworkGlobals<E> {
|
|||||||
config: Arc<NetworkConfig>,
|
config: Arc<NetworkConfig>,
|
||||||
spec: Arc<ChainSpec>,
|
spec: Arc<ChainSpec>,
|
||||||
) -> NetworkGlobals<E> {
|
) -> NetworkGlobals<E> {
|
||||||
let metadata = MetaData::V3(MetaDataV3 {
|
let initial_cgc = spec.custody_requirement;
|
||||||
seq_number: 0,
|
Self::new_test_globals_with_initial_cgc(trusted_peers, initial_cgc, config, spec)
|
||||||
attnets: Default::default(),
|
|
||||||
syncnets: Default::default(),
|
|
||||||
custody_group_count: spec.custody_requirement,
|
|
||||||
});
|
|
||||||
Self::new_test_globals_with_metadata(trusted_peers, metadata, config, spec)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn new_test_globals_with_metadata(
|
pub(crate) fn new_test_globals_with_initial_cgc(
|
||||||
trusted_peers: Vec<PeerId>,
|
trusted_peers: Vec<PeerId>,
|
||||||
// TODO: todo! Apply to enr
|
initial_cgc: u64,
|
||||||
_metadata: MetaData<E>,
|
|
||||||
config: Arc<NetworkConfig>,
|
config: Arc<NetworkConfig>,
|
||||||
spec: Arc<ChainSpec>,
|
spec: Arc<ChainSpec>,
|
||||||
) -> NetworkGlobals<E> {
|
) -> NetworkGlobals<E> {
|
||||||
@@ -273,7 +271,7 @@ impl<E: EthSpec> NetworkGlobals<E> {
|
|||||||
let keypair = libp2p::identity::secp256k1::Keypair::generate();
|
let keypair = libp2p::identity::secp256k1::Keypair::generate();
|
||||||
let enr_key: discv5::enr::CombinedKey = discv5::enr::CombinedKey::from_secp256k1(&keypair);
|
let enr_key: discv5::enr::CombinedKey = discv5::enr::CombinedKey::from_secp256k1(&keypair);
|
||||||
let enr = discv5::enr::Enr::builder().build(&enr_key).unwrap();
|
let enr = discv5::enr::Enr::builder().build(&enr_key).unwrap();
|
||||||
let cgc_updates = CGCUpdates::new(spec.custody_requirement);
|
let cgc_updates = CGCUpdates::new(initial_cgc);
|
||||||
NetworkGlobals::new(enr, cgc_updates, trusted_peers, false, config, spec)
|
NetworkGlobals::new(enr, cgc_updates, trusted_peers, false, config, spec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,13 +314,12 @@ mod test {
|
|||||||
|
|
||||||
let custody_group_count = spec.number_of_custody_groups / 2;
|
let custody_group_count = spec.number_of_custody_groups / 2;
|
||||||
let subnet_sampling_size = spec.sampling_size(custody_group_count).unwrap();
|
let subnet_sampling_size = spec.sampling_size(custody_group_count).unwrap();
|
||||||
let metadata = get_metadata(custody_group_count);
|
|
||||||
let config = Arc::new(NetworkConfig::default());
|
let config = Arc::new(NetworkConfig::default());
|
||||||
let slot = Slot::new(0);
|
let slot = Slot::new(0);
|
||||||
|
|
||||||
let globals = NetworkGlobals::<E>::new_test_globals_with_metadata(
|
let globals = NetworkGlobals::<E>::new_test_globals_with_initial_cgc(
|
||||||
vec![],
|
vec![],
|
||||||
metadata,
|
custody_group_count,
|
||||||
config,
|
config,
|
||||||
Arc::new(spec),
|
Arc::new(spec),
|
||||||
);
|
);
|
||||||
@@ -340,13 +337,12 @@ mod test {
|
|||||||
|
|
||||||
let custody_group_count = spec.number_of_custody_groups / 2;
|
let custody_group_count = spec.number_of_custody_groups / 2;
|
||||||
let subnet_sampling_size = spec.sampling_size(custody_group_count).unwrap();
|
let subnet_sampling_size = spec.sampling_size(custody_group_count).unwrap();
|
||||||
let metadata = get_metadata(custody_group_count);
|
|
||||||
let config = Arc::new(NetworkConfig::default());
|
let config = Arc::new(NetworkConfig::default());
|
||||||
let slot = Slot::new(0);
|
let slot = Slot::new(0);
|
||||||
|
|
||||||
let globals = NetworkGlobals::<E>::new_test_globals_with_metadata(
|
let globals = NetworkGlobals::<E>::new_test_globals_with_initial_cgc(
|
||||||
vec![],
|
vec![],
|
||||||
metadata,
|
custody_group_count,
|
||||||
config,
|
config,
|
||||||
Arc::new(spec),
|
Arc::new(spec),
|
||||||
);
|
);
|
||||||
@@ -355,13 +351,4 @@ mod test {
|
|||||||
subnet_sampling_size as usize
|
subnet_sampling_size as usize
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_metadata(custody_group_count: u64) -> MetaData<E> {
|
|
||||||
MetaData::V3(MetaDataV3 {
|
|
||||||
seq_number: 0,
|
|
||||||
attnets: Default::default(),
|
|
||||||
syncnets: Default::default(),
|
|
||||||
custody_group_count,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user