From 3ce1d7cb21fd6acc3fbdd91b7228d3032add0afe Mon Sep 17 00:00:00 2001 From: kdeme Date: Thu, 19 Sep 2024 17:56:11 +0200 Subject: [PATCH] Use discv5's maxDiscv5TalkRespPayload const for payload size calc --- fluffy/network/wire/portal_protocol.nim | 17 ++--------------- vendor/nim-eth | 2 +- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/fluffy/network/wire/portal_protocol.nim b/fluffy/network/wire/portal_protocol.nim index 55e7275558..93cc1254d3 100644 --- a/fluffy/network/wire/portal_protocol.nim +++ b/fluffy/network/wire/portal_protocol.nim @@ -116,19 +116,6 @@ const ## value in milliseconds initialLookups = 1 ## Amount of lookups done when populating the routing table - # TalkResp message is a response message so the session is established and a - # regular discv5 packet is assumed for size calculation. - # Regular message = IV + header + message - # talkResp message = rlp: [request-id, response] - talkRespOverhead = - 16 + # IV size - 55 + # header size - 1 + # talkResp msg id - 3 + # rlp encoding outer list, max length will be encoded in 2 bytes - 9 + # request id (max = 8) + 1 byte from rlp encoding byte string - 3 + # rlp encoding response byte string, max length in 2 bytes - 16 # HMAC - # These are the concurrent offers per Portal wire protocol that is running. # Using the `offerQueue` allows for limiting the amount of offers send and # thus how many streams can be started. @@ -385,7 +372,7 @@ proc handleFindNodes(p: PortalProtocol, fn: FindNodesMessage): seq[byte] = # will still be passed. const nodesOverhead = 1 + 1 + 4 # msg id + total + container offset - maxPayloadSize = maxDiscv5PacketSize - talkRespOverhead - nodesOverhead + maxPayloadSize = maxDiscv5TalkRespPayload - nodesOverhead enrOverhead = 4 # per added ENR, 4 bytes offset overhead let enrs = truncateEnrs(nodes, maxPayloadSize, enrOverhead) @@ -402,7 +389,7 @@ proc handleFindContent( ): seq[byte] = const contentOverhead = 1 + 1 # msg id + SSZ Union selector - maxPayloadSize = maxDiscv5PacketSize - talkRespOverhead - contentOverhead + maxPayloadSize = maxDiscv5TalkRespPayload - contentOverhead enrOverhead = 4 # per added ENR, 4 bytes offset overhead let contentId = p.toContentId(fc.contentKey).valueOr: diff --git a/vendor/nim-eth b/vendor/nim-eth index 4eecab27ef..aa1e738a97 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit 4eecab27efb6a743098632024505474d34a65e9b +Subproject commit aa1e738a97d1995c1ddb821123e4842409218b0c