From f25ed140989733b9bac1e426f181af19dea3a49d Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 14 Sep 2020 13:06:24 -0700 Subject: [PATCH 01/10] init --- Cargo.lock | 11 +++++- Cargo.toml | 2 +- nix/sources.json | 8 ++-- src/dfx/Cargo.toml | 10 +++-- src/dfx/src/commands/canister/call.rs | 29 ++++++++++----- src/dfx/src/commands/canister/create.rs | 8 ++-- src/dfx/src/commands/canister/delete.rs | 21 ++++++++--- src/dfx/src/commands/canister/install.rs | 37 ++++++++++++++++++- src/dfx/src/commands/canister/mod.rs | 22 ++++++++++- .../src/commands/canister/request_status.rs | 15 +++++--- src/dfx/src/commands/canister/start.rs | 22 ++++++++--- src/dfx/src/commands/canister/status.rs | 22 ++++++++--- src/dfx/src/commands/canister/stop.rs | 21 ++++++++--- src/dfx/src/commands/deploy.rs | 5 ++- src/dfx/src/commands/ping.rs | 4 +- src/dfx/src/lib/environment.rs | 19 ++++++++-- src/dfx/src/lib/error/mod.rs | 8 ++++ src/dfx/src/lib/installers/assets.rs | 16 ++++++-- src/dfx/src/lib/message.rs | 4 +- .../operations/canister/create_canister.rs | 27 +++++++++----- .../operations/canister/deploy_canisters.rs | 27 +++++++++++--- .../operations/canister/install_canister.rs | 22 ++++++++--- src/dfx/src/lib/provider.rs | 4 +- src/dfx/src/lib/waiter.rs | 7 ++-- src/dfx/src/util/mod.rs | 12 +++++- 25 files changed, 287 insertions(+), 96 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa7b5354bb..c52ca5521a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -982,6 +982,7 @@ dependencies = [ "futures", "hex", "hotwatch", + "humanize-rs", "ic-agent", "ic-types", "indicatif", @@ -1579,6 +1580,12 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +[[package]] +name = "humanize-rs" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "016b02deb8b0c415d8d56a6f0ab265e50c22df61194e37f9be75ed3a722de8a6" + [[package]] name = "humantime" version = "1.3.0" @@ -1644,7 +1651,7 @@ dependencies = [ [[package]] name = "ic-agent" version = "0.1.0" -source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=next#35a0f9851cf8cceea34acf405ba50c84ab5fbc5e" +source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=pshahi/ingress-expiry-two#b57f659d431198feaca98f7ef9adf9b1fdff7807" dependencies = [ "async-trait", "base32", @@ -1672,7 +1679,7 @@ dependencies = [ [[package]] name = "ic-types" version = "0.1.1" -source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=next#35a0f9851cf8cceea34acf405ba50c84ab5fbc5e" +source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=pshahi/ingress-expiry-two#b57f659d431198feaca98f7ef9adf9b1fdff7807" dependencies = [ "base32", "crc32fast", diff --git a/Cargo.toml b/Cargo.toml index eaa1d3163d..faa8aa9215 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,4 +4,4 @@ members = [ ] [patch.crates-io] -ic-types = { git = "ssh://git@github.com/dfinity-lab/agent-rust.git", branch = "next", version = "0.1.1" } +ic-types = { git = "ssh://git@github.com/dfinity-lab/agent-rust.git", branch = "pshahi/ingress-expiry-two", version = "0.1.1" } diff --git a/nix/sources.json b/nix/sources.json index 9d39370420..93cd25e749 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -39,14 +39,14 @@ }, "dfinity": { "repo": "ssh://git@github.com/dfinity-lab/dfinity", - "rev": "70434f1ecac5227dc8e5d30635f7aceb7c257e3f", - "tag": "release-2020-09-04.RC00", + "rev": "d0856d8d60b5a2d2a7b6f50fa0fa1d68db9264dc", + "branch": "akhi3030/expiry-time", "type": "git" }, "ic-ref": { "repo": "ssh://git@github.com/dfinity-lab/ic-ref", - "rev": "493f0862ddd9970b8fb09e4e97f95fab1764b18e", - "tag": "release-0.9", + "rev": "7c1e8bae654588790374ec1a23f40f579405b31c", + "tag": "0.10.2", "type": "git" }, "motoko": { diff --git a/src/dfx/Cargo.toml b/src/dfx/Cargo.toml index 2e24f991f0..b9110ce36f 100644 --- a/src/dfx/Cargo.toml +++ b/src/dfx/Cargo.toml @@ -37,6 +37,7 @@ lazy-init = "0.3.0" lazy_static = "1.4.0" libflate = "0.1.27" hotwatch = "0.4.3" +humanize-rs = "0.1.5" mockall = "0.6.0" pem = "0.7.0" petgraph = "0.5.0" @@ -68,14 +69,15 @@ wasmparser = "0.45.0" [dependencies.ic-agent] version = "0.1.0" git = "ssh://git@github.com/dfinity-lab/agent-rust.git" -branch = "next" -rev = "35a0f9851cf8cceea34acf405ba50c84ab5fbc5e" +branch = "pshahi/ingress-expiry-two" +rev = "b57f659d431198feaca98f7ef9adf9b1fdff7807" [dependencies.ic-types] version = "0.1.1" git = "ssh://git@github.com/dfinity-lab/agent-rust.git" -branch = "next" -rev = "35a0f9851cf8cceea34acf405ba50c84ab5fbc5e" +branch = "pshahi/ingress-expiry-two" +rev = "b57f659d431198feaca98f7ef9adf9b1fdff7807" + [dev-dependencies] env_logger = "0.6" diff --git a/src/dfx/src/commands/canister/call.rs b/src/dfx/src/commands/canister/call.rs index be26401aba..a87972c80d 100644 --- a/src/dfx/src/commands/canister/call.rs +++ b/src/dfx/src/commands/canister/call.rs @@ -3,8 +3,8 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::waiter::create_waiter; -use crate::util::{blob_from_arguments, get_candid_type, print_idl_blob}; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::{blob_from_arguments, expiry_duration, get_candid_type, print_idl_blob}; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_types::principal::Principal as CanisterId; use std::option::Option; @@ -125,26 +125,35 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { // Get the argument, get the type, convert the argument to the type and return // an error if any of it doesn't work. let arg_value = blob_from_arguments(arguments, arg_type, &method_type)?; - let client = env + let agent = env .get_agent() .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); + + let timeout = args.value_of("expiry_duration"); + let duration = expiry_duration(timeout)?; + if is_query { - let blob = runtime.block_on(client.query_raw(&canister_id, method_name, &arg_value))?; + let blob = + runtime.block_on(agent.query_raw(&canister_id, method_name, &arg_value, None))?; print_idl_blob(&blob, output_type, &method_type) .map_err(|e| DfxError::InvalidData(format!("Invalid IDL blob: {}", e)))?; } else if args.is_present("async") { - let request_id = - runtime.block_on(client.update_raw(&canister_id, method_name, &arg_value))?; - + let request_id = runtime.block_on( + agent + .update(&canister_id, &method_name) + .with_arg(&arg_value) + .call(), + )?; eprint!("Request ID: "); println!("0x{}", String::from(request_id)); } else { let blob = runtime.block_on( - client + agent .update(&canister_id, &method_name) .with_arg(&arg_value) - .call_and_wait(create_waiter()), + .expire_after(duration) + .call_and_wait(waiter_with_timeout(duration)), )?; print_idl_blob(&blob, output_type, &method_type) @@ -152,4 +161,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { } Ok(()) -} +} \ No newline at end of file diff --git a/src/dfx/src/commands/canister/create.rs b/src/dfx/src/commands/canister/create.rs index 9954edff2b..88ef4bc369 100644 --- a/src/dfx/src/commands/canister/create.rs +++ b/src/dfx/src/commands/canister/create.rs @@ -29,18 +29,20 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; + let timeout = args.value_of("expiry_duration"); + if let Some(canister_name) = args.value_of("canister_name") { - create_canister(env, canister_name)?; + create_canister(env, canister_name, timeout)?; Ok(()) } else if args.is_present("all") { // Create all canisters. if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - create_canister(env, canister_name)?; + create_canister(env, canister_name, timeout)?; } } Ok(()) } else { Err(DfxError::CanisterNameMissing()) } -} +} \ No newline at end of file diff --git a/src/dfx/src/commands/canister/delete.rs b/src/dfx/src/commands/canister/delete.rs index 008428779b..0b142efc41 100644 --- a/src/dfx/src/commands/canister/delete.rs +++ b/src/dfx/src/commands/canister/delete.rs @@ -2,7 +2,8 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; @@ -28,7 +29,12 @@ pub fn construct() -> App<'static, 'static> { ) } -async fn delete_canister(env: &dyn Environment, agent: &Agent, canister_name: &str) -> DfxResult { +async fn delete_canister( + env: &dyn Environment, + agent: &Agent, + canister_name: &str, + timeout: Option<&str>, +) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let mut canister_id_store = CanisterIdStore::for_env(env)?; @@ -39,8 +45,9 @@ async fn delete_canister(env: &dyn Environment, agent: &Agent, canister_name: &s canister_name, canister_id.to_text(), ); + let duration = expiry_duration(timeout)?; - mgr.delete_canister(create_waiter(), &canister_id) + mgr.delete_canister(waiter_with_timeout(duration), &canister_id) .await .map_err(DfxError::from)?; @@ -57,19 +64,21 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .get_agent() .ok_or(DfxError::CommandMustBeRunInAProject)?; + let timeout = args.value_of("expiry_duration"); + let mut runtime = Runtime::new().expect("Unable to create a runtime"); if let Some(canister_name) = args.value_of("canister_name") { - runtime.block_on(delete_canister(env, &agent, &canister_name))?; + runtime.block_on(delete_canister(env, &agent, &canister_name, timeout))?; Ok(()) } else if args.is_present("all") { if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - runtime.block_on(delete_canister(env, &agent, &canister_name))?; + runtime.block_on(delete_canister(env, &agent, &canister_name, timeout))?; } } Ok(()) } else { Err(DfxError::CanisterNameMissing()) } -} +} \ No newline at end of file diff --git a/src/dfx/src/commands/canister/install.rs b/src/dfx/src/commands/canister/install.rs index 79217af9b5..96f8170c88 100644 --- a/src/dfx/src/commands/canister/install.rs +++ b/src/dfx/src/commands/canister/install.rs @@ -6,7 +6,9 @@ use crate::lib::models::canister_id_store::CanisterIdStore; use crate::lib::operations::canister::install_canister; use clap::{App, Arg, ArgMatches, SubCommand}; -use ic_agent::{ComputeAllocation, InstallMode}; +use humanize_rs::bytes::{Bytes, Unit}; +use ic_agent::{ComputeAllocation, InstallMode, MemoryAllocation}; + use std::convert::TryFrom; use std::str::FromStr; use tokio::runtime::Runtime; @@ -51,6 +53,13 @@ pub fn construct() -> App<'static, 'static> { .takes_value(true) .validator(compute_allocation_validator), ) + .arg( + Arg::with_name("memory-allocation") + .help(UserMessage::InstallMemoryAllocation.to_str()) + .long("memory-allocation") + .takes_value(true) + .validator(memory_allocation_validator), + ) } fn compute_allocation_validator(compute_allocation: String) -> Result<(), String> { @@ -62,18 +71,38 @@ fn compute_allocation_validator(compute_allocation: String) -> Result<(), String Err("Must be a percent between 0 and 100".to_string()) } +fn memory_allocation_validator(memory_allocation: String) -> Result<(), String> { + let limit = Bytes::new(256, Unit::TByte).map_err(|_| "Parse Overflow.")?; + if let Ok(bytes) = memory_allocation.parse::() { + if bytes.size() <= limit.size() { + return Ok(()); + } + } + Err("Must be a value between 0..256 TB inclusive.".to_string()) +} + pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let config = env .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; + + let timeout = args.value_of("expiry_duration"); + let agent = env .get_agent() .ok_or(DfxError::CommandMustBeRunInAProject)?; + let compute_allocation = args.value_of("compute-allocation").map(|arg| { ComputeAllocation::try_from(arg.parse::().unwrap()) .expect("Compute Allocation must be a percentage.") }); + let memory_allocation: Option = + args.value_of("memory_allocation").map(|arg| { + MemoryAllocation::try_from(u64::try_from(arg.parse::().unwrap().size()).unwrap()) + .expect("Memory allocation must be between 0 and 2^48 (i.e 256TB), inclusively.") + }); + let mode = InstallMode::from_str(args.value_of("mode").unwrap())?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); @@ -90,6 +119,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { &canister_info, compute_allocation, mode, + memory_allocation, + timeout, ))?; Ok(()) } else if args.is_present("all") { @@ -105,6 +136,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { &canister_info, compute_allocation, mode.clone(), + memory_allocation, + timeout, ))?; } } @@ -112,4 +145,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { } else { Err(DfxError::CanisterNameMissing()) } -} +} \ No newline at end of file diff --git a/src/dfx/src/commands/canister/mod.rs b/src/dfx/src/commands/canister/mod.rs index c7f4f3d818..660795c6b6 100644 --- a/src/dfx/src/commands/canister/mod.rs +++ b/src/dfx/src/commands/canister/mod.rs @@ -4,6 +4,7 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::provider::create_agent_environment; use clap::{App, Arg, ArgMatches, SubCommand}; +use humanize_rs::duration::parse; mod call; mod create; @@ -38,9 +39,28 @@ pub fn construct() -> App<'static, 'static> { .long("network") .takes_value(true), ) + .arg( + Arg::with_name("expiry-duration") + .long("expiry-duration") + .help(UserMessage::CanisterCallExpiryDuration.to_str()) + .takes_value(true) + .default_value("5m") + .validator(expiry_duration_validator), + ) .subcommands(builtins().into_iter().map(|x| x.get_subcommand().clone())) } +fn expiry_duration_validator(expiry_duration: String) -> Result<(), String> { + if let Ok(_ed) = parse(&expiry_duration) { + return Ok(()); + } + let err = format!( + r#""Invalid input: {}. Expected a duration-type string e.g. "1h", "1h 30m""#, + expiry_duration + ); + Err(err) +} + pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let subcommand = args.subcommand(); @@ -60,4 +80,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { eprintln!(); Ok(()) } -} +} \ No newline at end of file diff --git a/src/dfx/src/commands/canister/request_status.rs b/src/dfx/src/commands/canister/request_status.rs index 44f31e9e4e..c68ab140bf 100644 --- a/src/dfx/src/commands/canister/request_status.rs +++ b/src/dfx/src/commands/canister/request_status.rs @@ -1,9 +1,9 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; use crate::util::clap::validators; -use crate::util::print_idl_blob; +use crate::util::{expiry_duration, print_idl_blob}; use clap::{App, Arg, ArgMatches, SubCommand}; use delay::Waiter; use ic_agent::{AgentError, Replied, RequestId, RequestStatusResponse}; @@ -35,13 +35,17 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let mut waiter = create_waiter(); + let timeout = args.value_of("expiry_duration"); + + let duration = expiry_duration(timeout)?; + + let mut waiter = waiter_with_timeout(duration); let Replied::CallReplied(blob) = runtime .block_on(async { waiter.start(); loop { - match agent.request_status_raw(&request_id).await? { + match agent.request_status_raw(&request_id, None).await? { RequestStatusResponse::Replied { reply } => return Ok(reply), RequestStatusResponse::Rejected { reject_code, @@ -55,6 +59,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { RequestStatusResponse::Unknown => (), RequestStatusResponse::Received => (), RequestStatusResponse::Processing => (), + RequestStatusResponse::Done => (), }; waiter @@ -66,4 +71,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { print_idl_blob(&blob, None, &None) .map_err(|e| DfxError::InvalidData(format!("Invalid IDL blob: {}", e)))?; Ok(()) -} +} \ No newline at end of file diff --git a/src/dfx/src/commands/canister/start.rs b/src/dfx/src/commands/canister/start.rs index 3becc2c92c..3f4fabd4aa 100644 --- a/src/dfx/src/commands/canister/start.rs +++ b/src/dfx/src/commands/canister/start.rs @@ -2,7 +2,8 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; @@ -28,12 +29,19 @@ pub fn construct() -> App<'static, 'static> { ) } -async fn start_canister(env: &dyn Environment, agent: &Agent, canister_name: &str) -> DfxResult { +async fn start_canister( + env: &dyn Environment, + agent: &Agent, + canister_name: &str, + timeout: Option<&str>, +) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let canister_id_store = CanisterIdStore::for_env(env)?; let canister_id = canister_id_store.get(canister_name)?; + let duration = expiry_duration(timeout)?; + info!( log, "Starting code for canister {}, with canister_id {}", @@ -41,7 +49,7 @@ async fn start_canister(env: &dyn Environment, agent: &Agent, canister_name: &st canister_id.to_text(), ); - mgr.start_canister(create_waiter(), &canister_id) + mgr.start_canister(waiter_with_timeout(duration), &canister_id) .await .map_err(DfxError::from)?; @@ -58,17 +66,19 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let mut runtime = Runtime::new().expect("Unable to create a runtime"); + let timeout = args.value_of("expiry_duration"); + if let Some(canister_name) = args.value_of("canister_name") { - runtime.block_on(start_canister(env, &agent, &canister_name))?; + runtime.block_on(start_canister(env, &agent, &canister_name, timeout))?; Ok(()) } else if args.is_present("all") { if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - runtime.block_on(start_canister(env, &agent, &canister_name))?; + runtime.block_on(start_canister(env, &agent, &canister_name, timeout))?; } } Ok(()) } else { Err(DfxError::CanisterNameMissing()) } -} +} \ No newline at end of file diff --git a/src/dfx/src/commands/canister/status.rs b/src/dfx/src/commands/canister/status.rs index 938ae1279f..36000dc838 100644 --- a/src/dfx/src/commands/canister/status.rs +++ b/src/dfx/src/commands/canister/status.rs @@ -2,7 +2,8 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; @@ -28,14 +29,21 @@ pub fn construct() -> App<'static, 'static> { ) } -async fn canister_status(env: &dyn Environment, agent: &Agent, canister_name: &str) -> DfxResult { +async fn canister_status( + env: &dyn Environment, + agent: &Agent, + canister_name: &str, + timeout: Option<&str>, +) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let canister_id_store = CanisterIdStore::for_env(env)?; let canister_id = canister_id_store.get(canister_name)?; + let duration = expiry_duration(timeout)?; + let status = mgr - .canister_status(create_waiter(), &canister_id) + .canister_status(waiter_with_timeout(duration), &canister_id) .await .map_err(DfxError::from)?; info!(log, "Canister {}'s status is {}.", canister_name, status); @@ -53,17 +61,19 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let mut runtime = Runtime::new().expect("Unable to create a runtime"); + let timeout = args.value_of("expiry_duration"); + if let Some(canister_name) = args.value_of("canister_name") { - runtime.block_on(canister_status(env, &agent, &canister_name))?; + runtime.block_on(canister_status(env, &agent, &canister_name, timeout))?; Ok(()) } else if args.is_present("all") { if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - runtime.block_on(canister_status(env, &agent, &canister_name))?; + runtime.block_on(canister_status(env, &agent, &canister_name, timeout))?; } } Ok(()) } else { Err(DfxError::CanisterNameMissing()) } -} +} \ No newline at end of file diff --git a/src/dfx/src/commands/canister/stop.rs b/src/dfx/src/commands/canister/stop.rs index 016e88495d..e20ad59de5 100644 --- a/src/dfx/src/commands/canister/stop.rs +++ b/src/dfx/src/commands/canister/stop.rs @@ -2,7 +2,8 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; @@ -28,12 +29,19 @@ pub fn construct() -> App<'static, 'static> { ) } -async fn stop_canister(env: &dyn Environment, agent: &Agent, canister_name: &str) -> DfxResult { +async fn stop_canister( + env: &dyn Environment, + agent: &Agent, + canister_name: &str, + timeout: Option<&str>, +) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let canister_id_store = CanisterIdStore::for_env(env)?; let canister_id = canister_id_store.get(canister_name)?; + let duration = expiry_duration(timeout)?; + info!( log, "Stopping code for canister {}, with canister_id {}", @@ -41,7 +49,7 @@ async fn stop_canister(env: &dyn Environment, agent: &Agent, canister_name: &str canister_id.to_text(), ); - mgr.stop_canister(create_waiter(), &canister_id) + mgr.stop_canister(waiter_with_timeout(duration), &canister_id) .await .map_err(DfxError::from)?; @@ -57,18 +65,19 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); + let timeout = args.value_of("expiry_duration"); if let Some(canister_name) = args.value_of("canister_name") { - runtime.block_on(stop_canister(env, &agent, &canister_name))?; + runtime.block_on(stop_canister(env, &agent, &canister_name, timeout))?; Ok(()) } else if args.is_present("all") { if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - runtime.block_on(stop_canister(env, &agent, &canister_name))?; + runtime.block_on(stop_canister(env, &agent, &canister_name, timeout))?; } } Ok(()) } else { Err(DfxError::CanisterNameMissing()) } -} +} \ No newline at end of file diff --git a/src/dfx/src/commands/deploy.rs b/src/dfx/src/commands/deploy.rs index 5cbccdfe1b..e750b9f03e 100644 --- a/src/dfx/src/commands/deploy.rs +++ b/src/dfx/src/commands/deploy.rs @@ -25,7 +25,8 @@ pub fn construct() -> App<'static, 'static> { pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let env = create_agent_environment(env, args)?; + let timeout = args.value_of("expiry_duration"); let canister = args.value_of("canister_name"); - deploy_canisters(&env, canister) -} + deploy_canisters(&env, canister, timeout) +} \ No newline at end of file diff --git a/src/dfx/src/commands/ping.rs b/src/dfx/src/commands/ping.rs index 4d38ba5afb..7038a659de 100644 --- a/src/dfx/src/commands/ping.rs +++ b/src/dfx/src/commands/ping.rs @@ -37,7 +37,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { other => Err(other), })?; - let env = AgentEnvironment::new(env, network_descriptor)?; + let env = AgentEnvironment::new(env, network_descriptor, args)?; let agent = env .get_agent() @@ -48,4 +48,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { println!("{}", status); Ok(()) -} +} \ No newline at end of file diff --git a/src/dfx/src/lib/environment.rs b/src/dfx/src/lib/environment.rs index 50b1a5ff8b..e82944e885 100644 --- a/src/dfx/src/lib/environment.rs +++ b/src/dfx/src/lib/environment.rs @@ -5,7 +5,9 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::identity::identity_manager::IdentityManager; use crate::lib::network::network_descriptor::NetworkDescriptor; use crate::lib::progress_bar::ProgressBar; +use crate::util::expiry_duration; +use clap::ArgMatches; use ic_agent::{Agent, AgentConfig, Identity}; use semver::Version; use slog::{Logger, Record}; @@ -13,6 +15,7 @@ use std::collections::BTreeMap; use std::fs::create_dir_all; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; +use std::time::Duration; #[cfg(test)] use mockall::automock; @@ -210,13 +213,17 @@ impl<'a> AgentEnvironment<'a> { pub fn new( backend: &'a dyn Environment, network_descriptor: NetworkDescriptor, + args: &ArgMatches<'_>, ) -> DfxResult { let identity = IdentityManager::new(backend)?.instantiate_selected_identity()?; + let timeout = args.value_of("expiry_duration"); + let duration = expiry_duration(timeout)?; + let agent_url = network_descriptor.providers.first().unwrap(); Ok(AgentEnvironment { backend, - agent: create_agent(backend.get_logger().clone(), agent_url, identity) + agent: create_agent(backend.get_logger().clone(), agent_url, identity, duration) .expect("Failed to construct agent."), network_descriptor, }) @@ -407,7 +414,12 @@ impl ic_agent::PasswordManager for AgentClient { } } -fn create_agent(logger: Logger, url: &str, identity: Box) -> Option { +fn create_agent( + logger: Logger, + url: &str, + identity: Box, + duration: Duration, +) -> Option { AgentClient::new(logger, url.to_string()) .ok() .and_then(|executor| { @@ -415,8 +427,9 @@ fn create_agent(logger: Logger, url: &str, identity: Box) -> Optio url: url.to_string(), identity, password_manager: Some(Box::new(executor)), + ing_exp_duration: Some(duration), ..AgentConfig::default() }) .ok() }) -} +} \ No newline at end of file diff --git a/src/dfx/src/lib/error/mod.rs b/src/dfx/src/lib/error/mod.rs index a4b8293af7..f04bd4ef0b 100644 --- a/src/dfx/src/lib/error/mod.rs +++ b/src/dfx/src/lib/error/mod.rs @@ -143,6 +143,8 @@ pub enum DfxError { /// Could not save the contents of the file CouldNotSaveCanisterIds(String, std::io::Error), + + HumanizeParseError(humanize_rs::ParseError), } /// The result of running a DFX command. @@ -306,3 +308,9 @@ impl From for DfxError { DfxError::Unknown(err) } } + +impl From for DfxError { + fn from(err: humanize_rs::ParseError) -> DfxError { + DfxError::HumanizeParseError(err) + } +} \ No newline at end of file diff --git a/src/dfx/src/lib/installers/assets.rs b/src/dfx/src/lib/installers/assets.rs index 3c73e0633d..761cc71c26 100644 --- a/src/dfx/src/lib/installers/assets.rs +++ b/src/dfx/src/lib/installers/assets.rs @@ -1,13 +1,19 @@ use crate::lib::canister_info::assets::AssetsCanisterInfo; use crate::lib::canister_info::CanisterInfo; use crate::lib::error::DfxResult; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; use candid::Encode; + use ic_agent::Agent; use std::path::Path; +use std::time::Duration; use walkdir::WalkDir; -pub async fn post_install_store_assets(info: &CanisterInfo, agent: &Agent) -> DfxResult { +pub async fn post_install_store_assets( + info: &CanisterInfo, + agent: &Agent, + duration: Duration, +) -> DfxResult { let assets_canister_info = info.as_info::()?; let output_assets_path = assets_canister_info.get_output_assets_path(); @@ -25,12 +31,14 @@ pub async fn post_install_store_assets(info: &CanisterInfo, agent: &Agent) -> Df let canister_id = info.get_canister_id().expect("Could not find canister ID."); let method_name = String::from("store"); + agent .update(&canister_id, &method_name) .with_arg(&blob) - .call_and_wait(create_waiter()) + .expire_after(duration) + .call_and_wait(waiter_with_timeout(duration)) .await?; } } Ok(()) -} +} \ No newline at end of file diff --git a/src/dfx/src/lib/message.rs b/src/dfx/src/lib/message.rs index e35e9ff128..decac045f3 100644 --- a/src/dfx/src/lib/message.rs +++ b/src/dfx/src/lib/message.rs @@ -54,10 +54,12 @@ user_message!( InstallAll => "Deploys all canisters configured in the project dfx.json files.", InstallCanisterName => "Specifies the canister name to deploy. You must specify either canister name or the --all option.", InstallComputeAllocation => "Specifies the canister's compute allocation. This should be a percent in the range [0..100]", + InstallMemoryAllocation => "Specifies how much memory the canister is allowed to use in total. This should be a value in the range [0..256 TB]", InstallMode => "Specifies the type of deployment. You can set the canister deployment modes to install, reinstall, or upgrade.", // dfx canister mod ManageCanister => "Manages canisters deployed on a network replica.", + CanisterCallExpiryDuration => "The duration of time for which the message will considered valid and processed by the Internet Computer. Default value is set to 5 minutes.", // dfx canister delete DeleteCanister => "Deletes a canister on the Internet Computer network.", @@ -160,4 +162,4 @@ impl fmt::Display for UserMessage { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", &self.to_str()) } -} +} \ No newline at end of file diff --git a/src/dfx/src/lib/operations/canister/create_canister.rs b/src/dfx/src/lib/operations/canister/create_canister.rs index 1f7c4904ff..b89336aab3 100644 --- a/src/dfx/src/lib/operations/canister/create_canister.rs +++ b/src/dfx/src/lib/operations/canister/create_canister.rs @@ -2,26 +2,25 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::models::canister_id_store::CanisterIdStore; use crate::lib::provider::get_network_context; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; use ic_agent::ManagementCanister; use slog::info; use std::format; use tokio::runtime::Runtime; -pub fn create_canister(env: &dyn Environment, canister_name: &str) -> DfxResult { +pub fn create_canister( + env: &dyn Environment, + canister_name: &str, + timeout: Option<&str>, +) -> DfxResult { let log = env.get_logger(); info!(log, "Creating canister {:?}...", canister_name); env.get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; - let mgr = ManagementCanister::new( - env.get_agent() - .ok_or(DfxError::CommandMustBeRunInAProject)?, - ); - let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let mut canister_id_store = CanisterIdStore::for_env(env)?; let network_name = get_network_context()?; @@ -44,7 +43,15 @@ pub fn create_canister(env: &dyn Environment, canister_name: &str) -> DfxResult Ok(()) } None => { - let cid = runtime.block_on(mgr.create_canister(create_waiter()))?; + let mgr = ManagementCanister::new( + env.get_agent() + .ok_or(DfxError::CommandMustBeRunInAProject)?, + ); + + let duration = expiry_duration(timeout)?; + + let mut runtime = Runtime::new().expect("Unable to create a runtime"); + let cid = runtime.block_on(mgr.create_canister(waiter_with_timeout(duration)))?; let canister_id = cid.to_text(); info!( log, @@ -58,4 +65,4 @@ pub fn create_canister(env: &dyn Environment, canister_name: &str) -> DfxResult }?; Ok(()) -} +} \ No newline at end of file diff --git a/src/dfx/src/lib/operations/canister/deploy_canisters.rs b/src/dfx/src/lib/operations/canister/deploy_canisters.rs index 71c1b99220..a43af355d2 100644 --- a/src/dfx/src/lib/operations/canister/deploy_canisters.rs +++ b/src/dfx/src/lib/operations/canister/deploy_canisters.rs @@ -11,7 +11,11 @@ use ic_agent::{AgentError, InstallMode}; use slog::{info, warn}; use tokio::runtime::Runtime; -pub fn deploy_canisters(env: &dyn Environment, some_canister: Option<&str>) -> DfxResult { +pub fn deploy_canisters( + env: &dyn Environment, + some_canister: Option<&str>, + timeout: Option<&str>, +) -> DfxResult { let log = env.get_logger(); let config = env @@ -26,11 +30,17 @@ pub fn deploy_canisters(env: &dyn Environment, some_canister: Option<&str>) -> D info!(log, "Deploying all canisters."); } - register_canisters(env, &canister_names, &initial_canister_id_store)?; + register_canisters(env, &canister_names, &initial_canister_id_store, timeout)?; build_canisters(env, &canister_names, &config)?; - install_canisters(env, &canister_names, &initial_canister_id_store, &config)?; + install_canisters( + env, + &canister_names, + &initial_canister_id_store, + &config, + timeout, + )?; info!(log, "Deployed canisters."); @@ -49,6 +59,7 @@ fn register_canisters( env: &dyn Environment, canister_names: &[String], canister_id_store: &CanisterIdStore, + timeout: Option<&str>, ) -> DfxResult { let canisters_to_create = canister_names .iter() @@ -60,7 +71,7 @@ fn register_canisters( } else { info!(env.get_logger(), "Creating canisters..."); for canister_name in &canisters_to_create { - create_canister(env, &canister_name)?; + create_canister(env, &canister_name, timeout)?; } } Ok(()) @@ -79,6 +90,7 @@ fn install_canisters( canister_names: &[String], initial_canister_id_store: &CanisterIdStore, config: &Config, + timeout: Option<&str>, ) -> DfxResult { info!(env.get_logger(), "Installing canisters..."); @@ -99,12 +111,15 @@ fn install_canisters( let canister_id = canister_id_store.get(&canister_name)?; let canister_info = CanisterInfo::load(&config, &canister_name, Some(canister_id))?; let compute_allocation = None; + let memory_allocation = None; let result = runtime.block_on(install_canister( env, &agent, &canister_info, compute_allocation, first_mode, + memory_allocation, + timeout, )); match result { Err(DfxError::AgentError(AgentError::ReplicaError { @@ -127,6 +142,8 @@ fn install_canisters( &canister_info, compute_allocation, second_mode, + memory_allocation, + timeout, )) } other => other, @@ -134,4 +151,4 @@ fn install_canisters( } Ok(()) -} +} \ No newline at end of file diff --git a/src/dfx/src/lib/operations/canister/install_canister.rs b/src/dfx/src/lib/operations/canister/install_canister.rs index 455cea56b9..b5a7c020c0 100644 --- a/src/dfx/src/lib/operations/canister/install_canister.rs +++ b/src/dfx/src/lib/operations/canister/install_canister.rs @@ -2,9 +2,12 @@ use crate::lib::canister_info::CanisterInfo; use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::installers::assets::post_install_store_assets; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; -use ic_agent::{Agent, CanisterAttributes, ComputeAllocation, InstallMode, ManagementCanister}; +use ic_agent::{ + Agent, CanisterAttributes, ComputeAllocation, InstallMode, ManagementCanister, MemoryAllocation, +}; use slog::info; pub async fn install_canister( @@ -13,6 +16,8 @@ pub async fn install_canister( canister_info: &CanisterInfo, compute_allocation: Option, mode: InstallMode, + memory_allocation: Option, + timeout: Option<&str>, ) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); @@ -32,20 +37,25 @@ pub async fn install_canister( .expect("Cannot get WASM output path."); let wasm = std::fs::read(wasm_path)?; + let duration = expiry_duration(timeout)?; + mgr.install_code( - create_waiter(), + waiter_with_timeout(duration), &canister_id, mode, &wasm, &[], - &CanisterAttributes { compute_allocation }, + &CanisterAttributes { + compute_allocation, + memory_allocation, + }, ) .await .map_err(DfxError::from)?; if canister_info.get_type() == "assets" { - post_install_store_assets(&canister_info, &agent).await?; + post_install_store_assets(&canister_info, &agent, duration).await?; } Ok(()) -} +} \ No newline at end of file diff --git a/src/dfx/src/lib/provider.rs b/src/dfx/src/lib/provider.rs index fc1f59958b..5c4c4e936a 100644 --- a/src/dfx/src/lib/provider.rs +++ b/src/dfx/src/lib/provider.rs @@ -81,7 +81,7 @@ pub fn create_agent_environment<'a>( ) -> DfxResult> { let network_descriptor = get_network_descriptor(env, args)?; - AgentEnvironment::new(env, network_descriptor) + AgentEnvironment::new(env, network_descriptor, args) } pub fn command_line_provider_to_url(s: &str) -> DfxResult { @@ -119,4 +119,4 @@ mod tests { "http://127.0.0.1:8000" ); } -} +} \ No newline at end of file diff --git a/src/dfx/src/lib/waiter.rs b/src/dfx/src/lib/waiter.rs index 32d5e5ad78..fe2caad901 100644 --- a/src/dfx/src/lib/waiter.rs +++ b/src/dfx/src/lib/waiter.rs @@ -3,11 +3,10 @@ use std::time::Duration; const RETRY_PAUSE: Duration = Duration::from_millis(200); const MAX_RETRY_PAUSE: Duration = Duration::from_secs(1); -const REQUEST_TIMEOUT: Duration = Duration::from_secs(120); -pub fn create_waiter() -> Delay { +pub fn waiter_with_timeout(duration: Duration) -> Delay { Delay::builder() .exponential_backoff_capped(RETRY_PAUSE, 1.4, MAX_RETRY_PAUSE) - .timeout(REQUEST_TIMEOUT) + .timeout(duration) .build() -} +} \ No newline at end of file diff --git a/src/dfx/src/util/mod.rs b/src/dfx/src/util/mod.rs index 09260e13ed..1515a54a6d 100644 --- a/src/dfx/src/util/mod.rs +++ b/src/dfx/src/util/mod.rs @@ -2,10 +2,20 @@ use crate::lib::error::{DfxError, DfxResult}; use candid::parser::typing::{check_prog, TypeEnv}; use candid::types::{Function, Type}; use candid::{parser::value::IDLValue, IDLArgs, IDLProg}; +use humanize_rs::duration::parse; +use std::time::Duration; pub mod assets; pub mod clap; +pub fn expiry_duration(timeout: Option<&str>) -> DfxResult { + let dur = match timeout { + Some(expiry_duration) => parse(expiry_duration), + None => Ok(Duration::from_secs(60 * 5)), // 5 minutes is max ingress timeout + }?; + Ok(dur) +} + /// Deserialize and print return values from canister method. pub fn print_idl_blob( blob: &[u8], @@ -117,4 +127,4 @@ pub fn blob_from_arguments( } v => Err(DfxError::Unknown(format!("Invalid type: {}", v))), } -} +} \ No newline at end of file From 4ade5bccc67592903beb6ba70481932002018c99 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 14 Sep 2020 13:09:22 -0700 Subject: [PATCH 02/10] fmt --- src/dfx/src/commands/canister/call.rs | 2 +- src/dfx/src/commands/canister/create.rs | 2 +- src/dfx/src/commands/canister/delete.rs | 2 +- src/dfx/src/commands/canister/install.rs | 2 +- src/dfx/src/commands/canister/mod.rs | 2 +- src/dfx/src/commands/canister/request_status.rs | 2 +- src/dfx/src/commands/canister/start.rs | 2 +- src/dfx/src/commands/canister/status.rs | 2 +- src/dfx/src/commands/canister/stop.rs | 2 +- src/dfx/src/commands/deploy.rs | 2 +- src/dfx/src/commands/ping.rs | 2 +- src/dfx/src/lib/environment.rs | 2 +- src/dfx/src/lib/error/mod.rs | 2 +- src/dfx/src/lib/installers/assets.rs | 2 +- src/dfx/src/lib/message.rs | 2 +- src/dfx/src/lib/operations/canister/create_canister.rs | 2 +- src/dfx/src/lib/operations/canister/deploy_canisters.rs | 2 +- src/dfx/src/lib/operations/canister/install_canister.rs | 2 +- src/dfx/src/lib/provider.rs | 2 +- src/dfx/src/lib/waiter.rs | 2 +- src/dfx/src/util/mod.rs | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/dfx/src/commands/canister/call.rs b/src/dfx/src/commands/canister/call.rs index a87972c80d..40a658a4dc 100644 --- a/src/dfx/src/commands/canister/call.rs +++ b/src/dfx/src/commands/canister/call.rs @@ -161,4 +161,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { } Ok(()) -} \ No newline at end of file +} diff --git a/src/dfx/src/commands/canister/create.rs b/src/dfx/src/commands/canister/create.rs index 88ef4bc369..cabfbf744d 100644 --- a/src/dfx/src/commands/canister/create.rs +++ b/src/dfx/src/commands/canister/create.rs @@ -45,4 +45,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { } else { Err(DfxError::CanisterNameMissing()) } -} \ No newline at end of file +} diff --git a/src/dfx/src/commands/canister/delete.rs b/src/dfx/src/commands/canister/delete.rs index 0b142efc41..06cc95f88b 100644 --- a/src/dfx/src/commands/canister/delete.rs +++ b/src/dfx/src/commands/canister/delete.rs @@ -81,4 +81,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { } else { Err(DfxError::CanisterNameMissing()) } -} \ No newline at end of file +} diff --git a/src/dfx/src/commands/canister/install.rs b/src/dfx/src/commands/canister/install.rs index 96f8170c88..963f8823a9 100644 --- a/src/dfx/src/commands/canister/install.rs +++ b/src/dfx/src/commands/canister/install.rs @@ -145,4 +145,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { } else { Err(DfxError::CanisterNameMissing()) } -} \ No newline at end of file +} diff --git a/src/dfx/src/commands/canister/mod.rs b/src/dfx/src/commands/canister/mod.rs index 660795c6b6..8c18ee3ac1 100644 --- a/src/dfx/src/commands/canister/mod.rs +++ b/src/dfx/src/commands/canister/mod.rs @@ -80,4 +80,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { eprintln!(); Ok(()) } -} \ No newline at end of file +} diff --git a/src/dfx/src/commands/canister/request_status.rs b/src/dfx/src/commands/canister/request_status.rs index c68ab140bf..28a47c0e07 100644 --- a/src/dfx/src/commands/canister/request_status.rs +++ b/src/dfx/src/commands/canister/request_status.rs @@ -71,4 +71,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { print_idl_blob(&blob, None, &None) .map_err(|e| DfxError::InvalidData(format!("Invalid IDL blob: {}", e)))?; Ok(()) -} \ No newline at end of file +} diff --git a/src/dfx/src/commands/canister/start.rs b/src/dfx/src/commands/canister/start.rs index 3f4fabd4aa..40b638ae58 100644 --- a/src/dfx/src/commands/canister/start.rs +++ b/src/dfx/src/commands/canister/start.rs @@ -81,4 +81,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { } else { Err(DfxError::CanisterNameMissing()) } -} \ No newline at end of file +} diff --git a/src/dfx/src/commands/canister/status.rs b/src/dfx/src/commands/canister/status.rs index 36000dc838..3d018b439f 100644 --- a/src/dfx/src/commands/canister/status.rs +++ b/src/dfx/src/commands/canister/status.rs @@ -76,4 +76,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { } else { Err(DfxError::CanisterNameMissing()) } -} \ No newline at end of file +} diff --git a/src/dfx/src/commands/canister/stop.rs b/src/dfx/src/commands/canister/stop.rs index e20ad59de5..d2df7d5784 100644 --- a/src/dfx/src/commands/canister/stop.rs +++ b/src/dfx/src/commands/canister/stop.rs @@ -80,4 +80,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { } else { Err(DfxError::CanisterNameMissing()) } -} \ No newline at end of file +} diff --git a/src/dfx/src/commands/deploy.rs b/src/dfx/src/commands/deploy.rs index e750b9f03e..5800f327c7 100644 --- a/src/dfx/src/commands/deploy.rs +++ b/src/dfx/src/commands/deploy.rs @@ -29,4 +29,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let canister = args.value_of("canister_name"); deploy_canisters(&env, canister, timeout) -} \ No newline at end of file +} diff --git a/src/dfx/src/commands/ping.rs b/src/dfx/src/commands/ping.rs index 7038a659de..bb11ee92e2 100644 --- a/src/dfx/src/commands/ping.rs +++ b/src/dfx/src/commands/ping.rs @@ -48,4 +48,4 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { println!("{}", status); Ok(()) -} \ No newline at end of file +} diff --git a/src/dfx/src/lib/environment.rs b/src/dfx/src/lib/environment.rs index e82944e885..50ac024b20 100644 --- a/src/dfx/src/lib/environment.rs +++ b/src/dfx/src/lib/environment.rs @@ -432,4 +432,4 @@ fn create_agent( }) .ok() }) -} \ No newline at end of file +} diff --git a/src/dfx/src/lib/error/mod.rs b/src/dfx/src/lib/error/mod.rs index f04bd4ef0b..562dfa9b2a 100644 --- a/src/dfx/src/lib/error/mod.rs +++ b/src/dfx/src/lib/error/mod.rs @@ -313,4 +313,4 @@ impl From for DfxError { fn from(err: humanize_rs::ParseError) -> DfxError { DfxError::HumanizeParseError(err) } -} \ No newline at end of file +} diff --git a/src/dfx/src/lib/installers/assets.rs b/src/dfx/src/lib/installers/assets.rs index 761cc71c26..3b2a94f597 100644 --- a/src/dfx/src/lib/installers/assets.rs +++ b/src/dfx/src/lib/installers/assets.rs @@ -41,4 +41,4 @@ pub async fn post_install_store_assets( } } Ok(()) -} \ No newline at end of file +} diff --git a/src/dfx/src/lib/message.rs b/src/dfx/src/lib/message.rs index decac045f3..832cba0543 100644 --- a/src/dfx/src/lib/message.rs +++ b/src/dfx/src/lib/message.rs @@ -162,4 +162,4 @@ impl fmt::Display for UserMessage { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", &self.to_str()) } -} \ No newline at end of file +} diff --git a/src/dfx/src/lib/operations/canister/create_canister.rs b/src/dfx/src/lib/operations/canister/create_canister.rs index b89336aab3..797c2366c2 100644 --- a/src/dfx/src/lib/operations/canister/create_canister.rs +++ b/src/dfx/src/lib/operations/canister/create_canister.rs @@ -65,4 +65,4 @@ pub fn create_canister( }?; Ok(()) -} \ No newline at end of file +} diff --git a/src/dfx/src/lib/operations/canister/deploy_canisters.rs b/src/dfx/src/lib/operations/canister/deploy_canisters.rs index a43af355d2..d2dac9695c 100644 --- a/src/dfx/src/lib/operations/canister/deploy_canisters.rs +++ b/src/dfx/src/lib/operations/canister/deploy_canisters.rs @@ -151,4 +151,4 @@ fn install_canisters( } Ok(()) -} \ No newline at end of file +} diff --git a/src/dfx/src/lib/operations/canister/install_canister.rs b/src/dfx/src/lib/operations/canister/install_canister.rs index b5a7c020c0..b79621dcde 100644 --- a/src/dfx/src/lib/operations/canister/install_canister.rs +++ b/src/dfx/src/lib/operations/canister/install_canister.rs @@ -58,4 +58,4 @@ pub async fn install_canister( } Ok(()) -} \ No newline at end of file +} diff --git a/src/dfx/src/lib/provider.rs b/src/dfx/src/lib/provider.rs index 5c4c4e936a..e089db6368 100644 --- a/src/dfx/src/lib/provider.rs +++ b/src/dfx/src/lib/provider.rs @@ -119,4 +119,4 @@ mod tests { "http://127.0.0.1:8000" ); } -} \ No newline at end of file +} diff --git a/src/dfx/src/lib/waiter.rs b/src/dfx/src/lib/waiter.rs index fe2caad901..3e322d4f75 100644 --- a/src/dfx/src/lib/waiter.rs +++ b/src/dfx/src/lib/waiter.rs @@ -9,4 +9,4 @@ pub fn waiter_with_timeout(duration: Duration) -> Delay { .exponential_backoff_capped(RETRY_PAUSE, 1.4, MAX_RETRY_PAUSE) .timeout(duration) .build() -} \ No newline at end of file +} diff --git a/src/dfx/src/util/mod.rs b/src/dfx/src/util/mod.rs index 1515a54a6d..62e8ad3118 100644 --- a/src/dfx/src/util/mod.rs +++ b/src/dfx/src/util/mod.rs @@ -127,4 +127,4 @@ pub fn blob_from_arguments( } v => Err(DfxError::Unknown(format!("Invalid type: {}", v))), } -} \ No newline at end of file +} From 4b61adfbd6611545189a1dfda7fcfe8dc02419e5 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 14 Sep 2020 15:51:37 -0700 Subject: [PATCH 03/10] update ref, agent, fix --- nix/sources.json | 4 ++-- src/dfx/Cargo.toml | 4 ++-- src/dfx/src/commands/canister/install.rs | 1 + src/dfx/src/commands/canister/request_status.rs | 8 +++++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index 93cd25e749..54183635a5 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -45,8 +45,8 @@ }, "ic-ref": { "repo": "ssh://git@github.com/dfinity-lab/ic-ref", - "rev": "7c1e8bae654588790374ec1a23f40f579405b31c", - "tag": "0.10.2", + "rev": "7d453c4b09f78b3fa1f06df6a3ff00e51b11ca3e", + "tag": "release-0.10", "type": "git" }, "motoko": { diff --git a/src/dfx/Cargo.toml b/src/dfx/Cargo.toml index b9110ce36f..6bedf0f176 100644 --- a/src/dfx/Cargo.toml +++ b/src/dfx/Cargo.toml @@ -70,13 +70,13 @@ wasmparser = "0.45.0" version = "0.1.0" git = "ssh://git@github.com/dfinity-lab/agent-rust.git" branch = "pshahi/ingress-expiry-two" -rev = "b57f659d431198feaca98f7ef9adf9b1fdff7807" +rev = "93ef7cff4b11859719f43733c1d223f254d29e86" [dependencies.ic-types] version = "0.1.1" git = "ssh://git@github.com/dfinity-lab/agent-rust.git" branch = "pshahi/ingress-expiry-two" -rev = "b57f659d431198feaca98f7ef9adf9b1fdff7807" +rev = "93ef7cff4b11859719f43733c1d223f254d29e86" [dev-dependencies] diff --git a/src/dfx/src/commands/canister/install.rs b/src/dfx/src/commands/canister/install.rs index 963f8823a9..5749d5b1f5 100644 --- a/src/dfx/src/commands/canister/install.rs +++ b/src/dfx/src/commands/canister/install.rs @@ -57,6 +57,7 @@ pub fn construct() -> App<'static, 'static> { Arg::with_name("memory-allocation") .help(UserMessage::InstallMemoryAllocation.to_str()) .long("memory-allocation") + .default_value("8GB") .takes_value(true) .validator(memory_allocation_validator), ) diff --git a/src/dfx/src/commands/canister/request_status.rs b/src/dfx/src/commands/canister/request_status.rs index 28a47c0e07..d6e51a5c78 100644 --- a/src/dfx/src/commands/canister/request_status.rs +++ b/src/dfx/src/commands/canister/request_status.rs @@ -59,7 +59,13 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { RequestStatusResponse::Unknown => (), RequestStatusResponse::Received => (), RequestStatusResponse::Processing => (), - RequestStatusResponse::Done => (), + RequestStatusResponse::Done => { + return Err(DfxError::AgentError( + AgentError::RequestStatusDoneNoReply(String::from( + request_id, + )), + )) + } }; waiter From 46f0132ef9ae6910be60de477bae5a2bfcdc2650 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 14 Sep 2020 16:00:09 -0700 Subject: [PATCH 04/10] branch not tag, and remove comma --- nix/sources.json | 2 +- src/dfx/src/commands/canister/request_status.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index 54183635a5..fe060eeee7 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -46,7 +46,7 @@ "ic-ref": { "repo": "ssh://git@github.com/dfinity-lab/ic-ref", "rev": "7d453c4b09f78b3fa1f06df6a3ff00e51b11ca3e", - "tag": "release-0.10", + "branch": "release-0.10", "type": "git" }, "motoko": { diff --git a/src/dfx/src/commands/canister/request_status.rs b/src/dfx/src/commands/canister/request_status.rs index d6e51a5c78..c0fbe88842 100644 --- a/src/dfx/src/commands/canister/request_status.rs +++ b/src/dfx/src/commands/canister/request_status.rs @@ -60,11 +60,9 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { RequestStatusResponse::Received => (), RequestStatusResponse::Processing => (), RequestStatusResponse::Done => { - return Err(DfxError::AgentError( - AgentError::RequestStatusDoneNoReply(String::from( - request_id, - )), - )) + return Err(DfxError::AgentError(AgentError::RequestStatusDoneNoReply( + String::from(request_id), + ))) } }; From dfd6ff14c9d95d3bd8dcb54ee6872651530a19de Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 14 Sep 2020 18:38:00 -0700 Subject: [PATCH 05/10] convert command-line arguments from strings in the command layer and rename variable to timeout --- src/dfx/src/commands/canister/call.rs | 7 +++---- src/dfx/src/commands/canister/create.rs | 3 ++- src/dfx/src/commands/canister/delete.rs | 8 ++++---- src/dfx/src/commands/canister/install.rs | 3 ++- src/dfx/src/commands/canister/request_status.rs | 6 ++---- src/dfx/src/commands/canister/start.rs | 9 ++++----- src/dfx/src/commands/canister/status.rs | 9 ++++----- src/dfx/src/commands/canister/stop.rs | 9 ++++----- src/dfx/src/commands/deploy.rs | 3 ++- src/dfx/src/commands/ping.rs | 4 +++- src/dfx/src/lib/environment.rs | 13 ++++--------- src/dfx/src/lib/installers/assets.rs | 6 +++--- .../src/lib/operations/canister/create_canister.rs | 12 +++--------- .../src/lib/operations/canister/deploy_canisters.rs | 7 ++++--- .../src/lib/operations/canister/install_canister.rs | 10 ++++------ src/dfx/src/lib/provider.rs | 4 +++- 16 files changed, 51 insertions(+), 62 deletions(-) diff --git a/src/dfx/src/commands/canister/call.rs b/src/dfx/src/commands/canister/call.rs index 40a658a4dc..5853e072ed 100644 --- a/src/dfx/src/commands/canister/call.rs +++ b/src/dfx/src/commands/canister/call.rs @@ -130,8 +130,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let timeout = args.value_of("expiry_duration"); - let duration = expiry_duration(timeout)?; + let timeout = expiry_duration(args.value_of("expiry_duration"))?; if is_query { let blob = @@ -152,8 +151,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { agent .update(&canister_id, &method_name) .with_arg(&arg_value) - .expire_after(duration) - .call_and_wait(waiter_with_timeout(duration)), + .expire_after(timeout) + .call_and_wait(waiter_with_timeout(timeout)), )?; print_idl_blob(&blob, output_type, &method_type) diff --git a/src/dfx/src/commands/canister/create.rs b/src/dfx/src/commands/canister/create.rs index cabfbf744d..7c5b101afc 100644 --- a/src/dfx/src/commands/canister/create.rs +++ b/src/dfx/src/commands/canister/create.rs @@ -2,6 +2,7 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::operations::canister::create_canister; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; @@ -29,7 +30,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; - let timeout = args.value_of("expiry_duration"); + let timeout = expiry_duration(args.value_of("expiry_duration"))?; if let Some(canister_name) = args.value_of("canister_name") { create_canister(env, canister_name, timeout)?; diff --git a/src/dfx/src/commands/canister/delete.rs b/src/dfx/src/commands/canister/delete.rs index 06cc95f88b..33d58e78b3 100644 --- a/src/dfx/src/commands/canister/delete.rs +++ b/src/dfx/src/commands/canister/delete.rs @@ -8,6 +8,7 @@ use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; use slog::info; +use std::time::Duration; use tokio::runtime::Runtime; pub fn construct() -> App<'static, 'static> { @@ -33,7 +34,7 @@ async fn delete_canister( env: &dyn Environment, agent: &Agent, canister_name: &str, - timeout: Option<&str>, + timeout: Duration, ) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); @@ -45,9 +46,8 @@ async fn delete_canister( canister_name, canister_id.to_text(), ); - let duration = expiry_duration(timeout)?; - mgr.delete_canister(waiter_with_timeout(duration), &canister_id) + mgr.delete_canister(waiter_with_timeout(timeout), &canister_id) .await .map_err(DfxError::from)?; @@ -64,7 +64,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .get_agent() .ok_or(DfxError::CommandMustBeRunInAProject)?; - let timeout = args.value_of("expiry_duration"); + let timeout = expiry_duration(args.value_of("expiry_duration"))?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); diff --git a/src/dfx/src/commands/canister/install.rs b/src/dfx/src/commands/canister/install.rs index 5749d5b1f5..7f715d1a0d 100644 --- a/src/dfx/src/commands/canister/install.rs +++ b/src/dfx/src/commands/canister/install.rs @@ -4,6 +4,7 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; use crate::lib::operations::canister::install_canister; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use humanize_rs::bytes::{Bytes, Unit}; @@ -87,7 +88,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; - let timeout = args.value_of("expiry_duration"); + let timeout = expiry_duration(args.value_of("expiry_duration"))?; let agent = env .get_agent() diff --git a/src/dfx/src/commands/canister/request_status.rs b/src/dfx/src/commands/canister/request_status.rs index c0fbe88842..761dd7d988 100644 --- a/src/dfx/src/commands/canister/request_status.rs +++ b/src/dfx/src/commands/canister/request_status.rs @@ -35,11 +35,9 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let timeout = args.value_of("expiry_duration"); + let timeout = expiry_duration(args.value_of("expiry_duration"))?; - let duration = expiry_duration(timeout)?; - - let mut waiter = waiter_with_timeout(duration); + let mut waiter = waiter_with_timeout(timeout); let Replied::CallReplied(blob) = runtime .block_on(async { diff --git a/src/dfx/src/commands/canister/start.rs b/src/dfx/src/commands/canister/start.rs index 40b638ae58..b6a8f33175 100644 --- a/src/dfx/src/commands/canister/start.rs +++ b/src/dfx/src/commands/canister/start.rs @@ -8,6 +8,7 @@ use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; use slog::info; +use std::time::Duration; use tokio::runtime::Runtime; pub fn construct() -> App<'static, 'static> { @@ -33,15 +34,13 @@ async fn start_canister( env: &dyn Environment, agent: &Agent, canister_name: &str, - timeout: Option<&str>, + timeout: Duration, ) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let canister_id_store = CanisterIdStore::for_env(env)?; let canister_id = canister_id_store.get(canister_name)?; - let duration = expiry_duration(timeout)?; - info!( log, "Starting code for canister {}, with canister_id {}", @@ -49,7 +48,7 @@ async fn start_canister( canister_id.to_text(), ); - mgr.start_canister(waiter_with_timeout(duration), &canister_id) + mgr.start_canister(waiter_with_timeout(timeout), &canister_id) .await .map_err(DfxError::from)?; @@ -66,7 +65,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let timeout = args.value_of("expiry_duration"); + let timeout = expiry_duration(args.value_of("expiry_duration"))?; if let Some(canister_name) = args.value_of("canister_name") { runtime.block_on(start_canister(env, &agent, &canister_name, timeout))?; diff --git a/src/dfx/src/commands/canister/status.rs b/src/dfx/src/commands/canister/status.rs index 3d018b439f..e5252daca5 100644 --- a/src/dfx/src/commands/canister/status.rs +++ b/src/dfx/src/commands/canister/status.rs @@ -8,6 +8,7 @@ use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; use slog::info; +use std::time::Duration; use tokio::runtime::Runtime; pub fn construct() -> App<'static, 'static> { @@ -33,17 +34,15 @@ async fn canister_status( env: &dyn Environment, agent: &Agent, canister_name: &str, - timeout: Option<&str>, + timeout: Duration, ) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let canister_id_store = CanisterIdStore::for_env(env)?; let canister_id = canister_id_store.get(canister_name)?; - let duration = expiry_duration(timeout)?; - let status = mgr - .canister_status(waiter_with_timeout(duration), &canister_id) + .canister_status(waiter_with_timeout(timeout), &canister_id) .await .map_err(DfxError::from)?; info!(log, "Canister {}'s status is {}.", canister_name, status); @@ -61,7 +60,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let timeout = args.value_of("expiry_duration"); + let timeout = expiry_duration(args.value_of("expiry_duration"))?; if let Some(canister_name) = args.value_of("canister_name") { runtime.block_on(canister_status(env, &agent, &canister_name, timeout))?; diff --git a/src/dfx/src/commands/canister/stop.rs b/src/dfx/src/commands/canister/stop.rs index d2df7d5784..27799ed365 100644 --- a/src/dfx/src/commands/canister/stop.rs +++ b/src/dfx/src/commands/canister/stop.rs @@ -8,6 +8,7 @@ use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; use slog::info; +use std::time::Duration; use tokio::runtime::Runtime; pub fn construct() -> App<'static, 'static> { @@ -33,15 +34,13 @@ async fn stop_canister( env: &dyn Environment, agent: &Agent, canister_name: &str, - timeout: Option<&str>, + timeout: Duration, ) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let canister_id_store = CanisterIdStore::for_env(env)?; let canister_id = canister_id_store.get(canister_name)?; - let duration = expiry_duration(timeout)?; - info!( log, "Stopping code for canister {}, with canister_id {}", @@ -49,7 +48,7 @@ async fn stop_canister( canister_id.to_text(), ); - mgr.stop_canister(waiter_with_timeout(duration), &canister_id) + mgr.stop_canister(waiter_with_timeout(timeout), &canister_id) .await .map_err(DfxError::from)?; @@ -65,7 +64,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let timeout = args.value_of("expiry_duration"); + let timeout = expiry_duration(args.value_of("expiry_duration"))?; if let Some(canister_name) = args.value_of("canister_name") { runtime.block_on(stop_canister(env, &agent, &canister_name, timeout))?; diff --git a/src/dfx/src/commands/deploy.rs b/src/dfx/src/commands/deploy.rs index 5800f327c7..4b5837eb5a 100644 --- a/src/dfx/src/commands/deploy.rs +++ b/src/dfx/src/commands/deploy.rs @@ -3,6 +3,7 @@ use crate::lib::error::DfxResult; use crate::lib::message::UserMessage; use crate::lib::operations::canister::deploy_canisters; use crate::lib::provider::create_agent_environment; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; pub fn construct() -> App<'static, 'static> { @@ -25,7 +26,7 @@ pub fn construct() -> App<'static, 'static> { pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let env = create_agent_environment(env, args)?; - let timeout = args.value_of("expiry_duration"); + let timeout = expiry_duration(args.value_of("expiry_duration"))?; let canister = args.value_of("canister_name"); deploy_canisters(&env, canister, timeout) diff --git a/src/dfx/src/commands/ping.rs b/src/dfx/src/commands/ping.rs index bb11ee92e2..17ef2d1d9d 100644 --- a/src/dfx/src/commands/ping.rs +++ b/src/dfx/src/commands/ping.rs @@ -4,6 +4,7 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::network::network_descriptor::NetworkDescriptor; use crate::lib::provider::{command_line_provider_to_url, get_network_descriptor}; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use tokio::runtime::Runtime; @@ -37,7 +38,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { other => Err(other), })?; - let env = AgentEnvironment::new(env, network_descriptor, args)?; + let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let env = AgentEnvironment::new(env, network_descriptor, timeout)?; let agent = env .get_agent() diff --git a/src/dfx/src/lib/environment.rs b/src/dfx/src/lib/environment.rs index 50ac024b20..3355879ac5 100644 --- a/src/dfx/src/lib/environment.rs +++ b/src/dfx/src/lib/environment.rs @@ -5,9 +5,7 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::identity::identity_manager::IdentityManager; use crate::lib::network::network_descriptor::NetworkDescriptor; use crate::lib::progress_bar::ProgressBar; -use crate::util::expiry_duration; -use clap::ArgMatches; use ic_agent::{Agent, AgentConfig, Identity}; use semver::Version; use slog::{Logger, Record}; @@ -213,17 +211,14 @@ impl<'a> AgentEnvironment<'a> { pub fn new( backend: &'a dyn Environment, network_descriptor: NetworkDescriptor, - args: &ArgMatches<'_>, + timeout: Duration, ) -> DfxResult { let identity = IdentityManager::new(backend)?.instantiate_selected_identity()?; - let timeout = args.value_of("expiry_duration"); - let duration = expiry_duration(timeout)?; - let agent_url = network_descriptor.providers.first().unwrap(); Ok(AgentEnvironment { backend, - agent: create_agent(backend.get_logger().clone(), agent_url, identity, duration) + agent: create_agent(backend.get_logger().clone(), agent_url, identity, timeout) .expect("Failed to construct agent."), network_descriptor, }) @@ -418,7 +413,7 @@ fn create_agent( logger: Logger, url: &str, identity: Box, - duration: Duration, + timeout: Duration, ) -> Option { AgentClient::new(logger, url.to_string()) .ok() @@ -427,7 +422,7 @@ fn create_agent( url: url.to_string(), identity, password_manager: Some(Box::new(executor)), - ing_exp_duration: Some(duration), + ing_exp_duration: Some(timeout), ..AgentConfig::default() }) .ok() diff --git a/src/dfx/src/lib/installers/assets.rs b/src/dfx/src/lib/installers/assets.rs index 3b2a94f597..d4aa060f0e 100644 --- a/src/dfx/src/lib/installers/assets.rs +++ b/src/dfx/src/lib/installers/assets.rs @@ -12,7 +12,7 @@ use walkdir::WalkDir; pub async fn post_install_store_assets( info: &CanisterInfo, agent: &Agent, - duration: Duration, + timeout: Duration, ) -> DfxResult { let assets_canister_info = info.as_info::()?; let output_assets_path = assets_canister_info.get_output_assets_path(); @@ -35,8 +35,8 @@ pub async fn post_install_store_assets( agent .update(&canister_id, &method_name) .with_arg(&blob) - .expire_after(duration) - .call_and_wait(waiter_with_timeout(duration)) + .expire_after(timeout) + .call_and_wait(waiter_with_timeout(timeout)) .await?; } } diff --git a/src/dfx/src/lib/operations/canister/create_canister.rs b/src/dfx/src/lib/operations/canister/create_canister.rs index 797c2366c2..f4dd3a430b 100644 --- a/src/dfx/src/lib/operations/canister/create_canister.rs +++ b/src/dfx/src/lib/operations/canister/create_canister.rs @@ -3,18 +3,14 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::models::canister_id_store::CanisterIdStore; use crate::lib::provider::get_network_context; use crate::lib::waiter::waiter_with_timeout; -use crate::util::expiry_duration; use ic_agent::ManagementCanister; use slog::info; use std::format; +use std::time::Duration; use tokio::runtime::Runtime; -pub fn create_canister( - env: &dyn Environment, - canister_name: &str, - timeout: Option<&str>, -) -> DfxResult { +pub fn create_canister(env: &dyn Environment, canister_name: &str, timeout: Duration) -> DfxResult { let log = env.get_logger(); info!(log, "Creating canister {:?}...", canister_name); @@ -48,10 +44,8 @@ pub fn create_canister( .ok_or(DfxError::CommandMustBeRunInAProject)?, ); - let duration = expiry_duration(timeout)?; - let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let cid = runtime.block_on(mgr.create_canister(waiter_with_timeout(duration)))?; + let cid = runtime.block_on(mgr.create_canister(waiter_with_timeout(timeout)))?; let canister_id = cid.to_text(); info!( log, diff --git a/src/dfx/src/lib/operations/canister/deploy_canisters.rs b/src/dfx/src/lib/operations/canister/deploy_canisters.rs index d2dac9695c..b8e6add2bf 100644 --- a/src/dfx/src/lib/operations/canister/deploy_canisters.rs +++ b/src/dfx/src/lib/operations/canister/deploy_canisters.rs @@ -9,12 +9,13 @@ use crate::lib::operations::canister::create_canister; use crate::lib::operations::canister::install_canister; use ic_agent::{AgentError, InstallMode}; use slog::{info, warn}; +use std::time::Duration; use tokio::runtime::Runtime; pub fn deploy_canisters( env: &dyn Environment, some_canister: Option<&str>, - timeout: Option<&str>, + timeout: Duration, ) -> DfxResult { let log = env.get_logger(); @@ -59,7 +60,7 @@ fn register_canisters( env: &dyn Environment, canister_names: &[String], canister_id_store: &CanisterIdStore, - timeout: Option<&str>, + timeout: Duration, ) -> DfxResult { let canisters_to_create = canister_names .iter() @@ -90,7 +91,7 @@ fn install_canisters( canister_names: &[String], initial_canister_id_store: &CanisterIdStore, config: &Config, - timeout: Option<&str>, + timeout: Duration, ) -> DfxResult { info!(env.get_logger(), "Installing canisters..."); diff --git a/src/dfx/src/lib/operations/canister/install_canister.rs b/src/dfx/src/lib/operations/canister/install_canister.rs index b79621dcde..618e0ee2fc 100644 --- a/src/dfx/src/lib/operations/canister/install_canister.rs +++ b/src/dfx/src/lib/operations/canister/install_canister.rs @@ -3,12 +3,12 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::installers::assets::post_install_store_assets; use crate::lib::waiter::waiter_with_timeout; -use crate::util::expiry_duration; use ic_agent::{ Agent, CanisterAttributes, ComputeAllocation, InstallMode, ManagementCanister, MemoryAllocation, }; use slog::info; +use std::time::Duration; pub async fn install_canister( env: &dyn Environment, @@ -17,7 +17,7 @@ pub async fn install_canister( compute_allocation: Option, mode: InstallMode, memory_allocation: Option, - timeout: Option<&str>, + timeout: Duration, ) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); @@ -37,10 +37,8 @@ pub async fn install_canister( .expect("Cannot get WASM output path."); let wasm = std::fs::read(wasm_path)?; - let duration = expiry_duration(timeout)?; - mgr.install_code( - waiter_with_timeout(duration), + waiter_with_timeout(timeout), &canister_id, mode, &wasm, @@ -54,7 +52,7 @@ pub async fn install_canister( .map_err(DfxError::from)?; if canister_info.get_type() == "assets" { - post_install_store_assets(&canister_info, &agent, duration).await?; + post_install_store_assets(&canister_info, &agent, timeout).await?; } Ok(()) diff --git a/src/dfx/src/lib/provider.rs b/src/dfx/src/lib/provider.rs index e089db6368..782ac772d4 100644 --- a/src/dfx/src/lib/provider.rs +++ b/src/dfx/src/lib/provider.rs @@ -2,6 +2,7 @@ use crate::config::dfinity::ConfigNetwork; use crate::lib::environment::{AgentEnvironment, Environment}; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::network::network_descriptor::NetworkDescriptor; +use crate::util::expiry_duration; use clap::ArgMatches; use lazy_static::lazy_static; use std::sync::{Arc, RwLock}; @@ -80,8 +81,9 @@ pub fn create_agent_environment<'a>( args: &ArgMatches<'_>, ) -> DfxResult> { let network_descriptor = get_network_descriptor(env, args)?; + let duration = expiry_duration(args.value_of("expiry_duration"))?; - AgentEnvironment::new(env, network_descriptor, args) + AgentEnvironment::new(env, network_descriptor, duration) } pub fn command_line_provider_to_url(s: &str) -> DfxResult { From f1af2dc82e5d5d215bd34824bff67ff9ca3894d7 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 14 Sep 2020 21:59:36 -0700 Subject: [PATCH 06/10] remove configurability of expiry duration and use default value of 5 min --- src/dfx/src/commands/canister/call.rs | 2 +- src/dfx/src/commands/canister/create.rs | 2 +- src/dfx/src/commands/canister/delete.rs | 2 +- src/dfx/src/commands/canister/install.rs | 4 ++-- src/dfx/src/commands/canister/mod.rs | 21 ------------------- .../src/commands/canister/request_status.rs | 2 +- src/dfx/src/commands/canister/start.rs | 2 +- src/dfx/src/commands/canister/status.rs | 2 +- src/dfx/src/commands/canister/stop.rs | 2 +- src/dfx/src/commands/deploy.rs | 2 +- src/dfx/src/commands/ping.rs | 2 +- src/dfx/src/lib/environment.rs | 2 +- src/dfx/src/lib/message.rs | 1 - src/dfx/src/lib/provider.rs | 5 ++--- src/dfx/src/util/mod.rs | 10 +++------ 15 files changed, 17 insertions(+), 44 deletions(-) diff --git a/src/dfx/src/commands/canister/call.rs b/src/dfx/src/commands/canister/call.rs index 5853e072ed..1298f14c0e 100644 --- a/src/dfx/src/commands/canister/call.rs +++ b/src/dfx/src/commands/canister/call.rs @@ -130,7 +130,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let timeout = expiry_duration(); if is_query { let blob = diff --git a/src/dfx/src/commands/canister/create.rs b/src/dfx/src/commands/canister/create.rs index 7c5b101afc..98bcc0d81b 100644 --- a/src/dfx/src/commands/canister/create.rs +++ b/src/dfx/src/commands/canister/create.rs @@ -30,7 +30,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; - let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let timeout = expiry_duration(); if let Some(canister_name) = args.value_of("canister_name") { create_canister(env, canister_name, timeout)?; diff --git a/src/dfx/src/commands/canister/delete.rs b/src/dfx/src/commands/canister/delete.rs index 33d58e78b3..b63ee656b6 100644 --- a/src/dfx/src/commands/canister/delete.rs +++ b/src/dfx/src/commands/canister/delete.rs @@ -64,7 +64,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .get_agent() .ok_or(DfxError::CommandMustBeRunInAProject)?; - let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let timeout = expiry_duration(); let mut runtime = Runtime::new().expect("Unable to create a runtime"); diff --git a/src/dfx/src/commands/canister/install.rs b/src/dfx/src/commands/canister/install.rs index 7f715d1a0d..38048d6ef1 100644 --- a/src/dfx/src/commands/canister/install.rs +++ b/src/dfx/src/commands/canister/install.rs @@ -88,7 +88,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; - let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let timeout = expiry_duration(); let agent = env .get_agent() @@ -100,7 +100,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { }); let memory_allocation: Option = - args.value_of("memory_allocation").map(|arg| { + args.value_of("memory-allocation").map(|arg| { MemoryAllocation::try_from(u64::try_from(arg.parse::().unwrap().size()).unwrap()) .expect("Memory allocation must be between 0 and 2^48 (i.e 256TB), inclusively.") }); diff --git a/src/dfx/src/commands/canister/mod.rs b/src/dfx/src/commands/canister/mod.rs index 8c18ee3ac1..b846a35c2b 100644 --- a/src/dfx/src/commands/canister/mod.rs +++ b/src/dfx/src/commands/canister/mod.rs @@ -4,7 +4,6 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::provider::create_agent_environment; use clap::{App, Arg, ArgMatches, SubCommand}; -use humanize_rs::duration::parse; mod call; mod create; @@ -39,31 +38,11 @@ pub fn construct() -> App<'static, 'static> { .long("network") .takes_value(true), ) - .arg( - Arg::with_name("expiry-duration") - .long("expiry-duration") - .help(UserMessage::CanisterCallExpiryDuration.to_str()) - .takes_value(true) - .default_value("5m") - .validator(expiry_duration_validator), - ) .subcommands(builtins().into_iter().map(|x| x.get_subcommand().clone())) } -fn expiry_duration_validator(expiry_duration: String) -> Result<(), String> { - if let Ok(_ed) = parse(&expiry_duration) { - return Ok(()); - } - let err = format!( - r#""Invalid input: {}. Expected a duration-type string e.g. "1h", "1h 30m""#, - expiry_duration - ); - Err(err) -} - pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let subcommand = args.subcommand(); - let agent_env = create_agent_environment(env, args)?; if let (name, Some(subcommand_args)) = subcommand { diff --git a/src/dfx/src/commands/canister/request_status.rs b/src/dfx/src/commands/canister/request_status.rs index 761dd7d988..bf47b55d35 100644 --- a/src/dfx/src/commands/canister/request_status.rs +++ b/src/dfx/src/commands/canister/request_status.rs @@ -35,7 +35,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let timeout = expiry_duration(); let mut waiter = waiter_with_timeout(timeout); diff --git a/src/dfx/src/commands/canister/start.rs b/src/dfx/src/commands/canister/start.rs index b6a8f33175..bdda4b8642 100644 --- a/src/dfx/src/commands/canister/start.rs +++ b/src/dfx/src/commands/canister/start.rs @@ -65,7 +65,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let timeout = expiry_duration(); if let Some(canister_name) = args.value_of("canister_name") { runtime.block_on(start_canister(env, &agent, &canister_name, timeout))?; diff --git a/src/dfx/src/commands/canister/status.rs b/src/dfx/src/commands/canister/status.rs index e5252daca5..536aa5bc86 100644 --- a/src/dfx/src/commands/canister/status.rs +++ b/src/dfx/src/commands/canister/status.rs @@ -60,7 +60,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let timeout = expiry_duration(); if let Some(canister_name) = args.value_of("canister_name") { runtime.block_on(canister_status(env, &agent, &canister_name, timeout))?; diff --git a/src/dfx/src/commands/canister/stop.rs b/src/dfx/src/commands/canister/stop.rs index 27799ed365..69208cb876 100644 --- a/src/dfx/src/commands/canister/stop.rs +++ b/src/dfx/src/commands/canister/stop.rs @@ -64,7 +64,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let timeout = expiry_duration(); if let Some(canister_name) = args.value_of("canister_name") { runtime.block_on(stop_canister(env, &agent, &canister_name, timeout))?; diff --git a/src/dfx/src/commands/deploy.rs b/src/dfx/src/commands/deploy.rs index 4b5837eb5a..1067851dd3 100644 --- a/src/dfx/src/commands/deploy.rs +++ b/src/dfx/src/commands/deploy.rs @@ -26,7 +26,7 @@ pub fn construct() -> App<'static, 'static> { pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let env = create_agent_environment(env, args)?; - let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let timeout = expiry_duration(); let canister = args.value_of("canister_name"); deploy_canisters(&env, canister, timeout) diff --git a/src/dfx/src/commands/ping.rs b/src/dfx/src/commands/ping.rs index 17ef2d1d9d..d76f38cee8 100644 --- a/src/dfx/src/commands/ping.rs +++ b/src/dfx/src/commands/ping.rs @@ -38,7 +38,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { other => Err(other), })?; - let timeout = expiry_duration(args.value_of("expiry_duration"))?; + let timeout = expiry_duration(); let env = AgentEnvironment::new(env, network_descriptor, timeout)?; let agent = env diff --git a/src/dfx/src/lib/environment.rs b/src/dfx/src/lib/environment.rs index 3355879ac5..e19cad3e03 100644 --- a/src/dfx/src/lib/environment.rs +++ b/src/dfx/src/lib/environment.rs @@ -422,7 +422,7 @@ fn create_agent( url: url.to_string(), identity, password_manager: Some(Box::new(executor)), - ing_exp_duration: Some(timeout), + ingress_expiry_duration: Some(timeout), ..AgentConfig::default() }) .ok() diff --git a/src/dfx/src/lib/message.rs b/src/dfx/src/lib/message.rs index 832cba0543..45ae47aaa3 100644 --- a/src/dfx/src/lib/message.rs +++ b/src/dfx/src/lib/message.rs @@ -59,7 +59,6 @@ user_message!( // dfx canister mod ManageCanister => "Manages canisters deployed on a network replica.", - CanisterCallExpiryDuration => "The duration of time for which the message will considered valid and processed by the Internet Computer. Default value is set to 5 minutes.", // dfx canister delete DeleteCanister => "Deletes a canister on the Internet Computer network.", diff --git a/src/dfx/src/lib/provider.rs b/src/dfx/src/lib/provider.rs index 782ac772d4..9e59a322e9 100644 --- a/src/dfx/src/lib/provider.rs +++ b/src/dfx/src/lib/provider.rs @@ -81,9 +81,8 @@ pub fn create_agent_environment<'a>( args: &ArgMatches<'_>, ) -> DfxResult> { let network_descriptor = get_network_descriptor(env, args)?; - let duration = expiry_duration(args.value_of("expiry_duration"))?; - - AgentEnvironment::new(env, network_descriptor, duration) + let timeout = expiry_duration(); + AgentEnvironment::new(env, network_descriptor, timeout) } pub fn command_line_provider_to_url(s: &str) -> DfxResult { diff --git a/src/dfx/src/util/mod.rs b/src/dfx/src/util/mod.rs index 62e8ad3118..c85171c6b2 100644 --- a/src/dfx/src/util/mod.rs +++ b/src/dfx/src/util/mod.rs @@ -2,18 +2,14 @@ use crate::lib::error::{DfxError, DfxResult}; use candid::parser::typing::{check_prog, TypeEnv}; use candid::types::{Function, Type}; use candid::{parser::value::IDLValue, IDLArgs, IDLProg}; -use humanize_rs::duration::parse; use std::time::Duration; pub mod assets; pub mod clap; -pub fn expiry_duration(timeout: Option<&str>) -> DfxResult { - let dur = match timeout { - Some(expiry_duration) => parse(expiry_duration), - None => Ok(Duration::from_secs(60 * 5)), // 5 minutes is max ingress timeout - }?; - Ok(dur) +pub fn expiry_duration() -> Duration { + // 5 minutes is max ingress timeout + Duration::from_secs(60 * 5) } /// Deserialize and print return values from canister method. From 3e7dd5a290826d35f3b28bc4c463cb5ade98ae50 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 14 Sep 2020 22:16:16 -0700 Subject: [PATCH 07/10] update agent --- Cargo.lock | 4 ++-- src/dfx/Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c52ca5521a..e13901f3e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1651,7 +1651,7 @@ dependencies = [ [[package]] name = "ic-agent" version = "0.1.0" -source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=pshahi/ingress-expiry-two#b57f659d431198feaca98f7ef9adf9b1fdff7807" +source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=pshahi/ingress-expiry-two#8646ba549ad044a8946dbffef3838f5c07594106" dependencies = [ "async-trait", "base32", @@ -1679,7 +1679,7 @@ dependencies = [ [[package]] name = "ic-types" version = "0.1.1" -source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=pshahi/ingress-expiry-two#b57f659d431198feaca98f7ef9adf9b1fdff7807" +source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=pshahi/ingress-expiry-two#8646ba549ad044a8946dbffef3838f5c07594106" dependencies = [ "base32", "crc32fast", diff --git a/src/dfx/Cargo.toml b/src/dfx/Cargo.toml index 6bedf0f176..62abef0751 100644 --- a/src/dfx/Cargo.toml +++ b/src/dfx/Cargo.toml @@ -70,13 +70,13 @@ wasmparser = "0.45.0" version = "0.1.0" git = "ssh://git@github.com/dfinity-lab/agent-rust.git" branch = "pshahi/ingress-expiry-two" -rev = "93ef7cff4b11859719f43733c1d223f254d29e86" +rev = "8646ba549ad044a8946dbffef3838f5c07594106" [dependencies.ic-types] version = "0.1.1" git = "ssh://git@github.com/dfinity-lab/agent-rust.git" branch = "pshahi/ingress-expiry-two" -rev = "93ef7cff4b11859719f43733c1d223f254d29e86" +rev = "8646ba549ad044a8946dbffef3838f5c07594106" [dev-dependencies] From 1a29248a1f9ff4fb1e603ffd0d272e0c45745454 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi <50885601+p-shahi@users.noreply.github.com> Date: Tue, 15 Sep 2020 11:26:23 -0700 Subject: [PATCH 08/10] Update sources.json --- nix/sources.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index fe060eeee7..3fd31bccbd 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -39,8 +39,8 @@ }, "dfinity": { "repo": "ssh://git@github.com/dfinity-lab/dfinity", - "rev": "d0856d8d60b5a2d2a7b6f50fa0fa1d68db9264dc", - "branch": "akhi3030/expiry-time", + "rev": "ed4b1ae420f863a7b8393af058a2d62deebba2ed", + "branch": "master", "type": "git" }, "ic-ref": { From 3604cd84df3dcb5f15da936fd8816fa65751ea86 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi <50885601+p-shahi@users.noreply.github.com> Date: Tue, 15 Sep 2020 13:25:48 -0700 Subject: [PATCH 09/10] Update sources.json --- nix/sources.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/sources.json b/nix/sources.json index a48399278a..ed3248f6a6 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -40,7 +40,7 @@ "dfinity": { "repo": "ssh://git@github.com/dfinity-lab/dfinity", "rev": "ed4b1ae420f863a7b8393af058a2d62deebba2ed", - "branch": "master", + "tag": "release-2020-09-15.RC00", "type": "git" }, "ic-ref": { From 6347cb3e1338895e16d19b40a63c530829969315 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Tue, 15 Sep 2020 13:52:19 -0700 Subject: [PATCH 10/10] update rust agent --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/dfx/Cargo.toml | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e13901f3e6..27aa0620a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1651,7 +1651,7 @@ dependencies = [ [[package]] name = "ic-agent" version = "0.1.0" -source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=pshahi/ingress-expiry-two#8646ba549ad044a8946dbffef3838f5c07594106" +source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=next#9d611f08cb55923fc6ff5bf0136e8f4b848dd2cc" dependencies = [ "async-trait", "base32", @@ -1679,7 +1679,7 @@ dependencies = [ [[package]] name = "ic-types" version = "0.1.1" -source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=pshahi/ingress-expiry-two#8646ba549ad044a8946dbffef3838f5c07594106" +source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=next#9d611f08cb55923fc6ff5bf0136e8f4b848dd2cc" dependencies = [ "base32", "crc32fast", diff --git a/Cargo.toml b/Cargo.toml index faa8aa9215..eaa1d3163d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,4 +4,4 @@ members = [ ] [patch.crates-io] -ic-types = { git = "ssh://git@github.com/dfinity-lab/agent-rust.git", branch = "pshahi/ingress-expiry-two", version = "0.1.1" } +ic-types = { git = "ssh://git@github.com/dfinity-lab/agent-rust.git", branch = "next", version = "0.1.1" } diff --git a/src/dfx/Cargo.toml b/src/dfx/Cargo.toml index 62abef0751..9a49e3e0b3 100644 --- a/src/dfx/Cargo.toml +++ b/src/dfx/Cargo.toml @@ -69,14 +69,14 @@ wasmparser = "0.45.0" [dependencies.ic-agent] version = "0.1.0" git = "ssh://git@github.com/dfinity-lab/agent-rust.git" -branch = "pshahi/ingress-expiry-two" -rev = "8646ba549ad044a8946dbffef3838f5c07594106" +branch = "next" +rev = "9d611f08cb55923fc6ff5bf0136e8f4b848dd2cc" [dependencies.ic-types] version = "0.1.1" git = "ssh://git@github.com/dfinity-lab/agent-rust.git" -branch = "pshahi/ingress-expiry-two" -rev = "8646ba549ad044a8946dbffef3838f5c07594106" +branch = "next" +rev = "9d611f08cb55923fc6ff5bf0136e8f4b848dd2cc" [dev-dependencies]