Skip to content

Commit

Permalink
chore: Update ic-agent and ic-agent's reverse dependencies to v0.39 (#…
Browse files Browse the repository at this point in the history
…3282)

I created this PR by following these instructions from @nathanosdev:

> The following crates should use version 3.0.2:
> 1. `ic-response-verification`
> 2. `ic-certification`
> 3. `ic-certificate-verification`
> 4. `ic-http-certification`
> 5. `ic-cbor`
> 
> I recommend just setting them to `3` in `Cargo.toml` and `^3.0.2` in
`external_crates.bzl` so they can be updated more easily in the future.
That's how it's setup in `ic-http-gateway` too.
> And `ic-http-gateway` can be set to version `0.1.0`. The git tag
reference can be removed now.

I also updated `ic-agent` to 0.39 because that is the version of
`ic-agent` that `ic-http-gateway` v0.1.0 depends on. In doing so, I also
updated `ic-utils` and `ic-transport-types`. I also moved the
`ic-http-gateway` dependency to the workspace-level `Cargo.toml`.

It seems like there were a number of breaking changes in these crates,
so I also went through and fixed all the code that became broken.

---------

Co-authored-by: IDX GitLab Automation <[email protected]>
  • Loading branch information
anchpop and sa-idx-admin authored Jan 7, 2025
1 parent c741e34 commit 0cd1ac6
Show file tree
Hide file tree
Showing 28 changed files with 3,663 additions and 5,309 deletions.
2,796 changes: 999 additions & 1,797 deletions Cargo.Bazel.Fuzzing.json.lock

Large diffs are not rendered by default.

318 changes: 158 additions & 160 deletions Cargo.Bazel.Fuzzing.toml.lock

Large diffs are not rendered by default.

2,796 changes: 999 additions & 1,797 deletions Cargo.Bazel.json.lock

Large diffs are not rendered by default.

316 changes: 157 additions & 159 deletions Cargo.Bazel.toml.lock

Large diffs are not rendered by default.

