From 1a79855c31fc049eaa1096adf09e9d21c2ea0901 Mon Sep 17 00:00:00 2001 From: R0ck Date: Tue, 8 Sep 2026 14:43:39 +0100 Subject: [PATCH] bridge: the seed is parsed whole, and is 64 bits wide strtoul saturates at ULONG_MAX where a long is 32 bits, which is every Windows target, so a seed above 2^32 came in as 0xFFFFFFFF and every node of a run but the first booted with one identity, private key included. strtoull, into a uint64_t, so the number the simulator sends means the same thing on every platform. The simulator sends a value that fits in 32 bits either way, so no identity changes where the mesh already worked. MeshBench/meshbench#712 Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01Q9HbD44EKWWTRYgxbFGxf6 --- bridge/main.cpp | 9 +++++++-- variants/host/target.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bridge/main.cpp b/bridge/main.cpp index 93a3bd7..2545af2 100644 --- a/bridge/main.cpp +++ b/bridge/main.cpp @@ -56,7 +56,7 @@ int g_stuck_irq_ms = 0; extern int g_sf; extern float g_bwKHz; extern int g_cr; -extern uint32_t g_identity_seed; +extern uint64_t g_identity_seed; namespace { @@ -175,7 +175,12 @@ int main(int argc, char** argv) { for (int i = 1; i < argc; i++) { auto next = [&]() { return i + 1 < argc ? argv[++i] : ""; }; if (!strcmp(argv[i], "--bridge")) bridge = next(); - else if (!strcmp(argv[i], "--seed")) g_identity_seed = (uint32_t)strtoul(next(), nullptr, 10); + // strtoull, and the whole of it. strtoul saturates at ULONG_MAX where a + // long is 32 bits - every Windows target - so a seed above 2^32 came in + // as 0xFFFFFFFF, and every node of a run but the first booted with one + // identity. The simulator sends a value that fits in 32 bits either way, + // so a seed it sends means the same thing on every platform. + else if (!strcmp(argv[i], "--seed")) g_identity_seed = strtoull(next(), nullptr, 10); else if (!strcmp(argv[i], "--sf")) g_sf = atoi(next()); else if (!strcmp(argv[i], "--bw-khz")) g_bwKHz = (float)atof(next()); else if (!strcmp(argv[i], "--cr")) g_cr = atoi(next()); diff --git a/variants/host/target.cpp b/variants/host/target.cpp index ecb2fe7..ebf8518 100644 --- a/variants/host/target.cpp +++ b/variants/host/target.cpp @@ -58,7 +58,7 @@ int g_cr = 1; // reproducible from its seed, and a hardware RNG is the one thing that cannot // be — so the seam that would ordinarily be RadioNoiseListener is the seam // where determinism gets injected. -uint32_t g_identity_seed = 4417; +uint64_t g_identity_seed = 4417; bool radio_init() { // std_init walks RadioLib's begin(): calibration, TCXO, the modem