Skip to content

Multibuy 2.0: Hotspot/Region Deny Lists & Service Modernization#4

Merged
macpie merged 13 commits intomainfrom
macpie/multibuy2.0
Apr 2, 2026
Merged

Multibuy 2.0: Hotspot/Region Deny Lists & Service Modernization#4
macpie merged 13 commits intomainfrom
macpie/multibuy2.0

Conversation

@macpie
Copy link
Copy Markdown
Member

@macpie macpie commented Mar 30, 2026

Summary

  • Augment the gRPC protocol with hotspot_key and region fields so HPR can send hotspot identity and region alongside packet keys
  • Add configurable hotspot and region deny lists — the service returns denied=true while still incrementing the counter for tracking
  • Modernize the service architecture, dependencies, CI, and Docker setup
  • Will need Multi Buy 2.0 proto#479

What changed

Protocol & Deny Lists

  • MultiBuyIncReqV1 now includes hotspot_key (bytes) and region (helium.region enum)
  • MultiBuyIncResV1 now includes denied (bool) — backward compatible (proto3 default false)
  • Deny lists configured via denied_hotspots (base58 keys) and denied_regions (e.g. US915, EU868) in settings or env vars
  • Invalid deny list entries fail fast at startup instead of being silently skipped

Architecture

  • Restructured into cli/, state, cache, tasks/, metrics/ modules
  • Mutex<HashMap> replaced with DashMap for per-shard locking under concurrent load
  • Cache size tracked with AtomicUsize for lock-free accurate metrics
  • Cache timestamps use Instant instead of SystemTime (immune to clock adjustments)
  • task-manager (from helium/oracles) manages gRPC server and cache cleanup with graceful SIGTERM/SIGINT shutdown
  • custom-tracing for dynamic log level updates
  • clap subcommand: multi_buy_service -c settings.toml server

Metrics (Prometheus on :19011)

Metric Type
multi_buy_hit_total Counter
multi_buy_denied_total Counter
multi_buy_cache_size Gauge
multi_buy_cache_cleaned_total Counter
multi_buy_request_duration_ms Histogram

CI/CD & Docker

  • Replaced old build.yaml with Docker-based ci.yml (cached base image, parallel fmt/clippy/nextest, Debian packaging + GHCR image on
    tags)
  • Multi-stage Dockerfile (basebuilderrunner on debian:bookworm-slim) with non-root user
  • Pinned rust-toolchain.toml to 1.91.1

Tests

  • 10 integration tests via cargo nextest: counting, key independence, hotspot/region deny, empty key, graceful shutdown,
    100-concurrent-request correctness, cache expiry

- Add hotspot_key and region fields to gRPC protocol for filtering
- Add configurable hotspot and region deny lists via settings/env vars
- Restructure into cli/grpc/metrics modules for better separation
- Use task-manager for graceful shutdown of gRPC server and cache cleanup
- Use custom-tracing for dynamic log level updates
- Add structured metrics module following oracles patterns
- Replace old CI workflow with Docker-based base image caching
- Add Dockerfile with multi-stage build (base/builder/runner)
- Add rust-toolchain.toml pinning to 1.91.1
- Add integration tests for counting, deny lists, and shutdown
- Update README with full configuration reference and env vars
macpie added 4 commits March 30, 2026 15:38
Resolve Cargo.toml and Cargo.lock conflicts by keeping our
modernized dependencies. Picks up LICENSE and CONTRIBUTING.md
from main.
- Replace Mutex<HashMap> with DashMap for per-shard locking under concurrency
- Use DashMap entry() API to avoid redundant lookups
- Track cache size with AtomicUsize for lock-free accurate metrics
- Use Instant instead of SystemTime for cache timestamps
- Fail fast on invalid deny list entries at startup
- Propagate metrics startup errors instead of swallowing them
- Add Default impl for Cache to satisfy clippy
- Add non-root user in Dockerfile
- Fix stale comment in settings.rs
- Add concurrent request and cache expiry integration tests
@macpie macpie changed the title Multibuy 2.0 Multibuy 2.0: Hotspot/Region Deny Lists & Service Modernization Mar 30, 2026
macpie added 3 commits March 31, 2026 11:19
Extract hotspot/region deny list functionality from the main service
into examples/deny_lists.rs and examples/allow_lists.rs. The core
service now only handles counting and cache cleanup.
macpie and others added 3 commits April 1, 2026 09:41
Co-authored-by: Michael Jeffrey <michaeldjeffrey@gmail.com>
Co-authored-by: Michael Jeffrey <michaeldjeffrey@gmail.com>
Remove manual AtomicUsize cache size tracking in favor of
gauge increment/set. Drop cache_cleaned_total metric, unused
parking_lot dep, and tokio full feature. Switch helium-proto
to master and CI to cargo test.
@macpie macpie marked this pull request as ready for review April 1, 2026 18:22
allow_lists.hotspots.len(),
allow_lists.regions.len()
);
println!("(empty hotspot list = all hotspots allowed)");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
println!("(empty hotspot list = all hotspots allowed)");

@macpie macpie merged commit 2618acf into main Apr 2, 2026
7 checks passed
@macpie macpie deleted the macpie/multibuy2.0 branch April 2, 2026 16:40
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