2,339 changes: 1,167 additions & 1,172 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 10 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -558,26 +558,23 @@ hyper-rustls = { version = "0.27.3", default-features = false, features = [
] }
hyper-socks2 = { version = "0.9.1", default-features = false }
hyper-util = { version = "0.1.10", features = ["full"] }
ic-agent = { version = "0.37.1", features = [
"experimental_sync_call",
"hyper",
"reqwest",
"pem",
] }
ic-agent = { version = "0.39.2", features = ["pem", "ring"] }
ic-bn-lib = { git = "https://github.com/dfinity/ic-bn-lib", rev = "d74a6527fbaf8a2c1a7076983cc84f5c5a727923" }
ic-btc-interface = "0.2.2"
ic-cbor = "2.6.0"
ic-canister-sig-creation = { git = "https://github.com/dfinity/ic-canister-sig-creation", rev = "7f9e931954637526295269155881207f6c832d6d" }
ic-cbor = "3"
ic-cdk = "0.16.0"
ic-cdk-macros = "0.9.0"
ic-cdk-timers = "0.7.0"
ic-certificate-verification = "2.6.0"
ic-certification = "2.6.0"
ic-http-certification = "2.6.0"
ic-response-verification = "2.6.0"
ic-certificate-verification = "3"
ic-certification = "3"
ic-http-certification = "3"
ic-http-gateway = "0.1"
ic-response-verification = "3"
ic-sha3 = "1.0.0"
ic-stable-structures = "0.6.5"
ic-transport-types = { version = "0.37.1" }
ic-utils = { version = "0.37.0", features = ["raw"] }
ic-transport-types = { version = "0.39.2" }
ic-utils = { version = "0.39", features = ["raw"] }
ic_bls12_381 = { version = "0.10.0", default-features = false, features = [
"groups",
"pairings",
Expand Down
31 changes: 13 additions & 18 deletions bazel/external_crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -569,13 +569,8 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
version = "^0.18.11",
),
"ic-agent": crate.spec(
version = "^0.37.1",
features = [
"experimental_sync_call",
"hyper",
"reqwest",
"pem",
],
version = "^0.39.2",
features = ["pem", "ring"],
),
"ic-bn-lib": crate.spec(
git = "https://github.com/dfinity/ic-bn-lib",
Expand All @@ -588,10 +583,11 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
version = "^0.2.0",
),
"ic-canister-sig-creation": crate.spec(
version = "^1.0.1",
git = "https://github.com/dfinity/ic-canister-sig-creation",
rev = "7f9e931954637526295269155881207f6c832d6d",
),
"ic-cbor": crate.spec(
version = "2.6.0",
version = "3.0.2",
),
"ic-cdk": crate.spec(
version = "^0.16.0",
Expand All @@ -606,17 +602,16 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
version = "^0.3.1",
),
"ic-certification": crate.spec(
version = "2.6.0",
version = "3.0.2",
),
"ic-certificate-verification": crate.spec(
version = "2.6.0",
version = "3.0.2",
),
"ic-http-certification": crate.spec(
version = "2.6.0",
version = "3.0.2",
),
"ic-http-gateway": crate.spec(
git = "https://github.com/dfinity/http-gateway",
tag = "0.1.0-b0",
version = "0.1.0",
),
"ic-metrics-encoder": crate.spec(
version = "^1.1.1",
Expand All @@ -626,7 +621,7 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
default_features = False,
),
"ic-response-verification": crate.spec(
version = "2.6.0",
version = "3.0.2",
),
"ic-sha3": crate.spec(
version = "^1.0.0",
Expand All @@ -646,10 +641,10 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
version = "^3.0.0",
),
"ic-transport-types": crate.spec(
version = "^0.37.1",
version = "^0.39.2",
),
"ic-utils": crate.spec(
version = "^0.37.0",
version = "^0.39.0",
features = ["raw"],
),
"ic-verify-bls-signature": crate.spec(
Expand Down Expand Up @@ -879,7 +874,7 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
],
),
"opentelemetry_sdk": crate.spec(
version = "^0.27.0",
version = "^0.27.1",
features = [
"trace",
"rt-tokio",
Expand Down
2 changes: 1 addition & 1 deletion packages/ic-signature-verification/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ documentation = "https://docs.rs/ic-signature-verification"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ic-canister-sig-creation = "1.0"
ic-canister-sig-creation = { workspace = true }
ic-certification = { workspace = true }
ic-verify-bls-signature = { version = "0.6", default-features = false, features = [
"alloc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,10 @@ impl Check for Checker {
})?;

// Phase 4 - Ensure canister mentions known domain.
let request = HttpRequest {
method: String::from("GET"),
url: String::from("/.well-known/ic-domains"),
headers: vec![],
body: vec![],
};
let request = HttpRequest::get("/.well-known/ic-domains").build();

let (response,) = HttpRequestCanister::create(&self.agent, canister_id)
.http_request(&request.method, &request.url, vec![], vec![], None)
.http_request(&request.method(), &request.url(), vec![], vec![], None)
.call()
.await
.map_err(|_| CheckError::KnownDomainsUnavailable {
Expand All @@ -197,16 +192,18 @@ impl Check for Checker {
}?;

// Check response certification
let response_for_verification = HttpResponse {
status_code: response.status_code,
headers: response
let response_for_verification = HttpResponse::ok(
// body
response.body.clone(),
// headers
response
.headers
.iter()
.map(|field| (field.0.to_string(), field.1.to_string()))
.collect::<Vec<(String, String)>>(),
body: response.body.clone(),
upgrade: response.upgrade,
};
)
.with_upgrade(response.upgrade.unwrap_or_default())
.build();
let max_cert_time_offset_ns = 300_000_000_000;
let current_time_ns = SystemTime::now()
.duration_since(UNIX_EPOCH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ use axum::{
use candid::{DecoderConfig, Principal};
use chacha20poly1305::{KeyInit, XChaCha20Poly1305};
use clap::Parser;
use ic_agent::{
agent::http_transport::reqwest_transport::ReqwestTransport, identity::Secp256k1Identity, Agent,
};
use ic_agent::{identity::Secp256k1Identity, Agent};
use instant_acme::{Account, AccountCredentials, NewAccount};
use opentelemetry::{
metrics::{Counter, Histogram, MeterProvider as _},
Expand Down Expand Up @@ -198,15 +196,13 @@ async fn main() -> Result<(), Error> {
static USER_AGENT: &str = "Ic-Certificate-Issuer";
let client = reqwest::Client::builder().user_agent(USER_AGENT).build()?;

let transport =
ReqwestTransport::create_with_client(cli.orchestrator_uri.to_string(), client)?;

let f = File::open(cli.identity_path).context("failed to open identity file")?;
let identity = Secp256k1Identity::from_pem(f).context("failed to create basic identity")?;

let agent = Agent::builder()
.with_identity(identity)
.with_transport(transport)
.with_url(cli.orchestrator_uri.to_string())
.with_http_client(client)
.build()?;

let root_key = cli
Expand Down
10 changes: 3 additions & 7 deletions rs/http_endpoints/fuzz/fuzz_targets/execute_call_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ use axum::body::Body;
use bytes::Bytes;
use http_body_util::Full;
use hyper::{Method, Request, Response};
use ic_agent::{
agent::{http_transport::reqwest_transport::ReqwestTransport, UpdateBuilder},
export::Principal,
identity::AnonymousIdentity,
Agent,
};
use ic_agent::{agent::UpdateBuilder, export::Principal, identity::AnonymousIdentity, Agent};
use ic_config::http_handler::Config;
use ic_error_types::{ErrorCode, UserError};
use ic_http_endpoints_public::{call_v2, IngressValidatorBuilder};
Expand Down Expand Up @@ -166,7 +161,8 @@ fn new_update_call(
) -> Vec<u8> {
let agent = Agent::builder()
.with_identity(AnonymousIdentity)
.with_transport(ReqwestTransport::create(format!("http://{}", addr)).unwrap())
.with_url(format!("http://{}", addr))
.with_http_client(reqwest::Client::new())
.build()
.unwrap();
let update = UpdateBuilder::new(&agent, effective_canister_id, content.method_name)
Expand Down
13 changes: 5 additions & 8 deletions rs/monitoring/tracing/jaeger_exporter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ pub fn jaeger_exporter(
.build()?;

let tracer = sdk_trace::TracerProvider::builder()
.with_config(
sdk_trace::Config::default()
.with_sampler(sdk_trace::Sampler::TraceIdRatioBased(0.01))
.with_resource(Resource::new(vec![KeyValue::new(
"service.name",
service_name,
)])),
)
.with_sampler(sdk_trace::Sampler::TraceIdRatioBased(0.01))
.with_resource(Resource::new(vec![KeyValue::new(
"service.name",
service_name,
)]))
.with_batch_exporter(span_exporter, sdk_runtime::Tokio)
.build();

Expand Down
5 changes: 3 additions & 2 deletions rs/nervous_system/agent/src/agent_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ impl CallCanisters for Agent {
.with_arg(request_bytes)
.call()
.await?;
match request {
let (response, _cert) = match request {
ic_agent::agent::CallResponse::Response(response) => response,
ic_agent::agent::CallResponse::Poll(request_id) => {
self.wait(&request_id, canister_id).await?
}
}
};
response
} else {
self.query(&canister_id, request.method())
.with_arg(request_bytes)
Expand Down
2 changes: 1 addition & 1 deletion rs/pocket_ic_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ic-crypto-iccsa = { path = "../crypto/iccsa" }
ic-crypto-sha2 = { path = "../crypto/sha2" }
ic-crypto-utils-threshold-sig-der = { path = "../crypto/utils/threshold_sig_der" }
ic-error-types = { path = "../types/error_types" }
ic-http-gateway = { git = "https://github.com/dfinity/http-gateway", tag = "0.1.0-b0" }
ic-http-gateway = { workspace = true }
ic-http-endpoints-public = { path = "../http_endpoints/public" }
ic-https-outcalls-adapter = { path = "../https_outcalls/adapter" }
ic-https-outcalls-adapter-client = { path = "../https_outcalls/client" }
Expand Down
3 changes: 1 addition & 2 deletions rs/pocket_ic_server/src/state_api/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,7 @@ async fn handler(
|_| ErrorCause::RequestTooLarge,
)
})?
.to_bytes()
.to_vec();
.to_bytes();

let args = HttpGatewayRequestArgs {
canister_request: CanisterRequest::from_parts(parts, body),
Expand Down
19 changes: 6 additions & 13 deletions rs/pocket_ic_server/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use candid::{Encode, Principal};
use ic_agent::agent::{http_transport::ReqwestTransport, CallResponse};
use ic_agent::agent::CallResponse;
use ic_cdk::api::management_canister::main::CanisterIdRecord;
use ic_cdk::api::management_canister::provisional::ProvisionalCreateCanisterWithCyclesArgument;
use ic_interfaces_registry::{
Expand Down Expand Up @@ -313,14 +313,10 @@ async fn test_gateway(server_url: Url, https: bool) {
}
let client = builder.build().unwrap();

// create agent with custom transport
let transport = ReqwestTransport::create_with_client(
format!("{}://{}:{}", proto, localhost, port),
client.clone(),
)
.unwrap();
// create agent
let agent = ic_agent::Agent::builder()
.with_transport(transport)
.with_url(format!("{}://{}:{}", proto, localhost, port))
.with_http_client(client.clone())
.build()
.unwrap();
agent.fetch_root_key().await.unwrap();
Expand Down Expand Up @@ -897,12 +893,9 @@ fn test_specified_id_call_v3() {
.build()
.unwrap();
rt.block_on(async {
let transport = ReqwestTransport::create(endpoint.clone())
.unwrap()
.with_use_call_v3_endpoint();

let agent = ic_agent::Agent::builder()
.with_transport(transport)
.with_url(endpoint)
.with_http_client(reqwest::Client::new())
.build()
.unwrap();
agent.fetch_root_key().await.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ DEPENDENCIES = [
"@crate_index//:chrono",
"@crate_index//:ciborium",
"@crate_index//:ic-agent",
"@crate_index//:reqwest",
"@crate_index//:rusqlite",
"@crate_index//:serde",
"@crate_index//:tokio",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ic-ledger-hash-of = { path = "../../../../packages/ic-ledger-hash-of" }
ic-types = { path = "../../../types/types" }
icp-ledger = { path = "../../../ledger_suite/icp" }
on_wire = { path = "../../../rust_canisters/on_wire" }
reqwest = { workspace = true }
rusqlite = { version = "~0.28.0", features = ["bundled"] }
serde = { workspace = true }
tokio = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(clippy::disallowed_types)]
use dfn_protobuf::{ProtoBuf, ToProto};
use ic_agent::agent::http_transport::reqwest_transport::ReqwestTransport;
use ic_agent::identity::AnonymousIdentity;
use ic_agent::{Agent, AgentError, NonceGenerator};
use ic_ledger_core::block::EncodedBlock;
Expand Down Expand Up @@ -47,7 +46,8 @@ fn make_agent(url: Url) -> Result<Agent, AgentError> {
let is_exchanges_testnet = url.host_str() == Some("exchanges.testnet.dfinity.network");
Agent::builder()
.with_identity(AnonymousIdentity)
.with_transport(ReqwestTransport::create(url)?)
.with_url(url)
.with_http_client(reqwest::Client::new())
.with_nonce_generator(TimestampBlob::default())
// The testnet has an old replica version and the query
// verification wouldn't work so we disable it
Expand Down
5 changes: 2 additions & 3 deletions rs/rosetta-api/icp/tests/system_tests/common/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::common::constants::MAX_ROSETTA_SYNC_ATTEMPTS;
use candid::{Decode, Encode};
use ic_agent::agent::http_transport::ReqwestTransport;
use ic_agent::identity::BasicIdentity;
use ic_agent::Agent;
use ic_agent::Identity;
Expand Down Expand Up @@ -37,10 +36,10 @@ pub async fn get_custom_agent(basic_identity: Arc<dyn Identity>, port: u16) -> A
let replica_url = Url::parse(&format!("http://localhost:{}", port)).unwrap();

// Setup the agent
let transport = ReqwestTransport::create(replica_url.clone()).unwrap();
let agent = Agent::builder()
.with_url(replica_url.clone())
.with_http_client(reqwest::Client::new())
.with_identity(basic_identity)
.with_arc_transport(Arc::new(transport))
.build()
.unwrap();

Expand Down
9 changes: 4 additions & 5 deletions rs/rosetta-api/icrc1/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ use axum::{
Router,
};
use clap::{Parser, ValueEnum};
use ic_agent::{
agent::http_transport::reqwest_transport::ReqwestTransport, identity::AnonymousIdentity, Agent,
};
use ic_agent::{identity::AnonymousIdentity, Agent};
use ic_base_types::CanisterId;
use ic_icrc_rosetta::{
common::constants::{BLOCK_SYNC_WAIT_SECS, MAX_BLOCK_SYNC_WAIT_SECS},
Expand Down Expand Up @@ -294,10 +292,11 @@ async fn main() -> Result<()> {

let ic_agent = Agent::builder()
.with_identity(AnonymousIdentity)
.with_transport(ReqwestTransport::create(
.with_url(
Url::parse(&network_url)
.context(format!("Failed to parse URL {}", network_url.clone()))?,
)?)
)
.with_http_client(reqwest::Client::new())
.build()?;

// Only fetch root key if the network is not the mainnet
Expand Down
Loading

0 comments on commit 0cd1ac6

Please sign in to comment.