Updates the libp2p to the second newest commit => Allow only one topic per message (#1819)
As @AgeManning mentioned the newest libp2p version had some problems and got downgraded again on lighthouse master. This is an intermediate version that makes no problems and only adds a small change of allowing only one topic per message.
This commit is contained in:
parent
7870b81ade
commit
1644289a08
30
Cargo.lock
generated
30
Cargo.lock
generated
@ -3037,7 +3037,7 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p"
|
name = "libp2p"
|
||||||
version = "0.29.0"
|
version = "0.29.0"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic",
|
"atomic",
|
||||||
"bytes 0.5.6",
|
"bytes 0.5.6",
|
||||||
@ -3054,7 +3054,7 @@ dependencies = [
|
|||||||
"libp2p-tcp",
|
"libp2p-tcp",
|
||||||
"libp2p-websocket",
|
"libp2p-websocket",
|
||||||
"multihash",
|
"multihash",
|
||||||
"parity-multiaddr 0.9.3 (git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c)",
|
"parity-multiaddr 0.9.3 (git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669)",
|
||||||
"parking_lot 0.11.0",
|
"parking_lot 0.11.0",
|
||||||
"pin-project 0.4.27",
|
"pin-project 0.4.27",
|
||||||
"smallvec 1.4.2",
|
"smallvec 1.4.2",
|
||||||
@ -3098,7 +3098,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-core"
|
name = "libp2p-core"
|
||||||
version = "0.22.2"
|
version = "0.22.2"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"asn1_der",
|
"asn1_der",
|
||||||
"bs58",
|
"bs58",
|
||||||
@ -3112,7 +3112,7 @@ dependencies = [
|
|||||||
"log 0.4.11",
|
"log 0.4.11",
|
||||||
"multihash",
|
"multihash",
|
||||||
"multistream-select 0.8.3",
|
"multistream-select 0.8.3",
|
||||||
"parity-multiaddr 0.9.3 (git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c)",
|
"parity-multiaddr 0.9.3 (git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669)",
|
||||||
"parking_lot 0.11.0",
|
"parking_lot 0.11.0",
|
||||||
"pin-project 0.4.27",
|
"pin-project 0.4.27",
|
||||||
"prost",
|
"prost",
|
||||||
@ -3131,7 +3131,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-core-derive"
|
name = "libp2p-core-derive"
|
||||||
version = "0.20.2"
|
version = "0.20.2"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
@ -3140,7 +3140,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-dns"
|
name = "libp2p-dns"
|
||||||
version = "0.22.0"
|
version = "0.22.0"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.3.6",
|
"futures 0.3.6",
|
||||||
"libp2p-core 0.22.2",
|
"libp2p-core 0.22.2",
|
||||||
@ -3150,7 +3150,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-gossipsub"
|
name = "libp2p-gossipsub"
|
||||||
version = "0.22.1"
|
version = "0.22.1"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.12.3",
|
"base64 0.12.3",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
@ -3174,7 +3174,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-identify"
|
name = "libp2p-identify"
|
||||||
version = "0.22.0"
|
version = "0.22.0"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.3.6",
|
"futures 0.3.6",
|
||||||
"libp2p-core 0.22.2",
|
"libp2p-core 0.22.2",
|
||||||
@ -3189,7 +3189,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-mplex"
|
name = "libp2p-mplex"
|
||||||
version = "0.23.0"
|
version = "0.23.0"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes 0.5.6",
|
"bytes 0.5.6",
|
||||||
"fnv",
|
"fnv",
|
||||||
@ -3204,7 +3204,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-noise"
|
name = "libp2p-noise"
|
||||||
version = "0.24.1"
|
version = "0.24.1"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes 0.5.6",
|
"bytes 0.5.6",
|
||||||
"curve25519-dalek",
|
"curve25519-dalek",
|
||||||
@ -3225,7 +3225,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-swarm"
|
name = "libp2p-swarm"
|
||||||
version = "0.22.0"
|
version = "0.22.0"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"either",
|
"either",
|
||||||
"futures 0.3.6",
|
"futures 0.3.6",
|
||||||
@ -3240,7 +3240,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-tcp"
|
name = "libp2p-tcp"
|
||||||
version = "0.22.0"
|
version = "0.22.0"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.3.6",
|
"futures 0.3.6",
|
||||||
"futures-timer",
|
"futures-timer",
|
||||||
@ -3255,7 +3255,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-websocket"
|
name = "libp2p-websocket"
|
||||||
version = "0.23.1"
|
version = "0.23.1"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-tls",
|
"async-tls",
|
||||||
"either",
|
"either",
|
||||||
@ -3680,7 +3680,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "multistream-select"
|
name = "multistream-select"
|
||||||
version = "0.8.3"
|
version = "0.8.3"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes 0.5.6",
|
"bytes 0.5.6",
|
||||||
"futures 0.3.6",
|
"futures 0.3.6",
|
||||||
@ -4005,7 +4005,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-multiaddr"
|
name = "parity-multiaddr"
|
||||||
version = "0.9.3"
|
version = "0.9.3"
|
||||||
source = "git+https://github.com/sigp/rust-libp2p?rev=a731aa803d986977c25a77ed2b002d9578f7377c#a731aa803d986977c25a77ed2b002d9578f7377c"
|
source = "git+https://github.com/sigp/rust-libp2p?rev=8c6ce6eb1228de568568f6cd72fb134dea5f9669#8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayref",
|
"arrayref",
|
||||||
"bs58",
|
"bs58",
|
||||||
|
@ -42,7 +42,7 @@ regex = "1.3.9"
|
|||||||
[dependencies.libp2p]
|
[dependencies.libp2p]
|
||||||
#version = "0.23.0"
|
#version = "0.23.0"
|
||||||
git = "https://github.com/sigp/rust-libp2p"
|
git = "https://github.com/sigp/rust-libp2p"
|
||||||
rev = "a731aa803d986977c25a77ed2b002d9578f7377c"
|
rev = "8c6ce6eb1228de568568f6cd72fb134dea5f9669"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["websocket", "identify", "mplex", "noise", "gossipsub", "dns", "tcp-tokio"]
|
features = ["websocket", "identify", "mplex", "noise", "gossipsub", "dns", "tcp-tokio"]
|
||||||
|
|
||||||
|
@ -90,8 +90,8 @@ pub enum BehaviourEvent<TSpec: EthSpec> {
|
|||||||
id: MessageId,
|
id: MessageId,
|
||||||
/// The peer from which we received this message, not the peer that published it.
|
/// The peer from which we received this message, not the peer that published it.
|
||||||
source: PeerId,
|
source: PeerId,
|
||||||
/// The topics that this message was sent on.
|
/// The topic that this message was sent on.
|
||||||
topics: Vec<TopicHash>,
|
topic: TopicHash,
|
||||||
/// The message itself.
|
/// The message itself.
|
||||||
message: PubsubMessage<TSpec>,
|
message: PubsubMessage<TSpec>,
|
||||||
},
|
},
|
||||||
@ -537,7 +537,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
|||||||
} => {
|
} => {
|
||||||
// Note: We are keeping track here of the peer that sent us the message, not the
|
// Note: We are keeping track here of the peer that sent us the message, not the
|
||||||
// peer that originally published the message.
|
// peer that originally published the message.
|
||||||
match PubsubMessage::decode(&gs_msg.topics, gs_msg.data()) {
|
match PubsubMessage::decode(&gs_msg.topic, gs_msg.data()) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!(self.log, "Could not decode gossipsub message"; "error" => e);
|
debug!(self.log, "Could not decode gossipsub message"; "error" => e);
|
||||||
//reject the message
|
//reject the message
|
||||||
@ -554,7 +554,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
|||||||
self.add_event(BehaviourEvent::PubsubMessage {
|
self.add_event(BehaviourEvent::PubsubMessage {
|
||||||
id,
|
id,
|
||||||
source: propagation_source,
|
source: propagation_source,
|
||||||
topics: gs_msg.topics,
|
topic: gs_msg.topic,
|
||||||
message: msg,
|
message: msg,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -94,78 +94,58 @@ impl<T: EthSpec> PubsubMessage<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This decodes `data` into a `PubsubMessage` given a list of topics.
|
/// This decodes `data` into a `PubsubMessage` given a topic.
|
||||||
///
|
|
||||||
/// The topics are checked
|
|
||||||
/// in order and as soon as one topic matches the decoded data, we return the data.
|
|
||||||
/* Note: This is assuming we are not hashing topics. If we choose to hash topics, these will
|
/* Note: This is assuming we are not hashing topics. If we choose to hash topics, these will
|
||||||
* need to be modified.
|
* need to be modified.
|
||||||
*
|
|
||||||
* Also note that a message can be associated with many topics. As soon as one of the topics is
|
|
||||||
* known we match. If none of the topics are known we return an unknown state.
|
|
||||||
*/
|
*/
|
||||||
pub fn decode(topics: &[TopicHash], data: &MessageData) -> Result<Self, String> {
|
pub fn decode(topic: &TopicHash, data: &MessageData) -> Result<Self, String> {
|
||||||
let mut unknown_topics = Vec::new();
|
match GossipTopic::decode(topic.as_str()) {
|
||||||
for topic in topics {
|
Err(_) => Err(format!("Unknown gossipsub topic: {:?}", topic)),
|
||||||
match GossipTopic::decode(topic.as_str()) {
|
Ok(gossip_topic) => {
|
||||||
Err(_) => {
|
let decompressed_data = match gossip_topic.encoding() {
|
||||||
unknown_topics.push(topic);
|
GossipEncoding::SSZSnappy => data.decompressed.as_ref()?.as_slice(),
|
||||||
continue;
|
};
|
||||||
}
|
// the ssz decoders
|
||||||
Ok(gossip_topic) => {
|
match gossip_topic.kind() {
|
||||||
let decompressed_data = match gossip_topic.encoding() {
|
GossipKind::BeaconAggregateAndProof => {
|
||||||
GossipEncoding::SSZSnappy => data.decompressed.as_ref()?.as_slice(),
|
let agg_and_proof =
|
||||||
};
|
SignedAggregateAndProof::from_ssz_bytes(decompressed_data)
|
||||||
// the ssz decoders
|
|
||||||
match gossip_topic.kind() {
|
|
||||||
GossipKind::BeaconAggregateAndProof => {
|
|
||||||
let agg_and_proof =
|
|
||||||
SignedAggregateAndProof::from_ssz_bytes(decompressed_data)
|
|
||||||
.map_err(|e| format!("{:?}", e))?;
|
|
||||||
return Ok(PubsubMessage::AggregateAndProofAttestation(Box::new(
|
|
||||||
agg_and_proof,
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
GossipKind::Attestation(subnet_id) => {
|
|
||||||
let attestation = Attestation::from_ssz_bytes(decompressed_data)
|
|
||||||
.map_err(|e| format!("{:?}", e))?;
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
return Ok(PubsubMessage::Attestation(Box::new((
|
Ok(PubsubMessage::AggregateAndProofAttestation(Box::new(
|
||||||
*subnet_id,
|
agg_and_proof,
|
||||||
attestation,
|
)))
|
||||||
))));
|
}
|
||||||
}
|
GossipKind::Attestation(subnet_id) => {
|
||||||
GossipKind::BeaconBlock => {
|
let attestation = Attestation::from_ssz_bytes(decompressed_data)
|
||||||
let beacon_block = SignedBeaconBlock::from_ssz_bytes(decompressed_data)
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
.map_err(|e| format!("{:?}", e))?;
|
Ok(PubsubMessage::Attestation(Box::new((
|
||||||
return Ok(PubsubMessage::BeaconBlock(Box::new(beacon_block)));
|
*subnet_id,
|
||||||
}
|
attestation,
|
||||||
GossipKind::VoluntaryExit => {
|
))))
|
||||||
let voluntary_exit =
|
}
|
||||||
SignedVoluntaryExit::from_ssz_bytes(decompressed_data)
|
GossipKind::BeaconBlock => {
|
||||||
.map_err(|e| format!("{:?}", e))?;
|
let beacon_block = SignedBeaconBlock::from_ssz_bytes(decompressed_data)
|
||||||
return Ok(PubsubMessage::VoluntaryExit(Box::new(voluntary_exit)));
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
}
|
Ok(PubsubMessage::BeaconBlock(Box::new(beacon_block)))
|
||||||
GossipKind::ProposerSlashing => {
|
}
|
||||||
let proposer_slashing =
|
GossipKind::VoluntaryExit => {
|
||||||
ProposerSlashing::from_ssz_bytes(decompressed_data)
|
let voluntary_exit = SignedVoluntaryExit::from_ssz_bytes(decompressed_data)
|
||||||
.map_err(|e| format!("{:?}", e))?;
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
return Ok(PubsubMessage::ProposerSlashing(Box::new(
|
Ok(PubsubMessage::VoluntaryExit(Box::new(voluntary_exit)))
|
||||||
proposer_slashing,
|
}
|
||||||
)));
|
GossipKind::ProposerSlashing => {
|
||||||
}
|
let proposer_slashing = ProposerSlashing::from_ssz_bytes(decompressed_data)
|
||||||
GossipKind::AttesterSlashing => {
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
let attester_slashing =
|
Ok(PubsubMessage::ProposerSlashing(Box::new(proposer_slashing)))
|
||||||
AttesterSlashing::from_ssz_bytes(decompressed_data)
|
}
|
||||||
.map_err(|e| format!("{:?}", e))?;
|
GossipKind::AttesterSlashing => {
|
||||||
return Ok(PubsubMessage::AttesterSlashing(Box::new(
|
let attester_slashing = AttesterSlashing::from_ssz_bytes(decompressed_data)
|
||||||
attester_slashing,
|
.map_err(|e| format!("{:?}", e))?;
|
||||||
)));
|
Ok(PubsubMessage::AttesterSlashing(Box::new(attester_slashing)))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(format!("Unknown gossipsub topics: {:?}", unknown_topics))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encodes a `PubsubMessage` based on the topic encodings. The first known encoding is used. If
|
/// Encodes a `PubsubMessage` based on the topic encodings. The first known encoding is used. If
|
||||||
|
Loading…
Reference in New Issue
Block a user