Sync sim mini update (#1018)
* Include syncing status as a node fn * Update sync sim to use de node/syncing endpoint
This commit is contained in:
parent
9e42a851e4
commit
b88b3ffe40
@ -24,8 +24,8 @@ pub use operation_pool::PersistedOperationPool;
|
|||||||
pub use proto_array_fork_choice::core::ProtoArray;
|
pub use proto_array_fork_choice::core::ProtoArray;
|
||||||
pub use rest_types::{
|
pub use rest_types::{
|
||||||
CanonicalHeadResponse, Committee, HeadBeaconBlock, IndividualVotesRequest,
|
CanonicalHeadResponse, Committee, HeadBeaconBlock, IndividualVotesRequest,
|
||||||
IndividualVotesResponse, ValidatorDutiesRequest, ValidatorDutyBytes, ValidatorRequest,
|
IndividualVotesResponse, SyncingResponse, ValidatorDutiesRequest, ValidatorDutyBytes,
|
||||||
ValidatorResponse, ValidatorSubscription,
|
ValidatorRequest, ValidatorResponse, ValidatorSubscription,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Setting a long timeout for debug ensures that crypto-heavy operations can still succeed.
|
// Setting a long timeout for debug ensures that crypto-heavy operations can still succeed.
|
||||||
@ -654,6 +654,13 @@ impl<E: EthSpec> Node<E> {
|
|||||||
.into_future()
|
.into_future()
|
||||||
.and_then(move |url| client.json_get(url, vec![]))
|
.and_then(move |url| client.json_get(url, vec![]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn syncing_status(&self) -> impl Future<Item = SyncingResponse, Error = Error> {
|
||||||
|
let client = self.0.clone();
|
||||||
|
self.url("syncing")
|
||||||
|
.into_future()
|
||||||
|
.and_then(move |url| client.json_get(url, vec![]))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Provides the functions on the `/advanced` endpoint of the node.
|
/// Provides the functions on the `/advanced` endpoint of the node.
|
||||||
|
@ -353,27 +353,24 @@ pub fn verify_syncing<E: EthSpec>(
|
|||||||
pub fn check_still_syncing<E: EthSpec>(
|
pub fn check_still_syncing<E: EthSpec>(
|
||||||
network: &LocalNetwork<E>,
|
network: &LocalNetwork<E>,
|
||||||
) -> impl Future<Item = bool, Error = String> {
|
) -> impl Future<Item = bool, Error = String> {
|
||||||
let net = network.clone();
|
|
||||||
network
|
network
|
||||||
.remote_nodes()
|
.remote_nodes()
|
||||||
.into_future()
|
.into_future()
|
||||||
// get all head epochs
|
// get syncing status of nodes
|
||||||
.and_then(|remote_nodes| {
|
.and_then(|remote_nodes| {
|
||||||
stream::unfold(remote_nodes.into_iter(), |mut iter| {
|
stream::unfold(remote_nodes.into_iter(), |mut iter| {
|
||||||
iter.next().map(|remote_node| {
|
iter.next().map(|remote_node| {
|
||||||
remote_node
|
remote_node
|
||||||
.http
|
.http
|
||||||
.beacon()
|
.node()
|
||||||
.get_head()
|
.syncing_status()
|
||||||
.map(|head| head.finalized_slot.epoch(E::slots_per_epoch()))
|
.map(|status| status.is_syncing)
|
||||||
.map(|epoch| (epoch, iter))
|
.map(|status| (status, iter))
|
||||||
.map_err(|e| format!("Get head via http failed: {:?}", e))
|
.map_err(|e| format!("Get syncing status via http failed: {:?}", e))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
})
|
})
|
||||||
// find current epoch
|
.and_then(move |status| Ok(status.iter().any(|is_syncing| *is_syncing)))
|
||||||
.and_then(move |epochs| net.bootnode_epoch().map(|epoch| (epochs, epoch)))
|
|
||||||
.and_then(move |(epochs, epoch)| Ok(epochs.iter().any(|head_epoch| *head_epoch != epoch)))
|
|
||||||
.map_err(|e| format!("Failed syncing check: {:?}", e))
|
.map_err(|e| format!("Failed syncing check: {:?}", e))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user