mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-25 13:07:18 +00:00
Shift gossip duplication into gossipsub (#1025)
* Remove hidden gossip source, improve logging * Shift gossip cache into gossipsub
This commit is contained in:
parent
2871253905
commit
49c77fe74b
@ -8,7 +8,7 @@ edition = "2018"
|
|||||||
hex = "0.3"
|
hex = "0.3"
|
||||||
# rust-libp2p is presently being sourced from a Sigma Prime fork of the
|
# rust-libp2p is presently being sourced from a Sigma Prime fork of the
|
||||||
# `libp2p/rust-libp2p` repository.
|
# `libp2p/rust-libp2p` repository.
|
||||||
libp2p = { git = "https://github.com/SigP/rust-libp2p", rev = "2b6d002161f142b1db350f6d1302b4a84a1d4234" }
|
libp2p = { git = "https://github.com/SigP/rust-libp2p", rev = "8517d93012e9a5cc1d61fbee52c8da59727347ed" }
|
||||||
types = { path = "../../eth2/types" }
|
types = { path = "../../eth2/types" }
|
||||||
hashmap_delay = { path = "../../eth2/utils/hashmap_delay" }
|
hashmap_delay = { path = "../../eth2/utils/hashmap_delay" }
|
||||||
eth2_ssz_types = { path = "../../eth2/utils/ssz_types" }
|
eth2_ssz_types = { path = "../../eth2/utils/ssz_types" }
|
||||||
|
@ -49,6 +49,7 @@ pub struct Behaviour<TSubstream: AsyncRead + AsyncWrite, TSpec: EthSpec> {
|
|||||||
/// A cache of recently seen gossip messages. This is used to filter out any possible
|
/// A cache of recently seen gossip messages. This is used to filter out any possible
|
||||||
/// duplicates that may still be seen over gossipsub.
|
/// duplicates that may still be seen over gossipsub.
|
||||||
#[behaviour(ignore)]
|
#[behaviour(ignore)]
|
||||||
|
// TODO: Remove this
|
||||||
seen_gossip_messages: LruCache<MessageId, ()>,
|
seen_gossip_messages: LruCache<MessageId, ()>,
|
||||||
/// A collections of variables accessible outside the network service.
|
/// A collections of variables accessible outside the network service.
|
||||||
#[behaviour(ignore)]
|
#[behaviour(ignore)]
|
||||||
@ -349,7 +350,14 @@ impl<TSubstream: AsyncRead + AsyncWrite, TSpec: EthSpec>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warn!(self.log, "A duplicate gossipsub message was received"; "message" => format!("{:?}", gs_msg));
|
match PubsubMessage::<TSpec>::decode(&gs_msg.topics, &gs_msg.data) {
|
||||||
|
Err(e) => {
|
||||||
|
debug!(self.log, "Could not decode gossipsub message"; "error" => format!("{}", e))
|
||||||
|
}
|
||||||
|
Ok(msg) => {
|
||||||
|
crit!(self.log, "A duplicate gossipsub message was received"; "message_source" => format!("{}", gs_msg.source), "propagated_peer" => format!("{}",propagation_source), "message" => format!("{}", msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GossipsubEvent::Subscribed { peer_id, topic } => {
|
GossipsubEvent::Subscribed { peer_id, topic } => {
|
||||||
|
@ -172,3 +172,30 @@ impl<T: EthSpec> PubsubMessage<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: EthSpec> std::fmt::Display for PubsubMessage<T> {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
PubsubMessage::BeaconBlock(block) => write!(
|
||||||
|
f,
|
||||||
|
"Beacon Block: slot: {}, proposer_index: {}",
|
||||||
|
block.message.slot, block.message.proposer_index
|
||||||
|
),
|
||||||
|
PubsubMessage::AggregateAndProofAttestation(att) => write!(
|
||||||
|
f,
|
||||||
|
"Aggregate and Proof: slot: {}, index: {}, aggregator_index: {}",
|
||||||
|
att.message.aggregate.data.slot,
|
||||||
|
att.message.aggregate.data.index,
|
||||||
|
att.message.aggregator_index,
|
||||||
|
),
|
||||||
|
PubsubMessage::Attestation(data) => write!(
|
||||||
|
f,
|
||||||
|
"Attestation: subnet_id: {}, attestation_slot: {}, attestation_index: {}",
|
||||||
|
*data.0, data.1.data.slot, data.1.data.index,
|
||||||
|
),
|
||||||
|
PubsubMessage::VoluntaryExit(_data) => write!(f, "Voluntary Exit"),
|
||||||
|
PubsubMessage::ProposerSlashing(_data) => write!(f, "Proposer Slashing"),
|
||||||
|
PubsubMessage::AttesterSlashing(_data) => write!(f, "Attester Slashing"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user