replace instant with web-time (#5800)

* replace instant with web_time

* Merge branch 'unstable' into replace-instant-gossipsub

# Conflicts:
#	Cargo.lock
#	beacon_node/lighthouse_network/Cargo.toml
This commit is contained in:
João Oliveira
2024-05-30 20:18:35 +01:00
committed by GitHub
parent 17dc978760
commit bbe9242811
10 changed files with 20 additions and 15 deletions

13
Cargo.lock generated
View File

@@ -3376,7 +3376,6 @@ dependencies = [
"futures-timer", "futures-timer",
"getrandom", "getrandom",
"hex_fmt", "hex_fmt",
"instant",
"libp2p", "libp2p",
"prometheus-client", "prometheus-client",
"quick-protobuf", "quick-protobuf",
@@ -3388,6 +3387,7 @@ dependencies = [
"sha2 0.10.8", "sha2 0.10.8",
"tracing", "tracing",
"void", "void",
"web-time",
] ]
[[package]] [[package]]
@@ -4956,7 +4956,6 @@ dependencies = [
"futures", "futures",
"gossipsub", "gossipsub",
"hex", "hex",
"instant",
"lazy_static", "lazy_static",
"libp2p", "libp2p",
"libp2p-mplex", "libp2p-mplex",
@@ -9365,6 +9364,16 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "web-time"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]] [[package]]
name = "web3signer_tests" name = "web3signer_tests"
version = "0.1.0" version = "0.1.0"

View File

@@ -45,7 +45,6 @@ bytes = { workspace = true }
either = { workspace = true } either = { workspace = true }
# Local dependencies # Local dependencies
instant = "0.1.12"
void = "1.0.2" void = "1.0.2"
libp2p-mplex = "0.41" libp2p-mplex = "0.41"
@@ -64,4 +63,3 @@ async-channel = { workspace = true }
[features] [features]
libp2p-websocket = [] libp2p-websocket = []

View File

@@ -10,7 +10,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
[features] [features]
wasm-bindgen = ["getrandom/js", "instant/wasm-bindgen"] wasm-bindgen = ["getrandom/js"]
[dependencies] [dependencies]
async-channel = { workspace = true } async-channel = { workspace = true }
@@ -25,7 +25,6 @@ futures-ticker = "0.0.3"
futures-timer = "3.0.2" futures-timer = "3.0.2"
getrandom = "0.2.12" getrandom = "0.2.12"
hex_fmt = "0.3.0" hex_fmt = "0.3.0"
instant = "0.1.12"
libp2p = { version = "0.53", default-features = false } libp2p = { version = "0.53", default-features = false }
quick-protobuf = "0.8" quick-protobuf = "0.8"
quick-protobuf-codec = "0.3" quick-protobuf-codec = "0.3"
@@ -35,8 +34,8 @@ serde = { version = "1", optional = true, features = ["derive"] }
sha2 = "0.10.8" sha2 = "0.10.8"
tracing = "0.1.37" tracing = "0.1.37"
void = "1.0.2" void = "1.0.2"
prometheus-client = "0.22.0" prometheus-client = "0.22.0"
web-time = "1.1.0"
[dev-dependencies] [dev-dependencies]
quickcheck = { workspace = true } quickcheck = { workspace = true }

View File

@@ -20,13 +20,13 @@
//! Data structure for efficiently storing known back-off's when pruning peers. //! Data structure for efficiently storing known back-off's when pruning peers.
use crate::topic::TopicHash; use crate::topic::TopicHash;
use instant::Instant;
use libp2p::identity::PeerId; use libp2p::identity::PeerId;
use std::collections::{ use std::collections::{
hash_map::{Entry, HashMap}, hash_map::{Entry, HashMap},
HashSet, HashSet,
}; };
use std::time::Duration; use std::time::Duration;
use web_time::Instant;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct HeartbeatIndex(usize); struct HeartbeatIndex(usize);

View File

