chore(NODE-1953): Implement new dynamic route provider#209
Conversation
|
✅ No security or compliance issues detected. Reviewed everything up to 1e57956. Security Overview
Detected Code Changes| Change Type | Relevant files ... (code changes summary truncated to fit VCS comment limits.) |
There was a problem hiding this comment.
Pull request overview
This PR replaces the previous ic_bn_lib dynamic route provider integration with an in-repo dynamic route provider that discovers API boundary nodes, health-checks them, and selects routes using weighted round-robin based on latency and reliability.
Changes:
- Introduces a new dynamic routing subsystem (
FetcherManager→HealthCheckManager→RoutesManager→DynamicRouteProvider) undersrc/routing/ic/route_provider/. - Switches IC routing setup to use Hyper-based clients/services and updates mainnet root subnet ID handling to a
Principalconstant. - Adds a local WRR implementation and tests for WRR, health checking, fetching, and route selection.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/routing/ic/routing_table_manager.rs | Updates tests to use the new MAINNET_ROOT_SUBNET_ID constant type. |
| src/routing/ic/route_provider/wrr.rs | Adds a weighted round-robin implementation used by the new route snapshot. |
| src/routing/ic/route_provider/routes.rs | Adds route snapshot building and ranking logic (latency/reliability → weights) plus tests. |
| src/routing/ic/route_provider/provider.rs | Adds DynamicRouteProvider and task orchestration managers implementing RouteProvider. |
| src/routing/ic/route_provider/mod.rs | Adds the new route provider module API and wiring via setup_route_provider. |
| src/routing/ic/route_provider/health.rs | Adds HTTP health checker + per-node health actors + manager producing HealthyNode snapshots. |
| src/routing/ic/route_provider/fetcher.rs | Adds agent-based node discovery fetcher + manager publishing refreshed node lists. |
| src/routing/ic/route_provider.rs | Removes the old route provider wiring (previous ic_bn_lib dynamic routing builder usage). |
| src/routing/ic/mod.rs | Changes MAINNET_ROOT_SUBNET_ID to a Principal constant and updates imports. |
| src/routing/ic/http_service.rs | Switches derive usage to derive_new::new. |
| src/core.rs | Rewires startup to build Hyper clients/services and pass them into the new route provider setup. |
| Cargo.toml | Adds thiserror dependency used by the new route provider module. |
| Cargo.lock | Locks thiserror version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Bownairo
left a comment
There was a problem hiding this comment.
A lot of these are just questions, but I think I've mostly got it 🙂. The roles in the description were really helpful to guide the review.
Bownairo
left a comment
There was a problem hiding this comment.
I just realized ic-agent still has its own DynamicRouteProvider and the rest of the stack. If that's in use elsewhere, does this one deserve a new name? Or will that one be cleared out?
It's gated under a very-secret |
|
@Bownairo Thanks for the review 👍 |
A bit simplified version of
DynamicRouteProviderfromagent-rs. It takes into account both node latency & reliability to pick the best nodes, uses Weighted Round Robin to do that.Entity roles are as follows:
FetcherManagerfetches a fresh list of API BNs usingArc<dyn FetchesNodes>(AgentFetcheris included to implement that trait) and sends this list down a channelRouteProviderManagergets a copy of it to share it withDynamicRouteProviderso that it knows how many total nodes there are (required forRouteProvidertrait)HealthCheckManageralso receives the same list and spawnsHealthCheckActors for each node to perform healthchecks usingArc<dyn ChecksHealth>(HttpHealthCheckeris included to do that using an HTTP client). Once the set of healthy nodes changes (and also periodically) it sends the healthy node list (along with latency/reliability stats) down a channel. When the list is updated it figures out which nodes are added/removed and stops & spawns the corresponding actors.RoutesManagerreceives this list, processes and builds a snapshot of URLs for theDynamicRouteProviderto use and shares it usingArcSwapDynamicRouteProviderimplements the actualRouteProvidertrait & uses WRR in theRouteSnapshotto respond to URL queries.