Skip to content

packet: only copy bloom filter into beacon when available#162

Merged
geonnave merged 1 commit into
DotBots:developfrom
geonnave:fix-bloom-beacon-race
Jun 16, 2026
Merged

packet: only copy bloom filter into beacon when available#162
geonnave merged 1 commit into
DotBots:developfrom
geonnave:fix-bloom-beacon-race

Conversation

@geonnave

Copy link
Copy Markdown
Contributor

Problem

The gateway recomputes its bloom filter in the main loop, but beacons are
built in the radio slot ISR. When a beacon is built while a recompute is in
flight, it copies a half-rebuilt filter onto the air. A joined node that fails
the membership test on such a beacon concludes it has been evicted and leaves
with MARI_PEER_LOST_BLOOM.

Under a join storm this is frequent: the gateway sets the filter dirty and
recomputes after every join, so the recompute window is open much of the time,
and a single bad beacon can drop already-joined nodes. They rejoin, trigger
another recompute, and the network bounces instead of settling.

This regressed when the bloom became a mandatory beacon field in 8d20a54,
which dropped the prior mr_bloom_gateway_is_available() guard around the copy.

Change

Restore the guard: only copy the filter into the beacon when it is available,
so a beacon is never populated from a filter that is mid-recompute.

Validation

On the testbed, the reason-6 (MARI_PEER_LOST_BLOOM) disconnects observed
during network formation no longer occur.

Known limitation / follow-up

When the filter is unavailable the copy is skipped, which leaves the beacon's
bloom_filter field zeroed, and the node side has no empty-filter guard yet.
A node-side "treat an all-zero filter as no-info, skip the check" guard (or
gateway-side double-buffering) is a planned follow-up to close that remaining
window fully.

The bloom filter is recomputed in the gateway main loop while beacons are
built in the radio slot ISR. Copying mid-recompute puts a partial bloom on
the air, and a joined node that fails the membership test on such a beacon
leaves with MARI_PEER_LOST_BLOOM. Gate the copy on availability so a beacon
is not populated from a filter that is mid-recompute.

AI-assisted: Claude Opus 4.8
@geonnave geonnave merged commit 99f8dd2 into DotBots:develop Jun 16, 2026
2 checks passed
@geonnave geonnave deleted the fix-bloom-beacon-race branch June 16, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant