Skip to content

Commit

Permalink
chore: Update to new ic-agent version (#3445)
Browse files Browse the repository at this point in the history
* Update to new ic-agent version

* .

* fix some tests, add env var for disabling query cert

* per command

* fix other tests

* 0.30.2
  • Loading branch information
adamspofford-dfinity authored Nov 17, 2023
1 parent e91c27c commit 1496ae1
Show file tree
Hide file tree
Showing 16 changed files with 133 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ jobs:
path: /usr/local/bin
- name: Setup dfx binary
run: chmod +x /usr/local/bin/dfx
- name: Disable query verification in ic-ref
if: ${{ matrix.backend == 'ic-ref' }}
run: |
echo DFX_DISABLE_QUERY_VERIFICATION=1 >> $GITHUB_ENV
- name: start and deploy
run: |
pwd
Expand Down
92 changes: 79 additions & 13 deletions Cargo.lock

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

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ rust-version = "1.71.1"
license = "Apache-2.0"

[workspace.dependencies]
candid = { version = "0.9.0", features = [ "parser" ] }
ic-agent = "0.29.0"
candid = { version = "0.9.0", features = ["parser"] }
ic-agent = "0.30.2"
ic-asset = { path = "src/canisters/frontend/ic-asset" }
ic-cdk = "0.10.0"
ic-identity-hsm = "0.29.0"
ic-utils = "0.29.0"
ic-identity-hsm = "0.30.2"
ic-utils = "0.30.2"

aes-gcm = "0.9.4"
anyhow = "1.0.56"
anstyle = "1.0.0"
argon2 = "0.4.0"
backoff = { version = "0.4.0", features = [ "futures", "tokio" ] }
backoff = { version = "0.4.0", features = ["futures", "tokio"] }
base64 = "0.13.0"
byte-unit = "4.0.14"
bytes = "1.2.1"
Expand Down Expand Up @@ -69,19 +69,19 @@ url = "2.1.0"
walkdir = "2.3.2"

[patch.crates-io.ic-agent]
version = "0.29.0"
version = "0.30.2"
git = "https://github.com/dfinity/agent-rs.git"
rev = "b91b85b7b6ba6bfaf9dfd616b7c7c8f966bf8f68"
rev = "ed0862a45d5973ff123cbabc4ac40a89821b18c6"

[patch.crates-io.ic-identity-hsm]
version = "0.29.0"
version = "0.30.2"
git = "https://github.com/dfinity/agent-rs.git"
rev = "b91b85b7b6ba6bfaf9dfd616b7c7c8f966bf8f68"
rev = "ed0862a45d5973ff123cbabc4ac40a89821b18c6"

[patch.crates-io.ic-utils]
version = "0.29.0"
version = "0.30.2"
git = "https://github.com/dfinity/agent-rs.git"
rev = "b91b85b7b6ba6bfaf9dfd616b7c7c8f966bf8f68"
rev = "ed0862a45d5973ff123cbabc4ac40a89821b18c6"

[profile.release]
panic = 'abort'
Expand Down
1 change: 1 addition & 0 deletions e2e/tests-dfx/certificate.bash
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ teardown() {
# The wallet does not have a query call forward method (currently calls forward from wallet's update method)
# So call with users Identity as sender here
# There may need to be a query version of wallet_call
declare -x DFX_DISABLE_QUERY_VERIFICATION=1
assert_command dfx canister call certificate_backend hello_query '("Buckaroo")'
assert_eq '("Hullo, Buckaroo!")'
}
4 changes: 2 additions & 2 deletions src/canisters/frontend/ic-asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! # Example
//!
//! ```rust,no_run
//! use ic_agent::agent::{Agent, http_transport::ReqwestHttpReplicaV2Transport};
//! use ic_agent::agent::{Agent, http_transport::ReqwestTransport};
//! use ic_agent::identity::BasicIdentity;
//! use ic_utils::Canister;
//! use std::time::Duration;
Expand All @@ -12,7 +12,7 @@
//! # let pemfile = "";
//! # let canister_id = "";
//! let agent = Agent::builder()
//! .with_transport(ReqwestHttpReplicaV2Transport::create(replica_url)?)
//! .with_transport(ReqwestTransport::create(replica_url)?)
//! .with_identity(BasicIdentity::from_pem_file(pemfile)?)
//! .build()?;
//! let canister = Canister::builder()
Expand Down
6 changes: 3 additions & 3 deletions src/canisters/frontend/icx-asset/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ async fn main() -> anyhow::Result<()> {
let logger = support::new_logger();

let agent = Agent::builder()
.with_transport(
agent::http_transport::ReqwestHttpReplicaV2Transport::create(opts.replica.clone())?,
)
.with_transport(agent::http_transport::ReqwestTransport::create(
opts.replica.clone(),
)?)
.with_boxed_identity(create_identity(opts.pem))
.build()?;

Expand Down
3 changes: 2 additions & 1 deletion src/dfx-core/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ pub fn network_to_pathcompat(network_name: &str) -> String {

pub fn expiry_duration() -> Duration {
// 5 minutes is max ingress timeout
Duration::from_secs(60 * 5)
// 4 minutes accounts for possible replica drift
Duration::from_secs(60 * 4)
}
2 changes: 1 addition & 1 deletion src/dfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mime.workspace = true
mime_guess.workspace = true
net2 = "0.2.34"
num-traits.workspace = true
os_str_bytes = "6.3.0"
os_str_bytes = { version = "6.3.0", features = ["conversions"] }
patch = "0.7.0"
pem.workspace = true
petgraph = "0.6.0"
Expand Down
4 changes: 2 additions & 2 deletions src/dfx/src/commands/canister/deposit_cycles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ pub async fn exec(
opts: DepositCyclesOpts,
mut call_sender: &CallSender,
) -> DfxResult {
fetch_root_key_if_needed(env).await?;

let proxy_sender;

// choose default wallet if no wallet is specified
Expand All @@ -79,8 +81,6 @@ pub async fn exec(

let config = env.get_config_or_anyhow()?;

fetch_root_key_if_needed(env).await?;

if let Some(canister) = opts.canister.as_deref() {
deposit_cycles(env, canister, call_sender, cycles).await
} else if opts.all {
Expand Down
6 changes: 3 additions & 3 deletions src/dfx/src/commands/canister/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use candid::Principal;
use clap::Parser;
use dfx_core::identity::CallSender;
use ic_agent::agent::Transport;
use ic_agent::{agent::http_transport::ReqwestHttpReplicaV2Transport, RequestId};
use ic_agent::{agent::http_transport::ReqwestTransport, RequestId};
use std::{fs::File, path::Path};
use std::{io::Read, str::FromStr};

Expand Down Expand Up @@ -40,8 +40,8 @@ pub async fn exec(
message.validate()?;

let network = message.network.clone();
let transport = ReqwestHttpReplicaV2Transport::create(network)
.context("Failed to create transport object.")?;
let transport =
ReqwestTransport::create(network).context("Failed to create transport object.")?;
let content = hex::decode(&message.content).context("Failed to decode message content.")?;
let canister_id = Principal::from_text(message.canister_id.clone())
.with_context(|| format!("Failed to parse canister id {:?}.", message.canister_id))?;
Expand Down
3 changes: 3 additions & 0 deletions src/dfx/src/commands/cycles/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::nns_types::account_identifier::Subaccount;
use crate::lib::operations::cycles_ledger;
use crate::lib::root_key::fetch_root_key_if_needed;
use crate::util::{format_as_trillions, pretty_thousand_separators};
use candid::Principal;
use clap::Parser;
Expand Down Expand Up @@ -29,6 +30,8 @@ pub struct CyclesBalanceOpts {
}

pub async fn exec(env: &dyn Environment, opts: CyclesBalanceOpts) -> DfxResult {
fetch_root_key_if_needed(env).await?;

let agent = env.get_agent();

let owner = opts.owner.unwrap_or_else(|| {
Expand Down
Loading

0 comments on commit 1496ae1

Please sign in to comment.