mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
V0.11.0 network update (#976)
* Adjust RPC methods to match v0.11.1 * Adds fork handling for gossipsub topics * Update gossipsub topics to v0.11.0
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::service::NetworkMessage;
|
||||
use beacon_chain::{AttestationType, BeaconChain, BeaconChainTypes};
|
||||
use eth2_libp2p::{
|
||||
rpc::{RPCError, RPCErrorResponse, RPCRequest, RPCResponse, RequestId, ResponseTermination},
|
||||
MessageId, PeerId, PubsubData, PubsubMessage, RPCEvent,
|
||||
MessageId, PeerId, PubsubMessage, RPCEvent,
|
||||
};
|
||||
use futures::future::Future;
|
||||
use futures::stream::Stream;
|
||||
@@ -217,9 +217,9 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
peer_id: PeerId,
|
||||
gossip_message: PubsubMessage<T::EthSpec>,
|
||||
) {
|
||||
match gossip_message.data {
|
||||
match gossip_message {
|
||||
// Attestations should never reach the router.
|
||||
PubsubData::AggregateAndProofAttestation(aggregate_and_proof) => {
|
||||
PubsubMessage::AggregateAndProofAttestation(aggregate_and_proof) => {
|
||||
if self
|
||||
.processor
|
||||
.should_forward_aggregate_attestation(&aggregate_and_proof)
|
||||
@@ -232,7 +232,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
AttestationType::Aggregated,
|
||||
);
|
||||
}
|
||||
PubsubData::Attestation(subnet_attestation) => {
|
||||
PubsubMessage::Attestation(subnet_attestation) => {
|
||||
if self
|
||||
.processor
|
||||
.should_forward_attestation(&subnet_attestation.1)
|
||||
@@ -245,7 +245,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
AttestationType::Unaggregated { should_store: true },
|
||||
);
|
||||
}
|
||||
PubsubData::BeaconBlock(block) => match self.processor.should_forward_block(block) {
|
||||
PubsubMessage::BeaconBlock(block) => match self.processor.should_forward_block(block) {
|
||||
Ok(verified_block) => {
|
||||
self.propagate_message(id, peer_id.clone());
|
||||
self.processor.on_block_gossip(peer_id, verified_block);
|
||||
@@ -255,19 +255,19 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
"error" => format!("{:?}", e));
|
||||
}
|
||||
},
|
||||
PubsubData::VoluntaryExit(_exit) => {
|
||||
PubsubMessage::VoluntaryExit(_exit) => {
|
||||
// TODO: Apply more sophisticated validation
|
||||
self.propagate_message(id, peer_id.clone());
|
||||
// TODO: Handle exits
|
||||
debug!(self.log, "Received a voluntary exit"; "peer_id" => format!("{}", peer_id) );
|
||||
}
|
||||
PubsubData::ProposerSlashing(_proposer_slashing) => {
|
||||
PubsubMessage::ProposerSlashing(_proposer_slashing) => {
|
||||
// TODO: Apply more sophisticated validation
|
||||
self.propagate_message(id, peer_id.clone());
|
||||
// TODO: Handle proposer slashings
|
||||
debug!(self.log, "Received a proposer slashing"; "peer_id" => format!("{}", peer_id) );
|
||||
}
|
||||
PubsubData::AttesterSlashing(_attester_slashing) => {
|
||||
PubsubMessage::AttesterSlashing(_attester_slashing) => {
|
||||
// TODO: Apply more sophisticated validation
|
||||
self.propagate_message(id, peer_id.clone());
|
||||
// TODO: Handle attester slashings
|
||||
|
||||
@@ -25,7 +25,7 @@ pub(crate) const FUTURE_SLOT_TOLERANCE: u64 = 1;
|
||||
/// Keeps track of syncing information for known connected peers.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct PeerSyncInfo {
|
||||
fork_version: [u8; 4],
|
||||
fork_digest: [u8; 4],
|
||||
pub finalized_root: Hash256,
|
||||
pub finalized_epoch: Epoch,
|
||||
pub head_root: Hash256,
|
||||
@@ -35,7 +35,7 @@ pub struct PeerSyncInfo {
|
||||
impl From<StatusMessage> for PeerSyncInfo {
|
||||
fn from(status: StatusMessage) -> PeerSyncInfo {
|
||||
PeerSyncInfo {
|
||||
fork_version: status.fork_version,
|
||||
fork_digest: status.fork_digest,
|
||||
finalized_root: status.finalized_root,
|
||||
finalized_epoch: status.finalized_epoch,
|
||||
head_root: status.head_root,
|
||||
@@ -123,7 +123,7 @@ impl<T: BeaconChainTypes> Processor<T> {
|
||||
self.log,
|
||||
"Sending Status Request";
|
||||
"peer" => format!("{:?}", peer_id),
|
||||
"fork_version" => format!("{:?}", status_message.fork_version),
|
||||
"fork_digest" => format!("{:?}", status_message.fork_digest),
|
||||
"finalized_root" => format!("{:?}", status_message.finalized_root),
|
||||
"finalized_epoch" => format!("{:?}", status_message.finalized_epoch),
|
||||
"head_root" => format!("{}", status_message.head_root),
|
||||
@@ -147,7 +147,7 @@ impl<T: BeaconChainTypes> Processor<T> {
|
||||
self.log,
|
||||
"Received Status Request";
|
||||
"peer" => format!("{:?}", peer_id),
|
||||
"fork_version" => format!("{:?}", status.fork_version),
|
||||
"fork_digest" => format!("{:?}", status.fork_digest),
|
||||
"finalized_root" => format!("{:?}", status.finalized_root),
|
||||
"finalized_epoch" => format!("{:?}", status.finalized_epoch),
|
||||
"head_root" => format!("{}", status.head_root),
|
||||
@@ -193,12 +193,14 @@ impl<T: BeaconChainTypes> Processor<T> {
|
||||
|
||||
let start_slot = |epoch: Epoch| epoch.start_slot(T::EthSpec::slots_per_epoch());
|
||||
|
||||
if local.fork_version != remote.fork_version {
|
||||
if local.fork_digest != remote.fork_digest {
|
||||
// The node is on a different network/fork, disconnect them.
|
||||
debug!(
|
||||
self.log, "Handshake Failure";
|
||||
"peer" => format!("{:?}", peer_id),
|
||||
"reason" => "network_id"
|
||||
"reason" => "incompatible forks",
|
||||
"our_fork" => hex::encode(local.fork_digest),
|
||||
"their_fork" => hex::encode(remote.fork_digest)
|
||||
);
|
||||
|
||||
self.network
|
||||
@@ -631,8 +633,9 @@ pub(crate) fn status_message<T: BeaconChainTypes>(
|
||||
) -> Option<StatusMessage> {
|
||||
let head_info = beacon_chain.head_info().ok()?;
|
||||
|
||||
// TODO: Update fork digest calculation
|
||||
Some(StatusMessage {
|
||||
fork_version: head_info.fork.current_version,
|
||||
fork_digest: head_info.fork.current_version,
|
||||
finalized_root: head_info.finalized_checkpoint.root,
|
||||
finalized_epoch: head_info.finalized_checkpoint.epoch,
|
||||
head_root: head_info.block_root,
|
||||
|
||||
Reference in New Issue
Block a user