From 77d873ef4ac01d0624e94bb807a18537318d9ff3 Mon Sep 17 00:00:00 2001 From: kdeme Date: Fri, 16 Jul 2021 21:33:35 +0000 Subject: [PATCH] deploy: 9b03601bed6a204f8ce6ef38b009605ac3cf4d55 --- waku/v1/protocol/waku_bridge.nim | 4 +++- waku/v1/protocol/waku_mail.nim | 7 +++++-- waku/v1/protocol/waku_protocol.nim | 18 +++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/waku/v1/protocol/waku_bridge.nim b/waku/v1/protocol/waku_bridge.nim index 3227c242d..50a6bad2d 100644 --- a/waku/v1/protocol/waku_bridge.nim +++ b/waku/v1/protocol/waku_bridge.nim @@ -1,6 +1,6 @@ # # Waku - Whisper Bridge -# (c) Copyright 2019 +# (c) Copyright 2018-2021 # Status Research & Development GmbH # # Licensed under either of @@ -8,6 +8,8 @@ # MIT license (LICENSE-MIT) # +{.push raises: [Defect].} + import eth/p2p, eth/p2p/rlpx_protocols/whisper_protocol, diff --git a/waku/v1/protocol/waku_mail.nim b/waku/v1/protocol/waku_mail.nim index aea073465..3bad0d2b4 100644 --- a/waku/v1/protocol/waku_mail.nim +++ b/waku/v1/protocol/waku_mail.nim @@ -1,12 +1,15 @@ # # Waku Mail Client & Server -# (c) Copyright 2019 +# (c) Copyright 2018-2021 # Status Research & Development GmbH # # Licensed under either of -# Apache License, version 2.0, (LICENSE-APACHEv2) +# Apache License, version 2.0, (LICENSE-APACHEv2)F # MIT license (LICENSE-MIT) # + +{.push raises: [Defect].} + import chronos, eth/[p2p, async_utils], diff --git a/waku/v1/protocol/waku_protocol.nim b/waku/v1/protocol/waku_protocol.nim index 9e073c0f2..6ad456ff9 100644 --- a/waku/v1/protocol/waku_protocol.nim +++ b/waku/v1/protocol/waku_protocol.nim @@ -1,6 +1,6 @@ # # Waku -# (c) Copyright 2018-2019 +# (c) Copyright 2018-2021 # Status Research & Development GmbH # # Licensed under either of @@ -37,6 +37,8 @@ ## However, they only make real sense after ``connectToNetwork`` was started. As ## else there will be no peers to send and receive messages from. +{.push raises: [Defect].} + import options, tables, times, chronos, chronicles, metrics, eth/[keys, async_utils, p2p], eth/p2p/rlpx_protocols/whisper/whisper_types, @@ -143,9 +145,14 @@ proc append*(rlpWriter: var RlpWriter, value: StatusOptions) = let bytes = list.finish() - rlpWriter.append(rlpFromBytes(bytes)) + try: + rlpWriter.append(rlpFromBytes(bytes)) + except RlpError as e: + # bytes is valid rlp just created here, rlpFromBytes should thus never fail + raiseAssert e.msg -proc read*(rlp: var Rlp, T: typedesc[StatusOptions]): T = +proc read*(rlp: var Rlp, T: typedesc[StatusOptions]): + T {.raises: [RlpError, Defect].}= if not rlp.isList(): raise newException(RlpTypeMismatch, "List expected, but the source RLP is not a list.") @@ -433,7 +440,7 @@ proc run(peer: Peer) {.async, raises: [Defect].} = peer.processQueue() await sleepAsync(messageInterval) -proc pruneReceived(node: EthereumNode) {.raises: [].} = +proc pruneReceived(node: EthereumNode) = if node.peerPool != nil: # XXX: a bit dirty to need to check for this here ... var wakuNet = node.protocolState(Waku) @@ -561,7 +568,8 @@ proc unsubscribeFilter*(node: EthereumNode, filterId: string): bool = var filter: Filter return node.protocolState(Waku).filters.take(filterId, filter) -proc getFilterMessages*(node: EthereumNode, filterId: string): seq[ReceivedMessage] = +proc getFilterMessages*(node: EthereumNode, filterId: string): + seq[ReceivedMessage] {.raises: [KeyError, Defect].} = ## Get all the messages currently in the filter queue. This will reset the ## filter message queue. return node.protocolState(Waku).filters.getFilterMessages(filterId)