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

Disc v5.1 implementation #72

Merged
merged 46 commits into from
Sep 30, 2020
Merged

Conversation

Nashatyrev
Copy link
Contributor

@Nashatyrev Nashatyrev commented Sep 16, 2020

PR Description

Disc v5.1 implementation (ethereum/devp2p#157)

  • 5.1 packet messages
  • Test vectors for new messages
  • Refactor Pipeline approach (planning as a separate PR)
  • Unit tests for new messages
  • Integrate new messages
  • Update negotiation
  • implement TALKREQ/TALKRESP (planning as a separate PR)
  • check interop with Lighthouse
  • (?) check interop with Prysm (not sure Prysm is ready now)

Fixed Issue(s)

Fixes Consensys/teku#2797

@Nashatyrev Nashatyrev marked this pull request as ready for review September 24, 2020 18:40
.collect(Collectors.toList());

List<List<NodeRecord>> nodeRecordsList =
Lists.partition(nodeRecordInfos, MAX_NODES_PER_MESSAGE);
Copy link

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."

Copy link
Contributor Author

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 :/

Copy link
Contributor Author

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

Copy link

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.

Copy link
Contributor Author

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

return new AuthDataImpl(gcmNonce);
}

static Header<AuthData> createHeader(Bytes32 srcNodeId, Bytes12 gcmNonce) {
Copy link

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?

Suggested change
static Header<AuthData> createHeader(Bytes32 srcNodeId, Bytes12 gcmNonce) {
static Header<AuthData> createOrdinaryHeader(Bytes32 srcNodeId, Bytes12 gcmNonce) {

Copy link
Contributor Author

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 the Header class
  • Left *Packet.create() methods
  • Removed almost all others

.collect(Collectors.toList());

List<List<NodeRecord>> nodeRecordsList =
Lists.partition(nodeRecordInfos, MAX_NODES_PER_MESSAGE);
Copy link

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.

Nashatyrev and others added 6 commits September 30, 2020 12:24
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
@Nashatyrev Nashatyrev merged commit 53cb77f into Consensys:master Sep 30, 2020
@Nashatyrev
Copy link
Contributor Author

'Umbrella' issue for all implementers: ethereum/consensus-specs#2059

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 this pull request may close these issues.

Update to discv5.1
2 participants