Skip to content

Commit

Permalink
Reject connections to peers on old proto. versions
Browse files Browse the repository at this point in the history
Avoid connecting to peers that are on protocol versions that don't
recognize a network update.
  • Loading branch information
jvff committed Jul 23, 2021
1 parent 35a599c commit fda74f5
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions zebra-network/src/peer/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,17 +567,9 @@ pub async fn negotiate_version(
Err(HandshakeError::NonceReuse)?;
}

// TODO: Reject connections with nodes that don't know about the current network upgrade (#1334)
// Use the latest non-finalized block height, rather than the minimum
if remote_version
< Version::min_remote_for_height(
config.network,
// This code will be replaced in #1334
constants::INITIAL_MIN_NETWORK_PROTOCOL_VERSION
.activation_height(config.network)
.expect("minimum network protocol network upgrade has an activation height"),
)
{
let tip_height = best_tip_height.non_finalized();
let min_version = Version::min_remote_for_height(config.network, tip_height);
if remote_version < min_version {
// Disconnect if peer is using an obsolete version.
Err(HandshakeError::ObsoleteVersion(remote_version))?;
}
Expand Down

0 comments on commit fda74f5

Please sign in to comment.