From decfd66a789391630425f837bb6bb29874dfb287 Mon Sep 17 00:00:00 2001 From: tersec Date: Wed, 21 Oct 2020 20:03:12 +0000 Subject: [PATCH] bump libp2p: seq[byte] message IDs and improve reject/ignore handling (#1898) * bump libp2p: use seq[byte] message IDs and improve reject/ignore handling * bump libp2p to pick up debug message details --- beacon_chain/eth2_network.nim | 9 +++++---- vendor/nim-libp2p | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index 8478e350d..4d789bb61 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -1361,7 +1361,7 @@ proc getPersistentNetKeys*(rng: var BrHmacDrbgContext, let privKey = res.get() return KeyPair(seckey: privKey, pubkey: privkey.getKey().tryGet()) -func gossipId(data: openArray[byte]): string = +func gossipId(data: openArray[byte]): seq[byte] = # https://github.com/ethereum/eth2.0-specs/blob/v1.0.0-rc.0/specs/phase0/p2p-interface.md#topics-and-messages # We don't use non-Snappy-compressed messages, so don't define # MESSAGE_DOMAIN_INVALID_SNAPPY. @@ -1370,9 +1370,10 @@ func gossipId(data: openArray[byte]): string = h.update uint_to_bytes4(MESSAGE_DOMAIN_VALID_SNAPPY) h.update data - string.fromBytes(messageDigest.data.toOpenArray(0, 19)) + result = newSeq[byte](20) + result[0..19] = messageDigest.data.toOpenArray(0, 19) -func msgIdProvider(m: messages.Message): string = +func msgIdProvider(m: messages.Message): seq[byte] = gossipId(m.data) proc createEth2Node*(rng: ref BrHmacDrbgContext, @@ -1467,4 +1468,4 @@ proc broadcast*(node: Eth2Node, topic: string, msg: auto) = let data = snappy.encode(SSZ.encode(msg)) var futSnappy = node.pubsub.publish(topic & "_snappy", data) - traceMessage(futSnappy, gossipId(data)) + traceMessage(futSnappy, string.fromBytes(gossipId(data))) diff --git a/vendor/nim-libp2p b/vendor/nim-libp2p index 9c5835682..eeaa62fee 160000 --- a/vendor/nim-libp2p +++ b/vendor/nim-libp2p @@ -1 +1 @@ -Subproject commit 9c58356823dd47591bdd1a0df17345fca16d6719 +Subproject commit eeaa62feecf7717859cc2a65d93ff4165a0764c4