mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-06-16 14:39:34 +00:00
feat: bump nim-libp2p to v2.0.0 (#3929)
* bump nim-libp2p pin to v2.0.0 tag * bump json_rpc to v0.6.1, lsquic to v0.5.1, boringssl to v0.0.8 (latest tags) * add libp2p_mix dep; repoint libp2p/protocols/mix -> libp2p_mix * pin nimble.lock: websock / protobuf_serialization / npeg / jwt * Makefile: add -d:libp2p_quic_support * regenerate nix/deps.nix (adds libp2p_mix, refreshes pins) * migrate rng ref HmacDrbgContext -> libp2p Rng across prod/channels/tests (interface-only; same DRBG) * waku_switch: TransportConfig factory; unified 2.0.0 connection limits (withMaxInOut, withMaxConnections); local MaxConnections * waku_relay/rendezvous/discv5/kademlia: v2.0.0 API (rng, config, ServiceDiscovery rename) * call Service.setup() on post-build switch services (2.0.0 split setup/start) * drop libp2p/utils/semaphore -> chronos AsyncSemaphore * add logos_delivery/waku/compat/option_valueor shim (Option[T] valueOr/withValue, dropped upstream) * add std/options where a transitive re-export was removed * add newStandardSwitch shim (libp2p removed it in 2.0.0); mounts yamux+mplex to match prod muxer * PeerId.random(rng); common.rng()/crypto.newRng(); hoist shared rng (instantiation cleanup) * update expectations for 2.0.0 defaults: DEFAULT_PROTOCOLS += /ipfs/id/push/1.0.0; agent "nim-libp2p" * drop relay reboot/reconnect test (asserted a Switch restart capability that is simply not supported) * fix up a few tests that were flaking on MacOS (libp2p upgrade may have exposed these)
This commit is contained in:
parent
54c890856f
commit
6837ae0c1f
3
Makefile
3
Makefile
@ -147,6 +147,9 @@ NIM_PARAMS := $(NIM_PARAMS) -d:disable_libbacktrace
|
||||
# enable experimental exit is dest feature in libp2p mix
|
||||
NIM_PARAMS := $(NIM_PARAMS) -d:libp2p_mix_experimental_exit_is_dest
|
||||
|
||||
# enable libp2p's QUIC transport
|
||||
NIM_PARAMS := $(NIM_PARAMS) -d:libp2p_quic_support
|
||||
|
||||
ifeq ($(POSTGRES), 1)
|
||||
NIM_PARAMS := $(NIM_PARAMS) -d:postgres -d:nimDebugDlOpen
|
||||
endif
|
||||
|
||||
@ -305,7 +305,7 @@ proc readInput(wfd: AsyncFD) {.thread, raises: [Defect, CatchableError].} =
|
||||
|
||||
{.pop.}
|
||||
# @TODO confutils.nim(775, 17) Error: can raise an unlisted exception: ref IOError
|
||||
proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
|
||||
proc processInput(rfd: AsyncFD, rng: crypto.Rng) {.async.} =
|
||||
let
|
||||
transp = fromPipe(rfd)
|
||||
conf = Chat2Conf.load()
|
||||
@ -313,7 +313,7 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
|
||||
if conf.nodekey.isSome():
|
||||
conf.nodekey.get()
|
||||
else:
|
||||
PrivateKey.random(Secp256k1, rng[]).tryGet()
|
||||
PrivateKey.random(Secp256k1, rng).tryGet()
|
||||
|
||||
# set log level
|
||||
if conf.logLevel != LogLevel.NONE:
|
||||
@ -568,7 +568,7 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
|
||||
|
||||
runForever()
|
||||
|
||||
proc main(rng: ref HmacDrbgContext) {.async.} =
|
||||
proc main(rng: crypto.Rng) {.async.} =
|
||||
let (rfd, wfd) = createAsyncPipe()
|
||||
if rfd == asyncInvalidPipe or wfd == asyncInvalidPipe:
|
||||
raise newException(ValueError, "Could not initialize pipe!")
|
||||
|
||||
@ -272,7 +272,7 @@ when isMainModule:
|
||||
if conf.nodekey.isSome():
|
||||
conf.nodekey.get()
|
||||
else:
|
||||
crypto.PrivateKey.random(Secp256k1, rng[]).tryGet()
|
||||
crypto.PrivateKey.random(Secp256k1, rng).tryGet()
|
||||
|
||||
let bridge = Chat2Matterbridge.new(
|
||||
mbHostUri = "http://" & $initTAddress(conf.mbHostAddress, Port(conf.mbHostPort)),
|
||||
|
||||
@ -388,7 +388,7 @@ proc maintainSubscription(
|
||||
|
||||
{.pop.}
|
||||
# @TODO confutils.nim(775, 17) Error: can raise an unlisted exception: ref IOError
|
||||
proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
|
||||
proc processInput(rfd: AsyncFD, rng: crypto.Rng) {.async.} =
|
||||
let
|
||||
transp = fromPipe(rfd)
|
||||
conf = Chat2Conf.load()
|
||||
@ -396,7 +396,7 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
|
||||
if conf.nodekey.isSome():
|
||||
conf.nodekey.get()
|
||||
else:
|
||||
PrivateKey.random(Secp256k1, rng[]).tryGet()
|
||||
PrivateKey.random(Secp256k1, rng).tryGet()
|
||||
|
||||
# set log level
|
||||
if conf.logLevel != LogLevel.NONE:
|
||||
@ -660,7 +660,7 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
|
||||
|
||||
runForever()
|
||||
|
||||
proc main(rng: ref HmacDrbgContext) {.async.} =
|
||||
proc main(rng: crypto.Rng) {.async.} =
|
||||
let (rfd, wfd) = createAsyncPipe()
|
||||
if rfd == asyncInvalidPipe or wfd == asyncInvalidPipe:
|
||||
raise newException(ValueError, "Could not initialize pipe!")
|
||||
|
||||
@ -423,7 +423,7 @@ proc initAndStartApp(
|
||||
let
|
||||
# some hardcoded parameters
|
||||
rng = keys.newRng()
|
||||
key = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||
key = crypto.PrivateKey.random(Secp256k1, rng)[]
|
||||
nodeTcpPort = Port(60000)
|
||||
nodeUdpPort = Port(9000)
|
||||
flags = CapabilitiesBitfield.init(
|
||||
|
||||
@ -161,7 +161,7 @@ proc pingNode(
|
||||
error "Failed to ping the peer", peer = peerInfo, err = msg
|
||||
return false
|
||||
|
||||
proc main(rng: ref HmacDrbgContext): Future[int] {.async.} =
|
||||
proc main(rng: Rng): Future[int] {.async.} =
|
||||
let conf: WakuCanaryConf = WakuCanaryConf.load()
|
||||
|
||||
# create dns resolver
|
||||
@ -192,7 +192,7 @@ proc main(rng: ref HmacDrbgContext): Future[int] {.async.} =
|
||||
quit(QuitFailure)
|
||||
|
||||
let
|
||||
nodeKey = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||
nodeKey = crypto.PrivateKey.random(Secp256k1, rng)[]
|
||||
bindIp = parseIpAddress("0.0.0.0")
|
||||
wsBindPort = Port(conf.nodePort + WebSocketPortOffset)
|
||||
nodeTcpPort = Port(conf.nodePort)
|
||||
|
||||
@ -7,8 +7,8 @@ import
|
||||
confutils,
|
||||
libp2p/crypto/crypto,
|
||||
libp2p/crypto/curve25519,
|
||||
libp2p/protocols/mix,
|
||||
libp2p/protocols/mix/curve25519,
|
||||
libp2p_mix,
|
||||
libp2p_mix/curve25519,
|
||||
libp2p/multiaddress,
|
||||
eth/keys,
|
||||
eth/p2p/discoveryv5/enr,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/json
|
||||
import chronos, chronicles, results, strutils, libp2p/multiaddress, ffi
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[options, json, strutils, net]
|
||||
import chronos, chronicles, results, confutils, confutils/std/net, ffi
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[sequtils, strutils, tables]
|
||||
import chronicles, chronos, results, options, json, ffi
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import options, std/[strutils, sequtils]
|
||||
import chronicles, chronos, results, ffi
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import options, std/[json, strformat]
|
||||
import chronicles, chronos, results, ffi
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[net, sequtils, strutils, json], strformat
|
||||
import chronicles, chronos, stew/byteutils, results, ffi
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[json, sugar, strutils, options]
|
||||
import chronos, chronicles, results, stew/byteutils, ffi
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[atomics, options, macros]
|
||||
import chronicles, chronos, chronos/threadsync, ffi
|
||||
import
|
||||
|
||||
@ -28,7 +28,7 @@ requires "nim >= 2.2.4",
|
||||
"toml_serialization",
|
||||
"faststreams",
|
||||
# Networking & P2P
|
||||
"https://github.com/vacp2p/nim-libp2p.git#ff8d51857b4b79a68468e7bcc27b2026cca02996",
|
||||
"https://github.com/vacp2p/nim-libp2p.git#v2.0.0",
|
||||
"eth",
|
||||
"nat_traversal",
|
||||
"dnsdisc",
|
||||
@ -40,7 +40,7 @@ requires "nim >= 2.2.4",
|
||||
"secp256k1",
|
||||
"bearssl",
|
||||
# RPC & APIs
|
||||
"https://github.com/status-im/nim-json-rpc.git#43bbf499143eb45046c83ac9794c9e3280a2b8e7",
|
||||
"https://github.com/status-im/nim-json-rpc.git#v0.6.1",
|
||||
"presto",
|
||||
"web3",
|
||||
# Database
|
||||
@ -67,8 +67,9 @@ requires "https://github.com/logos-messaging/nim-sds.git#abdd40cc645f1b024c3ee99
|
||||
|
||||
requires "https://github.com/NagyZoltanPeter/nim-brokers.git#v3.1.1"
|
||||
|
||||
requires "https://github.com/vacp2p/nim-lsquic"
|
||||
requires "https://github.com/vacp2p/nim-lsquic.git#v0.5.1"
|
||||
requires "https://github.com/vacp2p/nim-jwt.git#057ec95eb5af0eea9c49bfe9025b3312c95dc5f2"
|
||||
requires "https://github.com/logos-co/nim-libp2p-mix#380513117d556bf8f70066f5e72a7fd74fe36ba6"
|
||||
|
||||
proc getMyCPU(): string =
|
||||
## Need to set cpu more explicit manner to avoid arch issues between dependencies
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
## Reliable Channel type.
|
||||
##
|
||||
## A `ReliableChannel` orchestrates segmentation, SDS (end-to-end
|
||||
@ -93,7 +94,7 @@ type
|
||||
channelId: ChannelId
|
||||
contentTopic: ContentTopic
|
||||
senderId: SdsParticipantID
|
||||
rng: ref HmacDrbgContext
|
||||
rng: libp2p_crypto.Rng
|
||||
segmentation: SegmentationHandler
|
||||
sdsHandler: SdsHandler
|
||||
rateLimit: RateLimitManager
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
## This module is in charge of taking care of the messages that this node is expecting to
|
||||
## receive and is backed by store-v3 requests to get an additional degree of certainty
|
||||
##
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[options, times], chronos
|
||||
import brokers/broker_context
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import chronicles, chronos, results
|
||||
import std/options
|
||||
import brokers/broker_context
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/options
|
||||
import chronos, chronicles
|
||||
import brokers/broker_context
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
## This module reinforces the publish operation with regular store-v3 requests.
|
||||
##
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[net, options]
|
||||
|
||||
import chronicles, chronos, libp2p/peerid, results
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[net, options]
|
||||
|
||||
import results
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import libp2p/crypto/crypto
|
||||
{.push raises: [].}
|
||||
|
||||
import bearssl/rand, std/times, chronos
|
||||
@ -23,7 +25,7 @@ type
|
||||
PartiallyConnected
|
||||
Connected
|
||||
|
||||
proc new*(T: typedesc[RequestId], rng: ref HmacDrbgContext): T =
|
||||
proc new*(T: typedesc[RequestId], rng: crypto.Rng): T =
|
||||
## Generate a new RequestId using the provided RNG.
|
||||
RequestId(request_utils.generateRequestId(rng))
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import
|
||||
std/[times, strutils, os, sets, strformat, tables],
|
||||
results,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
# Simple async pool driver for postgress.
|
||||
# Inspired by: https://github.com/treeform/pg/
|
||||
{.push raises: [].}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
# The code in this file is an adaptation of the Sqlite KV Store found in nim-eth.
|
||||
# https://github.com/status-im/nim-eth/blob/master/eth/db/kvstore_sqlite3.nim
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import std/options, results, eth/keys as eth_keys, libp2p/crypto/crypto as libp2p_crypto
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
## RequestRateLimiter
|
||||
##
|
||||
## RequestRateLimiter is a general service protection mechanism.
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[strutils, math], results, regex
|
||||
|
||||
proc parseMsgSize*(input: string): Result[uint64, string] =
|
||||
|
||||
32
logos_delivery/waku/compat/option_valueor.nim
Normal file
32
logos_delivery/waku/compat/option_valueor.nim
Normal file
@ -0,0 +1,32 @@
|
||||
## Polyfill: `valueOr` / `withValue` templates for `std/options.Option[T]`.
|
||||
##
|
||||
## Previously provided transitively by `libp2p/utility`, removed in
|
||||
## nim-libp2p PR #2162 (commit 8a9943145). logos-delivery uses these
|
||||
## templates pervasively on `Option[T]`.
|
||||
|
||||
{.push raises: [].}
|
||||
|
||||
import std/[macros, options]
|
||||
|
||||
template valueOr*[T](self: Option[T], body: untyped): untyped =
|
||||
let temp = (self)
|
||||
if temp.isSome:
|
||||
temp.get()
|
||||
else:
|
||||
body
|
||||
|
||||
template withValue*[T](self: Option[T], value, body: untyped): untyped =
|
||||
let temp = (self)
|
||||
if temp.isSome:
|
||||
let `value` {.inject.} = temp.get()
|
||||
body
|
||||
|
||||
macro withValue*[T](self: Option[T], value, body, elseStmt: untyped): untyped =
|
||||
let elseBody = elseStmt[0]
|
||||
quote:
|
||||
let temp = (`self`)
|
||||
if temp.isSome:
|
||||
let `value` {.inject.} = temp.get()
|
||||
`body`
|
||||
else:
|
||||
`elseBody`
|
||||
@ -1,3 +1,4 @@
|
||||
import libp2p/crypto/crypto
|
||||
import
|
||||
chronos,
|
||||
chronicles,
|
||||
@ -7,7 +8,7 @@ import
|
||||
|
||||
const AutonatCheckInterval = Opt.some(chronos.seconds(30))
|
||||
|
||||
proc getAutonatService*(rng: ref HmacDrbgContext): AutonatService =
|
||||
proc getAutonatService*(rng: crypto.Rng): AutonatService =
|
||||
## AutonatService request other peers to dial us back
|
||||
## flagging us as Reachable or NotReachable.
|
||||
## minConfidence is used as threshold to determine the state.
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
import libp2p/crypto/crypto
|
||||
import libp2p/crypto/rng
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
@ -82,7 +85,7 @@ proc shardingPredicate*(
|
||||
|
||||
proc new*(
|
||||
T: type WakuDiscoveryV5,
|
||||
rng: ref HmacDrbgContext,
|
||||
rng: crypto.Rng,
|
||||
conf: WakuDiscoveryV5Config,
|
||||
record: Option[waku_enr.Record],
|
||||
peerManager: Option[PeerManager] = none(PeerManager),
|
||||
@ -90,7 +93,7 @@ proc new*(
|
||||
newAsyncEventQueue[SubscriptionEvent](30),
|
||||
): T =
|
||||
let protocol = newProtocol(
|
||||
rng = rng,
|
||||
rng = rng.bearSslDrbgRef,
|
||||
config = conf.discv5Config.get(protocol.defaultDiscoveryConfig),
|
||||
bindPort = conf.port,
|
||||
bindIp = conf.address,
|
||||
@ -407,7 +410,7 @@ proc setupDiscoveryV5*(
|
||||
nodeTopicSubscriptionQueue: AsyncEventQueue[SubscriptionEvent],
|
||||
conf: Discv5Conf,
|
||||
dynamicBootstrapNodes: seq[RemotePeerInfo],
|
||||
rng: ref HmacDrbgContext,
|
||||
rng: crypto.Rng,
|
||||
key: crypto.PrivateKey,
|
||||
p2pListenAddress: IpAddress,
|
||||
portsShift: uint16,
|
||||
@ -463,7 +466,7 @@ proc setupAndStartDiscv5*(
|
||||
nodeTopicSubscriptionQueue: AsyncEventQueue[SubscriptionEvent],
|
||||
conf: Discv5Conf,
|
||||
dynamicBootstrapNodes: seq[RemotePeerInfo],
|
||||
rng: ref HmacDrbgContext,
|
||||
rng: crypto.Rng,
|
||||
key: crypto.PrivateKey,
|
||||
p2pListenAddress: IpAddress,
|
||||
portsShift: uint16,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
## A set of utilities to integrate EIP-1459 DNS-based discovery
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import std/[options, sequtils]
|
||||
@ -9,9 +10,9 @@ import
|
||||
libp2p/[peerid, multiaddress, switch],
|
||||
libp2p/extended_peer_record,
|
||||
libp2p/crypto/curve25519,
|
||||
libp2p/protocols/[kademlia, kad_disco],
|
||||
libp2p/protocols/kademlia_discovery/types as kad_types,
|
||||
libp2p/protocols/mix/mix_protocol
|
||||
libp2p/protocols/[kademlia, service_discovery],
|
||||
libp2p/protocols/service_discovery/types as svdisc_types,
|
||||
libp2p_mix/mix_protocol
|
||||
|
||||
import logos_delivery/waku/waku_core, logos_delivery/waku/node/peer_manager
|
||||
|
||||
@ -32,7 +33,7 @@ type
|
||||
advertiseMix*: bool = false
|
||||
|
||||
WakuKademlia* = ref object
|
||||
protocol*: KademliaDiscovery
|
||||
protocol*: ServiceDiscovery
|
||||
peerManager: PeerManager
|
||||
discoveryLoop: Future[void]
|
||||
running*: bool
|
||||
@ -50,13 +51,15 @@ proc new*(
|
||||
if params.bootstrapNodes.len == 0:
|
||||
info "creating kademlia discovery as seed node (no bootstrap nodes)"
|
||||
|
||||
let kademlia = KademliaDiscovery.new(
|
||||
let kademlia = ServiceDiscovery.new(
|
||||
switch,
|
||||
bootstrapNodes = params.bootstrapNodes,
|
||||
config = KadDHTConfig.new(
|
||||
validator = kad_types.ExtEntryValidator(), selector = kad_types.ExtEntrySelector()
|
||||
validator = svdisc_types.ExtEntryValidator(),
|
||||
selector = svdisc_types.ExtEntrySelector(),
|
||||
),
|
||||
codec = ExtendedKademliaDiscoveryCodec,
|
||||
rng = switch.rng,
|
||||
codec = ExtendedServiceDiscoveryCodec,
|
||||
)
|
||||
|
||||
try:
|
||||
@ -68,11 +71,9 @@ proc new*(
|
||||
# initial self-signed peer record published to the DHT
|
||||
if params.advertiseMix:
|
||||
if params.mixPubKey.isSome():
|
||||
let alreadyAdvertising = kademlia.startAdvertising(
|
||||
kademlia.startAdvertising(
|
||||
ServiceInfo(id: MixProtocolID, data: @(params.mixPubKey.get()))
|
||||
)
|
||||
if alreadyAdvertising:
|
||||
warn "mix service was already being advertised"
|
||||
debug "extended kademlia advertising mix service",
|
||||
keyHex = byteutils.toHex(params.mixPubKey.get()),
|
||||
bootstrapNodes = params.bootstrapNodes.len
|
||||
@ -164,7 +165,9 @@ proc lookupMixPeers*(
|
||||
let mixService = ServiceInfo(id: MixProtocolID, data: @[])
|
||||
var records: seq[ExtendedPeerRecord]
|
||||
try:
|
||||
records = await wk.protocol.lookup(mixService)
|
||||
let advertisements = (await wk.protocol.lookup(mixService)).valueOr:
|
||||
return err("mix peer lookup failed: " & $error)
|
||||
records = advertisements.mapIt(it.data)
|
||||
except CatchableError:
|
||||
return err("mix peer lookup failed: " & getCurrentExceptionMsg())
|
||||
|
||||
@ -202,7 +205,7 @@ proc runDiscoveryLoop(
|
||||
|
||||
var records: seq[ExtendedPeerRecord]
|
||||
try:
|
||||
records = await wk.protocol.randomRecords()
|
||||
records = await wk.protocol.lookupRandom()
|
||||
except CatchableError as e:
|
||||
warn "extended kademlia discovery failed", error = e.msg
|
||||
await sleepAsync(interval)
|
||||
|
||||
@ -15,6 +15,7 @@ import
|
||||
../waku_enr,
|
||||
../discovery/waku_discv5,
|
||||
../waku_node,
|
||||
../node/waku_switch,
|
||||
../net/net_config,
|
||||
../node/peer_manager,
|
||||
../common/rate_limit/setting,
|
||||
@ -22,7 +23,7 @@ import
|
||||
|
||||
type
|
||||
WakuNodeBuilder* = object # General
|
||||
nodeRng: Option[ref crypto.HmacDrbgContext]
|
||||
nodeRng: Option[crypto.Rng]
|
||||
nodeKey: Option[crypto.PrivateKey]
|
||||
netConfig: Option[NetConfig]
|
||||
record: Option[enr.Record]
|
||||
@ -58,7 +59,7 @@ proc init*(T: type WakuNodeBuilder): WakuNodeBuilder =
|
||||
|
||||
## General
|
||||
|
||||
proc withRng*(builder: var WakuNodeBuilder, rng: ref crypto.HmacDrbgContext) =
|
||||
proc withRng*(builder: var WakuNodeBuilder, rng: crypto.Rng) =
|
||||
builder.nodeRng = some(rng)
|
||||
|
||||
proc withNodeKey*(builder: var WakuNodeBuilder, nodeKey: crypto.PrivateKey) =
|
||||
@ -158,7 +159,7 @@ proc withSwitchConfiguration*(
|
||||
## Build
|
||||
|
||||
proc build*(builder: WakuNodeBuilder): Result[WakuNode, string] =
|
||||
var rng: ref crypto.HmacDrbgContext
|
||||
var rng: crypto.Rng
|
||||
if builder.nodeRng.isNone():
|
||||
rng = crypto.newRng()
|
||||
else:
|
||||
@ -191,7 +192,7 @@ proc build*(builder: WakuNodeBuilder): Result[WakuNode, string] =
|
||||
wsAddress = builder.netConfig.get().wsHostAddress,
|
||||
transportFlags = {ServerFlags.ReuseAddr, ServerFlags.TcpNoDelay},
|
||||
rng = rng,
|
||||
maxConnections = builder.switchMaxConnections.get(builders.MaxConnections),
|
||||
maxConnections = builder.switchMaxConnections.get(MaxConnections),
|
||||
wssEnabled = builder.netConfig.get().wssEnabled,
|
||||
secureKeyPath = builder.switchSslSecureKey.get(""),
|
||||
secureCertPath = builder.switchSslSecureCert.get(""),
|
||||
@ -211,7 +212,7 @@ proc build*(builder: WakuNodeBuilder): Result[WakuNode, string] =
|
||||
maxServicePeers = some(builder.maxServicePeers),
|
||||
colocationLimit = builder.colocationLimit,
|
||||
shardedPeerManagement = builder.shardAware,
|
||||
maxConnections = builder.switchMaxConnections.get(builders.MaxConnections),
|
||||
maxConnections = builder.switchMaxConnections.get(MaxConnections),
|
||||
)
|
||||
|
||||
var node: WakuNode
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import chronicles, std/options, results
|
||||
import libp2p/[peerid, multiaddress, peerinfo]
|
||||
import logos_delivery/waku/factory/waku_conf
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import chronicles, std/options, results
|
||||
import libp2p/crypto/crypto, libp2p/crypto/curve25519, libp2p/protocols/mix/curve25519
|
||||
import libp2p/crypto/crypto, libp2p/crypto/curve25519, libp2p_mix/curve25519
|
||||
import ../waku_conf, logos_delivery/waku/waku_mix
|
||||
|
||||
logScope:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import chronicles, std/[net, options], results
|
||||
import logos_delivery/waku/common/rate_limit/setting
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[options, strutils, sequtils]
|
||||
import chronicles, results, chronos
|
||||
import ../waku_conf, ./store_sync_conf_builder
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import
|
||||
libp2p/crypto/crypto,
|
||||
libp2p/multiaddress,
|
||||
@ -327,13 +328,13 @@ proc withStaticNodes*(builder: var WakuConfBuilder, staticNodes: seq[string]) =
|
||||
## Building
|
||||
|
||||
proc nodeKey(
|
||||
builder: WakuConfBuilder, rng: ref HmacDrbgContext
|
||||
builder: WakuConfBuilder, rng: crypto.Rng
|
||||
): Result[crypto.PrivateKey, string] =
|
||||
if builder.nodeKey.isSome():
|
||||
return ok(builder.nodeKey.get())
|
||||
else:
|
||||
warn "missing node key, generating new set"
|
||||
let nodeKey = crypto.PrivateKey.random(Secp256k1, rng[]).valueOr:
|
||||
let nodeKey = crypto.PrivateKey.random(Secp256k1, rng).valueOr:
|
||||
error "Failed to generate key", error = error
|
||||
return err("Failed to generate key: " & $error)
|
||||
return ok(nodeKey)
|
||||
@ -526,7 +527,7 @@ proc enforceSecurityConstraints(builder: WakuConfBuilder): Result[void, string]
|
||||
ok()
|
||||
|
||||
proc build*(
|
||||
builder: var WakuConfBuilder, rng: ref HmacDrbgContext = crypto.newRng()
|
||||
builder: var WakuConfBuilder, rng: crypto.Rng = crypto.newRng()
|
||||
): Result[WakuConf, string] =
|
||||
## Return a WakuConf that contains all mandatory parameters
|
||||
## Applies some sane defaults that are applicable across any usage
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import
|
||||
chronicles,
|
||||
chronos,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import
|
||||
std/[options, sequtils],
|
||||
chronicles,
|
||||
@ -55,7 +56,7 @@ proc setupPeerStorage(): Result[Option[WakuPeerStorage], string] =
|
||||
proc initNode(
|
||||
conf: WakuConf,
|
||||
netConfig: NetConfig,
|
||||
rng: ref HmacDrbgContext,
|
||||
rng: crypto.Rng,
|
||||
record: enr.Record,
|
||||
peerStore: Option[WakuPeerStorage],
|
||||
relay: Relay,
|
||||
@ -459,7 +460,7 @@ proc startNode*(
|
||||
return ok()
|
||||
|
||||
proc setupNode*(
|
||||
wakuConf: WakuConf, rng: ref HmacDrbgContext = crypto.newRng(), relay: Relay
|
||||
wakuConf: WakuConf, rng: crypto.Rng = crypto.newRng(), relay: Relay
|
||||
): Future[Result[WakuNode, string]] {.async.} =
|
||||
let netConfig = (
|
||||
await networkConfiguration(
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
@ -62,7 +63,7 @@ const git_version* {.strdefine.} = "n/a"
|
||||
type Waku* = ref object
|
||||
stateInfo*: WakuStateInfo
|
||||
conf*: WakuConf
|
||||
rng*: ref HmacDrbgContext
|
||||
rng*: crypto.Rng
|
||||
|
||||
key: crypto.PrivateKey
|
||||
|
||||
@ -86,7 +87,7 @@ type Waku* = ref object
|
||||
brokerCtx*: BrokerContext
|
||||
|
||||
proc setupSwitchServices(
|
||||
waku: Waku, conf: WakuConf, circuitRelay: Relay, rng: ref HmacDrbgContext
|
||||
waku: Waku, conf: WakuConf, circuitRelay: Relay, rng: crypto.Rng
|
||||
) =
|
||||
proc onReservation(addresses: seq[MultiAddress]) {.gcsafe, raises: [].} =
|
||||
info "circuit relay handler new reserve event",
|
||||
@ -114,6 +115,17 @@ proc setupSwitchServices(
|
||||
else:
|
||||
waku.node.switch.services = @[Service(autonatService)]
|
||||
|
||||
# libp2p 2.0.0 split Service.setup out of Service.start: the switch runs setup
|
||||
# only at build time (SwitchBuilder.setupServices), while switch.start calls
|
||||
# just start. These services are created and attached post-build, so setup must
|
||||
# be invoked explicitly here -- otherwise AutonatService.addressMapper stays nil
|
||||
# and the peerInfo.update() inside start dereferences it (SIGSEGV).
|
||||
for service in waku.node.switch.services:
|
||||
try:
|
||||
service.setup(waku.node.switch)
|
||||
except ServiceSetupError as e:
|
||||
error "failed to set up libp2p switch service", error = e.msg
|
||||
|
||||
## Initialisation
|
||||
|
||||
proc newCircuitRelay(isRelayClient: bool): Relay =
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[options, sets], chronos, web3, stew/byteutils, stint, results, chronicles
|
||||
|
||||
import logos_delivery/waku/incentivization/rpc, tests/waku_rln_relay/utils_onchain
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
@ -25,6 +26,7 @@ import
|
||||
common/callbacks,
|
||||
common/utils/parse_size_units,
|
||||
node/health_monitor/online_monitor,
|
||||
node/waku_switch,
|
||||
],
|
||||
./peer_store/peer_storage,
|
||||
./waku_peer_store
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
@ -7,7 +8,8 @@ import
|
||||
eth/p2p/discoveryv5/enr,
|
||||
libp2p/builders,
|
||||
libp2p/peerstore,
|
||||
libp2p/crypto/curve25519
|
||||
libp2p/crypto/curve25519,
|
||||
libp2p_mix/pool
|
||||
|
||||
import
|
||||
../../waku_core,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import std/[sequtils, sets, tables, options], chronos, chronicles, metrics, results
|
||||
import libp2p/[peerid, peerinfo]
|
||||
import brokers/broker_context
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import chronicles, chronos, metrics, metrics/chronos_httpserver
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
@ -23,8 +24,8 @@ import
|
||||
libp2p/transports/wstransport,
|
||||
libp2p/utility,
|
||||
libp2p/utils/offsettedseq,
|
||||
libp2p/protocols/mix,
|
||||
libp2p/protocols/mix/mix_protocol,
|
||||
libp2p_mix,
|
||||
libp2p_mix/mix_protocol,
|
||||
brokers/broker_context,
|
||||
brokers/request_broker
|
||||
|
||||
@ -120,7 +121,7 @@ type
|
||||
wakuAutoSharding*: Option[Sharding]
|
||||
enr*: enr.Record
|
||||
libp2pPing*: Ping
|
||||
rng*: ref rand.HmacDrbgContext
|
||||
rng*: crypto.Rng
|
||||
brokerCtx*: BrokerContext
|
||||
wakuRendezvous*: WakuRendezVous
|
||||
wakuRendezvousClient*: rendezvous_client.WakuRendezVousClient
|
||||
@ -215,7 +216,7 @@ proc new*(
|
||||
peerManager: PeerManager,
|
||||
rateLimitSettings: ProtocolRateLimitSettings = DefaultProtocolRateLimit,
|
||||
# TODO: make this argument required after tests are updated
|
||||
rng: ref HmacDrbgContext = crypto.newRng(),
|
||||
rng: crypto.Rng = crypto.newRng(),
|
||||
): T {.raises: [Defect, LPError, IOError, TLSStreamProtocolError].} =
|
||||
## Creates a Waku Node instance.
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
@ -17,7 +18,7 @@ import
|
||||
libp2p/transports/tcptransport,
|
||||
libp2p/transports/wstransport,
|
||||
libp2p/utility,
|
||||
libp2p/protocols/mix
|
||||
libp2p_mix
|
||||
|
||||
import
|
||||
../waku_node,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -18,10 +18,12 @@ import
|
||||
# override nim-libp2p default value (which is also 1)
|
||||
const MaxConnectionsPerPeer* = 1
|
||||
|
||||
const MaxConnections* = 50
|
||||
|
||||
proc withWsTransport*(b: SwitchBuilder): SwitchBuilder =
|
||||
b.withTransport(
|
||||
proc(upgr: Upgrade, privateKey: crypto.PrivateKey): Transport =
|
||||
WsTransport.new(upgr)
|
||||
proc(config: TransportConfig): Transport =
|
||||
WsTransport.new(config.upgr, rng = config.rng)
|
||||
)
|
||||
|
||||
proc getSecureKey(path: string): TLSPrivateKey {.raises: [Defect, IOError].} =
|
||||
@ -59,7 +61,7 @@ proc newWakuSwitch*(
|
||||
wsAddress = none(MultiAddress),
|
||||
secureManagers: openarray[SecureProtocol] = [SecureProtocol.Noise],
|
||||
transportFlags: set[ServerFlags] = {},
|
||||
rng: ref HmacDrbgContext,
|
||||
rng: crypto.Rng,
|
||||
inTimeout: Duration = 5.minutes,
|
||||
outTimeout: Duration = 5.minutes,
|
||||
maxConnections = MaxConnections,
|
||||
@ -79,9 +81,6 @@ proc newWakuSwitch*(
|
||||
var b = SwitchBuilder
|
||||
.new()
|
||||
.withRng(rng)
|
||||
.withMaxConnections(maxConnections)
|
||||
.withMaxIn(maxIn)
|
||||
.withMaxOut(maxOut)
|
||||
.withMaxConnsPerPeer(maxConnsPerPeer)
|
||||
.withYamux()
|
||||
.withMplex(inTimeout, outTimeout)
|
||||
@ -92,6 +91,15 @@ proc newWakuSwitch*(
|
||||
.withCircuitRelay(circuitRelay)
|
||||
.withAutonat()
|
||||
|
||||
# libp2p 2.0.0 folded withMaxConnections and withMaxInOut into a single
|
||||
# `limits` field: they are mutually exclusive (last one wins), and
|
||||
# ConnectionLimits.maxInOut asserts maxIn/maxOut > 0. So apply explicit in/out
|
||||
# limits only when both are provided (>0); otherwise use the shared total cap.
|
||||
if maxIn > 0 and maxOut > 0:
|
||||
b = b.withMaxInOut(maxIn, maxOut)
|
||||
else:
|
||||
b = b.withMaxConnections(maxConnections)
|
||||
|
||||
if peerStoreCapacity.isSome():
|
||||
b = b.withPeerStore(peerStoreCapacity.get())
|
||||
else:
|
||||
@ -112,6 +120,6 @@ proc newWakuSwitch*(
|
||||
b = b.withAddress(address)
|
||||
|
||||
if not rendezvous.isNil():
|
||||
b = b.withRendezVous(rendezvous)
|
||||
b = b.withRendezVous()
|
||||
|
||||
b.build()
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
## Public facade and main driver types for the persistency library.
|
||||
##
|
||||
## ``Persistency`` is the per-root coordinator; one instance owns one
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import net, tables
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import chronicles, json_serialization, presto/route
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import chronicles, json_serialization, presto/route
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import results
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import chronos, std/[options, sequtils], results
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
{.push raises: [].}
|
||||
|
||||
import bearssl/rand, stew/byteutils
|
||||
import libp2p/crypto/crypto, stew/byteutils
|
||||
|
||||
proc generateRequestId*(rng: ref HmacDrbgContext): string =
|
||||
proc generateRequestId*(rng: crypto.Rng): string =
|
||||
var bytes: array[10, byte]
|
||||
hmacDrbgGenerate(rng[], bytes)
|
||||
rng.generate(bytes)
|
||||
return byteutils.toHex(bytes)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import results, chronicles, chronos
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import std/strutils, results, chronicles, chronos
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import std/options, results, stew/sorted_set, chronicles, chronos
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
# The code in this file is an adaptation of the Sqlite KV Store found in nim-eth.
|
||||
# https://github.com/status-im/nim-eth/blob/master/eth/db/kvstore_sqlite3.nim
|
||||
{.push raises: [].}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import std/[strutils, options], regex, results
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import results, chronicles, chronos
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
## Waku content topics definition and namespacing utils
|
||||
##
|
||||
## See 23/WAKU2-TOPICS RFC: https://rfc.vac.dev/spec/23/
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
## Waku autosharding utils
|
||||
##
|
||||
## See 51/WAKU2-RELAY-SHARDING RFC: https://rfc.vac.dev/spec/51/#automatic-sharding
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/[options, bitops, sequtils, net, tables], results, eth/keys, libp2p/crypto/crypto
|
||||
import ../common/enr, ../waku_core/codecs
|
||||
import libp2p/protocols/mix
|
||||
import libp2p_mix
|
||||
|
||||
const CapabilitiesEnrField* = "waku2"
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import libp2p/crypto/crypto
|
||||
## Waku Filter client for subscribing and receiving filtered messages
|
||||
|
||||
{.push raises: [].}
|
||||
@ -23,13 +25,13 @@ logScope:
|
||||
|
||||
type WakuFilterClient* = ref object of LPProtocol
|
||||
brokerCtx: BrokerContext
|
||||
rng: ref HmacDrbgContext
|
||||
rng: crypto.Rng
|
||||
peerManager: PeerManager
|
||||
pushHandlers: seq[FilterPushHandler]
|
||||
|
||||
func generateRequestId(rng: ref HmacDrbgContext): string =
|
||||
func generateRequestId(rng: crypto.Rng): string =
|
||||
var bytes: array[10, byte]
|
||||
hmacDrbgGenerate(rng[], bytes)
|
||||
rng.generate(bytes)
|
||||
return byteutils.toHex(bytes)
|
||||
|
||||
proc sendSubscribeRequest(
|
||||
@ -210,9 +212,7 @@ proc initProtocolHandler(wfc: WakuFilterClient) =
|
||||
wfc.handler = handler
|
||||
wfc.codec = WakuFilterPushCodec
|
||||
|
||||
proc new*(
|
||||
T: type WakuFilterClient, peerManager: PeerManager, rng: ref HmacDrbgContext
|
||||
): T =
|
||||
proc new*(T: type WakuFilterClient, peerManager: PeerManager, rng: crypto.Rng): T =
|
||||
let brokerCtx = globalBrokerContext()
|
||||
let wfc = WakuFilterClient(
|
||||
brokerCtx: brokerCtx, rng: rng, peerManager: peerManager, pushHandlers: @[]
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
## Waku Filter protocol for subscribing and filtering messages
|
||||
|
||||
{.push raises: [].}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import options, json, strutils, sequtils, std/[tables, os]
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import results
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import libp2p/crypto/crypto
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import std/options, results, chronicles, chronos, metrics, bearssl/rand, stew/byteutils
|
||||
@ -16,12 +18,10 @@ logScope:
|
||||
topics = "waku lightpush client"
|
||||
|
||||
type WakuLightPushClient* = ref object
|
||||
rng*: ref rand.HmacDrbgContext
|
||||
rng*: crypto.Rng
|
||||
peerManager*: PeerManager
|
||||
|
||||
proc new*(
|
||||
T: type WakuLightPushClient, peerManager: PeerManager, rng: ref rand.HmacDrbgContext
|
||||
): T =
|
||||
proc new*(T: type WakuLightPushClient, peerManager: PeerManager, rng: crypto.Rng): T =
|
||||
WakuLightPushClient(peerManager: peerManager, rng: rng)
|
||||
|
||||
proc ensureTimestampSet(message: var WakuMessage) =
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import libp2p/crypto/crypto
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
@ -22,7 +24,7 @@ logScope:
|
||||
topics = "waku lightpush"
|
||||
|
||||
type WakuLightPush* = ref object of LPProtocol
|
||||
rng*: ref rand.HmacDrbgContext
|
||||
rng*: crypto.Rng
|
||||
peerManager*: PeerManager
|
||||
pushHandler*: PushMessageHandler
|
||||
requestRateLimiter*: RequestRateLimiter
|
||||
@ -156,7 +158,7 @@ proc initProtocolHandler(wl: WakuLightPush) =
|
||||
proc new*(
|
||||
T: type WakuLightPush,
|
||||
peerManager: PeerManager,
|
||||
rng: ref rand.HmacDrbgContext,
|
||||
rng: crypto.Rng,
|
||||
pushHandler: PushMessageHandler,
|
||||
autoSharding: Option[Sharding],
|
||||
rateLimitSetting: Option[RateLimitSetting] = none[RateLimitSetting](),
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import libp2p/crypto/crypto
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import std/options, results, chronicles, chronos, metrics, bearssl/rand, stew/byteutils
|
||||
@ -17,12 +19,10 @@ logScope:
|
||||
|
||||
type WakuLegacyLightPushClient* = ref object
|
||||
peerManager*: PeerManager
|
||||
rng*: ref rand.HmacDrbgContext
|
||||
rng*: crypto.Rng
|
||||
|
||||
proc new*(
|
||||
T: type WakuLegacyLightPushClient,
|
||||
peerManager: PeerManager,
|
||||
rng: ref rand.HmacDrbgContext,
|
||||
T: type WakuLegacyLightPushClient, peerManager: PeerManager, rng: crypto.Rng
|
||||
): T =
|
||||
WakuLegacyLightPushClient(peerManager: peerManager, rng: rng)
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import libp2p/crypto/crypto
|
||||
{.push raises: [].}
|
||||
|
||||
import std/options, results, stew/byteutils, chronicles, chronos, metrics, bearssl/rand
|
||||
@ -14,7 +15,7 @@ logScope:
|
||||
topics = "waku lightpush legacy"
|
||||
|
||||
type WakuLegacyLightPush* = ref object of LPProtocol
|
||||
rng*: ref rand.HmacDrbgContext
|
||||
rng*: crypto.Rng
|
||||
peerManager*: PeerManager
|
||||
pushHandler*: PushMessageHandler
|
||||
requestRateLimiter*: RequestRateLimiter
|
||||
@ -116,7 +117,7 @@ proc initProtocolHandler(wl: WakuLegacyLightPush) =
|
||||
proc new*(
|
||||
T: type WakuLegacyLightPush,
|
||||
peerManager: PeerManager,
|
||||
rng: ref rand.HmacDrbgContext,
|
||||
rng: crypto.Rng,
|
||||
pushHandler: PushMessageHandler,
|
||||
rateLimitSetting: Option[RateLimitSetting] = none[RateLimitSetting](),
|
||||
): T =
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user