Skip to content

chore(NODE-1953): Implement new dynamic route provider#209

Merged
blind-oracle merged 13 commits into
mainfrom
igor/route-provider
Jun 18, 2026
Merged

chore(NODE-1953): Implement new dynamic route provider#209
blind-oracle merged 13 commits into
mainfrom
igor/route-provider

Conversation

@blind-oracle

Copy link
Copy Markdown
Collaborator

A bit simplified version of DynamicRouteProvider from agent-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:

  • FetcherManager fetches a fresh list of API BNs using Arc<dyn FetchesNodes> (AgentFetcher is included to implement that trait) and sends this list down a channel
  • RouteProviderManager gets a copy of it to share it with DynamicRouteProvider so that it knows how many total nodes there are (required for RouteProvider trait)
  • HealthCheckManager also receives the same list and spawns HealthCheckActors for each node to perform healthchecks using Arc<dyn ChecksHealth> (HttpHealthChecker is 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.
  • RoutesManager receives this list, processes and builds a snapshot of URLs for the DynamicRouteProvider to use and shares it using ArcSwap
  • DynamicRouteProvider implements the actual RouteProvider trait & uses WRR in the RouteSnapshot to respond to URL queries.

@zeropath-ai

zeropath-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown

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.)

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.

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 (FetcherManagerHealthCheckManagerRoutesManagerDynamicRouteProvider) under src/routing/ic/route_provider/.
  • Switches IC routing setup to use Hyper-based clients/services and updates mainnet root subnet ID handling to a Principal constant.
  • 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.

Comment thread src/routing/ic/route_provider/wrr.rs Outdated
Comment thread src/routing/ic/route_provider/wrr.rs
Comment thread src/routing/ic/route_provider/wrr.rs
Comment thread src/routing/ic/route_provider/routes.rs Outdated
Comment thread src/routing/ic/route_provider/routes.rs
Comment thread src/routing/ic/route_provider/routes.rs
Comment thread src/routing/ic/route_provider/provider.rs Outdated
Comment thread src/routing/ic/route_provider/provider.rs
Comment thread src/routing/ic/route_provider/health.rs Outdated
Comment thread src/routing/ic/route_provider/provider.rs Outdated

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.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 8 comments.

Comment thread src/routing/ic/route_provider/routes.rs
Comment thread src/routing/ic/route_provider/routes.rs
Comment thread src/routing/ic/route_provider/routes.rs
Comment thread src/routing/ic/route_provider/routes.rs Outdated
Comment thread src/routing/ic/route_provider/routes.rs
Comment thread src/routing/ic/route_provider/provider.rs Outdated
Comment thread src/routing/ic/route_provider/fetcher.rs
Comment thread src/routing/ic/route_provider/wrr.rs

@Bownairo Bownairo 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.

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.

Comment thread src/routing/ic/route_provider/fetcher.rs
Comment thread src/routing/ic/route_provider/fetcher.rs
Comment thread src/routing/ic/route_provider/health.rs
Comment thread src/routing/ic/route_provider/health.rs
Comment thread src/routing/ic/route_provider/routes.rs Outdated
Comment thread src/core.rs Outdated
Comment thread src/core.rs
Comment thread src/routing/ic/route_provider/health.rs
Comment thread src/routing/ic/route_provider/provider.rs

@Bownairo Bownairo 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.

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?

Comment thread src/routing/ic/route_provider/provider.rs
Comment thread src/routing/ic/route_provider/provider.rs
Comment thread src/routing/ic/route_provider/provider.rs
@blind-oracle

Copy link
Copy Markdown
Collaborator Author

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 _internal_dynamic-routing feature and nobody really uses it (except Caffeine I think). Probably at some point we can either remove it or replace it with this new version.

@blind-oracle

Copy link
Copy Markdown
Collaborator Author

@Bownairo Thanks for the review 👍

@blind-oracle blind-oracle merged commit 20cddb0 into main Jun 18, 2026
6 checks passed
@blind-oracle blind-oracle deleted the igor/route-provider branch June 18, 2026 08:34
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.

3 participants