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) <noreply@anthropic.com>

* 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) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Igor Sirotin 2026-07-30 17:06:49 +01:00 committed by GitHub
parent 3288d2d88d
commit 504336efdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 5 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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)

View File

@ -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