chore: Bump dependencies for v0.31.0 (#2885)

* bump_dependencies.md: add nim-results dependency
* change imports stew/results to results
* switching to Nim 2.0.8
* waku.nimble: reflect the requirement nim 1.6.0 to 2.0.8
  Adding --mm:refc as nim 2.0 enables a new garbage collector that we're
  not yet ready to support
* adapt waku code to Nim 2.0
* gcsafe adaptations because Nim 2.0 is more strict
This commit is contained in:
Ivan FB 2024-07-09 13:14:28 +02:00 committed by GitHub
parent 8bfad3ab45
commit fd6a71cdd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
141 changed files with 239 additions and 227 deletions

View File

@ -31,6 +31,7 @@ Update `nwaku` "vendor" dependencies.
- [ ] nim-nat-traversal
- [ ] nim-presto
- [ ] nim-regex ( update to the latest tag version )
- [ ] nim-results
- [ ] nim-secp256k1
- [ ] nim-serialization
- [ ] nim-sqlite3-abi ( update to the latest tag version )

5
.gitmodules vendored
View File

@ -164,3 +164,8 @@
branch = master
path = vendor/nim-results
url = https://github.com/arnetheduck/nim-results.git
[submodule "vendor/db_connector"]
path = vendor/db_connector
url = https://github.com/nim-lang/db_connector.git
ignore = untracked
branch = master

View File

@ -1,7 +1,7 @@
import
math,
std/sequtils,
stew/results,
results,
options,
waku/[
waku_rln_relay/protocol_types,

View File

@ -8,7 +8,7 @@ import
chronos,
chronos/timer as chtimer,
stew/byteutils,
stew/results,
results,
serialization,
json_serialization as js,
times

View File

@ -4,7 +4,7 @@ import
chronicles,
chronos,
stew/byteutils,
stew/results,
results,
json_serialization as js
import
waku/[common/logging, waku_node, node/peer_manager, waku_core, waku_lightpush/client],

View File

@ -1,6 +1,6 @@
import
std/[strutils, strformat],
stew/results,
results,
chronos,
regex,
confutils,

View File

@ -2,7 +2,7 @@
import
std/[tables, strutils, times, sequtils, random],
stew/results,
results,
stew/shims/net,
chronicles,
chronicles/topics_registry,

View File

@ -4,7 +4,7 @@ import
confutils,
chronos,
std/strutils,
stew/results,
results,
stew/shims/net,
regex

View File

@ -10,7 +10,7 @@ import
metrics/chronos_httpserver,
presto/route,
presto/server,
stew/results,
results,
stew/shims/net
logScope:

View File

@ -2,7 +2,7 @@
import
std/json,
stew/results,
results,
stew/shims/net,
chronicles,
chronicles/topics_registry,

View File

@ -1,7 +1,7 @@
## Example showing how a resource restricted client may
## subscribe to messages without relay
import chronicles, chronos, stew/byteutils, stew/results
import chronicles, chronos, stew/byteutils, results
import waku/[common/logging, node/peer_manager, waku_core, waku_filter_v2/client]
const

View File

@ -1,7 +1,7 @@
## Example showing how a resource restricted client may
## use lightpush to publish messages without relay
import chronicles, chronos, stew/byteutils, stew/results
import chronicles, chronos, stew/byteutils, results
import waku/[common/logging, node/peer_manager, waku_core, waku_lightpush/client]
const

View File

@ -1,7 +1,7 @@
## Nim wrappers for the functions defined in librln
{.push raises: [].}
import stew/results
import results
######################################################################
## ERC-5564-BN254 module APIs

View File

@ -1,7 +1,7 @@
{.push raises: [].}
import
stew/results,
results,
waku/[common/logging,
waku_node,
waku_rln_relay,],

View File

@ -1,7 +1,6 @@
{.push raises: [].}
import
stew/results, chronicles, ./node_spec as Waku, ./stealth_commitment_protocol as SCP
import results, chronicles, ./node_spec as Waku, ./stealth_commitment_protocol as SCP
logScope:
topics = "waku stealthcommitments"

View File

@ -1,5 +1,5 @@
import std/[times, options]
import confutils, chronicles, chronos, stew/results
import confutils, chronicles, chronos, results
import waku/[waku_core, common/protobuf]
import libp2p/protobuf/minprotobuf

View File

@ -8,11 +8,11 @@ when defined(linux):
import std/[json, sequtils, atomics, times, strformat, options, atomics, strutils, os]
import chronicles, chronos
import
../../waku/common/base64,
../../waku/waku_core/message/message,
../../waku/node/waku_node,
../../waku/waku_core/topics/pubsub_topic,
../../../waku/waku_relay/protocol,
waku/common/base64,
waku/waku_core/message/message,
waku/node/waku_node,
waku/waku_core/topics/pubsub_topic,
waku/waku_relay/protocol,
./events/json_message_event,
./waku_thread/waku_thread,
./waku_thread/inter_thread_communication/requests/node_lifecycle_request,

1
library/nim.cfg Normal file
View File

@ -0,0 +1 @@
path = "../"

View File

@ -1,5 +1,5 @@
import std/json
import chronicles, chronos, stew/results
import chronicles, chronos, results
import ../../../../waku/factory/waku, ../../../../waku/node/waku_node
type DebugNodeMsgType* = enum

View File

@ -1,5 +1,5 @@
import std/[json, sequtils]
import chronos, stew/results, libp2p/multiaddress
import chronos, results, libp2p/multiaddress
import
../../../../waku/factory/waku,
../../../../waku/discovery/waku_dnsdisc,

View File

@ -1,5 +1,5 @@
import std/[options, sequtils, json, strutils, net]
import chronos, chronicles, stew/results, confutils, confutils/std/net
import chronos, chronicles, results, confutils, confutils/std/net
import
../../../../waku/node/peer_manager/peer_manager,

View File

@ -1,5 +1,5 @@
import std/[sequtils, strutils]
import chronicles, chronos, stew/results
import chronicles, chronos, results
import ../../../../waku/factory/waku, ../../../../waku/node/waku_node, ../../../alloc
type PeerManagementMsgType* = enum

View File

@ -1,5 +1,5 @@
import std/net
import chronicles, chronos, stew/byteutils, stew/results
import chronicles, chronos, stew/byteutils, results
import
../../../../../waku/waku_core/message/message,
../../../../../waku/factory/waku,

View File

@ -1,4 +1,4 @@
import chronos, stew/results
import chronos, results
import ../../../../../waku/factory/waku, ../../../../alloc, ../../../../callback
type StoreReqType* = enum

View File

@ -2,7 +2,7 @@
## The requests are created by the main thread and processed by
## the Waku Thread.
import std/json, stew/results
import std/json, results
import chronos
import
../../../waku/factory/waku,

View File

@ -2,7 +2,7 @@
## The response will be created from the Waku Thread and processed in
## the main thread.
import std/json, stew/results
import std/json, results
import ../../alloc
type ResponseType {.pure.} = enum

View File

@ -3,10 +3,9 @@
{.passc: "-fPIC".}
import std/[options, atomics, os, net]
import chronicles, chronos, chronos/threadsync, taskpools/channels_spsc_single, results
import
chronicles, chronos, chronos/threadsync, taskpools/channels_spsc_single, stew/results
import
../../../waku/factory/waku,
waku/factory/waku,
./inter_thread_communication/waku_thread_request,
./inter_thread_communication/waku_thread_response

View File

@ -1,6 +1,6 @@
{.used.}
import std/options, stew/results, testutils/unittests
import std/options, results, testutils/unittests
import waku/waku_core/topics
suite "Waku Message - Content topics namespacing":

View File

@ -18,6 +18,6 @@ proc newTestWakuStore*(
return proto
proc newTestWakuStoreClient*(switch: Switch): WakuStoreClient =
proc newTestWakuStoreClient*(switch: Switch): WakuStoreClient {.gcsafe.} =
let peerManager = PeerManager.new(switch)
WakuStoreClient.new(peerManager, rng)

View File

@ -3,7 +3,7 @@ when (NimMajor, NimMinor) < (1, 4):
else:
{.push raises: [].}
import chronicles, sequtils, stew/[results]
import chronicles, sequtils, results
import
waku/[waku_rln_relay/rln, waku_rln_relay/conversion_utils, factory/external_config]

View File

@ -3,7 +3,7 @@ when (NimMajor, NimMinor) < (1, 4):
else:
{.push raises: [].}
import chronicles, stew/[results], std/tempfiles
import chronicles, results, std/tempfiles
import
waku/[

1
vendor/db_connector vendored Submodule

@ -0,0 +1 @@
Subproject commit 70d2ab3ff9907cb5b1d863bfb333a0ced5ee1596

2
vendor/nim-bearssl vendored

@ -1 +1 @@
Subproject commit a806cbfab5fe8de49c76139f8705fff79daf99ee
Subproject commit 646fa2152b11980c24bf34b3e214b479c9d25f21

2
vendor/nim-chronos vendored

@ -1 +1 @@
Subproject commit 4ad38079dec8407c396ebaaf6ba60e5e94e3fce5
Subproject commit 13d28a5b710c414be17bfe36ca25bf34771875cc

@ -1 +1 @@
Subproject commit 0adf3b7db70736061bf12fa23c2fc51f395b289e
Subproject commit cb640db2cd66d7f4a1810a7df51b55f6f59cf3c5

2
vendor/nim-dnsdisc vendored

@ -1 +1 @@
Subproject commit c138792c9385208626a005ffa0833101760b0da5
Subproject commit 38f853df30bcfdb73055b7fd7de284a47eebecc2

@ -1 +1 @@
Subproject commit 11b9d952a80ec87e2443405a6a5382f9daac51f8
Subproject commit dbc4a95df60238157dcf286f6125188cb72f37c1

@ -1 +1 @@
Subproject commit be57dbc902d36f37540897e98c69aa80f868cb45
Subproject commit 98496aa24d9364d1652e531f5f346de9b7cb3e15

@ -1 +1 @@
Subproject commit 4d0b0662ed960ab2c5a1ddbd08f77048bac13ae7
Subproject commit 89f7be1783b2f828a95dea1496fdac3510532997

@ -1 +1 @@
Subproject commit aab85b6d242df38706664373f089675235953ab8
Subproject commit 4db9cae5ac0225e3439f577f5c5cd67086232b3f

2
vendor/nim-libp2p vendored

@ -1 +1 @@
Subproject commit d0af3fbe8559f69195657a360c3dd4ac4552c811
Subproject commit 94d93cbf2531296f0e636aa702b500b242eb4158

2
vendor/nim-metrics vendored

@ -1 +1 @@
Subproject commit 0e768ca7fb7df4798649145a403e7db65cae1f8b
Subproject commit f068c85196cd4464e97d52ff0ea3d5ed8e59da1b

@ -1 +1 @@
Subproject commit 54bf8aa2913e8550463779beeae4b469941e039c
Subproject commit 459fc4968799bde97592137f42d93e5069f06e73

2
vendor/nim-presto vendored

@ -1 +1 @@
Subproject commit a9687dda1c3e20d5b066d42b33c2a63f018af93f
Subproject commit 2190421e09938696cd95d54b1f4753446c84c7a2

2
vendor/nim-results vendored

@ -1 +1 @@
Subproject commit 193d3c6648bd0f7e834d4ebd6a1e1d5f93998197
Subproject commit e2adf66b8bc2f41606e8469a5f0a850d1e545b55

@ -1 +1 @@
Subproject commit 194b715b16766e383b5aef92dd779fb182faf45d
Subproject commit c1795d1fb64b6cfe932a8d977a123b55a562dc52

@ -1 +1 @@
Subproject commit afae13adac25b6fa98bacf4b9f38458dc64317b0
Subproject commit 298a9554a885b2df59737bb3461aac8d0d339724

2
vendor/nim-stew vendored

@ -1 +1 @@
Subproject commit 104132fd0217e846b04dd26a5fbe3e43a4929a05
Subproject commit e00fea1f6e14234adb10d9c117a70905ae31872b

2
vendor/nim-stint vendored

@ -1 +1 @@
Subproject commit 9d2b382c5dc34f0d6bbd93b2a5d65dde85067e0f
Subproject commit 9a3348bd4499045fb211afeeaf2a54730060c081

@ -1 +1 @@
Subproject commit 24bbfcb8e4e256883fc959dc6f5c15fe7a84fca5
Subproject commit cb1fc73f3519fed5f3a8fbfa90afc9a96d5f5f5c

@ -1 +1 @@
Subproject commit 3db16f8ece5d0eba310c8f1ed812c6ff5a21a34a
Subproject commit 8c8959d84c12ecda6ea14c67bd68675b1936f8cf

@ -1 +1 @@
Subproject commit d7e7f1044def3c62d0b4bcec60c0b53876e44d71
Subproject commit 741274439ce72162ab3c740e7c0ef624d32725f9

2
vendor/nimcrypto vendored

@ -1 +1 @@
Subproject commit 485f7b3cfa83c1beecc0e31be0e964d697aa74d7
Subproject commit 71bca15508e2c0548f32b42a69bcfb1ccd9ab9ff

View File

@ -1,14 +1,14 @@
mode = ScriptMode.Verbose
### Package
version = "0.1.0"
author = "Status Research & Development GmbH"
description = "Waku, Private P2P Messaging for Resource-Restricted Devices"
license = "MIT or Apache License 2.0"
version = "0.1.0"
author = "Status Research & Development GmbH"
description = "Waku, Private P2P Messaging for Resource-Restricted Devices"
license = "MIT or Apache License 2.0"
#bin = @["build/waku"]
### Dependencies
requires "nim >= 1.6.0",
requires "nim >= 2.0.8",
"chronicles",
"confutils",
"chronos",
@ -22,7 +22,8 @@ requires "nim >= 1.6.0",
"libp2p", # Only for Waku v2
"web3",
"presto",
"regex"
"regex",
"db_connector"
### Helper functions
proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
@ -30,21 +31,26 @@ proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
mkDir "build"
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
var extra_params = params
for i in 2..<paramCount():
for i in 2 ..< paramCount():
extra_params &= " " & paramStr(i)
exec "nim " & lang & " --out:build/" & name & " " & extra_params & " " & srcDir & name & ".nim"
exec "nim " & lang & " --out:build/" & name & " --mm:refc " & extra_params & " " & srcDir & name &
".nim"
proc buildLibrary(name: string, srcDir = "./", params = "", `type` = "static") =
if not dirExists "build":
mkDir "build"
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
var extra_params = params
for i in 2..<paramCount():
for i in 2 ..< paramCount():
extra_params &= " " & paramStr(i)
if `type` == "static":
exec "nim c" & " --out:build/" & name & ".a --threads:on --app:staticlib --opt:size --noMain --header " & extra_params & " " & srcDir & name & ".nim"
exec "nim c" & " --out:build/" & name &
".a --threads:on --app:staticlib --opt:size --noMain --mm:refc --header " & extra_params &
" " & srcDir & name & ".nim"
else:
exec "nim c" & " --out:build/" & name & ".so --threads:on --app:lib --opt:size --noMain --header " & extra_params & " " & srcDir & name & ".nim"
exec "nim c" & " --out:build/" & name &
".so --threads:on --app:lib --opt:size --noMain --mm:refc --header " & extra_params & " " &
srcDir & name & ".nim"
proc buildMobileAndroid(srcDir = ".", params = "") =
let cpu = getEnv("CPU")
@ -55,10 +61,13 @@ proc buildMobileAndroid(srcDir = ".", params = "") =
mkDir outDir
var extra_params = params
for i in 2..<paramCount():
for i in 2 ..< paramCount():
extra_params &= " " & paramStr(i)
exec "nim c" & " --out:" & outDir & "/libwaku.so --threads:on --app:lib --opt:size --noMain -d:chronicles_sinks=textlines[dynamic] --header --passL:-L" & outdir & " --passL:-lrln --passL:-llog --cpu:" & cpu & " --os:android -d:androidNDK " & extra_params & " " & srcDir & "/libwaku.nim"
exec "nim c" & " --out:" & outDir &
"/libwaku.so --threads:on --app:lib --opt:size --noMain --mm:refc -d:chronicles_sinks=textlines[dynamic] --header --passL:-L" &
outdir & " --passL:-lrln --passL:-llog --cpu:" & cpu & " --os:android -d:androidNDK " &
extra_params & " " & srcDir & "/libwaku.nim"
proc test(name: string, params = "-d:chronicles_log_level=DEBUG", lang = "c") =
# XXX: When running `> NIM_PARAMS="-d:chronicles_log_level=INFO" make test2`
@ -140,4 +149,3 @@ task libWakuAndroid, "Build the mobile bindings for Android":
let srcDir = "./library"
let extraParams = "-d:chronicles_log_level=ERROR"
buildMobileAndroid srcDir, extraParams

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import stew/[results, byteutils, base64]
import stew/[byteutils, base64], results
type Base64String* = distinct string

View File

@ -1,3 +1,3 @@
import stew/results
import results
type DatabaseResult*[T] = Result[T, string]

View File

@ -1,6 +1,6 @@
import std/[times, strutils], stew/results, chronos
import std/[times, strutils], results, chronos
include db_postgres
include db_connector/db_postgres
type DataProc* = proc(result: ptr PGresult) {.closure, gcsafe, raises: [].}

View File

@ -2,7 +2,7 @@
# Inspired by: https://github.com/treeform/pg/
{.push raises: [].}
import std/[sequtils, nre, strformat, sets], stew/results, chronos
import std/[sequtils, nre, strformat, sets], results, chronos
import ./dbconn, ../common
type PgAsyncPoolState {.pure.} = enum

View File

@ -4,7 +4,7 @@
#
# Most of it is a direct copy, the only unique functions being `get` and `put`.
import std/[os, strutils, sequtils, algorithm], stew/results, chronicles, sqlite3_abi
import std/[os, strutils, sequtils, algorithm], results, chronicles, sqlite3_abi
import ./common
logScope:
@ -50,10 +50,10 @@ template checkErr*(op) =
type SqliteDatabase* = ref object of RootObj
env*: Sqlite
type DataProc* = proc(s: RawStmtPtr) {.closure.}
type DataProc* = proc(s: RawStmtPtr) {.closure, gcsafe.}
# the nim-eth definition is different; one more indirection
const NoopRowHandler* = proc(s: RawStmtPtr) {.closure.} =
const NoopRowHandler* = proc(s: RawStmtPtr) {.closure, gcsafe.} =
discard
proc new*(T: type SqliteDatabase, path: string, readOnly = false): DatabaseResult[T] =
@ -214,7 +214,9 @@ proc exec*[Params, Res](
discard sqlite3_reset(s) # same return information as step
discard sqlite3_clear_bindings(s) # no errors possible
proc query*(db: SqliteDatabase, query: string, onData: DataProc): DatabaseResult[bool] =
proc query*(
db: SqliteDatabase, query: string, onData: DataProc
): DatabaseResult[bool] {.gcsafe.} =
var s = prepare(db.env, query):
discard
@ -231,7 +233,7 @@ proc query*(db: SqliteDatabase, query: string, onData: DataProc): DatabaseResult
else:
return err($sqlite3_errstr(v))
return ok gotResults
finally:
except Exception, CatchableError:
# release implicit transaction
discard sqlite3_reset(s) # same return information as step
discard sqlite3_clear_bindings(s) # no errors possible

View File

@ -1,4 +1,4 @@
import std/strutils, regex, stew/results
import std/strutils, regex, results
proc validateDbUrl*(dbUrl: string): Result[string, string] =
## dbUrl mimics SQLAlchemy Database URL schema

View File

@ -2,7 +2,7 @@
import
std/[options, net],
stew/results,
results,
eth/keys as eth_keys,
eth/p2p/discoveryv5/enr,
libp2p/crypto/crypto as libp2p_crypto

View File

@ -1,7 +1,6 @@
{.push raises: [].}
import
std/options, stew/results, eth/keys as eth_keys, libp2p/crypto/crypto as libp2p_crypto
import std/options, results, eth/keys as eth_keys, libp2p/crypto/crypto as libp2p_crypto
import eth/p2p/discoveryv5/enr except TypedRecord, toTypedRecord

View File

@ -1,7 +1,7 @@
## This code has been copied and addapted from `status-im/nimbu-eth2` project.
## Link: https://github.com/status-im/nimbus-eth2/blob/c585b0a5b1ae4d55af38ad7f4715ad455e791552/beacon_chain/nimbus_binary_common.nim
import
std/[typetraits, os, strutils],
std/[typetraits, os, strutils, syncio],
chronicles,
chronicles/log_output,
chronicles/topics_registry
@ -53,7 +53,7 @@ proc stripAnsi(v: string): string =
res
proc writeAndFlush(f: File, s: LogOutputStr) =
proc writeAndFlush(f: syncio.File, s: LogOutputStr) =
try:
f.write(s)
f.flushFile()
@ -71,10 +71,10 @@ proc setupLogFormat(format: LogFormat, color = true) =
discard
proc stdoutOutputWriter(logLevel: LogLevel, msg: LogOutputStr) =
writeAndFlush(io.stdout, msg)
writeAndFlush(syncio.stdout, msg)
proc stdoutNoColorOutputWriter(logLevel: LogLevel, msg: LogOutputStr) =
writeAndFlush(io.stdout, stripAnsi(msg))
writeAndFlush(syncio.stdout, stripAnsi(msg))
when defaultChroniclesStream.outputs.type.arity == 2:
case format

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import std/[httpclient, json, uri, options], stew/results
import std/[httpclient, json, uri, options], results
const
# Resource locators

View File

@ -1,7 +1,7 @@
{.push raises: [].}
import std/[options, strutils, net]
import chronicles, eth/net/nat, stew/results, nativesockets
import chronicles, eth/net/nat, results, nativesockets
logScope:
topics = "nat"

View File

@ -1,4 +1,4 @@
import std/strutils, stew/results, regex
import std/strutils, results, regex
proc parseMsgSize*(input: string): Result[uint64, string] =
## Parses size strings such as "1.2 KiB" or "3Kb" and returns the equivalent number of bytes

View File

@ -2,7 +2,7 @@
import
std/[sequtils, strutils, options, sets, net, json],
stew/results,
results,
chronos,
chronicles,
metrics,

View File

@ -2,7 +2,7 @@
import
std/[options, net],
stew/results,
results,
chronicles,
libp2p/crypto/crypto,
libp2p/builders,

View File

@ -1,6 +1,6 @@
import
std/[strutils, strformat],
stew/results,
results,
chronos,
regex,
confutils,
@ -77,7 +77,8 @@ type WakuNodeConf* = object
.}: string
rlnRelayChainId* {.
desc: "Chain ID of the provided contract (optional, will fetch from RPC provider if not used)",
desc:
"Chain ID of the provided contract (optional, will fetch from RPC provider if not used)",
defaultValue: 0,
name: "rln-relay-chain-id"
.}: uint

View File

@ -5,7 +5,7 @@ import
libp2p/multiaddress,
libp2p/nameresolving/dnsresolver,
std/[options, sequtils, net],
stew/results
results
import
./external_config,
../common/utils/nat,

View File

@ -2,7 +2,7 @@
import
std/[options, sequtils],
stew/results,
results,
chronicles,
chronos,
libp2p/wire,

View File

@ -1,9 +1,7 @@
{.push raises: [].}
import
std/[options, sequtils, strutils, net],
stew/results,
libp2p/[multiaddress, multicodec]
std/[options, sequtils, strutils, net], results, libp2p/[multiaddress, multicodec]
import ../../waku/waku_core/peers
import ../waku_enr

View File

@ -108,14 +108,16 @@ proc calculateBackoff(
# Helper functions #
####################
proc insertOrReplace(ps: PeerStorage, remotePeerInfo: RemotePeerInfo) =
proc insertOrReplace(ps: PeerStorage, remotePeerInfo: RemotePeerInfo) {.gcsafe.} =
## Insert peer entry into persistent storage, or replace existing entry with updated info
ps.put(remotePeerInfo).isOkOr:
warn "failed to store peers", err = error
waku_peers_errors.inc(labelValues = ["storage_failure"])
return
proc addPeer*(pm: PeerManager, remotePeerInfo: RemotePeerInfo, origin = UnknownOrigin) =
proc addPeer*(
pm: PeerManager, remotePeerInfo: RemotePeerInfo, origin = UnknownOrigin
) {.gcsafe.} =
## Adds peer to manager for the specified protocol
if remotePeerInfo.peerId == pm.switch.peerInfo.peerId:
@ -257,7 +259,7 @@ proc dialPeer(
return none(Connection)
proc loadFromStorage(pm: PeerManager) =
proc loadFromStorage(pm: PeerManager) {.gcsafe.} =
## Load peers from storage, if available
trace "loading peers from storage"
@ -435,6 +437,8 @@ proc onPeerEvent(pm: PeerManager, peerId: PeerId, event: PeerEvent) {.async.} =
if pm.ipTable[ip].len == 0:
pm.ipTable.del(ip)
break
of Identified:
debug "event identified", peerId = peerId
pm.peerStore[ConnectionBook][peerId] = connectedness
pm.peerStore[DirectionBook][peerId] = direction
@ -458,7 +462,7 @@ proc new*(
maxFailedAttempts = MaxFailedAttempts,
colocationLimit = DefaultColocationLimit,
shardedPeerManagement = false,
): PeerManager =
): PeerManager {.gcsafe.} =
let capacity = switch.peerStore.capacity
let maxConnections = switch.connManager.inSema.size
if maxConnections > capacity:

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import std/[tables, strutils, os], stew/results, chronicles
import std/[tables, strutils, os], results, chronicles
import ../../../common/databases/db_sqlite, ../../../common/databases/common
logScope:

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import stew/results
import results
import ../../../waku_core, ../waku_peer_store
## This module defines a peer storage interface. Implementations of
@ -11,13 +11,15 @@ type
PeerStorageResult*[T] = Result[T, string]
DataProc* = proc(remotePeerInfo: RemotePeerInfo) {.closure, raises: [Defect].}
DataProc* = proc(remotePeerInfo: RemotePeerInfo) {.closure, gcsafe, raises: [Defect].}
# PeerStorage interface
method put*(
db: PeerStorage, remotePeerInfo: RemotePeerInfo
): PeerStorageResult[void] {.base.} =
): PeerStorageResult[void] {.base, gcsafe.} =
return err("Unimplemented")
method getAll*(db: PeerStorage, onData: DataProc): PeerStorageResult[void] {.base.} =
method getAll*(
db: PeerStorage, onData: DataProc
): PeerStorageResult[void] {.base, gcsafe.} =
return err("Unimplemented")

View File

@ -2,7 +2,7 @@
import
std/[sets, options],
stew/results,
results,
sqlite3_abi,
eth/p2p/discoveryv5/enr,
libp2p/protobuf/minprotobuf
@ -126,7 +126,7 @@ proc new*(T: type WakuPeerStorage, db: SqliteDatabase): PeerStorageResult[T] =
method put*(
db: WakuPeerStorage, remotePeerInfo: RemotePeerInfo
): PeerStorageResult[void] =
): PeerStorageResult[void] {.gcsafe.} =
## Adds a peer to storage or replaces existing entry if it already exists
let encoded = remotePeerInfo.encode().valueOr:
@ -142,7 +142,7 @@ method getAll*(
): PeerStorageResult[void] =
## Retrieves all peers from storage
proc peer(s: ptr sqlite3_stmt) {.raises: [ResultError[ProtoError]].} =
proc peer(s: ptr sqlite3_stmt) {.gcsafe, raises: [ResultError[ProtoError]].} =
let
# Stored Info
sTo = cast[ptr UncheckedArray[byte]](sqlite3_column_blob(s, 1))

View File

@ -5,7 +5,7 @@ import
chronos,
chronicles,
metrics,
stew/results,
results,
stew/byteutils,
eth/keys,
nimcrypto,

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import stew/results
import results
import ../waku_core, ../waku_noise/noise_types, ../waku_noise/noise_utils
# Decodes a WakuMessage to a PayloadV2

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import chronos, std/[options, sequtils], stew/results
import chronos, std/[options, sequtils], results
import ../discovery/waku_discv5, ../waku_relay, ../waku_core, ./message_cache
### Discovery

View File

@ -2,7 +2,7 @@
import
std/[sequtils, sugar, algorithm, options],
stew/results,
results,
chronicles,
chronos,
libp2p/protocols/pubsub

View File

@ -3,21 +3,21 @@
import net, tables
import presto
import
../../waku/waku_node,
../../waku/discovery/waku_discv5,
../../waku/factory/external_config,
../../waku/waku_api/message_cache,
../../waku/waku_api/handlers,
../../waku/waku_api/rest/server,
../../waku/waku_api/rest/debug/handlers as rest_debug_api,
../../waku/waku_api/rest/relay/handlers as rest_relay_api,
../../waku/waku_api/rest/filter/handlers as rest_filter_api,
../../waku/waku_api/rest/lightpush/handlers as rest_lightpush_api,
../../waku/waku_api/rest/store/handlers as rest_store_api,
../../waku/waku_api/rest/legacy_store/handlers as rest_store_legacy_api,
../../waku/waku_api/rest/health/handlers as rest_health_api,
../../waku/waku_api/rest/admin/handlers as rest_admin_api,
../../waku/waku_core/topics
waku/waku_node,
waku/discovery/waku_discv5,
waku/factory/external_config,
waku/waku_api/message_cache,
waku/waku_api/handlers,
waku/waku_api/rest/server,
waku/waku_api/rest/debug/handlers as rest_debug_api,
waku/waku_api/rest/relay/handlers as rest_relay_api,
waku/waku_api/rest/filter/handlers as rest_filter_api,
waku/waku_api/rest/lightpush/handlers as rest_lightpush_api,
waku/waku_api/rest/store/handlers as rest_store_api,
waku/waku_api/rest/legacy_store/handlers as rest_store_legacy_api,
waku/waku_api/rest/health/handlers as rest_health_api,
waku/waku_api/rest/admin/handlers as rest_admin_api,
waku/waku_core/topics
## Monitoring and external interfaces

View File

@ -2,7 +2,7 @@
import
chronicles, json_serialization, json_serialization/std/options, presto/[route, client]
import ./types, ../serdes, ../responses, ../rest_serdes, ../../waku/node/health_monitor
import ./types, ../serdes, ../responses, ../rest_serdes, waku/node/health_monitor
logScope:
topics = "waku node rest health_api"

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import std/strformat, stew/results, chronicles, uri, json_serialization, presto/route
import std/strformat, results, chronicles, uri, json_serialization, presto/route
import
../../../waku_core,
../../../waku_store_legacy/common,

View File

@ -10,9 +10,9 @@ import
presto/common
import
../../waku/node/peer_manager,
waku/node/peer_manager,
waku/waku_lightpush/common,
../../../waku_node,
../../waku/waku_lightpush/common,
../../handlers,
../serdes,
../responses,

View File

@ -2,7 +2,7 @@
import
std/[options, strutils, re, net],
stew/results,
results,
chronicles,
chronos,
chronos/apps/http/httpserver

View File

@ -2,7 +2,8 @@
import
std/sequtils,
stew/[byteutils, results],
stew/byteutils,
results,
chronicles,
json_serialization,
json_serialization/std/options,

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import std/typetraits, stew/results, chronicles, presto/common
import std/typetraits, results, chronicles, presto/common
import ./serdes
const MIMETYPE_JSON* = MediaType.init("application/json")

View File

@ -3,7 +3,7 @@
import
std/typetraits,
std/os,
stew/results,
results,
chronicles,
serialization,
json_serialization,

View File

@ -2,7 +2,7 @@
import
std/typetraits,
stew/results,
results,
stew/byteutils,
chronicles,
serialization,

View File

@ -2,7 +2,7 @@
import std/net
import
stew/results,
results,
chronicles,
chronos,
chronos/apps/http/httpserver,

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import std/strformat, stew/results, chronicles, uri, json_serialization, presto/route
import std/strformat, results, chronicles, uri, json_serialization, presto/route
import
../../../waku_core,
../../../waku_store/common,

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import std/options, stew/results, stew/byteutils, stew/arrayops, nimcrypto/sha2
import std/options, results, stew/byteutils, stew/arrayops, nimcrypto/sha2
import ../waku_core, ../common/paging
## Waku message digest

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import std/options, stew/results, chronos
import std/options, results, chronos
import ../waku_core, ./common
const DefaultPageSize*: uint = 25

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import stew/results, chronicles, chronos
import results, chronicles, chronos
import
../driver,
../../common/databases/dburl,

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import std/strutils, stew/results, chronicles, chronos
import std/strutils, results, chronicles, chronos
import
../../../common/databases/common,
../../../../migrations/message_store_postgres/pg_migration_manager,

View File

@ -2,10 +2,10 @@
import
std/[nre, options, sequtils, strutils, strformat, times],
stew/[results, byteutils, arrayops],
db_postgres,
postgres,
stew/[byteutils, arrayops],
results,
chronos,
db_connector/[postgres, db_common],
chronicles
import
../../../common/error_handling,

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import chronos, stew/results
import chronos, results
import ../../../common/databases/db_postgres, ../../../common/error_handling
## Simple query to validate that the postgres is working and attending requests

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import std/options, stew/results, stew/sorted_set, chronicles, chronos
import std/options, results, stew/sorted_set, chronicles, chronos
import ../../../waku_core, ../../common, ../../driver, ./index
logScope:
@ -9,7 +9,8 @@ logScope:
const QueueDriverDefaultMaxCapacity* = 25_000
type
QueryFilterMatcher = proc(index: Index, msg: WakuMessage): bool {.gcsafe, closure.}
QueryFilterMatcher =
proc(index: Index, msg: WakuMessage): bool {.gcsafe, raises: [], closure.}
QueueDriver* = ref object of ArchiveDriver
## Bounded repository for indexed messages
@ -81,7 +82,7 @@ proc getPage(
forward: bool = true,
cursor: Option[Index] = none(Index),
predicate: QueryFilterMatcher = nil,
): QueueDriverGetPageResult =
): QueueDriverGetPageResult {.raises: [].} =
## Populate a single page in forward direction
## Start at the `startCursor` (exclusive), or first entry (inclusive) if not defined.
## Page size must not exceed `maxPageSize`

View File

@ -1,10 +1,7 @@
{.push raises: [].}
import
std/[tables, strutils, os],
stew/results,
chronicles,
sqlite3_abi # sqlite3_column_int64
std/[tables, strutils, os], results, chronicles, sqlite3_abi # sqlite3_column_int64
import ../../../common/databases/db_sqlite, ../../../common/databases/common
logScope:

View File

@ -1,6 +1,6 @@
{.push raises: [].}
import std/[options, sequtils], stew/[results, byteutils], sqlite3_abi
import std/[options, sequtils], stew/byteutils, sqlite3_abi, results
import
../../../common/databases/db_sqlite,
../../../common/databases/common,
@ -261,7 +261,7 @@ proc selectAllMessages*(
db: SqliteDatabase
): DatabaseResult[
seq[(PubsubTopic, WakuMessage, seq[byte], Timestamp, WakuMessageHash)]
] =
] {.gcsafe.} =
## Retrieve all messages from the store.
var rows: seq[(PubsubTopic, WakuMessage, seq[byte], Timestamp, WakuMessageHash)]
proc queryRowCallback(s: ptr sqlite3_stmt) =
@ -426,7 +426,7 @@ proc execSelectMessagesV2WithLimitStmt(
return ok()
else:
return err($sqlite3_errstr(v))
finally:
except Exception, CatchableError:
# release implicit transaction
discard sqlite3_reset(s) # same return information as step
discard sqlite3_clear_bindings(s) # no errors possible
@ -497,7 +497,7 @@ proc execSelectMessageByHash(
return ok()
else:
return err($sqlite3_errstr(v))
finally:
except Exception, CatchableError:
# release implicit transaction
discard sqlite3_reset(s) # same return information as step
discard sqlite3_clear_bindings(s) # no errors possible
@ -628,7 +628,7 @@ proc execSelectMessagesWithLimitStmt(
return ok()
else:
return err($sqlite3_errstr(v))
finally:
except Exception, CatchableError:
# release implicit transaction
discard sqlite3_reset(s) # same return information as step
discard sqlite3_clear_bindings(s) # no errors possible

Some files were not shown because too many files have changed in this diff Show More