-
Notifications
You must be signed in to change notification settings - Fork 21
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
Disc v5.1 implementation #72
Conversation
…ldn't be decrypted - send WHOAREYOU in this case
src/main/java/org/ethereum/beacon/discovery/message/FindNodeMessage.java
Show resolved
Hide resolved
src/main/java/org/ethereum/beacon/discovery/message/FindNodeMessage.java
Show resolved
Hide resolved
src/main/java/org/ethereum/beacon/discovery/message/handler/FindNodeHandler.java
Show resolved
Hide resolved
src/main/java/org/ethereum/beacon/discovery/packet/impl/StaticHeaderImpl.java
Outdated
Show resolved
Hide resolved
.collect(Collectors.toList()); | ||
|
||
List<List<NodeRecord>> nodeRecordsList = | ||
Lists.partition(nodeRecordInfos, MAX_NODES_PER_MESSAGE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need any limits on this? The spec says: "The recommended result limit for FINDNODE queries is 16 nodes."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, with this respect the MAX_NODES_PER_MESSAGE
size is set to 4
here. This satisfies any limits except of Handshake
message. This is highly unlikely situation for a honest remote peer to send us back WhoAreYou
on a response packet but this is not a protocol violation and we should normally respond with Handshake
including the original Nodes
message.
Need to think about it more cause that would require more complex handling - you don't know in advance which packet your message would be delivered with :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a check on outgoing messages on their max size for this case. I think just dropping an outgoing Nodes
message if it for some reason is delivering with a Handshake
packet would be enough for now.
Also logged this issue #74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a limit on the overall total
though? Wasn't sure if the limit of 16 was per response or overall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sound like the 16 is recommended as a total ENRs returned (in one or more Nodes
packets) for a single FindNode
request.
Added the code which limits the number of ENRs
Also suggested to make this statement and the limit itself more explicit: https://github.com/ethereum/devp2p/pull/157/files#r497382489
src/main/java/org/ethereum/beacon/discovery/message/handler/FindNodeHandler.java
Outdated
Show resolved
Hide resolved
return new AuthDataImpl(gcmNonce); | ||
} | ||
|
||
static Header<AuthData> createHeader(Bytes32 srcNodeId, Bytes12 gcmNonce) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is only used in tests - should we move this to a test util?
static Header<AuthData> createHeader(Bytes32 srcNodeId, Bytes12 gcmNonce) { | |
static Header<AuthData> createOrdinaryHeader(Bytes32 srcNodeId, Bytes12 gcmNonce) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there are too many interface factory methods left from the very beginning. I have cleaned them up here: a77ff29
- moved all
create*Header
static methods to theHeader
class - Left
*Packet.create()
methods - Removed almost all others
src/main/java/org/ethereum/beacon/discovery/packet/HandshakeMessagePacket.java
Outdated
Show resolved
Hide resolved
src/main/java/org/ethereum/beacon/discovery/packet/impl/RawPacketImpl.java
Outdated
Show resolved
Hide resolved
…destNodeId instead of nodeId)
… Leave just Header.create* and *Packet.create()
.collect(Collectors.toList()); | ||
|
||
List<List<NodeRecord>> nodeRecordsList = | ||
Lists.partition(nodeRecordInfos, MAX_NODES_PER_MESSAGE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a limit on the overall total
though? Wasn't sure if the limit of 16 was per response or overall.
src/main/java/org/ethereum/beacon/discovery/pipeline/handler/OutgoingParcelHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/ethereum/beacon/discovery/pipeline/handler/OutgoingParcelHandler.java
Outdated
Show resolved
Hide resolved
Co-authored-by: mbaxter <meredith.baxter@consensys.net>
Co-authored-by: mbaxter <meredith.baxter@consensys.net>
…disc-v5.1 # Conflicts: # src/main/java/org/ethereum/beacon/discovery/message/handler/FindNodeHandler.java
'Umbrella' issue for all implementers: ethereum/consensus-specs#2059 |
PR Description
Disc v5.1 implementation (ethereum/devp2p#157)
Refactor(planning as a separate PR)Pipeline
approachimplement(planning as a separate PR)TALKREQ/TALKRESP
Fixed Issue(s)
Fixes Consensys/teku#2797