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

remove unused crates #805

Merged
merged 9 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 8 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
1,803 changes: 1,323 additions & 480 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage 1: Build
FROM lukemathwalker/cargo-chef:latest-rust-1.63 as chef
FROM lukemathwalker/cargo-chef:latest-rust-1.64 as chef
WORKDIR /build/
# hadolint ignore=DL3008
RUN apt-get update && \
Expand Down
1 change: 0 additions & 1 deletion fuel-chain-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ fuel-poa-coordinator = { path = "../fuel-poa-coordinator", version = "0.14.1" }
hex = { version = "0.4", features = ["serde"] }
itertools = "0.10"
rand = "0.8"
ron = "0.8"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk how this even got here 😅

serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
serde_with = "1.11"
Expand Down
2 changes: 0 additions & 2 deletions fuel-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ derive_more = { version = "0.99" }
eventsource-client = "0.10.2"
fuel-vm = { version = "0.22", features = ["serde"] }
futures = "0.3"
futures-timer = "3.0"
hex = "0.4"
itertools = "0.10"
json-decode = "0.6"
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
Expand Down
1 change: 0 additions & 1 deletion fuel-core-interfaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ anyhow = "1.0"
async-trait = "0.1"
derive_more = { version = "0.99" }
fuel-vm = { version = "0.22", default-features = false, features = ["random"] }
futures = "0.3"
lazy_static = "1.4"
parking_lot = "0.12"
secrecy = "0.8"
Expand Down
1 change: 0 additions & 1 deletion fuel-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ clap = { version = "3.2", features = ["env", "derive"] }
derive_more = { version = "0.99" }
dirs = "4.0"
enum-iterator = "1.2"
env_logger = "0.9"
fuel-block-executor = { path = "../fuel-block-executor", version = "0.14.1" }
fuel-block-importer = { path = "../fuel-block-importer", version = "0.14.1" }
fuel-block-producer = { path = "../fuel-block-producer", version = "0.14.1" }
Expand Down
1 change: 0 additions & 1 deletion fuel-metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ repository = "https://github.com/FuelLabs/fuel-core"
description = "Fuel metrics"

