From c861fa9f7560068874570598c81b7a1425a9e931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?rich=CE=9Brd?= Date: Thu, 10 Oct 2024 08:40:09 -0400 Subject: [PATCH] chore: remove warnings (#3106) - Removes deprecation and unused import warnings for libwaku - Removes unused imports - Adds .base. pragma to `SubscriptionObserver.onSubscribe` - Uses casting for uint to enums conversions - Bumps nim-chronicles --- library/events/json_message_event.nim | 4 ++-- library/libwaku.nim | 2 +- .../requests/discovery_request.nim | 3 +-- .../requests/node_lifecycle_request.nim | 2 +- .../requests/protocols/lightpush_request.nim | 4 ++-- vendor/nim-chronicles | 2 +- waku.nimble | 4 ++-- waku/common/rate_limit/per_peer_limiter.nim | 2 +- waku/factory/waku.nim | 2 +- waku/node/delivery_monitor/recv_monitor.nim | 2 +- waku/node/delivery_monitor/send_monitor.nim | 4 ++-- waku/node/delivery_monitor/subscriptions_observer.nim | 2 +- waku/waku_archive/archive.nim | 3 ++- waku/waku_archive/common.nim | 2 +- waku/waku_archive_legacy/archive.nim | 7 ++++--- waku/waku_archive_legacy/driver/queue_driver/index.nim | 2 +- waku/waku_filter_v2/common.nim | 2 +- waku/waku_filter_v2/subscriptions.nim | 2 +- waku/waku_lightpush/callbacks.nim | 1 - waku/waku_peer_exchange/protocol.nim | 2 +- waku/waku_peer_exchange/rpc_codec.nim | 2 +- waku/waku_rln_relay/protocol_metrics.nim | 8 +------- waku/waku_store/common.nim | 4 ++-- waku/waku_store_legacy/rpc.nim | 2 +- 24 files changed, 32 insertions(+), 38 deletions(-) diff --git a/library/events/json_message_event.nim b/library/events/json_message_event.nim index cab741a0ca..04dc0b8b4a 100644 --- a/library/events/json_message_event.nim +++ b/library/events/json_message_event.nim @@ -1,5 +1,5 @@ -import system, std/[json, sequtils] -import stew/[byteutils, results] +import system, results, std/json +import stew/byteutils import ../../waku/common/base64, ../../waku/waku_core/message, diff --git a/library/libwaku.nim b/library/libwaku.nim index f9e2a0b3a0..19b1194b96 100644 --- a/library/libwaku.nim +++ b/library/libwaku.nim @@ -5,7 +5,7 @@ when defined(linux): {.passl: "-Wl,-soname,libwaku.so".} -import std/[json, sequtils, atomics, strformat, options, atomics] +import std/[json, atomics, strformat, options, atomics] import chronicles, chronos import waku/common/base64, diff --git a/library/waku_thread/inter_thread_communication/requests/discovery_request.nim b/library/waku_thread/inter_thread_communication/requests/discovery_request.nim index 31ed8acfca..281f7cbf0d 100644 --- a/library/waku_thread/inter_thread_communication/requests/discovery_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/discovery_request.nim @@ -1,10 +1,9 @@ -import std/[json, sequtils] +import std/json import chronos, chronicles, results, libp2p/multiaddress import ../../../../waku/factory/waku, ../../../../waku/discovery/waku_dnsdisc, ../../../../waku/discovery/waku_discv5, - ../../../../waku/waku_peer_exchange, ../../../../waku/waku_core/peers, ../../../../waku/node/waku_node, ../../../alloc diff --git a/library/waku_thread/inter_thread_communication/requests/node_lifecycle_request.nim b/library/waku_thread/inter_thread_communication/requests/node_lifecycle_request.nim index b581718ce6..841d47db23 100644 --- a/library/waku_thread/inter_thread_communication/requests/node_lifecycle_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/node_lifecycle_request.nim @@ -1,4 +1,4 @@ -import std/[options, sequtils, json, strutils, net] +import std/[options, json, strutils, net] import chronos, chronicles, results, confutils, confutils/std/net import diff --git a/library/waku_thread/inter_thread_communication/requests/protocols/lightpush_request.nim b/library/waku_thread/inter_thread_communication/requests/protocols/lightpush_request.nim index 39d1bcac88..fed28f1127 100644 --- a/library/waku_thread/inter_thread_communication/requests/protocols/lightpush_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/protocols/lightpush_request.nim @@ -1,5 +1,5 @@ -import std/net, options -import chronicles, chronos, stew/byteutils, results +import options +import chronicles, chronos, results import ../../../../../waku/waku_core/message/message, ../../../../../waku/factory/waku, diff --git a/vendor/nim-chronicles b/vendor/nim-chronicles index a28bb9781c..4524912fca 160000 --- a/vendor/nim-chronicles +++ b/vendor/nim-chronicles @@ -1 +1 @@ -Subproject commit a28bb9781ce74e725796c307ad05083e646872be +Subproject commit 4524912fcacfd3965e32a9fe23c9bb12d48177ff diff --git a/waku.nimble b/waku.nimble index fccb6f6b11..ac4f7728c5 100644 --- a/waku.nimble +++ b/waku.nimble @@ -161,14 +161,14 @@ task libwakuStatic, "Build the cbindings waku node library": let name = "libwaku" buildLibrary name, "library/", - """-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" """, + """-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" --warning:Deprecated:off --warning:UnusedImport:on """, "static" task libwakuDynamic, "Build the cbindings waku node library": let name = "libwaku" buildLibrary name, "library/", - """-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" """, + """-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" --warning:Deprecated:off --warning:UnusedImport:on """, "dynamic" ### Mobile Android diff --git a/waku/common/rate_limit/per_peer_limiter.nim b/waku/common/rate_limit/per_peer_limiter.nim index 59921beee3..5cb96a2d13 100644 --- a/waku/common/rate_limit/per_peer_limiter.nim +++ b/waku/common/rate_limit/per_peer_limiter.nim @@ -6,7 +6,7 @@ {.push raises: [].} -import std/[options, tables], chronos/timer, libp2p/stream/connection, libp2p/utility +import std/[options, tables], libp2p/stream/connection import ./[single_token_limiter, service_metrics], ../../utils/tableutils diff --git a/waku/factory/waku.nim b/waku/factory/waku.nim index 99b6ef479a..e503ee8f0d 100644 --- a/waku/factory/waku.nim +++ b/waku/factory/waku.nim @@ -1,7 +1,7 @@ {.push raises: [].} import - std/[options, sequtils], + std/options, results, chronicles, chronos, diff --git a/waku/node/delivery_monitor/recv_monitor.nim b/waku/node/delivery_monitor/recv_monitor.nim index 3f82ddcd2e..7e89df5bc2 100644 --- a/waku/node/delivery_monitor/recv_monitor.nim +++ b/waku/node/delivery_monitor/recv_monitor.nim @@ -2,7 +2,7 @@ ## receive and is backed by store-v3 requests to get an additional degree of certainty ## -import std/[tables, sequtils, sets, options] +import std/[tables, sequtils, options] import chronos, chronicles, libp2p/utility import ../../waku_core, diff --git a/waku/node/delivery_monitor/send_monitor.nim b/waku/node/delivery_monitor/send_monitor.nim index ce1ccf0cc9..8a67e46b1c 100644 --- a/waku/node/delivery_monitor/send_monitor.nim +++ b/waku/node/delivery_monitor/send_monitor.nim @@ -1,7 +1,7 @@ ## This module reinforces the publish operation with regular store-v3 requests. ## -import std/[sets, sequtils] +import std/sequtils import chronos, chronicles, libp2p/utility import ./delivery_callback, @@ -206,7 +206,7 @@ proc startSendMonitor*(self: SendMonitor) = self.msgStoredCheckerHandle = self.checkIfMessagesStored() proc stopSendMonitor*(self: SendMonitor) = - self.msgStoredCheckerHandle.cancel() + discard self.msgStoredCheckerHandle.cancelAndWait() proc setDeliveryCallback*(self: SendMonitor, deliveryCb: DeliveryFeedbackCallback) = self.deliveryCb = deliveryCb diff --git a/waku/node/delivery_monitor/subscriptions_observer.nim b/waku/node/delivery_monitor/subscriptions_observer.nim index 0c5d552210..800117ae9d 100644 --- a/waku/node/delivery_monitor/subscriptions_observer.nim +++ b/waku/node/delivery_monitor/subscriptions_observer.nim @@ -9,5 +9,5 @@ method onSubscribe*( method onUnsubscribe*( self: SubscriptionObserver, pubsubTopic: string, contentTopics: seq[string] -) {.gcsafe, raises: [].} = +) {.base, gcsafe, raises: [].} = error "onUnsubscribe not implemented" diff --git a/waku/waku_archive/archive.nim b/waku/waku_archive/archive.nim index 7e1cce9dd4..604f8a82b7 100644 --- a/waku/waku_archive/archive.nim +++ b/waku/waku_archive/archive.nim @@ -2,9 +2,10 @@ import std/[times, options, sequtils, algorithm], - stew/[results, byteutils], + stew/[byteutils], chronicles, chronos, + results, metrics import ../common/paging, diff --git a/waku/waku_archive/common.nim b/waku/waku_archive/common.nim index 731dc11c45..5e5b2a1a97 100644 --- a/waku/waku_archive/common.nim +++ b/waku/waku_archive/common.nim @@ -1,6 +1,6 @@ {.push raises: [].} -import std/options, results, stew/byteutils, stew/arrayops, nimcrypto/sha2 +import std/options, results import ../waku_core, ../common/paging ## Public API types diff --git a/waku/waku_archive_legacy/archive.nim b/waku/waku_archive_legacy/archive.nim index f130ffc5f2..0abcc3068b 100644 --- a/waku/waku_archive_legacy/archive.nim +++ b/waku/waku_archive_legacy/archive.nim @@ -4,11 +4,12 @@ else: {.push raises: [].} import - std/[times, options, sequtils, strutils, algorithm], - stew/[results, byteutils], + std/[times, options, sequtils, algorithm], + stew/byteutils, chronicles, chronos, - metrics + metrics, + results import ../common/paging, ./driver, diff --git a/waku/waku_archive_legacy/driver/queue_driver/index.nim b/waku/waku_archive_legacy/driver/queue_driver/index.nim index d34b550c85..2328870d03 100644 --- a/waku/waku_archive_legacy/driver/queue_driver/index.nim +++ b/waku/waku_archive_legacy/driver/queue_driver/index.nim @@ -3,7 +3,7 @@ when (NimMajor, NimMinor) < (1, 4): else: {.push raises: [].} -import stew/byteutils, nimcrypto/sha2 +import nimcrypto/sha2 import ../../../waku_core, ../../common type Index* = object diff --git a/waku/waku_filter_v2/common.nim b/waku/waku_filter_v2/common.nim index ad0f23fdba..2d30137b4b 100644 --- a/waku/waku_filter_v2/common.nim +++ b/waku/waku_filter_v2/common.nim @@ -63,7 +63,7 @@ proc serviceUnavailable*( proc parse*(T: type FilterSubscribeErrorKind, kind: uint32): T = case kind of 000, 200, 300, 400, 404, 429, 503: - FilterSubscribeErrorKind(kind) + cast[FilterSubscribeErrorKind](kind) else: FilterSubscribeErrorKind.UNKNOWN diff --git a/waku/waku_filter_v2/subscriptions.nim b/waku/waku_filter_v2/subscriptions.nim index 7df21ea0f4..8a5c5bc91a 100644 --- a/waku/waku_filter_v2/subscriptions.nim +++ b/waku/waku_filter_v2/subscriptions.nim @@ -1,7 +1,7 @@ {.push raises: [].} import std/[sets, tables], chronicles, chronos, libp2p/peerid, stew/shims/sets -import ../waku_core, ../utils/tableutils, ../common/rate_limit/setting +import ../waku_core, ../utils/tableutils logScope: topics = "waku filter subscriptions" diff --git a/waku/waku_lightpush/callbacks.nim b/waku/waku_lightpush/callbacks.nim index 1c0396f25d..363ebfd3b5 100644 --- a/waku/waku_lightpush/callbacks.nim +++ b/waku/waku_lightpush/callbacks.nim @@ -4,7 +4,6 @@ import ../waku_core, ../waku_relay, ./common, - ./protocol, ./protocol_metrics, ../waku_rln_relay, ../waku_rln_relay/protocol_types diff --git a/waku/waku_peer_exchange/protocol.nim b/waku/waku_peer_exchange/protocol.nim index 27bb7bfb43..4bfc03c13b 100644 --- a/waku/waku_peer_exchange/protocol.nim +++ b/waku/waku_peer_exchange/protocol.nim @@ -1,5 +1,5 @@ import - std/[options, sequtils, random, sugar], + std/[options, sequtils, random], results, chronicles, chronos, diff --git a/waku/waku_peer_exchange/rpc_codec.nim b/waku/waku_peer_exchange/rpc_codec.nim index b698ffe9f5..e6eaa0ca20 100644 --- a/waku/waku_peer_exchange/rpc_codec.nim +++ b/waku/waku_peer_exchange/rpc_codec.nim @@ -42,7 +42,7 @@ proc decode*(T: type PeerExchangePeerInfo, buffer: seq[byte]): ProtoResult[T] = proc parse*(T: type PeerExchangeResponseStatusCode, status: uint32): T = case status of 200, 400, 429, 503: - PeerExchangeResponseStatusCode(status) + cast[PeerExchangeResponseStatusCode](status) else: PeerExchangeResponseStatusCode.UNKNOWN diff --git a/waku/waku_rln_relay/protocol_metrics.nim b/waku/waku_rln_relay/protocol_metrics.nim index 5d1ea563c4..ab9d119a3a 100644 --- a/waku/waku_rln_relay/protocol_metrics.nim +++ b/waku/waku_rln_relay/protocol_metrics.nim @@ -1,12 +1,6 @@ {.push raises: [].} -import - chronicles, - chronos, - metrics, - metrics/chronos_httpserver, - ./constants, - ../utils/collector +import chronicles, metrics, metrics/chronos_httpserver, ./constants, ../utils/collector export metrics diff --git a/waku/waku_store/common.nim b/waku/waku_store/common.nim index 2394cc7d58..c8ca46c162 100644 --- a/waku/waku_store/common.nim +++ b/waku/waku_store/common.nim @@ -76,7 +76,7 @@ type StoreQueryResult* = Result[StoreQueryResponse, StoreError] proc into*(errCode: ErrorCode): StatusCode = - StatusCode(uint32(errCode)) + cast[StatusCode](uint32(errCode)) proc new*(T: type StoreError, code: uint32, desc: string): T = let kind = ErrorCode.parse(code) @@ -98,7 +98,7 @@ proc new*(T: type StoreError, code: uint32, desc: string): T = proc parse*(T: type ErrorCode, kind: uint32): T = case kind of 000, 300, 400, 429, 503, 504: - ErrorCode(kind) + cast[ErrorCode](kind) else: ErrorCode.UNKNOWN diff --git a/waku/waku_store_legacy/rpc.nim b/waku/waku_store_legacy/rpc.nim index 8c448a04af..bce3e60cda 100644 --- a/waku/waku_store_legacy/rpc.nim +++ b/waku/waku_store_legacy/rpc.nim @@ -75,7 +75,7 @@ type proc parse*(T: type HistoryResponseErrorRPC, kind: uint32): T = case kind of 0, 1, 429, 503: - HistoryResponseErrorRPC(kind) + cast[HistoryResponseErrorRPC](kind) else: # TODO: Improve error variants/move to satus codes HistoryResponseErrorRPC.INVALID_CURSOR