Skip to content
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

replace instant with web-time #5800

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions beacon_node/lighthouse_network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ bytes = { workspace = true }
either = { workspace = true }

# Local dependencies
instant = "0.1.12"
void = "1.0.2"
libp2p-mplex = "0.41"

Expand All @@ -64,4 +63,3 @@ async-channel = { workspace = true }

[features]
libp2p-websocket = []

5 changes: 2 additions & 3 deletions beacon_node/lighthouse_network/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]

[features]
wasm-bindgen = ["getrandom/js", "instant/wasm-bindgen"]
wasm-bindgen = ["getrandom/js"]

[dependencies]
async-channel = { workspace = true }
Expand All @@ -25,7 +25,6 @@ futures-ticker = "0.0.3"
futures-timer = "3.0.2"
getrandom = "0.2.12"
hex_fmt = "0.3.0"
instant = "0.1.12"
libp2p = { version = "0.53", default-features = false }
quick-protobuf = "0.8"
quick-protobuf-codec = "0.3"
Expand All @@ -35,8 +34,8 @@ serde = { version = "1", optional = true, features = ["derive"] }
sha2 = "0.10.8"
tracing = "0.1.37"
void = "1.0.2"

prometheus-client = "0.22.0"
web-time = "1.1.0"

[dev-dependencies]
quickcheck = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/lighthouse_network/gossipsub/src/backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

//! Data structure for efficiently storing known back-off's when pruning peers.
use crate::topic::TopicHash;
use instant::Instant;
use libp2p::identity::PeerId;
use std::collections::{
hash_map::{Entry, HashMap},
HashSet,
};
use std::time::Duration;
use web_time::Instant;

#[derive(Copy, Clone)]
struct HeartbeatIndex(usize);
Expand Down
3 changes: 1 addition & 2 deletions beacon_node/lighthouse_network/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use futures_ticker::Ticker;
use prometheus_client::registry::Registry;
use rand::{seq::SliceRandom, thread_rng};

use instant::Instant;
use libp2p::core::{multiaddr::Protocol::Ip4, multiaddr::Protocol::Ip6, Endpoint, Multiaddr};
use libp2p::identity::Keypair;
use libp2p::identity::PeerId;
Expand All @@ -44,6 +43,7 @@ use libp2p::swarm::{
ConnectionDenied, ConnectionId, NetworkBehaviour, NotifyHandler, THandler, THandlerInEvent,
THandlerOutEvent, ToSwarm,
};
use web_time::{Instant, SystemTime};

use super::gossip_promises::GossipPromises;
use super::handler::{Handler, HandlerEvent, HandlerIn};
Expand All @@ -67,7 +67,6 @@ use super::{
types::RpcOut,
};
use super::{PublishError, SubscriptionError, TopicScoreParams, ValidationError};
use instant::SystemTime;
use quick_protobuf::{MessageWrite, Writer};
use std::{cmp::Ordering::Equal, fmt::Debug};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
use super::peer_score::RejectReason;
use super::MessageId;
use super::ValidationError;
use instant::Instant;
use libp2p::identity::PeerId;
use std::collections::HashMap;
use web_time::Instant;

/// Tracks recently sent `IWANT` messages and checks if peers respond to them.
#[derive(Default)]
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/lighthouse_network/gossipsub/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use asynchronous_codec::Framed;
use futures::future::Either;
use futures::prelude::*;
use futures::StreamExt;
use instant::Instant;
use libp2p::core::upgrade::DeniedUpgrade;
use libp2p::swarm::handler::{
ConnectionEvent, ConnectionHandler, ConnectionHandlerEvent, DialUpgradeError,
Expand All @@ -37,6 +36,7 @@ use std::{
pin::Pin,
task::{Context, Poll},
};
use web_time::Instant;

/// The event emitted by the Handler. This informs the behaviour of various events created
/// by the handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
use super::metrics::{Metrics, Penalty};
use super::time_cache::TimeCache;
use super::{MessageId, TopicHash};
use instant::Instant;
use libp2p::identity::PeerId;
use std::collections::{hash_map, HashMap, HashSet};
use std::net::IpAddr;
use std::time::Duration;
use web_time::Instant;

mod params;
use super::ValidationError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
//! This implements a time-based LRU cache for checking gossipsub message duplicates.

use fnv::FnvHashMap;
use instant::Instant;
use std::collections::hash_map::{
self,
Entry::{Occupied, Vacant},
};
use std::collections::VecDeque;
use std::time::Duration;
use web_time::Instant;

struct ExpiringElement<Element> {
/// The element that expires
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/lighthouse_network/gossipsub/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use async_channel::{Receiver, Sender};
use futures::stream::Peekable;
use futures::{Future, Stream, StreamExt};
use futures_timer::Delay;
use instant::Duration;
use libp2p::identity::PeerId;
use libp2p::swarm::ConnectionId;
use prometheus_client::encoding::EncodeLabelValue;
Expand All @@ -36,6 +35,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::task::{Context, Poll};
use std::{fmt, pin::Pin};
use web_time::Duration;

use crate::rpc_proto::proto;
#[cfg(feature = "serde")]
Expand Down
Loading