Skip to content
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

Handshake requests will exceed handshake limit after enough protocol updates #1090

Open
abizjak opened this issue Nov 22, 2023 · 0 comments
Open
Labels
[Prio] Low Should be fixed if time permits but can be postponed. [Type] Bug Something isn't working

Comments

@abizjak
Copy link
Contributor

abizjak commented Nov 22, 2023

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
@abizjak abizjak added [Prio] Low Should be fixed if time permits but can be postponed. [Type] Bug Something isn't working labels Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Prio] Low Should be fixed if time permits but can be postponed. [Type] Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant