8000 removed messages of unimplemented EpochSync by pompon0 · Pull Request #7911 · near/nearcore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

removed messages of unimplemented EpochSync #7911

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

Merged
merged 3 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 0 additions & 8 deletions chain/client/src/client_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,6 @@ impl ClientActor {

NetworkClientResponses::NoResponse
}
NetworkClientMessages::EpochSyncResponse(_peer_id, _response) => {
// TODO #3488
NetworkClientResponses::NoResponse
}
NetworkClientMessages::EpochSyncFinalizationResponse(_peer_id, _response) => {
// TODO #3488
NetworkClientResponses::NoResponse
}
NetworkClientMessages::PartialEncodedChunkRequest(part_request_msg, route_back) => {
let _ = self
.client
Expand Down
197 changes: 104 additions & 93 deletions < 10000 span class="Truncate"> chain/client/src/test_utils.rs

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions chain/client/src/view_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,14 +1258,6 @@ impl Handler<WithSpanContext<NetworkViewClientMessages>> for ViewClientActor {

NetworkViewClientResponses::AnnounceAccount(filtered_announce_accounts)
}
NetworkViewClientMessages::EpochSyncRequest { epoch_id: _epoch_id } => {
// TODO #3488
NetworkViewClientResponses::NoResponse
}
NetworkViewClientMessages::EpochSyncFinalizationRequest { epoch_id: _epoch_id } => {
// TODO #3488
NetworkViewClientResponses::NoResponse
}
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions chain/network/src/network_protocol/borsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ use near_primitives::block::{Block, BlockHeader, GenesisId};
use near_primitives::challenge::Challenge;
use near_primitives::hash::CryptoHash;
use near_primitives::network::{AnnounceAccount, PeerId};
use near_primitives::syncing::{EpochSyncFinalizationResponse, EpochSyncResponse};
use near_primitives::transaction::SignedTransaction;
use near_primitives::types::EpochId;
use std::fmt;
use std::fmt::Formatter;

Expand Down Expand Up @@ -134,12 +132,12 @@ pub(super) enum PeerMessage {
/// Gracefully disconnect from other peer.
Disconnect,
Challenge(Challenge),
_HandshakeV2,
EpochSyncRequest(EpochId),
EpochSyncResponse(Box<EpochSyncResponse>),
EpochSyncFinalizationRequest(EpochId),
EpochSyncFinalizationResponse(Box<EpochSyncFinalizationResponse>),

_HandshakeV2,
_EpochSyncRequest,
_EpochSyncResponse,
_EpochSyncFinalizationRequest,
_EpochSyncFinalizationResponse,
_RoutingTableSyncV2,
}
#[cfg(target_arch = "x86_64")] // Non-x86_64 doesn't match this requirement yet but it's not bad as it's not production-ready
Expand Down
26 changes: 8 additions & 18 deletions chain/network/src/network_protocol/borsh_conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ pub enum ParsePeerMessageError {
DeprecatedHandshakeV2,
#[error("RoutingTableSyncV2 is deprecated")]
DeprecatedRoutingTableSyncV2,
#[error("EpochSync is deprecated")]
DeprecatedEpochSync,
}

impl TryFrom<&net::PeerMessage> for mem::PeerMessage {
Expand Down Expand Up @@ -127,15 +129,13 @@ impl TryFrom<&net::PeerMessage> for mem::PeerMessage {
net::PeerMessage::Disconnect => mem::PeerMessage::Disconnect,
net::PeerMessage::Challenge(c) => mem::PeerMessage::Challenge(c),
net::PeerMessage::_HandshakeV2 => return Err(Self::Error::DeprecatedHandshakeV2),
net::PeerMessage::EpochSyncRequest(epoch_id) => {
mem::PeerMessage::EpochSyncRequest(epoch_id)
net::PeerMessage::_EpochSyncRequest => return Err(Self::Error::DeprecatedEpochSync),
net::PeerMessage::_EpochSyncResponse => return Err(Self::Error::DeprecatedEpochSync),
net::PeerMessage::_EpochSyncFinalizationRequest => {
return Err(Self::Error::DeprecatedEpochSync)
}
net::PeerMessage::EpochSyncResponse(esr) => mem::PeerMessage::EpochSyncResponse(esr),
net::PeerMessage::EpochSyncFinalizationRequest(epoch_id) => {
mem::PeerMessage::EpochSyncFinalizationRequest(epoch_id)
}
net::PeerMessage::EpochSyncFinalizationResponse(esfr) => {
mem::PeerMessage::EpochSyncFinalizationResponse(esfr)
net::PeerMessage::_EpochSyncFinalizationResponse => {
return Err(Self::Error::DeprecatedEpochSync)
}
net::PeerMessage::_RoutingTableSyncV2 => {
return Err(Self::Error::DeprecatedRoutingTableSyncV2)
Expand Down Expand Up @@ -175,16 +175,6 @@ impl From<&mem::PeerMessage> for net::PeerMessage {
mem::PeerMessage::Routed(r) => net::PeerMessage::Routed(Box::new(r.msg.clone())),
mem::PeerMessage::Disconnect => net::PeerMessage::Disconnect,
mem::PeerMessage::Challenge(c) => net::PeerMessage::Challenge(c),
mem::PeerMessage::EpochSyncRequest(epoch_id) => {
net::PeerMessage::EpochSyncRequest(epoch_id)
}
mem::PeerMessage::EpochSyncResponse(esr) => net::PeerMessage::EpochSyncResponse(esr),
mem::PeerMessage::EpochSyncFinalizationRequest(epoch_id) => {
net::PeerMessage::EpochSyncFinalizationRequest(epoch_id)
}
mem::PeerMessage::EpochSyncFinalizationResponse(esfr) => {
net::PeerMessage::EpochSyncFinalizationResponse(esfr)
}
}
}
}
5 changes: 0 additions & 5 deletions chain/network/src/network_protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use near_primitives::network::{AnnounceAccount, PeerId};
use near_primitives::sharding::{
ChunkHash, PartialEncodedChunk, PartialEncodedChunkPart, ReceiptProof, ShardChunkHeader,
};
use near_primitives::syncing::{EpochSyncFinalizationResponse, EpochSyncResponse};
use near_primitives::syncing::{ShardStateSyncResponse, ShardStateSyncResponseV1};
use near_primitives::transaction::SignedTransaction;
use near_primitives::types::{AccountId, EpochId};
Expand Down Expand Up @@ -256,10 +255,6 @@ pub enum PeerMessage {
/// Gracefully disconnect from other peer.
Disconnect,
Challenge(Challenge),
EpochSyncRequest(EpochId),
EpochSyncResponse(Box<EpochSyncResponse>),
EpochSyncFinalizationRequest(EpochId),
EpochSyncFinalizationResponse(Box<EpochSyncFinalizationResponse>),
Copy link
Contributor
9E81

Choose a reason for hiding this comment

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

ouch, good catch! So we actually have the capability to send these messages over the network, they are succesfully decoded, and than just get discarded as unxepected messages.

}

impl fmt::Display for PeerMessage {
Expand Down
29 changes: 1 addition & 28 deletions chain/network/src/network_protocol/network.proto
Original file line number Diff line number Diff line change
Expand Up @@ -316,28 +316,6 @@ message Challenge {
bytes borsh = 1;
}

// TODO: document it
message EpochSyncRequest {
CryptoHash epoch_id = 1;
}

// Wrapper of borsh-encoded EpochSyncResponse
// https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/core/primitives/src/syncing.rs#L225
message EpochSyncResponse {
bytes borsh = 1;
}

// TODO: document it
message EpochSyncFinalizationRequest {
CryptoHash epoch_id = 1;
}

// Wrapper of borsh-encoded EpochSyncFinalizationResponse
// https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/core/primitives/src/syncing.rs#L202
message EpochSyncFinalizationResponse {
bytes borsh = 1;
}

// Wrapper of borsh-encoded RoutingSyncV2
// https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/chain/network/src/network_protocol.rs#L225
message RoutingSyncV2 {
Expand All @@ -354,7 +332,7 @@ message PeerMessage {
// https://docs.google.com/document/d/1gCWmt9O-h_-5JDXIqbKxAaSS3Q9pryB1f9DDY1mMav4/edit
reserved 1,2,3;
// Deprecated fields.
reserved 24;
reserved 20,21,22,23,24;

oneof message_type {
Handshake handshake = 4;
Expand All @@ -380,10 +358,5 @@ message PeerMessage {
RoutedMessage routed = 17;
Disconnect disconnect = 18;
Challenge challenge = 19;

EpochSyncRequest epoch_sync_request = 20;
EpochSyncResponse epoch_sync_response = 21;
EpochSyncFinalizationRequest epoch_sync_finalization_request = 22;
EpochSyncFinalizationResponse epoch_sync_finalization_response = 23;
}
}
55 changes: 0 additions & 55 deletions chain/network/src/network_protocol/proto_conv/peer_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use crate::time::error::ComponentRange;
use borsh::{BorshDeserialize as _, BorshSerialize as _};
use near_primitives::block::{Block, BlockHeader};
use near_primitives::challenge::Challenge;
use near_primitives::syncing::{EpochSyncFinalizationResponse, EpochSyncResponse};
use near_primitives::transaction::SignedTransaction;
use near_primitives::types::EpochId;
use protobuf::MessageField as MF;
use std::sync::Arc;

Expand Down Expand Up @@ -155,30 +153,6 @@ impl From<&PeerMessage> for proto::PeerMessage {
borsh: r.try_to_vec().unwrap(),
..Default::default()
}),
PeerMessage::EpochSyncRequest(epoch_id) => {
ProtoMT::EpochSyncRequest(proto::EpochSyncRequest {
epoch_id: MF::some((&epoch_id.0).into()),
..Default::default()
})
}
PeerMessage::EpochSyncResponse(esr) => {
ProtoMT::EpochSyncResponse(proto::EpochSyncResponse {
borsh: esr.try_to_vec().unwrap(),
..Default::default()
})
}
PeerMessage::EpochSyncFinalizationRequest(epoch_id) => {
ProtoMT::EpochSyncFinalizationRequest(proto::EpochSyncFinalizationRequest {
epoch_id: MF::some((&epoch_id.0).into()),
..Default::default()
})
}
PeerMessage::EpochSyncFinalizationResponse(esfr) => {
ProtoMT::EpochSyncFinalizationResponse(proto::EpochSyncFinalizationResponse {
borsh: esfr.try_to_vec().unwrap(),
..Default::default()
})
}
}),
..Default::default()
}
Expand All @@ -188,8 +162,6 @@ impl From<&PeerMessage> for proto::PeerMessage {
pub type ParseTransactionError = borsh::maybestd::io::Error;
pub type ParseRoutedError = borsh::maybestd::io::Error;
pub type ParseChallengeError = borsh::maybestd::io::Error;
pub type ParseEpochSyncResponseError = borsh::maybestd::io::Error;
pub type ParseEpochSyncFinalizationResponseError = borsh::maybestd::io::Error;

#[derive(thiserror::Error, Debug)]
pub enum ParsePeerMessageError {
Expand Down Expand Up @@ -223,14 +195,6 @@ pub enum ParsePeerMessageError {
Routed(ParseRoutedError),
#[error("challenge: {0}")]
Challenge(ParseChallengeError),
#[error("epoch_sync_request: {0}")]
EpochSyncRequest(ParseRequiredError<ParseCryptoHashError>),
#[error("epoch_sync_response: {0}")]
EpochSyncResponse(ParseEpochSyncResponseError),
#[error("epoch_sync_finalization_request: {0}")]
EpochSyncFinalizationRequest(ParseRequiredError<ParseCryptoHashError>),
#[error("epoch_sync_finalization_response: {0}")]
EpochSyncFinalizationResponse(ParseEpochSyncFinalizationResponseError),
#[error("routed_created_at: {0}")]
RoutedCreatedAtTimestamp(ComponentRange),
#[error("sync_accounts_data: {0}")]
Expand Down Expand Up @@ -302,25 +266,6 @@ impl TryFrom<&proto::PeerMessage> for PeerMessage {
ProtoMT::Challenge(c) => PeerMessage::Challenge(
Challenge::try_from_slice(&c.borsh).map_err(Self::Error::Challenge)?,
),
ProtoMT::EpochSyncRequest(esr) => PeerMessage::EpochSyncRequest(EpochId(
try_from_required(&esr.epoch_id).map_err(Self::Error::EpochSyncRequest)?,
)),
ProtoMT::EpochSyncResponse(esr) => PeerMessage::EpochSyncResponse(Box::new(
EpochSyncResponse::try_from_slice(&esr.borsh)
.map_err(Self::Error::EpochSyncResponse)?,
)),
ProtoMT::EpochSyncFinalizationRequest(esr) => {
PeerMessage::EpochSyncFinalizationRequest(EpochId(
try_from_required(&esr.epoch_id)
.map_err(Self::Error::EpochSyncFinalizationRequest)?,
))
}
ProtoMT::EpochSyncFinalizationResponse(esr) => {
PeerMessage::EpochSyncFinalizationResponse(Box::new(
EpochSyncFinalizationResponse::try_from_slice(&esr.borsh)
.map_err(Self::Error::EpochSyncFinalizationResponse)?,
))
}
})
}
}
7 changes: 0 additions & 7 deletions chain/network/src/network_protocol/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use crate::time;
use crate::types::{HandshakeFailureReason, PeerMessage};
use crate::types::{PartialEncodedChunkRequestMsg, PartialEncodedChunkResponseMsg};
use anyhow::{bail, Context as _};
use near_primitives::syncing::EpochSyncResponse;
use near_primitives::types::EpochId;

#[test]
fn bad_account_data_size() {
Expand Down Expand Up @@ -58,7 +56,6 @@ fn serialize_deserialize() -> anyhow::Result<()> {
let a = data::make_signer(&mut rng);
let b = data::make_signer(&mut rng);
let edge = data::make_edge(&a, &b);
let epoch_id = EpochId(chain.blocks[1].hash().clone());

let chunk_hash = chain.blocks[3].chunks()[0].chunk_hash();
let routed_message1 = Box::new(data::make_routed_message(
Expand Down Expand Up @@ -98,10 +95,6 @@ fn serialize_deserialize() -> anyhow::Result<()> {
PeerMessage::Routed(routed_message2),
PeerMessage::Disconnect,
PeerMessage::Challenge(data::make_challenge(&mut rng)),
PeerMessage::EpochSyncRequest(epoch_id.clone()),
PeerMessage::EpochSyncResponse(Box::new(EpochSyncResponse::UpToDate)),
PeerMessage::EpochSyncFinalizationRequest(epoch_id),
// TODO: EpochSyncFinalizationResponse
];

// Check that serialize;deserialize = 1
Expand Down
23 changes: 0 additions & 23 deletions chain/network/src/peer_manager/peer_manager_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,29 +1096,6 @@ impl PeerManagerActor {
NetworkResponses::RouteNotFound
}
}
// unused: epoch sync is not implemented
NetworkRequests::EpochSyncRequest { peer_id, epoch_id } => {
if self
.state
.tier2
.send_message(peer_id, Arc::new(PeerMessage::EpochSyncRequest(epoch_id)))
{
NetworkResponses::NoResponse
} else {
NetworkResponses::RouteNotFound
}
}
// unused: epoch sync is not implemented
NetworkRequests::EpochSyncFinalizationRequest { peer_id, epoch_id } => {
if self.state.tier2.send_message(
peer_id,
Arc::new(PeerMessage::EpochSyncFinalizationRequest(epoch_id)),
) {
NetworkResponses::NoResponse
} else {
NetworkResponses::RouteNotFound
}
}
NetworkRequests::BanPeer { peer_id, ban_reason } => {
self.try_ban_peer(&peer_id, ban_reason);
NetworkResponses::NoResponse
Expand Down
15 changes: 0 additions & 15 deletions chain/network/src/testonly/fake_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use near_primitives::challenge::Challenge;
use near_primitives::hash::CryptoHash;
use near_primitives::network::AnnounceAccount;
use near_primitives::sharding::{ChunkHash, PartialEncodedChunkPart};
use near_primitives::syncing::EpochSyncResponse;
use near_primitives::transaction::SignedTransaction;
use near_primitives::types::EpochId;

Expand All @@ -22,9 +21,6 @@ pub enum Event {
ChunkRequest(ChunkHash),
Transaction(SignedTransaction),
Challenge(Challenge),
EpochSyncRequest(EpochId),
EpochSyncResponse(EpochSyncResponse),
EpochSyncFinalizationRequest(EpochId),
AnnounceAccount(Vec<(AnnounceAccount, Option<EpochId>)>),
}

Expand Down Expand Up @@ -57,14 +53,6 @@ impl actix::Handler<WithSpanContext<NetworkViewClientMessages>> for Actor {
self.event_sink.push(Event::BlockHeadersRequest(req));
NetworkViewClientResponses::NoResponse
}
NetworkViewClientMessages::EpochSyncRequest { epoch_id } => {
self.event_sink.push(Event::EpochSyncRequest(epoch_id));
NetworkViewClientResponses::NoResponse
}
NetworkViewClientMessages::EpochSyncFinalizationRequest { epoch_id } => {
self.event_sink.push(Event::EpochSyncFinalizationRequest(epoch_id));
NetworkViewClientResponses::NoResponse
}
NetworkViewClientMessages::AnnounceAccount(aas) => {
self.event_sink.push(Event::AnnounceAccount(aas.clone()));
NetworkViewClientResponses::AnnounceAccount(aas.into_iter().map(|a| a.0).collect())
Expand Down Expand Up @@ -103,9 +91,6 @@ impl actix::Handler<WithSpanContext<NetworkClientMessages>> for Actor {
resp = NetworkClientResponses::ValidTx;
}
NetworkClientMessages::Challenge(c) => self.event_sink.push(Event::Challenge(c)),
NetworkClientMessages::EpochSyncResponse(_, resp) => {
self.event_sink.push(Event::EpochSyncResponse(*resp))
}
NetworkClientMessages::NetworkInfo(_) => {}
msg => {
let msg_type: &'static str = msg.into();
Expand Down
Loading
0