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

BreachOfProtocol on network id mismatch #7727

Open
arnetheduck opened this issue Nov 6, 2024 · 7 comments · May be fixed by #7899
Open

BreachOfProtocol on network id mismatch #7727

arnetheduck opened this issue Nov 6, 2024 · 7 comments · May be fixed by #7899
Assignees

Comments

@arnetheduck
Copy link

In RLPx, BreachOfProtocol is used for malformed messages (invalid RLP) and other protocol violations.

However, when testing nimbus with nethermind it appears we're receiving it on networkid mismatch, ie when connecting a mainnet node to a holesky nethermind and vice versa. Normally, one would have expected a UselessPeer error.

return EthDisconnectReason.BreachOfProtocol;

Is this intentional?

@Marchhill
Copy link
Contributor

Marchhill commented Dec 2, 2024

@arnetheduck yes this seems to be the case, from the docs you sent there aren't any descriptions of when the different disconnection messages should be used. BreachOfProtocol seems like a reasonable error to throw here, is there a spec that says UselessPeer should be thrown?

@arnetheduck
Copy link
Author

Well, the linked spec says about BreachOfProtocol:

Breach of protocol, e.g. a malformed message, bad RLP, ...

I read that as a category of errors relating to structural protocol/encoding issues rather than valid data with mismatching higher-level interpretation. A breach of protcol would effectively be a bug in the implementation or malicious behavior whereas a network id mismatch is a benign issue that happens in a normally operating network with honest peers. Sure, the spec doesn't say this out loud but UselessPeer is what we get from other impls in this case.

@Marchhill
Copy link
Contributor

Well, the linked spec says about BreachOfProtocol:

Breach of protocol, e.g. a malformed message, bad RLP, ...

I read that as a category of errors relating to structural protocol/encoding issues rather than valid data with mismatching higher-level interpretation. A breach of protcol would effectively be a bug in the implementation or malicious behavior whereas a network id mismatch is a benign issue that happens in a normally operating network with honest peers. Sure, the spec doesn't say this out loud but UselessPeer is what we get from other impls in this case.

The chain number could be considered part of the encoding though, if we use version id x on chain y then this message is malformed. UselessPeer sounds more like a networking issue

@arnetheduck
Copy link
Author

I mean, it ultimately doesn't matter greatly tbh, except for some penalty time which probably only affects testnets practically - I noted that nethermind sends a different value than other clients in this particular case while looking into why there were so many protocol breaches from nethermind but not from others, to make sure nimbus is indeed not sending actual malformed messages that nethermind can't read. In other words, it's "normal" that we encounter peers on different chains - it would not be normal for nimbus to send malformed messages.

Feel free to close this issue if you're not planning to change it, I don't think it's worth that much.

The chain number could be considered part of the encoding though, if we use version id x

This would be a very unusual protocol, if "well-formed message with unknown version" is treated the same as "malformed message" - the reason to have a version field to begin with is to allow the consuming side to treat it gracefully rather than as a protocol breach. Nitpicking, this is a "well-formed message whose content I cannot interpret" (assuming the RLP is valid and the message follows all other formulaic constraints). Anyway.

@Marchhill
Copy link
Contributor

I mean, it ultimately doesn't matter greatly tbh, except for some penalty time which probably only affects testnets practically - I noted that nethermind sends a different value than other clients in this particular case while looking into why there were so many protocol breaches from nethermind but not from others, to make sure nimbus is indeed not sending actual malformed messages that nethermind can't read. In other words, it's "normal" that we encounter peers on different chains - it would not be normal for nimbus to send malformed messages.

Feel free to close this issue if you're not planning to change it, I don't think it's worth that much.

The chain number could be considered part of the encoding though, if we use version id x

This would be a very unusual protocol, if "well-formed message with unknown version" is treated the same as "malformed message" - the reason to have a version field to begin with is to allow the consuming side to treat it gracefully rather than as a protocol breach. Nitpicking, this is a "well-formed message whose content I cannot interpret" (assuming the RLP is valid and the message follows all other formulaic constraints). Anyway.

It's unclear to me what it should be since the spec is so vague. Do you know if other clients send UselessPeer in this situation?

@arnetheduck
Copy link
Author

It's unclear to me what it should be since the spec is so vague. Do you know if other clients send UselessPeer in this situation?

other clients send UselessPeer on network id mismatch, yes.

@Marchhill Marchhill linked a pull request Dec 12, 2024 that will close this issue
16 tasks
@Marchhill
Copy link
Contributor

@arnetheduck I implemented a PR for this, could you check if it works? Also how can I reproduce your test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants