Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Updating nim-chronicles, nim-chronos, nim-presto, nimcrypto, nim-libp2p, and nim-nat-transversal #2043

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vendor/nim-chronos
Submodule nim-chronos updated 64 files
+2 −2 .github/workflows/ci.yml
+1 −0 .gitignore
+1 −1 README.md
+21 −8 chronos.nimble
+9 −74 chronos/apps/http/httpbodyrw.nim
+322 −180 chronos/apps/http/httpclient.nim
+56 −4 chronos/apps/http/httpcommon.nim
+129 −0 chronos/apps/http/httpdebug.nim
+427 −243 chronos/apps/http/httpserver.nim
+5 −4 chronos/apps/http/httptable.nim
+15 −15 chronos/apps/http/multipart.nim
+29 −6 chronos/apps/http/shttpserver.nim
+405 −363 chronos/asyncfutures2.nim
+603 −213 chronos/asyncloop.nim
+158 −161 chronos/asyncmacro2.nim
+1,347 −0 chronos/asyncproc.nim
+48 −36 chronos/asyncsync.nim
+71 −4 chronos/config.nim
+5 −8 chronos/debugutils.nim
+251 −0 chronos/futures.nim
+7 −7 chronos/handles.nim
+23 −25 chronos/ioselects/ioselectors_epoll.nim
+33 −26 chronos/ioselects/ioselectors_kqueue.nim
+19 −22 chronos/ioselects/ioselectors_poll.nim
+407 −204 chronos/osdefs.nim
+1,348 −0 chronos/oserrno.nim
+122 −10 chronos/osutils.nim
+19 −15 chronos/ratelimit.nim
+9 −27 chronos/selectors2.nim
+14 −12 chronos/sendfile.nim
+3 −4 chronos/srcloc.nim
+52 −108 chronos/streams/asyncstream.nim
+26 −25 chronos/streams/tlsstream.nim
+416 −0 chronos/threadsync.nim
+1 −22 chronos/timer.nim
+103 −51 chronos/transports/common.nim
+78 −78 chronos/transports/datagram.nim
+6 −9 chronos/transports/ipnet.nim
+20 −21 chronos/transports/osnet.nim
+315 −283 chronos/transports/stream.nim
+12 −0 chronos/unittest2/asynctests.nim
+18 −6 tests/testall.nim
+150 −157 tests/testasyncstream.nim
+5 −5 tests/testbugs.nim
+4 −4 tests/testdatagram.nim
+486 −20 tests/testfut.nim
+26 −0 tests/testfutures.nim
+581 −133 tests/testhttpclient.nim
+256 −76 tests/testhttpserver.nim
+94 −1 tests/testmacro.nim
+1 −1 tests/testnet.nim
+42 −0 tests/testproc.bat
+468 −0 tests/testproc.nim
+28 −0 tests/testproc.sh
+38 −33 tests/testratelimit.nim
+61 −44 tests/testserver.nim
+9 −5 tests/testshttpserver.nim
+57 −38 tests/testsignal.nim
+74 −66 tests/testsoon.nim
+149 −71 tests/teststream.nim
+2 −2 tests/testsync.nim
+369 −0 tests/testthreadsync.nim
+17 −7 tests/testtime.nim
+3 −3 tests/testutils.nim
2 changes: 1 addition & 1 deletion vendor/nim-libp2p
2 changes: 1 addition & 1 deletion vendor/nim-nat-traversal
1 change: 1 addition & 0 deletions waku/node/rest/store/handlers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import
std/strformat,
stew/results,
chronicles,
uri,
json_serialization,
presto/route
import
Expand Down
15 changes: 6 additions & 9 deletions waku/node/waku_metrics.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,17 @@ const LogInterval = 30.seconds
logScope:
topics = "waku node metrics"


type
# https://github.com/nim-lang/Nim/issues/17369
MetricsLogger = proc(udata: pointer) {.gcsafe, raises: [Defect].}

proc startMetricsLog*() =
var logMetrics: MetricsLogger
var logMetrics: CallbackFunc

var cumulativeErrors = 0.float64
var cumulativeConns = 0.float64

let logRlnMetrics = getRlnMetricsLogger()

logMetrics = proc(udata: pointer) =
{.gcsafe.}:
logMetrics = CallbackFunc(
proc(udata: pointer) {.gcsafe.} =

# TODO: libp2p_pubsub_peers is not public, so we need to make this either
# public in libp2p or do our own peer counting after all.

Expand All @@ -62,6 +58,7 @@ proc startMetricsLog*() =
# Start protocol specific metrics logging
logRlnMetrics()

discard setTimer(Moment.fromNow(LogInterval), logMetrics)
discard setTimer(Moment.fromNow(LogInterval), logMetrics)
)

discard setTimer(Moment.fromNow(LogInterval), logMetrics)
4 changes: 2 additions & 2 deletions waku/node/waku_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ proc getAutonatService*(rng: ref HmacDrbgContext): AutonatService =
let autonatService = AutonatService.new(
autonatClient = AutonatClient.new(),
rng = rng,
scheduleInterval = Opt.some(chronos.seconds(120)),
scheduleInterval = some(chronos.seconds(120)),
askNewConnectedPeers = false,
numPeersToAsk = 3,
maxQueueSize = 3,
minConfidence = 0.7)

proc statusAndConfidenceHandler(networkReachability: NetworkReachability,
confidence: Opt[float]):
confidence: Option[float]):
Future[void] {.gcsafe, async.} =
if confidence.isSome():
info "Peer reachability status", networkReachability=networkReachability, confidence=confidence.get()
Expand Down
30 changes: 16 additions & 14 deletions waku/waku_archive/archive.nim
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,21 @@ proc startMessageRetentionPolicyPeriodicTask*(w: WakuArchive,
# Start the periodic message retention policy task
# https://github.com/nim-lang/Nim/issues/17369

var executeRetentionPolicy: proc(udata: pointer) {.gcsafe, raises: [Defect].}
executeRetentionPolicy = proc(udata: pointer) {.gcsafe.} =

try:
let retPolRes = waitFor w.executeMessageRetentionPolicy()
if retPolRes.isErr():
waku_archive_errors.inc(labelValues = [retPolicyFailure])
error "error in periodic retention policy", error = retPolRes.error
except CatchableError:
waku_archive_errors.inc(labelValues = [retPolicyFailure])
error "exception in periodic retention policy",
error = getCurrentExceptionMsg()

discard setTimer(Moment.fromNow(interval), executeRetentionPolicy)
var executeRetentionPolicy: CallbackFunc
executeRetentionPolicy =
CallbackFunc(
proc (arg: pointer) {.gcsafe, raises: [].} =
try:
let retPolRes = waitFor w.executeMessageRetentionPolicy()
if retPolRes.isErr():
waku_archive_errors.inc(labelValues = [retPolicyFailure])
error "error in periodic retention policy", error = retPolRes.error
except CatchableError:
waku_archive_errors.inc(labelValues = [retPolicyFailure])
error "exception in periodic retention policy",
error = getCurrentExceptionMsg()

discard setTimer(Moment.fromNow(interval), executeRetentionPolicy)
)

discard setTimer(Moment.fromNow(interval), executeRetentionPolicy)
10 changes: 6 additions & 4 deletions waku/waku_filter_v2/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,12 @@ const MaintainSubscriptionsInterval* = 1.minutes

proc startMaintainingSubscriptions*(wf: WakuFilter, interval: Duration) =
trace "starting to maintain subscriptions"
var maintainSubs: proc(udata: pointer) {.gcsafe, raises: [Defect].}
maintainSubs = proc(udata: pointer) {.gcsafe.} =
maintainSubscriptions(wf)
wf.maintenanceTask = setTimer(Moment.fromNow(interval), maintainSubs)
var maintainSubs: CallbackFunc
maintainSubs = CallbackFunc(
proc(udata: pointer) {.gcsafe.} =
maintainSubscriptions(wf)
wf.maintenanceTask = setTimer(Moment.fromNow(interval), maintainSubs)
)

wf.maintenanceTask = setTimer(Moment.fromNow(interval), maintainSubs)

Expand Down