Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(BOUN-1168): add dynamic route provider (Discovery Library) #568

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f831d96
feat: dynamic_route_provider
nikolay-komarevskiy Jun 25, 2024
556ad79
chore: add is_valid_domain()
nikolay-komarevskiy Jun 26, 2024
bfc28fe
fix: clippy
nikolay-komarevskiy Jun 26, 2024
973b377
chore: use Duration for LatencyMovAvg
nikolay-komarevskiy Jun 27, 2024
32bc62e
docs: add
nikolay-komarevskiy Jun 28, 2024
8bfe51b
chore: add DynamicRouteProviderBuilder
nikolay-komarevskiy Jul 16, 2024
ea4c8e5
chore: remove fetch_root_key() call
nikolay-komarevskiy Jul 16, 2024
f79efc3
fix: clippy
nikolay-komarevskiy Jul 16, 2024
a2d4799
chore: add mainnet test
nikolay-komarevskiy Jul 16, 2024
627331c
chore: add with_discovery_transport()
nikolay-komarevskiy Jul 16, 2024
9b6dea6
Merge remote-tracking branch 'origin/main' into BOUN-1186-add-discove…
nikolay-komarevskiy Jul 16, 2024
22fd241
chore: fix imports
nikolay-komarevskiy Jul 16, 2024
e7b6395
chore: remove error on run()
nikolay-komarevskiy Jul 17, 2024
a493beb
chore: remove errors in RoutingSnapshot
nikolay-komarevskiy Jul 17, 2024
df7b557
chore: remove anyhow
nikolay-komarevskiy Jul 17, 2024
38a8b45
chore: reduce public APIs
nikolay-komarevskiy Jul 17, 2024
1c93d1c
chore: relax versions
nikolay-komarevskiy Jul 19, 2024
05a7baa
chore: tmp use different name for bazel deps resolution
nikolay-komarevskiy Jul 22, 2024
e0ba859
Revert "chore: tmp use different name for bazel deps resolution"
nikolay-komarevskiy Jul 22, 2024
fe39797
chore: tmp enable fetch root key
nikolay-komarevskiy Jul 23, 2024
684aa06
Revert "chore: tmp enable fetch root key"
nikolay-komarevskiy Jul 23, 2024
ad521f4
chore: use specific tokio/tokio-util features
nikolay-komarevskiy Jul 23, 2024
7e9489a
Release 0.37.1 (#576)
adamspofford-dfinity Jul 25, 2024
af770c1
chore: set root_key for NodesFetcher
nikolay-komarevskiy Jul 30, 2024
8319e38
Merge branch 'main' into BOUN-1186-add-discovery-library
nikolay-komarevskiy Jul 30, 2024
05f7520
fix: remove suffix /api/v2
nikolay-komarevskiy Jul 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [0.37.1] - 2024-07-25

* Bug fix: Add `api/v2` prefix to read_state requests for hyper transport

## [0.37.0] - 2024-07-23
Expand Down
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ members = [
]

[workspace.package]
version = "0.37.0"
version = "0.37.1"
authors = ["DFINITY Stiftung <sdk@dfinity.org>"]
edition = "2021"
repository = "https://github.com/dfinity/agent-rs"
Expand All @@ -22,9 +22,9 @@ rust-version = "1.75.0"
license = "Apache-2.0"

[workspace.dependencies]
ic-agent = { path = "ic-agent", version = "0.37.0", default-features = false }
ic-utils = { path = "ic-utils", version = "0.37.0" }
ic-transport-types = { path = "ic-transport-types", version = "0.37.0" }
ic-agent = { path = "ic-agent", version = "0.37.1", default-features = false }
ic-utils = { path = "ic-utils", version = "0.37.1" }
ic-transport-types = { path = "ic-transport-types", version = "0.37.1" }

ic-certification = "2.2"
candid = "0.10.1"
Expand Down
8 changes: 7 additions & 1 deletion ic-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ hyper-rustls = { version = "0.27", default-features = false, features = [
"http1",
"http2",
], optional = true }
tokio = { version = "1.24.2", features = ["time"] }
tokio = { version = "1.24.2", features = ["macros", "time"] }
tower = { version = "0.4.13", optional = true }
async-trait = "^0.1.0"
tracing = "^0.1.0"
arc-swap = "^1.0.0"
simple_moving_average = "^1.0.0"
tracing-subscriber = "^0.2.0"
tokio-util = { version = "^0.7.0", features = ["rt"] }
rustls-webpki = "0.102"

[target.'cfg(target_family = "wasm")'.dependencies]
Expand Down
32 changes: 32 additions & 0 deletions ic-agent/src/agent/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,38 @@ impl AgentBuilder {
Agent::new(self.config)
}

#[cfg(all(feature = "reqwest", not(target_family = "wasm")))]
/// Set the dynamic transport layer for the [`Agent`], performing continuos discovery of the API boundary nodes and routing traffic via them based on the latencies.
pub async fn with_discovery_transport(self, client: reqwest::Client) -> Self {
use crate::agent::http_transport::{
dynamic_routing::{
dynamic_route_provider::{DynamicRouteProviderBuilder, IC0_SEED_DOMAIN},
node::Node,
snapshot::latency_based_routing::LatencyRoutingSnapshot,
},
route_provider::RouteProvider,
ReqwestTransport,
};

// TODO: This is a temporary solution to get the seed node.
let seed = Node::new(IC0_SEED_DOMAIN).unwrap();

let route_provider = DynamicRouteProviderBuilder::new(
LatencyRoutingSnapshot::new(),
vec![seed],
client.clone(),
)
.build()
.await;

let route_provider = Arc::new(route_provider) as Arc<dyn RouteProvider>;

let transport = ReqwestTransport::create_with_client_route(route_provider, client)
.expect("failed to create transport");

self.with_transport(transport)
}

/// Set the URL of the [Agent].
#[cfg(feature = "reqwest")]
pub fn with_url<S: Into<String>>(self, url: S) -> Self {
Expand Down
Loading