mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-04 13:24:39 +00:00
Set custody subnets on tests (#6382)
* Set custody subnets on tests * Enable sampling_with_retries test * Add another supernode to ensure the node can retry
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
use crate::discovery::enr::PEERDAS_CUSTODY_SUBNET_COUNT_ENR_KEY;
|
use crate::discovery::enr::PEERDAS_CUSTODY_SUBNET_COUNT_ENR_KEY;
|
||||||
use crate::discovery::CombinedKey;
|
use crate::discovery::{peer_id_to_node_id, CombinedKey};
|
||||||
use crate::{metrics, multiaddr::Multiaddr, types::Subnet, Enr, EnrExt, Gossipsub, PeerId};
|
use crate::{metrics, multiaddr::Multiaddr, types::Subnet, Enr, EnrExt, Gossipsub, PeerId};
|
||||||
use peer_info::{ConnectionDirection, PeerConnectionStatus, PeerInfo};
|
use peer_info::{ConnectionDirection, PeerConnectionStatus, PeerInfo};
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
@@ -723,6 +723,17 @@ impl<E: EthSpec> PeerDB<E> {
|
|||||||
.map(|csc| csc.into())
|
.map(|csc| csc.into())
|
||||||
.collect();
|
.collect();
|
||||||
peer_info.set_custody_subnets(all_subnets);
|
peer_info.set_custody_subnets(all_subnets);
|
||||||
|
} else {
|
||||||
|
let peer_info = self.peers.get_mut(&peer_id).expect("peer exists");
|
||||||
|
let node_id = peer_id_to_node_id(&peer_id).expect("convert peer_id to node_id");
|
||||||
|
let subnets = DataColumnSubnetId::compute_custody_subnets::<E>(
|
||||||
|
node_id.raw(),
|
||||||
|
spec.custody_requirement,
|
||||||
|
spec,
|
||||||
|
)
|
||||||
|
.expect("should compute custody subnets")
|
||||||
|
.collect();
|
||||||
|
peer_info.set_custody_subnets(subnets);
|
||||||
}
|
}
|
||||||
|
|
||||||
peer_id
|
peer_id
|
||||||
|
|||||||
@@ -1972,12 +1972,13 @@ fn sampling_happy_path() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore] // Ignoring due to flakiness https://github.com/sigp/lighthouse/issues/6319
|
|
||||||
fn sampling_with_retries() {
|
fn sampling_with_retries() {
|
||||||
let Some(mut r) = TestRig::test_setup_after_peerdas() else {
|
let Some(mut r) = TestRig::test_setup_after_peerdas() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
r.new_connected_peers_for_peerdas();
|
r.new_connected_peers_for_peerdas();
|
||||||
|
// Add another supernode to ensure that the node can retry.
|
||||||
|
r.new_connected_supernode_peer();
|
||||||
let (block, data_columns) = r.rand_block_and_data_columns();
|
let (block, data_columns) = r.rand_block_and_data_columns();
|
||||||
let block_root = block.canonical_root();
|
let block_root = block.canonical_root();
|
||||||
r.trigger_sample_block(block_root, block.slot());
|
r.trigger_sample_block(block_root, block.slot());
|
||||||
|
|||||||
Reference in New Issue
Block a user