Merge pull request #451 from status-im/remove-waku-mode

Update to use waku topic-interest
This commit is contained in:
Kim De Mey 2020-02-10 10:04:40 +01:00 committed by GitHub
commit 0a6e1b4ba7
7 changed files with 23 additions and 17 deletions

View File

@ -268,10 +268,10 @@ proc setupWakuRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) =
# there to have a full node no matter what message filters.
# Could also be moved to waku_protocol.nim
let config = node.protocolState(Waku).config
if config.wakuMode == WakuChan:
if config.topics.isSome():
try:
# TODO: an addTopics call would probably be more useful
let result = await node.setTopics(config.topics.concat(filter.topics))
let result = await node.setTopics(config.topics.get().concat(filter.topics))
if not result:
raise newException(ValueError, "Too many topics")
except CatchableError:

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit 3ee5651b7c1b967e9aa115d99125ed35ac3ab2f1
Subproject commit b89874f6cc35f2506de5d97c9a50978c77e0048f

@ -1 +1 @@
Subproject commit bfc48eda54a35b7c19cbb2994470655ad7a3bdd1
Subproject commit 2403c33929c74f2d150f50dc8bc3a598af70661a

2
vendor/nim-stew vendored

@ -1 +1 @@
Subproject commit 1c4293b3e754b5ea68a188b60b192801162cd44e
Subproject commit 50562b515a771cfc443557ee8e2dceee59207d52

View File

@ -72,10 +72,10 @@ type
defaultValue: false
name: "light-node" }: bool
wakuMode* {.
desc: "Select the Waku mode.",
defaultValue: WakuSan
name: "waku-mode" }: WakuMode
wakuTopicInterest* {.
desc: "Run as node with a topic-interest",
defaultValue: false
name: "waku-topic-interest" }: bool
wakuPow* {.
desc: "PoW requirement of Waku node.",

View File

@ -10,9 +10,8 @@ const
type
NodeType = enum
FullNode = "--waku-mode:WakuSan",
FullNode = "",
LightNode = "--light-node:on",
WakuNode = "--light-node:on --waku-mode:WakuChan"
Topology = enum
Star,
@ -43,8 +42,8 @@ type
label: string
proc initNodeCmd(nodeType: NodeType, shift: int, staticNodes: seq[string] = @[],
discovery = false, bootNodes: seq[string] = @[], master = false,
label: string): NodeInfo =
discovery = false, bootNodes: seq[string] = @[], topicInterest = false,
master = false, label: string): NodeInfo =
let
keypair = newKeyPair()
address = Address(ip: parseIpAddress("127.0.0.1"),
@ -53,6 +52,7 @@ proc initNodeCmd(nodeType: NodeType, shift: int, staticNodes: seq[string] = @[],
result.cmd = wakuNodeBin & " " & defaults & " "
result.cmd &= $nodeType & " "
result.cmd &= "--waku-topic-interest:" & $topicInterest & " "
result.cmd &= "--nodekey:" & $keypair.seckey & " "
result.cmd &= "--ports-shift:" & $shift & " "
if discovery:
@ -116,6 +116,8 @@ proc generatePrometheusConfig(nodes: seq[NodeInfo], outputFile: string) =
node: '{count}'"""
count += 1
var (path, file) = splitPath(outputFile)
createDir(path)
writeFile(outputFile, config)
proc proccessGrafanaDashboard(nodes: int, inputFile: string,
@ -167,8 +169,9 @@ when isMainModule:
for i in 0..<conf.testNodePeers:
# TODO: could also select nodes randomly
staticnodes.add(nodes[i].enode)
# Waku light node
nodes.add(initNodeCmd(WakuNode, 0, staticnodes, label = "light Waku node"))
# light node with topic interest
nodes.add(initNodeCmd(LightNode, 0, staticnodes, topicInterest = true,
label = "light node topic interest"))
# Regular light node
nodes.add(initNodeCmd(LightNode, 1, staticnodes, label = "light node"))

View File

@ -76,12 +76,15 @@ proc run(config: WakuNodeConf) =
addAllCapabilities = false)
if not config.bootnodeOnly:
node.addCapability Waku # Always enable Waku protocol
var topicInterest: Option[seq[waku_protocol.Topic]]
if config.wakuTopicInterest:
var topics: seq[waku_protocol.Topic]
topicInterest = some(topics)
let wakuConfig = WakuConfig(powRequirement: config.wakuPow,
bloom: fullBloom(),
isLightNode: config.lightNode,
maxMsgSize: waku_protocol.defaultMaxMsgSize,
wakuMode: config.wakuMode,
topics: @[])
topics: topicInterest)
node.configureWaku(wakuConfig)
if config.whisper or config.whisperBridge:
node.addCapability Whisper