mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
removing mix repo as dependency and using mix from libp2p repo (#3632)
* use released version of libp2p 1.14.2
This commit is contained in:
parent
9808e205af
commit
8be45180aa
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -184,7 +184,3 @@
|
|||||||
url = https://github.com/waku-org/waku-rlnv2-contract.git
|
url = https://github.com/waku-org/waku-rlnv2-contract.git
|
||||||
ignore = untracked
|
ignore = untracked
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "vendor/mix"]
|
|
||||||
path = vendor/mix
|
|
||||||
url = https://github.com/vacp2p/mix/
|
|
||||||
branch = main
|
|
||||||
|
|||||||
@ -29,8 +29,8 @@ import
|
|||||||
peerid, # Implement how peers interact
|
peerid, # Implement how peers interact
|
||||||
protobuf/minprotobuf, # message serialisation/deserialisation from and to protobufs
|
protobuf/minprotobuf, # message serialisation/deserialisation from and to protobufs
|
||||||
nameresolving/dnsresolver,
|
nameresolving/dnsresolver,
|
||||||
|
protocols/mix/curve25519,
|
||||||
] # define DNS resolution
|
] # define DNS resolution
|
||||||
import mix/curve25519
|
|
||||||
import
|
import
|
||||||
waku/[
|
waku/[
|
||||||
waku_core,
|
waku_core,
|
||||||
|
|||||||
@ -7,14 +7,14 @@ import
|
|||||||
confutils,
|
confutils,
|
||||||
libp2p/crypto/crypto,
|
libp2p/crypto/crypto,
|
||||||
libp2p/crypto/curve25519,
|
libp2p/crypto/curve25519,
|
||||||
|
libp2p/protocols/mix,
|
||||||
|
libp2p/protocols/mix/curve25519,
|
||||||
libp2p/multiaddress,
|
libp2p/multiaddress,
|
||||||
eth/keys,
|
eth/keys,
|
||||||
eth/p2p/discoveryv5/enr,
|
eth/p2p/discoveryv5/enr,
|
||||||
metrics,
|
metrics,
|
||||||
metrics/chronos_httpserver
|
metrics/chronos_httpserver
|
||||||
|
|
||||||
import mix, mix/mix_protocol, mix/curve25519
|
|
||||||
|
|
||||||
import
|
import
|
||||||
waku/[
|
waku/[
|
||||||
common/logging,
|
common/logging,
|
||||||
@ -119,7 +119,7 @@ proc setupAndPublish(rng: ref HmacDrbgContext, conf: LightPushMixConf) {.async.}
|
|||||||
conn = node.wakuMix.toConnection(
|
conn = node.wakuMix.toConnection(
|
||||||
MixDestination.init(dPeerId, pxPeerInfo.addrs[0]), # destination lightpush peer
|
MixDestination.init(dPeerId, pxPeerInfo.addrs[0]), # destination lightpush peer
|
||||||
WakuLightPushCodec, # protocol codec which will be used over the mix connection
|
WakuLightPushCodec, # protocol codec which will be used over the mix connection
|
||||||
Opt.some(MixParameters(expectReply: Opt.some(true), numSurbs: Opt.some(byte(1)))),
|
MixParameters(expectReply: Opt.some(true), numSurbs: Opt.some(byte(1))),
|
||||||
# mix parameters indicating we expect a single reply
|
# mix parameters indicating we expect a single reply
|
||||||
).valueOr:
|
).valueOr:
|
||||||
error "failed to create mix connection", error = error
|
error "failed to create mix connection", error = error
|
||||||
|
|||||||
1
vendor/mix
vendored
1
vendor/mix
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit 5e95337693ad0787baec1ee25293f454c2d105ca
|
|
||||||
2
vendor/nim-libp2p
vendored
2
vendor/nim-libp2p
vendored
@ -1 +1 @@
|
|||||||
Subproject commit aa8ce46f782240cb99a7222c474022b8cfd24e52
|
Subproject commit 0309685cd27d4bf763c8b3be86a76c33bcfe67ea
|
||||||
@ -24,14 +24,13 @@ requires "nim >= 2.2.4",
|
|||||||
"stew",
|
"stew",
|
||||||
"stint",
|
"stint",
|
||||||
"metrics",
|
"metrics",
|
||||||
"libp2p >= 1.13.0",
|
"libp2p >= 1.14.2",
|
||||||
"web3",
|
"web3",
|
||||||
"presto",
|
"presto",
|
||||||
"regex",
|
"regex",
|
||||||
"results",
|
"results",
|
||||||
"db_connector",
|
"db_connector",
|
||||||
"minilru",
|
"minilru"
|
||||||
"https://github.com/vacp2p/mix#0.1.0"
|
|
||||||
|
|
||||||
### Helper functions
|
### Helper functions
|
||||||
proc buildModule(filePath, params = "", lang = "c"): bool =
|
proc buildModule(filePath, params = "", lang = "c"): bool =
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import chronicles, std/options, results
|
import chronicles, std/options, results
|
||||||
import libp2p/crypto/crypto, libp2p/crypto/curve25519, mix/curve25519
|
import libp2p/crypto/crypto, libp2p/crypto/curve25519, libp2p/protocols/mix/curve25519
|
||||||
import ../waku_conf, waku/waku_mix
|
import ../waku_conf, waku/waku_mix
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import
|
|||||||
libp2p/transports/tcptransport,
|
libp2p/transports/tcptransport,
|
||||||
libp2p/transports/wstransport,
|
libp2p/transports/wstransport,
|
||||||
libp2p/utility,
|
libp2p/utility,
|
||||||
mix
|
libp2p/protocols/mix
|
||||||
|
|
||||||
import
|
import
|
||||||
../waku_node,
|
../waku_node,
|
||||||
@ -207,10 +207,8 @@ proc lightpushPublishHandler(
|
|||||||
let conn = node.wakuMix.toConnection(
|
let conn = node.wakuMix.toConnection(
|
||||||
MixDestination.init(peer.peerId, peer.addrs[0]),
|
MixDestination.init(peer.peerId, peer.addrs[0]),
|
||||||
WakuLightPushCodec,
|
WakuLightPushCodec,
|
||||||
Opt.some(
|
MixParameters(expectReply: Opt.some(true), numSurbs: Opt.some(byte(1))),
|
||||||
MixParameters(expectReply: Opt.some(true), numSurbs: Opt.some(byte(1)))
|
# indicating we only want a single path to be used for reply hence numSurbs = 1
|
||||||
# indicating we only want a single path to be used for reply hence numSurbs = 1
|
|
||||||
),
|
|
||||||
).valueOr:
|
).valueOr:
|
||||||
error "could not create mix connection"
|
error "could not create mix connection"
|
||||||
return lighpushErrorResult(
|
return lighpushErrorResult(
|
||||||
|
|||||||
@ -22,9 +22,8 @@ import
|
|||||||
libp2p/transports/tcptransport,
|
libp2p/transports/tcptransport,
|
||||||
libp2p/transports/wstransport,
|
libp2p/transports/wstransport,
|
||||||
libp2p/utility,
|
libp2p/utility,
|
||||||
mix,
|
libp2p/protocols/mix,
|
||||||
mix/mix_node,
|
libp2p/protocols/mix/mix_protocol
|
||||||
mix/mix_protocol
|
|
||||||
|
|
||||||
import
|
import
|
||||||
../waku_core,
|
../waku_core,
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import
|
import
|
||||||
std/[options, bitops, sequtils, net, tables], results, eth/keys, libp2p/crypto/crypto
|
std/[options, bitops, sequtils, net, tables], results, eth/keys, libp2p/crypto/crypto
|
||||||
import ../common/enr, ../waku_core/codecs
|
import ../common/enr, ../waku_core/codecs
|
||||||
import mix/mix_protocol
|
import libp2p/protocols/mix
|
||||||
|
|
||||||
const CapabilitiesEnrField* = "waku2"
|
const CapabilitiesEnrField* = "waku2"
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import chronicles, std/[options, tables, sequtils], chronos, results, metrics
|
import chronicles, std/[options, tables, sequtils], chronos, results, metrics, strutils
|
||||||
|
|
||||||
import
|
import
|
||||||
libp2p/crypto/curve25519,
|
libp2p/crypto/curve25519,
|
||||||
mix/mix_protocol,
|
libp2p/protocols/mix,
|
||||||
mix/mix_node,
|
libp2p/protocols/mix/mix_node,
|
||||||
mix/mix_metrics,
|
|
||||||
libp2p/[multiaddress, multicodec, peerid],
|
libp2p/[multiaddress, multicodec, peerid],
|
||||||
eth/common/keys
|
eth/common/keys
|
||||||
|
|
||||||
@ -117,14 +116,30 @@ proc startMixNodePoolMgr*(mix: WakuMix) {.async.} =
|
|||||||
heartbeat "Updating mix node pool", 5.seconds:
|
heartbeat "Updating mix node pool", 5.seconds:
|
||||||
mix.populateMixNodePool()
|
mix.populateMixNodePool()
|
||||||
]#
|
]#
|
||||||
|
|
||||||
proc toMixNodeTable(bootnodes: seq[MixNodePubInfo]): Table[PeerId, MixPubInfo] =
|
proc toMixNodeTable(bootnodes: seq[MixNodePubInfo]): Table[PeerId, MixPubInfo] =
|
||||||
var mixNodes = initTable[PeerId, MixPubInfo]()
|
var mixNodes = initTable[PeerId, MixPubInfo]()
|
||||||
for node in bootnodes:
|
for node in bootnodes:
|
||||||
let peerId = getPeerIdFromMultiAddr(node.multiAddr).valueOr:
|
let pInfo = parsePeerInfo(node.multiAddr).valueOr:
|
||||||
error "Failed to get peer id from multiaddress: ",
|
error "Failed to get peer id from multiaddress: ",
|
||||||
error = error, multiAddr = $node.multiAddr
|
error = error, multiAddr = $node.multiAddr
|
||||||
continue
|
continue
|
||||||
mixNodes[peerId] = createMixPubInfo(node.multiAddr, node.pubKey)
|
let peerId = pInfo.peerId
|
||||||
|
var peerPubKey: crypto.PublicKey
|
||||||
|
if not peerId.extractPublicKey(peerPubKey):
|
||||||
|
warn "Failed to extract public key from peerId, skipping node", peerId = peerId
|
||||||
|
continue
|
||||||
|
|
||||||
|
if peerPubKey.scheme != PKScheme.Secp256k1:
|
||||||
|
warn "Peer public key is not Secp256k1, skipping node",
|
||||||
|
peerId = peerId, scheme = peerPubKey.scheme
|
||||||
|
continue
|
||||||
|
|
||||||
|
let multiAddr = MultiAddress.init(node.multiAddr).valueOr:
|
||||||
|
error "Failed to parse multiaddress", multiAddr = node.multiAddr, error = error
|
||||||
|
continue
|
||||||
|
|
||||||
|
mixNodes[peerId] = MixPubInfo.init(peerId, multiAddr, node.pubKey, peerPubKey.skkey)
|
||||||
info "using mix bootstrap nodes ", bootNodes = mixNodes
|
info "using mix bootstrap nodes ", bootNodes = mixNodes
|
||||||
return mixNodes
|
return mixNodes
|
||||||
|
|
||||||
@ -138,10 +153,11 @@ proc new*(
|
|||||||
): WakuMixResult[T] =
|
): WakuMixResult[T] =
|
||||||
let mixPubKey = public(mixPrivKey)
|
let mixPubKey = public(mixPrivKey)
|
||||||
info "mixPrivKey", mixPrivKey = mixPrivKey, mixPubKey = mixPubKey
|
info "mixPrivKey", mixPrivKey = mixPrivKey, mixPubKey = mixPubKey
|
||||||
|
let nodeMultiAddr = MultiAddress.init(nodeAddr).valueOr:
|
||||||
|
return err("failed to parse mix node address: " & $nodeAddr & ", error: " & error)
|
||||||
let localMixNodeInfo = initMixNodeInfo(
|
let localMixNodeInfo = initMixNodeInfo(
|
||||||
nodeAddr, mixPubKey, mixPrivKey, peermgr.switch.peerInfo.publicKey.skkey,
|
peermgr.switch.peerInfo.peerId, nodeMultiAddr, mixPubKey, mixPrivKey,
|
||||||
peermgr.switch.peerInfo.privateKey.skkey,
|
peermgr.switch.peerInfo.publicKey.skkey, peermgr.switch.peerInfo.privateKey.skkey,
|
||||||
)
|
)
|
||||||
if bootnodes.len < mixMixPoolSize:
|
if bootnodes.len < mixMixPoolSize:
|
||||||
warn "publishing with mix won't work as there are less than 3 mix nodes in node pool"
|
warn "publishing with mix won't work as there are less than 3 mix nodes in node pool"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user