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

protocols/gossipsub: Revert back to wasm_timer for interval #2506

Merged
merged 10 commits into from Feb 14, 2022
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -69,6 +69,10 @@
- Update to `libp2p-websocket` `v0.34.0`.
- Update to `libp2p-yamux` `v0.36.0`.

- Drop support for gossipsub in the wasm32-unknown-unknown target (see [PR 2506]).

[PR 2506]: https://github.com/libp2p/rust-libp2p/pull/2506

## Version 0.42.1 [2022-02-02]

- Update individual crates.
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Expand Up @@ -81,7 +81,6 @@ libp2p-autonat = { version = "0.2.0", path = "protocols/autonat", optional = tru
libp2p-core = { version = "0.32.0", path = "core", default-features = false }
libp2p-dcutr = { version = "0.1.0", path = "protocols/dcutr", optional = true }
libp2p-floodsub = { version = "0.34.0", path = "protocols/floodsub", optional = true }
libp2p-gossipsub = { version = "0.36.0", path = "./protocols/gossipsub", optional = true }
libp2p-identify = { version = "0.34.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.35.0", path = "protocols/kad", optional = true }
libp2p-metrics = { version = "0.4.0", path = "misc/metrics", optional = true }
Expand Down Expand Up @@ -111,6 +110,9 @@ libp2p-mdns = { version = "0.35.0", path = "protocols/mdns", optional = true }
libp2p-tcp = { version = "0.32.0", path = "transports/tcp", default-features = false, optional = true }
libp2p-websocket = { version = "0.34.0", path = "transports/websocket", optional = true }

[target.'cfg(not(target_os = "unknown"))'.dependencies]
libp2p-gossipsub = { version = "0.36.0", path = "protocols/gossipsub", optional = true }

[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
async-trait = "0.1"
Expand Down
3 changes: 3 additions & 0 deletions misc/metrics/CHANGELOG.md
Expand Up @@ -14,7 +14,10 @@

- Move from `open-metrics-client` to `prometheus-client` (see [PR 2442]).

- Drop support for gossipsub in wasm32-unknown-unknown target (see [PR 2506]).

[PR 2442]: https://github.com/libp2p/rust-libp2p/pull/2442
[PR 2506]: https://github.com/libp2p/rust-libp2p/pull/2506

# 0.3.0 [2022-01-27]

Expand Down
4 changes: 3 additions & 1 deletion misc/metrics/Cargo.toml
Expand Up @@ -21,14 +21,16 @@ dcutr = ["libp2p-dcutr"]
[dependencies]
libp2p-core = { version = "0.32.0", path = "../../core", default-features = false }
libp2p-dcutr = { version = "0.1.0", path = "../../protocols/dcutr", optional = true }
libp2p-gossipsub = { version = "0.36.0", path = "../../protocols/gossipsub", optional = true }
libp2p-identify = { version = "0.34.0", path = "../../protocols/identify", optional = true }
libp2p-kad = { version = "0.35.0", path = "../../protocols/kad", optional = true }
libp2p-ping = { version = "0.34.0", path = "../../protocols/ping", optional = true }
libp2p-relay = { version = "0.7.0", path = "../../protocols/relay", optional = true }
libp2p-swarm = { version = "0.34.0", path = "../../swarm" }
prometheus-client = "0.15.0"

[target.'cfg(not(target_os = "unknown"))'.dependencies]
libp2p-gossipsub = { version = "0.36.0", path = "../../protocols/gossipsub", optional = true }

[dev-dependencies]
env_logger = "0.8.1"
futures = "0.3.1"
Expand Down
3 changes: 3 additions & 0 deletions misc/metrics/src/lib.rs
Expand Up @@ -28,6 +28,7 @@
#[cfg(feature = "dcutr")]
mod dcutr;
#[cfg(feature = "gossipsub")]
#[cfg(not(target_os = "unknown"))]
mod gossipsub;
#[cfg(feature = "identify")]
mod identify;
Expand All @@ -46,6 +47,7 @@ pub struct Metrics {
#[cfg(feature = "dcutr")]
dcutr: dcutr::Metrics,
#[cfg(feature = "gossipsub")]
#[cfg(not(target_os = "unknown"))]
gossipsub: gossipsub::Metrics,
#[cfg(feature = "identify")]
identify: identify::Metrics,
Expand Down Expand Up @@ -73,6 +75,7 @@ impl Metrics {
#[cfg(feature = "dcutr")]
dcutr: dcutr::Metrics::new(sub_registry),
#[cfg(feature = "gossipsub")]
#[cfg(not(target_os = "unknown"))]
gossipsub: gossipsub::Metrics::new(sub_registry),
#[cfg(feature = "identify")]
identify: identify::Metrics::new(sub_registry),
Expand Down
3 changes: 3 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
Expand Up @@ -10,9 +10,12 @@

- Merge NetworkBehaviour's inject_\* paired methods (see PR 2445).

- Revert to wasm-timer (see [PR 2506]).

[PR 2442]: https://github.com/libp2p/rust-libp2p/pull/2442
[PR 2481]: https://github.com/libp2p/rust-libp2p/pull/2481
[PR 2445]: https://github.com/libp2p/rust-libp2p/pull/2445
[PR 2506]: https://github.com/libp2p/rust-libp2p/pull/2506

# 0.35.0 [2022-01-27]

Expand Down
5 changes: 2 additions & 3 deletions protocols/gossipsub/Cargo.toml
Expand Up @@ -27,10 +27,9 @@ smallvec = "1.6.1"
prost = "0.9"
hex_fmt = "0.3.0"
regex = "1.4.0"
futures-timer = "3.0.2"
pin-project = "1.0.8"
instant = "0.1.11"
serde = { version = "1", optional = true, features = ["derive"] }
wasm-timer = "0.2.5"
instant = "0.1.11"
# Metrics dependencies
prometheus-client = "0.15.0"

Expand Down
14 changes: 7 additions & 7 deletions protocols/gossipsub/src/backoff.rs
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_core::PeerId;
use std::collections::{
hash_map::{Entry, HashMap},
HashSet,
};
use std::time::Duration;
use libp2p_core::PeerId;
use std::collections::{
hash_map::{Entry, HashMap},
HashSet,
};
use std::time::Duration;
use wasm_timer::Instant;

#[derive(Copy, Clone)]
struct HeartbeatIndex(usize);
Expand Down
9 changes: 5 additions & 4 deletions protocols/gossipsub/src/behaviour.rs
Expand Up @@ -36,7 +36,6 @@ use prometheus_client::registry::Registry;
use prost::Message;
use rand::{seq::SliceRandom, thread_rng};

use instant::Instant;
use libp2p_core::{
connection::ConnectionId, identity::Keypair, multiaddr::Protocol::Ip4,
multiaddr::Protocol::Ip6, ConnectedPoint, Multiaddr, PeerId,
Expand All @@ -45,7 +44,9 @@ use libp2p_swarm::{
dial_opts::{self, DialOpts},
IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
};
use wasm_timer::Instant;

use crate::backoff::BackoffStorage;
use crate::config::{GossipsubConfig, ValidationMode};
use crate::error::{PublishError, SubscriptionError, ValidationError};
use crate::gossip_promises::GossipPromises;
Expand All @@ -63,9 +64,9 @@ use crate::types::{
GossipsubSubscriptionAction, MessageAcceptance, MessageId, PeerInfo, RawGossipsubMessage,
};
use crate::types::{GossipsubRpc, PeerConnections, PeerKind};
use crate::{backoff::BackoffStorage, interval::Interval};
use crate::{rpc_proto, TopicScoreParams};
use std::{cmp::Ordering::Equal, fmt::Debug};
use wasm_timer::Interval;

#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -439,8 +440,8 @@ where
config.backoff_slack(),
),
mcache: MessageCache::new(config.history_gossip(), config.history_length()),
heartbeat: Interval::new_initial(
config.heartbeat_initial_delay(),
heartbeat: Interval::new_at(
Instant::now() + config.heartbeat_initial_delay(),
config.heartbeat_interval(),
),
heartbeat_ticks: 0,
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/gossip_promises.rs
Expand Up @@ -21,10 +21,10 @@
use crate::error::ValidationError;
use crate::peer_score::RejectReason;
use crate::MessageId;
use instant::Instant;
use libp2p_core::PeerId;
use log::debug;
use std::collections::HashMap;
use wasm_timer::Instant;

/// Tracks recently sent `IWANT` messages and checks if peers respond to them.
#[derive(Default)]
Expand Down
209 changes: 0 additions & 209 deletions protocols/gossipsub/src/interval.rs

This file was deleted.

1 change: 0 additions & 1 deletion protocols/gossipsub/src/lib.rs
Expand Up @@ -142,7 +142,6 @@ mod behaviour;
mod config;
mod gossip_promises;
mod handler;
mod interval;
mod mcache;
pub mod metrics;
mod peer_score;
Expand Down