Skip to content

fix: draw the address pool from a fixed seed so runs reuse it - #16

Merged
DTTerastar merged 1 commit into
mainfrom
fix/stable-address-pool
Oct 28, 2026
Merged

DTTerastar merged 1 commit into
mainfrom
fix/stable-address-pool

Conversation

@DTTerastar

@DTTerastar DTTerastar commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

--pool only capped a single run. address_pool() drew fresh random addresses on every start, and the selftest asserted two pools must differ. Each HIL pipeline (--pool 1024) therefore added up to 1,024 new HIL-<mac> devices downstream.

On the bench Home Assistant that reached 12,318 unique hil- devices over 20 runs through ESPresense Companion MQTT discovery. About 4,300 were still live. Spook re-walking every automation on each device-registry change kept the HA event loop busy.

Fix

  • Draw the pool from random.Random(POOL_SEED), so every run cycles the same addresses.
  • Keep draw order rather than sorting, so --pool 512 reuses the first 512 addresses of the 1024 pool.
  • Unbounded mode (--pool 0) and iBeacon addresses are unchanged and still use secrets.
  • The selftest now asserts the pool is stable, is prefix-consistent, and changes with the seed.

Testing

python3 ble_flood.py --selftest passes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Address pools now produce the same ordered addresses when generated with the same seed. Smaller pools match the beginning of larger pools generated with that seed.
    • Static addresses can use a supplied random generator; without one, secure random bytes are used.

The pool bounded a single run but every run drew a fresh one, so each HIL
pipeline left another --pool worth of devices downstream. After 20 runs at
--pool 1024, Home Assistant had 12,318 unique HIL- devices via ESPresense
Companion's MQTT discovery, and Spook re-walking every automation on each
device-registry change kept the event loop busy.

Seed the generator so every run cycles the same addresses, and draw them in
order so a smaller pool is a prefix of a larger one. The selftest now asserts
the pool is stable instead of asserting it differs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 28, 2026 16:45
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a48dac60-0a53-4a2e-9db4-585a3a551b4d
Commits

Reviewing files that changed from the base of the PR and between a3b3819 and 96db611.

Files selected for processing: 1
  • ble_flood.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

address_pool now creates repeatable ordered pools from a seed. random_static_address accepts an optional generator and uses secure random bytes when none is provided. The self-tests check repeatability, prefix consistency, and different-seed results.

Changes

Seeded address pool

Layer / File(s) Summary
Seeded pool generation and validation
ble_flood.py
address_pool uses a seeded generator to produce a repeatable, duplicate-free pool, with smaller pools matching prefixes of larger pools. random_static_address accepts an optional generator and retains secure random bytes as its default. Tests check pool repeatability, prefix consistency, and different-seed results.

Possibly related PRs

  • ESPresense/ble-loadgen#15: Changes the same address_pool behavior with a fixed address sequence, which conflicts with the seeded sequence in this PR.

Priority: Normal

Change: Bug fix

Merge Risk: Minimal · up to 96db6

No demonstrated issue blocks merging after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: bounded address pools now use a fixed seed so runs reuse the same addresses.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 1 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change that makes BLE address pools repeatable across runs.

No open issues 🎉

What changed in this PR

Makes BLE address pools repeatable across runs, preventing repeated HIL pipelines from continually adding new downstream devices for the same pool size.

Changes:

  • Uses a fixed seed to generate stable, unique pool addresses.
  • Preserves draw order so smaller pools are prefixes of larger pools.
  • Updates selftests for repeatability, prefix consistency, and seed sensitivity; unbounded and iBeacon address generation remain unchanged.
File Description
ble_flood.py Adds deterministic address pools, documents their behavior, and updates selftest assertions.

Review effort: Balanced

@DTTerastar
DTTerastar merged commit 402f245 into main Oct 28, 2026
3 checks passed
@DTTerastar
DTTerastar deleted the fix/stable-address-pool branch October 28, 2026 17:12
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.

2 participants