From 504336efdbb38e87afbc3bf67316bfcc09f01717 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Thu, 30 Jul 2026 17:06:49 +0100 Subject: [PATCH] feat(node-info): expose MaxMessageSize node info item (#4018) * 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) * 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) --------- Co-authored-by: Claude Opus 4.8 (1M context) --- logos_delivery/waku/factory/waku_state_info.nim | 10 ++++++++-- logos_delivery/waku/waku.nim | 2 +- tests/node/test_wakunode_health_monitor.nim | 8 ++++++-- tests/wakunode2/test_app.nim | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/logos_delivery/waku/factory/waku_state_info.nim b/logos_delivery/waku/factory/waku_state_info.nim index e608d5dd2..02db6eab1 100644 --- a/logos_delivery/waku/factory/waku_state_info.nim +++ b/logos_delivery/waku/factory/waku_state_info.nim @@ -7,6 +7,7 @@ import std/[tables, sequtils, strutils] 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 @@ -17,9 +18,11 @@ type MyPeerId MyBoundPorts MyMixPubKey + MaxMessageSize 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. @@ -52,8 +55,11 @@ proc getNodeInfoItem*(self: WakuStateInfo, infoItemId: NodeInfoId): string = if self.node.wakuMix.isNil(): return "" return self.node.wakuMix.pubKey.to0xHex() + of NodeInfoId.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 29b42a7ef..89af02454 100644 --- a/logos_delivery/waku/waku.nim +++ b/logos_delivery/waku/waku.nim @@ -234,7 +234,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 71203010f..39848acd0 100644 --- a/tests/node/test_wakunode_health_monitor.nim +++ b/tests/node/test_wakunode_health_monitor.nim @@ -234,7 +234,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(reliabilityEnabled: Opt.some(false)), waku) @@ -345,7 +347,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(reliabilityEnabled: Opt.some(false)), waku) diff --git a/tests/wakunode2/test_app.nim b/tests/wakunode2/test_app.nim index e9a0ecd47..c462c2e63 100644 --- a/tests/wakunode2/test_app.nim +++ b/tests/wakunode2/test_app.nim @@ -26,6 +26,20 @@ 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 + + ## 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