diff --git a/eth/p2p/auth.nim b/eth/p2p/auth.nim index 4a4a51a..875ffd1 100644 --- a/eth/p2p/auth.nim +++ b/eth/p2p/auth.nim @@ -384,7 +384,7 @@ proc decodeAuthMessageEip8(h: var Handshake, m: openarray[byte]): AuthStatus = h.remoteHPubkey = pubkey h.version = cast[ptr byte](versionBr.baseAddr)[] result = Success - except: + except CatchableError: result = RlpError proc decodeAckMessageEip8*(h: var Handshake, m: openarray[byte]): AuthStatus = @@ -417,7 +417,7 @@ proc decodeAckMessageEip8*(h: var Handshake, m: openarray[byte]): AuthStatus = copyMem(addr h.responderNonce[0], nonceBr.baseAddr, KeyLength) h.version = cast[ptr byte](versionBr.baseAddr)[] result = Success - except: + except CatchableError: result = RlpError proc decodeAckMessageV4(h: var Handshake, m: openarray[byte]): AuthStatus = diff --git a/eth/p2p/blockchain_sync.nim b/eth/p2p/blockchain_sync.nim index be14e21..cbc3aae 100644 --- a/eth/p2p/blockchain_sync.nim +++ b/eth/p2p/blockchain_sync.nim @@ -164,7 +164,7 @@ proc obtainBlocksFromPeer(syncCtx: SyncContext, peer: Peer) {.async.} = if bestBlockNumber > syncCtx.endBlockNumber: trace "New sync end block number", number = bestBlockNumber syncCtx.endBlockNumber = bestBlockNumber - except: + except CatchableError: debug "Exception in getBestBlockNumber()", exc = getCurrentException().name, err = getCurrentExceptionMsg() @@ -210,7 +210,7 @@ proc obtainBlocksFromPeer(syncCtx: SyncContext, peer: Peer) {.async.} = dataReceived = true else: warn "Bodies len != headers.len", bodies = bodies.len, headers = workItem.headers.len - except: + except CatchableError: # the success case sets `dataReceived`, so we can just fall back to the # failure path below. If we signal time-outs with exceptions such # failures will be easier to handle. @@ -231,7 +231,7 @@ proc obtainBlocksFromPeer(syncCtx: SyncContext, peer: Peer) {.async.} = workItem.state = Initial try: await peer.disconnect(SubprotocolReason) - except: + except CatchableError: discard syncCtx.handleLostPeer() break @@ -318,7 +318,7 @@ proc onPeerConnected(ctx: SyncContext, peer: Peer) = f.callback = proc(data: pointer) {.gcsafe.} = if f.failed: error "startSyncWithPeer failed", msg = f.readError.msg, peer - except: + except CatchableError: debug "Exception in startSyncWithPeer()", exc = getCurrentException().name, err = getCurrentExceptionMsg() diff --git a/eth/p2p/discovery.nim b/eth/p2p/discovery.nim index e14209c..b2f83e1 100644 --- a/eth/p2p/discovery.nim +++ b/eth/p2p/discovery.nim @@ -258,6 +258,7 @@ proc processClient(transp: DatagramTransport, proto.receive(a, buf) except: debug "Receive failed", err = getCurrentExceptionMsg() + raise proc open*(d: DiscoveryProtocol) = # TODO allow binding to specific IP / IPv6 / etc diff --git a/eth/p2p/rlpx.nim b/eth/p2p/rlpx.nim index 5b572c6..ec6d1fa 100644 --- a/eth/p2p/rlpx.nim +++ b/eth/p2p/rlpx.nim @@ -198,6 +198,7 @@ proc requestResolver[MsgType](msg: pointer, future: FutureBase) {.gcsafe.} = debug "Exception in requestResolver()", exc = getCurrentException().name, err = getCurrentExceptionMsg() + raise proc registerMsg(protocol: ProtocolInfo, id: int, name: string,