From 66085c48ba68135d78fe84918578b5a8fe2763f7 Mon Sep 17 00:00:00 2001 From: mraszyk <31483726+mraszyk@users.noreply.github.com> Date: Fri, 8 Sep 2023 23:05:38 +0200 Subject: [PATCH] feat: Unknown lookup status of a path in certificate yields error (#3278) Absence proofs have been recently enabled on the IC (see [MR](https://github.com/dfinity/ic/commit/2ac0fe91cd737977bf039c55502a31b363884c69)) and thus the IC is going to produce certificate whose lookup returns Absent for paths whose values are missing in the state tree. This PR reflects this change. --- CHANGELOG.md | 4 ++++ src/dfx/src/lib/state_tree/canister_info.rs | 7 ++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d7168c4f6..4b9bffcec4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ # UNRELEASED +### feat: Updated handling of missing values in state tree certificates + +The `Unknown` lookup of a path in a certificate results in an `AgentError` (the IC returns `Absent` for non-existing paths). + ### fix: dfx deploy urls printed for asset canisters ### chore: --emulator parameter is deprecated and will be discontinued soon diff --git a/src/dfx/src/lib/state_tree/canister_info.rs b/src/dfx/src/lib/state_tree/canister_info.rs index 7b01527bb9..f84b49c737 100644 --- a/src/dfx/src/lib/state_tree/canister_info.rs +++ b/src/dfx/src/lib/state_tree/canister_info.rs @@ -12,7 +12,7 @@ pub async fn read_state_tree_canister_controllers( .read_state_canister_info(canister_id, "controllers") .await { - Err(AgentError::LookupPathUnknown(_) | AgentError::LookupPathAbsent(_)) => { + Err(AgentError::LookupPathAbsent(_)) => { return Ok(None); } r => r.with_context(|| format!("Failed to read controllers of canister {canister_id}."))?, @@ -57,10 +57,7 @@ pub async fn read_state_tree_canister_module_hash( .await { Ok(blob) => Some(blob), - // If the canister is empty, this path does not exist. - // The replica doesn't support negative lookups, therefore if the canister - // is empty, the replica will return lookup_path([], Pruned _) = Unknown - Err(AgentError::LookupPathUnknown(_)) | Err(AgentError::LookupPathAbsent(_)) => None, + Err(AgentError::LookupPathAbsent(_)) => None, Err(x) => bail!(x), };