Update cuckoofilter requirement from 0.3.2 to 0.5.0 (#1763)

* Update cuckoofilter requirement from 0.3.2 to 0.5.0

Updates the requirements on [cuckoofilter](https://github.com/axiomhq/rust-cuckoofilter) to permit the latest version.
- [Release notes](https://github.com/axiomhq/rust-cuckoofilter/releases)
- [Changelog](https://github.com/axiomhq/rust-cuckoofilter/blob/master/CHANGELOG.md)
- [Commits](https://github.com/axiomhq/rust-cuckoofilter/commits)

Signed-off-by: dependabot[bot] <support@github.com>

* protocols/floodsub: Warn when Cuckoofilter has to evict item

With Cuckoofilter `v0.4.0` `add` and `test_and_add` return an error when
an old element has to be evicted in favor of a new one to take its
place. The previous behavior was panicing.

With this commit the error is logged on `warn` level.

* *: Update changelogs and cargo tomls

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
dependabot[bot] 2020-09-29 11:46:57 +02:00 committed by GitHub
parent f66f40bcd7
commit aaa6e4add3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 11 deletions

View File

@ -25,9 +25,9 @@
# Version 0.29.0 [unreleased]
- Update `libp2p-core`, `libp2p-gossipsub`, `libp2p-mplex`, `libp2p-noise`,
`libp2p-plaintext`, `libp2p-request-response`, `libp2p-websocket` and
`parity-multiaddr`.
- Update `libp2p-core`, `libp2p-floodsub`, `libp2p-gossipsub`, `libp2p-mplex`,
`libp2p-noise`, `libp2p-plaintext`, `libp2p-request-response`,
`libp2p-websocket` and `parity-multiaddr`.
# Version 0.28.1 [2020-09-10]

View File

@ -64,7 +64,7 @@ futures = "0.3.1"
lazy_static = "1.2"
libp2p-core = { version = "0.22.2", path = "core" }
libp2p-core-derive = { version = "0.20.2", path = "misc/core-derive" }
libp2p-floodsub = { version = "0.22.0", path = "protocols/floodsub", optional = true }
libp2p-floodsub = { version = "0.23.0", path = "protocols/floodsub", optional = true }
libp2p-gossipsub = { version = "0.22.1", path = "./protocols/gossipsub", optional = true }
libp2p-identify = { version = "0.22.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.23.1", path = "protocols/kad", optional = true }

View File

@ -1,3 +1,7 @@
# 0.23.0 [unreleased]
- Update dependencies.
# 0.22.0 [2020-09-09]
- Update `libp2p-swarm` and `libp2p-core`.

View File

@ -2,7 +2,7 @@
name = "libp2p-floodsub"
edition = "2018"
description = "Floodsub protocol for libp2p"
version = "0.22.0"
version = "0.23.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -10,11 +10,12 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
[dependencies]
cuckoofilter = "0.3.2"
cuckoofilter = "0.5.0"
fnv = "1.0"
futures = "0.3.1"
libp2p-core = { version = "0.22.0", path = "../../core" }
libp2p-swarm = { version = "0.22.0", path = "../../swarm" }
log = "0.4"
prost = "0.6.1"
rand = "0.7"
smallvec = "1.0"

View File

@ -21,7 +21,7 @@
use crate::protocol::{FloodsubProtocol, FloodsubMessage, FloodsubRpc, FloodsubSubscription, FloodsubSubscriptionAction};
use crate::topic::Topic;
use crate::FloodsubConfig;
use cuckoofilter::CuckooFilter;
use cuckoofilter::{CuckooError, CuckooFilter};
use fnv::FnvHashSet;
use libp2p_core::{Multiaddr, PeerId, connection::ConnectionId};
use libp2p_swarm::{
@ -33,6 +33,7 @@ use libp2p_swarm::{
NotifyHandler,
DialPeerCondition,
};
use log::warn;
use rand;
use smallvec::SmallVec;
use std::{collections::VecDeque, iter};
@ -206,7 +207,12 @@ impl Floodsub {
let self_subscribed = self.subscribed_topics.iter().any(|t| message.topics.iter().any(|u| t == u));
if self_subscribed {
self.received.add(&message);
if let Err(e @ CuckooError::NotEnoughSpace) = self.received.add(&message) {
warn!(
"Message was added to 'received' Cuckoofilter but some \
other message was removed as a consequence: {}", e,
);
}
if self.config.subscribe_local_messages {
self.events.push_back(
NetworkBehaviourAction::GenerateEvent(FloodsubEvent::Message(message.clone())));
@ -327,9 +333,16 @@ impl NetworkBehaviour for Floodsub {
for message in event.messages {
// Use `self.received` to skip the messages that we have already received in the past.
// Note that this can false positive.
if !self.received.test_and_add(&message) {
continue;
// Note that this can result in false positives.
match self.received.test_and_add(&message) {
Ok(true) => {}, // Message was added.
Ok(false) => continue, // Message already existed.
Err(e @ CuckooError::NotEnoughSpace) => { // Message added, but some other removed.
warn!(
"Message was added to 'received' Cuckoofilter but some \
other message was removed as a consequence: {}", e,
);
}
}
// Add the message to be dispatched to the user.