From 0a208949090c68b82670011b6c7e1c9f2596bb55 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Mon, 6 Jul 2026 21:13:19 +0100 Subject: [PATCH] refactor(node-info): source MaxMessageSize from node config Read the reported value from `conf.maxMessageSizeBytes` instead of the mounted relay. The relay only holds a copy of the configured value and is absent on relay-disabled (light) nodes, which would report an empty string. Sourcing from the config makes the item always available and reflects the node's configured limit directly. WakuStateInfo now holds the WakuConf it reports on; init takes it as an argument. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../waku/factory/waku_state_info.nim | 20 +++++++------------ logos_delivery/waku/waku.nim | 2 +- tests/node/test_wakunode_health_monitor.nim | 8 ++++++-- tests/wakunode2/test_app.nim | 6 ------ 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/logos_delivery/waku/factory/waku_state_info.nim b/logos_delivery/waku/factory/waku_state_info.nim index a2c591fb4..02db6eab1 100644 --- a/logos_delivery/waku/factory/waku_state_info.nim +++ b/logos_delivery/waku/factory/waku_state_info.nim @@ -5,13 +5,9 @@ ## accessible through the debug API. import std/[tables, sequtils, strutils] -import - metrics, - eth/p2p/discoveryv5/enr, - libp2p/peerid, - libp2p/protocols/pubsub/gossipsub, - stew/byteutils +import metrics, eth/p2p/discoveryv5/enr, libp2p/peerid, stew/byteutils import logos_delivery/waku/[waku_node, net/bound_ports] +import logos_delivery/waku/factory/waku_conf type NodeInfoId* {.pure.} = enum @@ -26,6 +22,7 @@ type WakuStateInfo* {.requiresInit.} = object node: WakuNode + conf: WakuConf proc getAllPossibleInfoItemIds*(self: WakuStateInfo): seq[NodeInfoId] = ## Returns all possible options that can be queried to learn about the node's information. @@ -59,13 +56,10 @@ proc getNodeInfoItem*(self: WakuStateInfo, infoItemId: NodeInfoId): string = return "" return self.node.wakuMix.pubKey.to0xHex() of NodeInfoId.MaxMessageSize: - ## Max message size (in bytes) accepted by the relay protocol. - ## Empty when the relay protocol is not mounted on this node. - if self.node.wakuRelay.isNil(): - return "" - return $self.node.wakuRelay.maxMessageSize + ## Configured max message size (in bytes) for this node. + return $self.conf.maxMessageSizeBytes else: return "unknown info item id" -proc init*(T: typedesc[WakuStateInfo], node: WakuNode): T = - return WakuStateInfo(node: node) +proc init*(T: typedesc[WakuStateInfo], node: WakuNode, conf: WakuConf): T = + return WakuStateInfo(node: node, conf: conf) diff --git a/logos_delivery/waku/waku.nim b/logos_delivery/waku/waku.nim index 29290483f..f8b8795d8 100644 --- a/logos_delivery/waku/waku.nim +++ b/logos_delivery/waku/waku.nim @@ -235,7 +235,7 @@ proc new*( return err("Failed setting up app callbacks: " & $error) var waku = Waku( - stateInfo: WakuStateInfo.init(node), + stateInfo: WakuStateInfo.init(node, wakuConf), conf: wakuConf, rng: rng, key: wakuConf.nodeKey, diff --git a/tests/node/test_wakunode_health_monitor.nim b/tests/node/test_wakunode_health_monitor.nim index c6f9d34e6..0ec69283f 100644 --- a/tests/node/test_wakunode_health_monitor.nim +++ b/tests/node/test_wakunode_health_monitor.nim @@ -235,7 +235,9 @@ suite "Health Monitor - events": # `waku.node` is read on the messaging path; `conf`/`stateInfo` are supplied # solely to satisfy Waku's {.requiresInit.} fields. let waku = Waku( - node: nodeA, conf: defaultTestWakuConf(), stateInfo: WakuStateInfo.init(nodeA) + node: nodeA, + conf: defaultTestWakuConf(), + stateInfo: WakuStateInfo.init(nodeA, defaultTestWakuConf()), ) let ds = MessagingClient .new(MessagingClientConf(useP2PReliability: false), waku) @@ -346,7 +348,9 @@ suite "Health Monitor - events": # `waku.node` is read on the messaging path; `conf`/`stateInfo` are supplied # solely to satisfy Waku's {.requiresInit.} fields. let waku = Waku( - node: nodeA, conf: defaultTestWakuConf(), stateInfo: WakuStateInfo.init(nodeA) + node: nodeA, + conf: defaultTestWakuConf(), + stateInfo: WakuStateInfo.init(nodeA, defaultTestWakuConf()), ) let ds = MessagingClient .new(MessagingClientConf(useP2PReliability: false), waku) diff --git a/tests/wakunode2/test_app.nim b/tests/wakunode2/test_app.nim index bc89671d3..1415ac41b 100644 --- a/tests/wakunode2/test_app.nim +++ b/tests/wakunode2/test_app.nim @@ -33,12 +33,6 @@ suite "Wakunode2 - Waku": let waku = (waitFor Waku.new(conf)).valueOr: raiseAssert error - defer: - (waitFor waku.stop()).isOkOr: - raiseAssert error - - (waitFor waku.start()).isOkOr: - raiseAssert error ## When let maxMessageSize = waku.stateInfo.getNodeInfoItem(NodeInfoId.MaxMessageSize)