mirror of
https://github.com/status-im/status-node-manager.git
synced 2025-02-22 09:18:23 +00:00
feat(waku utils): Set up default bootstrap node
This commit is contained in:
parent
dfefa8b852
commit
b9fa56ed9b
7
libs/waku_utils/example/constants.nim
Normal file
7
libs/waku_utils/example/constants.nim
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
const defaultWakuBootstrapNode* = "enr:-P-4QGVNANzbhCI49du6Moyw98AjuMhKoOpE_Jges9JlCq-I" &
|
||||||
|
"CAVadktjfcNpuhQgT0g1cu86_S3nbM7eYkCsqDAQG7UBgmlkgnY0" &
|
||||||
|
"gmlwhI_G-a6KbXVsdGlhZGRyc7hgAC02KG5vZGUtMDEuZG8tYW1z" &
|
||||||
|
"My5zdGF0dXMucHJvZC5zdGF0dXNpbS5uZXQGdl8ALzYobm9kZS0w" &
|
||||||
|
"MS5kby1hbXMzLnN0YXR1cy5wcm9kLnN0YXR1c2ltLm5ldAYBu94D" &
|
||||||
|
"iXNlY3AyNTZrMaECoVyonsTGEQvVioM562Q1fjzTb_vKD152PPId" &
|
||||||
|
"sV7sM6SDdGNwgnZfg3VkcIIjKIV3YWt1Mg8"
|
@ -15,7 +15,8 @@ import
|
|||||||
|
|
||||||
# Local modules
|
# Local modules
|
||||||
../../waku_handshake_utils,
|
../../waku_handshake_utils,
|
||||||
../../waku_node
|
../../waku_node,
|
||||||
|
../constants
|
||||||
|
|
||||||
const
|
const
|
||||||
wakuPort = 60000
|
wakuPort = 60000
|
||||||
@ -49,7 +50,8 @@ proc exampleJSWaku(rng: ref HmacDrbgContext) {.async.} =
|
|||||||
|
|
||||||
# Start nwaku instance
|
# Start nwaku instance
|
||||||
let node = await startWakuNode(rng, wakuPort, discv5Port,
|
let node = await startWakuNode(rng, wakuPort, discv5Port,
|
||||||
requiredConnectedPeers)
|
requiredConnectedPeers,
|
||||||
|
defaultWakuBootstrapNode)
|
||||||
|
|
||||||
# Perform the handshake
|
# Perform the handshake
|
||||||
initiatorHSResult = await initiatorHandshake(rng, node, pubSubTopic,
|
initiatorHSResult = await initiatorHandshake(rng, node, pubSubTopic,
|
||||||
|
@ -15,7 +15,8 @@ import
|
|||||||
|
|
||||||
# Local modules
|
# Local modules
|
||||||
../../waku_handshake_utils,
|
../../waku_handshake_utils,
|
||||||
../../waku_node
|
../../waku_node,
|
||||||
|
../constants
|
||||||
|
|
||||||
const
|
const
|
||||||
wakuPort = 60000
|
wakuPort = 60000
|
||||||
@ -47,7 +48,8 @@ proc exampleNwakuAgentA(rng: ref HmacDrbgContext) {.async.} =
|
|||||||
|
|
||||||
# Start nwaku instance
|
# Start nwaku instance
|
||||||
let node = await startWakuNode(rng, wakuPort, discv5Port,
|
let node = await startWakuNode(rng, wakuPort, discv5Port,
|
||||||
requiredConnectedPeers)
|
requiredConnectedPeers,
|
||||||
|
defaultWakuBootstrapNode)
|
||||||
|
|
||||||
# Perform the handshake
|
# Perform the handshake
|
||||||
agentAHSResult = await initiatorHandshake(rng, node, pubSubTopic, contentTopic,
|
agentAHSResult = await initiatorHandshake(rng, node, pubSubTopic, contentTopic,
|
||||||
|
@ -15,7 +15,8 @@ import
|
|||||||
|
|
||||||
# Local modules
|
# Local modules
|
||||||
../../waku_handshake_utils,
|
../../waku_handshake_utils,
|
||||||
../../waku_node
|
../../waku_node,
|
||||||
|
../constants
|
||||||
|
|
||||||
const
|
const
|
||||||
wakuPort = 50000
|
wakuPort = 50000
|
||||||
@ -61,7 +62,8 @@ proc exampleNwakuAgentB(rng: ref HmacDrbgContext) {.async.} =
|
|||||||
|
|
||||||
# Start nwaku instance
|
# Start nwaku instance
|
||||||
let node = await startWakuNode(rng, wakuPort, discv5Port,
|
let node = await startWakuNode(rng, wakuPort, discv5Port,
|
||||||
requiredConnectedPeers)
|
requiredConnectedPeers,
|
||||||
|
defaultWakuBootstrapNode)
|
||||||
|
|
||||||
# Make sure it matches the publisher. Use default value
|
# Make sure it matches the publisher. Use default value
|
||||||
# see spec: https://rfc.vac.dev/spec/23/
|
# see spec: https://rfc.vac.dev/spec/23/
|
||||||
|
@ -16,16 +16,10 @@ import
|
|||||||
|
|
||||||
proc startWakuNode*(rng: ref HmacDrbgContext,
|
proc startWakuNode*(rng: ref HmacDrbgContext,
|
||||||
wakuPort, discv5Port: uint16,
|
wakuPort, discv5Port: uint16,
|
||||||
requiredConnectedPeers: int
|
requiredConnectedPeers: int,
|
||||||
|
bootstrapNode: string
|
||||||
): Future[WakuNode] {.async.} =
|
): Future[WakuNode] {.async.} =
|
||||||
let
|
let
|
||||||
bootstrapNode = "enr:-P-4QGVNANzbhCI49du6Moyw98AjuMhKoOpE_Jges9JlCq-I" &
|
|
||||||
"CAVadktjfcNpuhQgT0g1cu86_S3nbM7eYkCsqDAQG7UBgmlkgnY0" &
|
|
||||||
"gmlwhI_G-a6KbXVsdGlhZGRyc7hgAC02KG5vZGUtMDEuZG8tYW1z" &
|
|
||||||
"My5zdGF0dXMucHJvZC5zdGF0dXNpbS5uZXQGdl8ALzYobm9kZS0w" &
|
|
||||||
"MS5kby1hbXMzLnN0YXR1cy5wcm9kLnN0YXR1c2ltLm5ldAYBu94D" &
|
|
||||||
"iXNlY3AyNTZrMaECoVyonsTGEQvVioM562Q1fjzTb_vKD152PPId" &
|
|
||||||
"sV7sM6SDdGNwgnZfg3VkcIIjKIV3YWt1Mg8"
|
|
||||||
nodeKey = crypto.PrivateKey.random(Secp256k1, rng[]).get()
|
nodeKey = crypto.PrivateKey.random(Secp256k1, rng[]).get()
|
||||||
ip = parseIpAddress("0.0.0.0")
|
ip = parseIpAddress("0.0.0.0")
|
||||||
flags = CapabilitiesBitfield.init(lightpush = false, filter = false,
|
flags = CapabilitiesBitfield.init(lightpush = false, filter = false,
|
||||||
@ -44,8 +38,8 @@ proc startWakuNode*(rng: ref HmacDrbgContext,
|
|||||||
builder.withNodeKey(nodeKey)
|
builder.withNodeKey(nodeKey)
|
||||||
builder.withRecord(record)
|
builder.withRecord(record)
|
||||||
builder.withNetworkConfigurationDetails(ip, Port(wakuPort)).tryGet()
|
builder.withNetworkConfigurationDetails(ip, Port(wakuPort)).tryGet()
|
||||||
let node = builder.build().tryGet()
|
|
||||||
|
|
||||||
|
let node = builder.build().tryGet()
|
||||||
var bootstrapNodeEnr: enr.Record
|
var bootstrapNodeEnr: enr.Record
|
||||||
discard bootstrapNodeEnr.fromURI(bootstrapNode)
|
discard bootstrapNodeEnr.fromURI(bootstrapNode)
|
||||||
|
|
||||||
|
@ -17,6 +17,13 @@ export
|
|||||||
const wakuHandshakeDataFilename* = "handshake_data.json"
|
const wakuHandshakeDataFilename* = "handshake_data.json"
|
||||||
const defaultWakuContentTopic* = "/snm/0.0.1/default/proto"
|
const defaultWakuContentTopic* = "/snm/0.0.1/default/proto"
|
||||||
const defaultWakuPubsubTopic* = "/waku/2/default-waku/proto"
|
const defaultWakuPubsubTopic* = "/waku/2/default-waku/proto"
|
||||||
|
const defaultWakuBootstrapNode* = "enr:-P-4QGVNANzbhCI49du6Moyw98AjuMhKoOpE_Jges9JlCq-I" &
|
||||||
|
"CAVadktjfcNpuhQgT0g1cu86_S3nbM7eYkCsqDAQG7UBgmlkgnY0" &
|
||||||
|
"gmlwhI_G-a6KbXVsdGlhZGRyc7hgAC02KG5vZGUtMDEuZG8tYW1z" &
|
||||||
|
"My5zdGF0dXMucHJvZC5zdGF0dXNpbS5uZXQGdl8ALzYobm9kZS0w" &
|
||||||
|
"MS5kby1hbXMzLnN0YXR1cy5wcm9kLnN0YXR1c2ltLm5ldAYBu94D" &
|
||||||
|
"iXNlY3AyNTZrMaECoVyonsTGEQvVioM562Q1fjzTb_vKD152PPId" &
|
||||||
|
"sV7sM6SDdGNwgnZfg3VkcIIjKIV3YWt1Mg8"
|
||||||
|
|
||||||
type
|
type
|
||||||
SNMStartUpCmd* {.pure.} = enum
|
SNMStartUpCmd* {.pure.} = enum
|
||||||
@ -96,6 +103,11 @@ type
|
|||||||
defaultValue: config.defaultWakuHandshakeFilePath()
|
defaultValue: config.defaultWakuHandshakeFilePath()
|
||||||
name: "waku-handshake-file" .}: string
|
name: "waku-handshake-file" .}: string
|
||||||
|
|
||||||
|
wakuBootstrapNode* {.
|
||||||
|
desc: "The bootstrap node to use for the Waku node"
|
||||||
|
defaultValue: defaultWakuBootstrapNode
|
||||||
|
name: "waku-bootstrap-node" .}: string
|
||||||
|
|
||||||
of SNMStartUpCmd.waku:
|
of SNMStartUpCmd.waku:
|
||||||
case wakuCmd* {.command.}: WakuCommand
|
case wakuCmd* {.command.}: WakuCommand
|
||||||
|
|
||||||
|
@ -117,9 +117,11 @@ proc wakuSendMessage*(wakuHost: ref WakuHost,
|
|||||||
proc init*(T: type WakuHost,
|
proc init*(T: type WakuHost,
|
||||||
rng: ref HmacDrbgContext,
|
rng: ref HmacDrbgContext,
|
||||||
config: StatusNodeManagerConfig): Future[WakuHost] {.async.} =
|
config: StatusNodeManagerConfig): Future[WakuHost] {.async.} =
|
||||||
|
|
||||||
let node = await startWakuNode(rng, config.wakuPort,
|
let node = await startWakuNode(rng, config.wakuPort,
|
||||||
config.discv5Port,
|
config.discv5Port,
|
||||||
config.requiredConnectedPeers)
|
config.requiredConnectedPeers,
|
||||||
|
config.wakuBootstrapNode)
|
||||||
|
|
||||||
# Try to load handshake data from file, if the file exists
|
# Try to load handshake data from file, if the file exists
|
||||||
let handshakeDataFile = OutFile(config.wakuHandshakeFile)
|
let handshakeDataFile = OutFile(config.wakuHandshakeFile)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user