Skip to content

feat: instance based router state#805

Open
dastansam wants to merge 9 commits intomainfrom
feat/instance-based-router-state
Open

feat: instance based router state#805
dastansam wants to merge 9 commits intomainfrom
feat/instance-based-router-state

Conversation

@dastansam
Copy link
Copy Markdown
Contributor

@dastansam dastansam commented Mar 15, 2026

  • completely remove all global state (OnceLock, static, etc.)
  • add qaul-sim crate for simulating network topology of qaul instances
  • add criterion benchmarks
  • add more integration tests

closes #786

@dastansam dastansam marked this pull request as ready for review March 22, 2026 13:50
Phase 1 of the instance-based libqaul refactoring. Each router
submodule now has a *State struct that owns what was previously in
global statics, enabling multiple independent nodes in one process.

- RouterState: top-level struct owning all router sub-state
- NeighboursState: per-module neighbour tables (internet/lan/ble)
- ConnectionTableState: per-module connection tables + local routes
- RoutingTableState: global routing table with instance methods
- SchedulerState: routing info scheduler
- FlooderState, FeedRequester/ResponserState, UserRequester/ResponserState
- UsersState: in-memory user table (no DB dependency)

All global statics are preserved for backward compatibility. The
existing code paths are unchanged — all 20 libqaul tests pass.

New qaul-sim crate provides full-mesh routing simulation:
- Topology: line, ring, grid, star, full-mesh graph builders
- Network: latency sampling with jitter and packet loss
- Simulator: discrete-time driver calling real libqaul code
- Metrics: convergence and reachability tracking
- Scenarios: predefined topologies + timed events
- Criterion benchmarks for convergence performance

24 simulation tests pass including convergence for line, ring,
grid, star, full-mesh topologies, link failure/recovery, latency
spikes, and network partition/heal scenarios.
…de/storage/rpc

Add *State structs to all modules with global statics, enabling
multi-instance use for simulation. Phases 2-4 of the instance-based
refactor:

- Phase 2 (Services): MessagingState, FeedState, ChatState,
  ChatFileState, CryptoStorageState, GroupStorageState, DtnModuleState,
  ServicesState
- Phase 3 (Connections): InternetState, BleModuleState, ConnectionsState
- Phase 4 (Node/Storage/RPC): UserAccountsState, ConfigurationState,
  DatabaseState, RpcState, SysRpcState, AuthenticationState,
  FileLoggerState

Global statics remain for backward compatibility. All existing tests
pass.
…on tests

- Add connection module support to links (BLE, Internet, LAN per link)
- Simulator now uses each link's module for routing differentiation
- Enhanced metrics: avg/max hop count, routes-by-module breakdown
- New scenarios: BLE-only mesh, mixed BLE+LAN, Internet relay,
  mixed star BLE+Internet
- Integration tests verifying all State structs are independently
  constructible and composable without global state
- New benchmarks for BLE mesh, mixed BLE+LAN, Internet relay convergence
- Total: 36 tests (up from 24), all passing
…ased refactoring

Remove ~950 lines of duplicate static→instance forwarding methods, unused
instance methods, _inner indirection, and dead code that accumulated during
the global-to-instance state migration:

- Router: remove ConnectionTable/Neighbours/RoutingTable static forwarders,
  callers now use router state directly
- Services: inline Feed/Messaging/DTN _inner methods into their State structs,
  remove static forwarding methods
- Rpc/Sys: remove unused RpcState/SysRpcState instance methods and no-op inits
- Authentication: inline _impl standalone functions into Authentication methods,
  remove unused AuthenticationState instance methods
- UserAccounts: remove unused UserAccountsState instance methods and no-op init
- Dead code: remove no-op Rtc::init and its callers
@dastansam dastansam force-pushed the feat/instance-based-router-state branch from 360ccf8 to 23ae124 Compare March 22, 2026 19:00
@dastansam dastansam requested a review from MathJud March 22, 2026 19:01
@dastansam dastansam changed the title Feat/instance based router state feat: instance based router state Apr 3, 2026
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.

rust: benchmarks

1 participant