This repository was archived by the owner on Nov 6, 2020. It is now read-only.
[devp2p discovery] assemble packet refactor#11566
Closed
niklasad1 wants to merge 10 commits into
Closed
Conversation
Introduced to achieve more type-safety than u8. Part of this the verify `packet_kind` before doing more expensive operations such as `hashing`, `signing`, `ecc recover` and similar
niklasad1
commented
Mar 12, 2020
|
|
||
| let payload_with_packet_id = &packet[HASH_LEN + SIGNATURE_LEN..]; | ||
| let packet_kind = payload_with_packet_id[0]; | ||
| let packet_kind: PacketKind = packet_kind.try_into().map_err(|e| { |
Collaborator
Author
There was a problem hiding this comment.
do this check earlier to avoid hashing, ecc recover when we get invalid/unsupported packet kinds
niklasad1
commented
Mar 16, 2020
| /// Helper to disassemble node discovery packets | ||
| /// | ||
| /// The packet format is: `hash || signature || packet_type || payload`, where the maximum packet length is 1280 bytes | ||
| fn disassemble_packet(packet: &[u8]) -> Result<(NodeId, &[u8], PacketKind, H256), Error> { |
Collaborator
Author
There was a problem hiding this comment.
currently, when we read a discovery UDP datagrams they are capped here
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NodeDiscoveryPacketexceeds the maximum size (1280 bytes).PacketKindinstadu8