From 0b0368a3059527442d4a1c4718131f9bd6340023 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Mon, 6 Jul 2026 20:20:02 +0100 Subject: [PATCH 1/2] feat(node-info): expose MaxMessageSize node info item Add a `MaxMessageSize` entry to `NodeInfoId` so the max message size (in bytes) accepted by the relay protocol can be queried through the node info surface, consumed by both the debug API and the FFI `get_node_info` / `get_available_node_info_ids` calls. The value is read from the mounted relay's `maxMessageSize` and is empty when the relay protocol is not mounted on the node (e.g. light nodes), mirroring the existing `MyMixPubKey` handling. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../waku/factory/waku_state_info.nim | 14 ++++++++++++- tests/wakunode2/test_app.nim | 20 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/logos_delivery/waku/factory/waku_state_info.nim b/logos_delivery/waku/factory/waku_state_info.nim index e608d5dd2..a2c591fb4 100644 --- a/logos_delivery/waku/factory/waku_state_info.nim +++ b/logos_delivery/waku/factory/waku_state_info.nim @@ -5,7 +5,12 @@ ## accessible through the debug API. import std/[tables, sequtils, strutils] -import metrics, eth/p2p/discoveryv5/enr, libp2p/peerid, stew/byteutils +import + metrics, + eth/p2p/discoveryv5/enr, + libp2p/peerid, + libp2p/protocols/pubsub/gossipsub, + stew/byteutils import logos_delivery/waku/[waku_node, net/bound_ports] type @@ -17,6 +22,7 @@ type MyPeerId MyBoundPorts MyMixPubKey + MaxMessageSize WakuStateInfo* {.requiresInit.} = object node: WakuNode @@ -52,6 +58,12 @@ proc getNodeInfoItem*(self: WakuStateInfo, infoItemId: NodeInfoId): string = if self.node.wakuMix.isNil(): 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 else: return "unknown info item id" diff --git a/tests/wakunode2/test_app.nim b/tests/wakunode2/test_app.nim index 879dcd7b5..bc89671d3 100644 --- a/tests/wakunode2/test_app.nim +++ b/tests/wakunode2/test_app.nim @@ -27,6 +27,26 @@ suite "Wakunode2 - Waku": check: version == git_version + test "max message size should be reported from node info": + ## Given + let conf = defaultTestWakuConf() + + 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) + + ## Then + check: + maxMessageSize == $conf.maxMessageSizeBytes + suite "Wakunode2 - Waku initialization": test "peer persistence setup should be successfully mounted": ## Given From 0a208949090c68b82670011b6c7e1c9f2596bb55 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Mon, 6 Jul 2026 21:13:19 +0100 Subject: [PATCH 2/2] 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)