Skip to content

Commit

Permalink
dependency requires newer Rust version
Browse files Browse the repository at this point in the history
  • Loading branch information
sesi200 committed Feb 3, 2025
1 parent 12afb3d commit 1d0018e
Show file tree
Hide file tree
Showing 30 changed files with 45 additions and 83 deletions.
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.78.0"
channel = "1.81.0"
components = ["rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]
8 changes: 1 addition & 7 deletions src/canisters/frontend/ic-asset/src/batch_upload/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,7 @@ async fn make_project_asset(
progress: Option<&dyn AssetSyncProgressRenderer>,
) -> Result<ProjectAsset, CreateProjectAssetError> {
let file_size = dfx_core::fs::metadata(&asset_descriptor.source)?.len();
let permits = std::cmp::max(
1,
std::cmp::min(
((file_size + 999999) / 1000000) as usize,
MAX_COST_SINGLE_FILE_MB,
),
);
let permits = (((file_size + 999999) / 1000000) as usize).clamp(1, MAX_COST_SINGLE_FILE_MB);
let _releaser = semaphores.file.acquire(permits).await;
let content = Content::load(&asset_descriptor.source)
.map_err(CreateProjectAssetError::LoadContentFailed)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,13 @@ impl CertifiedResponses {

/// If the path has certified responses this function creates a hash tree that proves...
/// * The path is part of the CertifiedResponses hash tree
///
/// The hash tree then includes certification for all valid responses for this path.
///
/// If the path has no certified responses this function creates a hash tree that proves...
/// * The absence of the path in the CertifiedResponses hash tree
/// * The presence/absence of a 404 response
///
/// The hash tree then includes certification for all valid responses for a 404 response.
///
/// # Return Value
Expand Down Expand Up @@ -217,11 +219,13 @@ impl CertifiedResponses {

/// If the path has certified responses this function creates a hash tree that proves...
/// * The path is part of the CertifiedResponses hash tree
///
/// The hash tree then includes certification the valid certification v1 response for this path.
///
/// If the path has no certified response this function creates a hash tree that proves...
/// * The absence of the path in the CertifiedResponses hash tree
/// * The presence/absence of a 404 response
///
/// The hash tree then includes certification for the valid certification v1 response for a 404 response.
///
/// # Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ impl HashTreePath {
/// Produces all `HashTreePath`s required to prove
/// - whether or not fallback file exists and
/// - that there is no fallback file with higher priority
///
/// in the hash tree.
pub fn fallback_paths_v2(&self) -> Vec<Self> {
let mut paths = Vec::new();
Expand Down
2 changes: 2 additions & 0 deletions src/dfx-core/src/config/project_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ pub struct ProjectTemplate {
/// - motoko=0
/// - rust=1
/// - everything else=2 (and then by display name)
///
/// For frontend:
/// - SvelteKit=0
/// - React=1
/// - Vue=2
/// - Vanilla JS=3
/// - No JS Template=4
/// - everything else=5 (and then by display name)
///
/// For extras:
/// - Internet Identity=0
/// - Bitcoin=1
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/actors/btc_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ fn btc_adapter_start_thread(
let thread_handler = move || {
let btc_adapter_path = config.btc_adapter_path.as_os_str();
let mut cmd = std::process::Command::new(btc_adapter_path);
cmd.arg(&config.config_path.to_string_lossy().to_string());
cmd.arg(config.config_path.to_string_lossy().to_string());

cmd.stdout(std::process::Stdio::inherit());
cmd.stderr(std::process::Stdio::inherit());
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/actors/canister_http_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn canister_http_adapter_start_thread(
let thread_handler = move || {
let adapter_path = config.adapter_path.as_os_str();
let mut cmd = std::process::Command::new(adapter_path);
cmd.arg(&config.config_path.to_string_lossy().to_string());
cmd.arg(config.config_path.to_string_lossy().to_string());

cmd.stdout(std::process::Stdio::inherit());
cmd.stderr(std::process::Stdio::inherit());
Expand Down
3 changes: 0 additions & 3 deletions src/dfx/src/actors/pocketic_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ pub struct PocketIcProxyConfig {
/// fixed replica address
pub replica_url: Option<Url>,

/// does the proxy need to fetch the root key
pub fetch_root_key: bool,

/// run pocket-ic in non-quiet mode
pub verbose: bool,

Expand Down
8 changes: 3 additions & 5 deletions src/dfx/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ pub fn exec(env: &dyn Environment, opts: CanisterBuildOpts) -> DfxResult {
slog::info!(logger, "Building canisters...");

let runtime = Runtime::new().expect("Unable to create a runtime");
let build_config =
BuildConfig::from_config(&config, env.get_network_descriptor().is_playground())?
.with_build_mode_check(build_mode_check)
.with_canisters_to_build(canisters_to_build)
.with_env_file(env_file);
let build_config = BuildConfig::from_config(&config)?
.with_canisters_to_build(canisters_to_build)
.with_env_file(env_file);
runtime.block_on(canister_pool.build_or_fail(&env, logger, &build_config))?;

Ok(())
Expand Down
6 changes: 2 additions & 4 deletions src/dfx/src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ pub fn exec(env: &dyn Environment, opts: GenerateOpts) -> DfxResult {
}
}
let build_config =
BuildConfig::from_config(&config, env.get_network_descriptor().is_playground())?
.with_canisters_to_build(build_before_generate);
BuildConfig::from_config(&config)?.with_canisters_to_build(build_before_generate);
let generate_config =
BuildConfig::from_config(&config, env.get_network_descriptor().is_playground())?
.with_canisters_to_build(canisters_to_generate);
BuildConfig::from_config(&config)?.with_canisters_to_build(canisters_to_generate);

if build_config
.canisters_to_build
Expand Down
3 changes: 1 addition & 2 deletions src/dfx/src/commands/language_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ pub fn exec(env: &dyn Environment, opts: LanguageServiceOpts) -> DfxResult {
}

// Add IDL directory flag
let build_config =
BuildConfig::from_config(&config, env.get_network_descriptor().is_playground())?;
let build_config = BuildConfig::from_config(&config)?;
package_arguments.append(&mut vec![
"--actor-idl".to_owned(),
(*build_config.lsp_root.to_string_lossy()).to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ fn get_agent_js_version_from_npm(dist_tag: &str) -> DfxResult<String> {
let output = Command::new(program::NPM)
.arg("show")
.arg("@dfinity/agent")
.arg(&format!("dist-tags.{}", dist_tag))
.arg(format!("dist-tags.{}", dist_tag))
.stdout(Stdio::piped())
.stderr(Stdio::inherit())
.output()
Expand Down
2 changes: 0 additions & 2 deletions src/dfx/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ pub fn exec(
}
save_json_file(&previous_config_path, &effective_config)?;

let network_descriptor = network_descriptor.clone();
let spinner = env.new_spinner("Starting local network...".into());
let system = actix::System::new();
let _proxy = system.block_on(async move {
Expand Down Expand Up @@ -412,7 +411,6 @@ pub fn exec(
let pocketic_proxy_config = PocketIcProxyConfig {
bind: address_and_port,
replica_url: None,
fetch_root_key: !network_descriptor.is_ic,
domains: proxy_domains,
verbose: env.get_verbose_level() > 0,
};
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/commands/wallet/add_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub async fn exec(env: &dyn Environment, opts: AddControllerOpts) -> DfxResult {
opts.controller
)
})?;
wallet_update(env, "add_controller", controller).await?;
wallet_update::<_, ()>(env, "add_controller", controller).await?;
println!("Added {} as a controller.", controller);
Ok(())
}
2 changes: 1 addition & 1 deletion src/dfx/src/commands/wallet/authorize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub async fn exec(env: &dyn Environment, opts: AuthorizeOpts) -> DfxResult {
opts.custodian
)
})?;
wallet_update(env, "authorize", custodian).await?;
wallet_update::<_, ()>(env, "authorize", custodian).await?;
println!("Authorized {} as a custodian.", custodian);
Ok(())
}
2 changes: 1 addition & 1 deletion src/dfx/src/commands/wallet/deauthorize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub async fn exec(env: &dyn Environment, opts: DeauthorizeOpts) -> DfxResult {
opts.custodian
)
})?;
wallet_update(env, "deauthorize", custodian).await?;
wallet_update::<_, ()>(env, "deauthorize", custodian).await?;
println!("Deauthorized {} as a custodian.", opts.custodian);
Ok(())
}
2 changes: 1 addition & 1 deletion src/dfx/src/commands/wallet/remove_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub async fn exec(env: &dyn Environment, opts: RemoveControllerOpts) -> DfxResul
opts.controller
)
})?;
wallet_update(env, "remove_controller", controller).await?;
wallet_update::<_, ()>(env, "remove_controller", controller).await?;
println!("Removed {} as a controller.", controller);
Ok(())
}
2 changes: 1 addition & 1 deletion src/dfx/src/commands/wallet/set_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct SetNameOpts {
}

pub async fn exec(env: &dyn Environment, opts: SetNameOpts) -> DfxResult {
wallet_update(env, "set_name", opts.name.clone()).await?;
wallet_update::<_, ()>(env, "set_name", opts.name.clone()).await?;
println!("Set name to {}.", opts.name);
Ok(())
}
1 change: 0 additions & 1 deletion src/dfx/src/lib/builders/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ impl CanisterBuilder for AssetsBuilder {
fs::write(&wasm_path, canister_assets).context("Failed to write asset canister wasm")?;
let idl_path = info.get_output_root().join(Path::new("assetstorage.did"));
Ok(BuildOutput {
canister_id: info.get_canister_id().expect("Could not find canister ID."),
wasm: WasmBuildOutput::File(wasm_path),
idl: IdlBuildOutput::File(idl_path),
})
Expand Down
2 changes: 0 additions & 2 deletions src/dfx/src/lib/builders/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ impl CanisterBuilder for CustomBuilder {
dependencies,
} = CustomBuilderExtra::try_from(info, pool)?;

let canister_id = info.get_canister_id().unwrap();
let vars = super::get_and_write_environment_variables(
info,
&config.network_name,
Expand All @@ -129,7 +128,6 @@ impl CanisterBuilder for CustomBuilder {
}

Ok(BuildOutput {
canister_id,
wasm: WasmBuildOutput::File(wasm),
idl: IdlBuildOutput::File(info.get_output_idl_path().to_path_buf()),
})
Expand Down
17 changes: 1 addition & 16 deletions src/dfx/src/lib/builders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pub enum IdlBuildOutput {
/// The output of a build.
#[derive(Debug)]
pub struct BuildOutput {
pub canister_id: CanisterId,
pub wasm: WasmBuildOutput,
pub idl: IdlBuildOutput,
}
Expand Down Expand Up @@ -482,16 +481,12 @@ fn write_environment_variables(vars: &[Env<'_>], write_path: &Path) -> DfxResult
#[derive(Clone, Debug)]
pub struct BuildConfig {
profile: Profile,
pub build_mode_check: bool,
pub network_name: String,
pub network_is_playground: bool,

/// The root of all IDL files.
pub idl_root: PathBuf,
/// The root for all language server files.
pub lsp_root: PathBuf,
/// The root for all build files.
pub build_root: PathBuf,
/// If only a subset of canisters should be built, then canisters_to_build contains these canisters' names.
/// If all canisters should be built, then this is None.
pub canisters_to_build: Option<Vec<String>>,
Expand All @@ -501,32 +496,22 @@ pub struct BuildConfig {

impl BuildConfig {
#[context("Failed to create build config.")]
pub fn from_config(config: &Config, network_is_playground: bool) -> DfxResult<Self> {
pub fn from_config(config: &Config) -> DfxResult<Self> {
let config_intf = config.get_config();
let network_name = util::network_to_pathcompat(&get_network_context()?);
let network_root = config.get_temp_path()?.join(&network_name);
let canister_root = network_root.join("canisters");

Ok(BuildConfig {
network_name,
network_is_playground,
profile: config_intf.profile.unwrap_or(Profile::Debug),
build_mode_check: false,
build_root: canister_root.clone(),
idl_root: canister_root.join("idl/"), // TODO: possibly move to `network_root.join("idl/")`
lsp_root: network_root.join("lsp/"),
canisters_to_build: None,
env_file: config.get_output_env_file(None)?,
})
}

pub fn with_build_mode_check(self, build_mode_check: bool) -> Self {
Self {
build_mode_check,
..self
}
}

pub fn with_canisters_to_build(self, canisters: Vec<String>) -> Self {
Self {
canisters_to_build: Some(canisters),
Expand Down
3 changes: 0 additions & 3 deletions src/dfx/src/lib/builders/motoko.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,6 @@ impl CanisterBuilder for MotokoBuilder {
motoko_compile(env, &self.logger, cache, &params)?;

Ok(BuildOutput {
canister_id: canister_info
.get_canister_id()
.expect("Could not find canister ID."),
wasm: WasmBuildOutput::File(motoko_info.get_output_wasm_path().to_path_buf()),
idl: IdlBuildOutput::File(canister_info.get_output_idl_path().to_path_buf()),
})
Expand Down
3 changes: 0 additions & 3 deletions src/dfx/src/lib/builders/pull.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::lib::builders::{
BuildConfig, BuildOutput, CanisterBuilder, IdlBuildOutput, WasmBuildOutput,
};
use crate::lib::canister_info::pull::PullCanisterInfo;
use crate::lib::canister_info::CanisterInfo;
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
Expand Down Expand Up @@ -45,9 +44,7 @@ impl CanisterBuilder for PullBuilder {
canister_info: &CanisterInfo,
_config: &BuildConfig,
) -> DfxResult<BuildOutput> {
let pull_info = canister_info.as_info::<PullCanisterInfo>()?;
Ok(BuildOutput {
canister_id: *pull_info.get_canister_id(),
// It's impossible to know if the downloaded wasm is gzip or not with only the info in `dfx.json`.
wasm: WasmBuildOutput::None,
idl: IdlBuildOutput::File(canister_info.get_output_idl_path().to_path_buf()),
Expand Down
3 changes: 0 additions & 3 deletions src/dfx/src/lib/builders/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ impl CanisterBuilder for RustBuilder {
let rust_info = canister_info.as_info::<RustCanisterInfo>()?;
let package = rust_info.get_package();

let canister_id = canister_info.get_canister_id().unwrap();

let mut cargo = Command::new("cargo");
cargo
.stdout(Stdio::inherit())
Expand Down Expand Up @@ -103,7 +101,6 @@ impl CanisterBuilder for RustBuilder {
}

Ok(BuildOutput {
canister_id,
wasm: WasmBuildOutput::File(rust_info.get_output_wasm_path().to_path_buf()),
idl: IdlBuildOutput::File(canister_info.get_output_idl_path().to_path_buf()),
})
Expand Down
10 changes: 4 additions & 6 deletions src/dfx/src/lib/canister_logs/log_visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,11 @@ impl LogVisibilityOpt {

// Removing.
if let Some(removed) = self.remove_log_viewer.as_ref() {
if let Some(visibility) = &current_visibility {
match visibility {
LogVisibility::Public | LogVisibility::Controllers => {
return Err(anyhow!("Removing reviewers is not allowed with 'public' or 'controllers' log visibility."));
}
_ => (),
match &current_visibility {
Some(LogVisibility::Public) | Some(LogVisibility::Controllers) => {
return Err(anyhow!("Removing reviewers is not allowed with 'public' or 'controllers' log visibility."));
}
_ => {}
}
for principal in removed {
if let Some(idx) = viewers.iter().position(|x| x == principal) {
Expand Down
5 changes: 3 additions & 2 deletions src/dfx/src/lib/deps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ pub struct PulledCanister {
/// - wasm_hash if defined in the dfx metadata
/// - wasm_hash_url content if defined in the dfx metadata
/// - otherwise read from canister_status
/// This field is kept here so that users can compare the hash of the downloaded wasm with it
/// If matched, we get extra confidence that the downloaded wasm is correct
///
/// This field is kept here so that users can compare the hash of the downloaded wasm with it.
/// If matched, we get extra confidence that the downloaded wasm is correct.
/// If not matched, it is still acceptable
pub wasm_hash: String,
/// The downloaded wasm hash when `dfx deps pull`
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/lib/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async fn migrate_canister(
settings: CanisterSettings,
}
wallet
.call(
.call::<(), _>(
Principal::management_canister(),
"update_settings",
Argument::from_candid((In {
Expand Down
7 changes: 3 additions & 4 deletions src/dfx/src/lib/operations/canister/deploy_canisters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,9 @@ async fn build_canisters(
let build_mode_check = false;
let canister_pool = CanisterPool::load(env, build_mode_check, canisters_to_load)?;

let build_config =
BuildConfig::from_config(config, env.get_network_descriptor().is_playground())?
.with_canisters_to_build(canisters_to_build.into())
.with_env_file(env_file);
let build_config = BuildConfig::from_config(config)?
.with_canisters_to_build(canisters_to_build.into())
.with_env_file(env_file);
canister_pool.build_or_fail(env, log, &build_config).await?;
Ok(canister_pool)
}
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/lib/operations/canister/install_canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ The command line value will be used.",
.expect("Selected identity not instantiated.");
// Before storing assets, make sure the DFX principal is in there first.
wallet
.call(
.call::<(), _>(
canister_id,
"authorize",
Argument::from_candid((self_id,)),
Expand Down
Loading

0 comments on commit 1d0018e

Please sign in to comment.