[dependencies]
anyhow = "1.0"
axum = "0.5"
lazy_static = "1.4"
once_cell = "1.16"
Expand Down
47 changes: 39 additions & 8 deletions fuel-p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,45 @@ description = "Fuel client networking"
anyhow = "1.0"
async-trait = "0.1"
bincode = "1.3"
fuel-core-interfaces = { path = "../fuel-core-interfaces", features = ["serde"], version = "0.14.1" }
fuel-core-interfaces = { path = "../fuel-core-interfaces", features = [
"serde",
], version = "0.14.1" }
fuel-metrics = { path = "../fuel-metrics", version = "0.14.1" } # TODO make this a feature
futures = "0.3"
futures-timer = "3.0"
ip_network = "0.4"
libp2p = { version = "0.49", default-features = false, features = [
"dns-tokio", "gossipsub", "identify", "kad", "mdns-tokio", "mplex", "noise",
"ping", "request-response", "secp256k1", "tcp-tokio", "yamux", "websocket"
libp2p = { version = "=0.50.0", default-features = false, features = [
"dns",
"gossipsub",
"identify",
"kad",
"macros",
"mdns",
"mplex",
"noise",
"ping",
"request-response",
"secp256k1",
"tcp",
"tokio",
"yamux",
"websocket",
] }
libp2p-core = "=0.38.0"
libp2p-dns = "=0.38.0"
libp2p-gossipsub = "=0.43.0"
libp2p-identify = "=0.41.0"
libp2p-kad = "=0.42.0"
libp2p-mdns = "=0.42.0"
libp2p-mplex = "=0.38.0"
libp2p-noise = "=0.41.0"
libp2p-ping = "=0.41.0"
libp2p-request-response = "=0.23.0"
libp2p-swarm = "=0.41.1"
libp2p-swarm-derive = "=0.31.0"
libp2p-tcp = "=0.38.0"
libp2p-websocket = "=0.40.0"
libp2p-yamux = "=0.42.0"
prometheus-client = "0.18"
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -32,14 +62,15 @@ tracing = "0.1"

[dev-dependencies]
ctor = "0.1"
fuel-core-interfaces = { path = "../fuel-core-interfaces", features = ["serde", "test-helpers"], version = "0.14.1" }
fuel-core-interfaces = { path = "../fuel-core-interfaces", features = [
"serde",
"test-helpers",
], version = "0.14.1" }
rand = "0.8"
tokio = { version = "1.21", features = ["full"] }
tracing-appender = "0.2"
tracing-attributes = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[features]
test-helpers = [
"fuel-core-interfaces/test-helpers",
]
test-helpers = ["fuel-core-interfaces/test-helpers"]
2 changes: 1 addition & 1 deletion fuel-p2p/src/behavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ use libp2p::{
RequestResponseEvent,
ResponseChannel,
},
swarm::NetworkBehaviour,
Multiaddr,
NetworkBehaviour,
PeerId,
};
use std::collections::HashMap;
Expand Down
6 changes: 3 additions & 3 deletions fuel-p2p/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use libp2p::{
mplex,
noise,
tcp::{
GenTcpConfig,
TokioTcpTransport,
tokio::Transport as TokioTcpTransport,
Config as TcpConfig,
},
yamux,
Multiaddr,
Expand Down Expand Up @@ -145,7 +145,7 @@ impl P2PConfig {
pub(crate) fn build_transport(local_keypair: Keypair) -> Boxed<(PeerId, StreamMuxerBox)> {
let transport = {
let generate_tcp_transport =
|| TokioTcpTransport::new(GenTcpConfig::new().port_reuse(true).nodelay(true));
|| TokioTcpTransport::new(TcpConfig::new().port_reuse(true).nodelay(true));

let tcp = generate_tcp_transport();

Expand Down
158 changes: 53 additions & 105 deletions fuel-p2p/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@ use futures::FutureExt;
use futures_timer::Delay;
use ip_network::IpNetwork;
use libp2p::{
core::{
connection::ConnectionId,
transport::ListenerId,
ConnectedPoint,
},
core::connection::ConnectionId,
kad::{
handler::KademliaHandlerProto,
store::MemoryStore,
Kademlia,
KademliaEvent,
QueryId,
},
mdns::MdnsEvent,
mdns::Event as MdnsEvent,
multiaddr::Protocol,
swarm::{
ConnectionHandler,
DialError,
IntoConnectionHandler,
NetworkBehaviour,
NetworkBehaviourAction,
Expand All @@ -28,12 +23,15 @@ use libp2p::{
Multiaddr,
PeerId,
};
use libp2p_swarm::derive_prelude::{
ConnectionClosed,
ConnectionEstablished,
};
use std::{
collections::{
HashSet,
VecDeque,
},
io,
task::{
Context,
Poll,
Expand Down Expand Up @@ -110,24 +108,56 @@ impl NetworkBehaviour for DiscoveryBehaviour {
}

// receive events from KademliaHandler and pass it down to kademlia
fn inject_event(
fn on_connection_handler_event(
&mut self,
peer_id: PeerId,
connection: ConnectionId,
event: <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent,
) {
self.kademlia.inject_event(peer_id, connection, event);
self.kademlia
.on_connection_handler_event(peer_id, connection, event);
}

fn inject_address_change(
fn on_swarm_event(
&mut self,
peer_id: &PeerId,
connection_id: &ConnectionId,
old: &ConnectedPoint,
new: &ConnectedPoint,
event: libp2p_swarm::derive_prelude::FromSwarm<Self::ConnectionHandler>,
) {
self.kademlia
.inject_address_change(peer_id, connection_id, old, new)
match &event {
libp2p_swarm::derive_prelude::FromSwarm::ConnectionEstablished(
ConnectionEstablished {
peer_id,
other_established,
..
},
) => {
if *other_established == 0 {
self.connected_peers.insert(*peer_id);
let addresses = self.addresses_of_peer(peer_id);

self.events
.push_back(DiscoveryEvent::Connected(*peer_id, addresses));

trace!("Connected to a peer {:?}", peer_id);
}
}
libp2p_swarm::derive_prelude::FromSwarm::ConnectionClosed(
ConnectionClosed {
peer_id,
remaining_established,
..
},
) => {
if *remaining_established == 0 {
self.connected_peers.remove(peer_id);
self.events
.push_back(DiscoveryEvent::Disconnected(*peer_id));

trace!("Disconnected from {:?}", peer_id);
}
}
_ => (),
}
self.kademlia.on_swarm_event(event)
}

// gets polled by the swarm
Expand Down Expand Up @@ -279,91 +309,6 @@ impl NetworkBehaviour for DiscoveryBehaviour {

list
}

fn inject_connection_established(
&mut self,
peer_id: &PeerId,
connection_id: &ConnectionId,
endpoint: &ConnectedPoint,
failed_addresses: Option<&Vec<Multiaddr>>,
other_established: usize,
) {
if other_established == 0 {
self.connected_peers.insert(*peer_id);
let addresses = self.addresses_of_peer(peer_id);

self.events
.push_back(DiscoveryEvent::Connected(*peer_id, addresses));

trace!("Connected to a peer {:?}", peer_id);
}

self.kademlia.inject_connection_established(
peer_id,
connection_id,
endpoint,
failed_addresses,
other_established,
);
}

fn inject_connection_closed(
&mut self,
peer_id: &PeerId,
connection_id: &ConnectionId,
connection_point: &ConnectedPoint,
handler: <Self::ConnectionHandler as IntoConnectionHandler>::Handler,
remaining_established: usize,
) {
if remaining_established == 0 {
self.connected_peers.remove(peer_id);
self.events
.push_back(DiscoveryEvent::Disconnected(*peer_id));

trace!("Disconnected from {:?}", peer_id);
}

self.kademlia.inject_connection_closed(
peer_id,
connection_id,
connection_point,
handler,
remaining_established,
);
}

fn inject_new_external_addr(&mut self, addr: &Multiaddr) {
self.kademlia.inject_new_external_addr(addr)
}

fn inject_expired_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr) {
self.kademlia.inject_expired_listen_addr(id, addr);
}

fn inject_dial_failure(
&mut self,
peer_id: Option<PeerId>,
handler: Self::ConnectionHandler,
err: &DialError,
) {
self.kademlia.inject_dial_failure(peer_id, handler, err)
}

fn inject_new_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr) {
self.kademlia.inject_new_listen_addr(id, addr)
}

fn inject_listener_error(
&mut self,
id: ListenerId,
err: &(dyn std::error::Error + 'static),
) {
self.kademlia.inject_listener_error(id, err)
}

fn inject_listener_closed(&mut self, id: ListenerId, reason: Result<(), &io::Error>) {
self.kademlia.inject_listener_closed(id, reason)
}
}

#[cfg(test)]
Expand Down Expand Up @@ -434,9 +379,12 @@ mod tests {
};

let listen_addr: Multiaddr = Protocol::Memory(rand::random::<u64>()).into();
let swarm_builder =
SwarmBuilder::new(transport, behaviour, keypair.public().to_peer_id())
.dial_concurrency_factor(NonZeroU8::new(1).expect("1 > 0"));
let swarm_builder = SwarmBuilder::without_executor(
transport,
behaviour,
keypair.public().to_peer_id(),
)
.dial_concurrency_factor(NonZeroU8::new(1).expect("1 > 0"));

let mut swarm = swarm_builder.build();

Expand Down
8 changes: 4 additions & 4 deletions fuel-p2p/src/discovery/mdns.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use libp2p::{
mdns::{
MdnsConfig,
MdnsEvent,
TokioMdns,
tokio::Behaviour as TokioMdns,
Config,
Event as MdnsEvent,
},
swarm::{
NetworkBehaviour,
Expand All @@ -26,7 +26,7 @@ pub enum MdnsWrapper {

impl Default for MdnsWrapper {
fn default() -> Self {
match TokioMdns::new(MdnsConfig::default()) {
match TokioMdns::new(Config::default()) {
Ok(mdns) => Self::Ready(mdns),
Err(err) => {
warn!("Failed to initialize mDNS: {:?}", err);
Expand Down
Loading