@@ -34,7 +34,6 @@ use futures_ticker::Ticker;
use prometheus_client::registry::Registry; use prometheus_client::registry::Registry;
use rand::{seq::SliceRandom, thread_rng}; use rand::{seq::SliceRandom, thread_rng};
use instant::Instant;
use libp2p::core::{multiaddr::Protocol::Ip4, multiaddr::Protocol::Ip6, Endpoint, Multiaddr}; use libp2p::core::{multiaddr::Protocol::Ip4, multiaddr::Protocol::Ip6, Endpoint, Multiaddr};
use libp2p::identity::Keypair; use libp2p::identity::Keypair;
use libp2p::identity::PeerId; use libp2p::identity::PeerId;
@@ -44,6 +43,7 @@ use libp2p::swarm::{
ConnectionDenied, ConnectionId, NetworkBehaviour, NotifyHandler, THandler, THandlerInEvent, ConnectionDenied, ConnectionId, NetworkBehaviour, NotifyHandler, THandler, THandlerInEvent,
THandlerOutEvent, ToSwarm, THandlerOutEvent, ToSwarm,
}; };
use web_time::{Instant, SystemTime};
use super::gossip_promises::GossipPromises; use super::gossip_promises::GossipPromises;
use super::handler::{Handler, HandlerEvent, HandlerIn}; use super::handler::{Handler, HandlerEvent, HandlerIn};
@@ -67,7 +67,6 @@ use super::{
types::RpcOut, types::RpcOut,
}; };
use super::{PublishError, SubscriptionError, TopicScoreParams, ValidationError}; use super::{PublishError, SubscriptionError, TopicScoreParams, ValidationError};
use instant::SystemTime;
use quick_protobuf::{MessageWrite, Writer}; use quick_protobuf::{MessageWrite, Writer};
use std::{cmp::Ordering::Equal, fmt::Debug}; use std::{cmp::Ordering::Equal, fmt::Debug};

View File

@@ -21,9 +21,9 @@
use super::peer_score::RejectReason; use super::peer_score::RejectReason;
use super::MessageId; use super::MessageId;
use super::ValidationError; use super::ValidationError;
use instant::Instant;
use libp2p::identity::PeerId; use libp2p::identity::PeerId;
use std::collections::HashMap; use std::collections::HashMap;
use web_time::Instant;
/// Tracks recently sent `IWANT` messages and checks if peers respond to them. /// Tracks recently sent `IWANT` messages and checks if peers respond to them.
#[derive(Default)] #[derive(Default)]

View File

@@ -26,7 +26,6 @@ use asynchronous_codec::Framed;
use futures::future::Either; use futures::future::Either;
use futures::prelude::*; use futures::prelude::*;
use futures::StreamExt; use futures::StreamExt;
use instant::Instant;
use libp2p::core::upgrade::DeniedUpgrade; use libp2p::core::upgrade::DeniedUpgrade;
use libp2p::swarm::handler::{ use libp2p::swarm::handler::{
ConnectionEvent, ConnectionHandler, ConnectionHandlerEvent, DialUpgradeError, ConnectionEvent, ConnectionHandler, ConnectionHandlerEvent, DialUpgradeError,
@@ -37,6 +36,7 @@ use std::{
pin::Pin, pin::Pin,
task::{Context, Poll}, task::{Context, Poll},
}; };
use web_time::Instant;
/// The event emitted by the Handler. This informs the behaviour of various events created /// The event emitted by the Handler. This informs the behaviour of various events created
/// by the handler. /// by the handler.

View File

@@ -24,11 +24,11 @@
use super::metrics::{Metrics, Penalty}; use super::metrics::{Metrics, Penalty};
use super::time_cache::TimeCache; use super::time_cache::TimeCache;
use super::{MessageId, TopicHash}; use super::{MessageId, TopicHash};
use instant::Instant;
use libp2p::identity::PeerId; use libp2p::identity::PeerId;
use std::collections::{hash_map, HashMap, HashSet}; use std::collections::{hash_map, HashMap, HashSet};
use std::net::IpAddr; use std::net::IpAddr;
use std::time::Duration; use std::time::Duration;
use web_time::Instant;
mod params; mod params;
use super::ValidationError; use super::ValidationError;

View File

@@ -21,13 +21,13 @@
//! This implements a time-based LRU cache for checking gossipsub message duplicates. //! This implements a time-based LRU cache for checking gossipsub message duplicates.
use fnv::FnvHashMap; use fnv::FnvHashMap;
use instant::Instant;
use std::collections::hash_map::{ use std::collections::hash_map::{
self, self,
Entry::{Occupied, Vacant}, Entry::{Occupied, Vacant},
}; };
use std::collections::VecDeque; use std::collections::VecDeque;
use std::time::Duration; use std::time::Duration;
use web_time::Instant;
struct ExpiringElement<Element> { struct ExpiringElement<Element> {
/// The element that expires /// The element that expires

View File

@@ -25,7 +25,6 @@ use async_channel::{Receiver, Sender};
use futures::stream::Peekable; use futures::stream::Peekable;
use futures::{Future, Stream, StreamExt}; use futures::{Future, Stream, StreamExt};
use futures_timer::Delay; use futures_timer::Delay;
use instant::Duration;
use libp2p::identity::PeerId; use libp2p::identity::PeerId;
use libp2p::swarm::ConnectionId; use libp2p::swarm::ConnectionId;
use prometheus_client::encoding::EncodeLabelValue; use prometheus_client::encoding::EncodeLabelValue;
@@ -36,6 +35,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc; use std::sync::Arc;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use std::{fmt, pin::Pin}; use std::{fmt, pin::Pin};
use web_time::Duration;
use crate::rpc_proto::proto; use crate::rpc_proto::proto;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]