Handshake requests will exceed handshake limit after enough protocol updates
abizjak opened this issue · comments
Bug Description
In the initial noise handshake the node has a hard limit of 1024 bytes for the message and it soft-bans the peer that exceeds this limit.
This is fine at the moment, but it will stop being fine after enough protocol updates. With each new protocol 32 bytes are added to the handshake to include the extra regenesis hash.
/// Creates a "high-level" handshake request to be sent to new peers.
pub fn produce_handshake_request(&self) -> anyhow::Result<Vec<u8>> {
let handshake_request = netmsg!(
NetworkRequest,
NetworkRequest::Handshake(Handshake {
remote_id: self.self_peer.id,
remote_port: self.self_peer.port(),
networks: read_or_die!(self.networks()).iter().copied().collect(),
node_version: Version::parse(env!("CARGO_PKG_VERSION"))?,
wire_versions: WIRE_PROTOCOL_VERSIONS.to_vec(),
genesis_blocks: read_or_die!(self.config.regenesis_arc.blocks).clone(),
proof: vec![],
})
);
let mut serialized = Vec::with_capacity(128);
handshake_request.serialize(&mut serialized)?;
Ok(serialized)
}
I don't know what the minimum number of protocol updates is that triggers the problem, but after 23 protocol updates the handshake is already too large. It works with 10, and I have not analyzed the sizes in between.
Steps to Reproduce
Start two nodes
Make ? protocol updates (23 is enough, probably a few fewer is enough)
Restart one of the nodes.
Expected Result
The node connects
Actual Result
The node fails with something like
ERROR: [receiving from 127.0.0.1:8000] expected message size (1.4 kiB) exceeds the handshake size limit (1.0 kiB)
Versions
- Software Version: <= 6.2