Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump candid #3505

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
696 changes: 353 additions & 343 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ base64 = "0.13.0"
byte-unit = "4.0.14"
bytes = "1.2.1"
clap = "4.2.0"
dialoguer = "0.10.0"
dialoguer = "0.11.0"
directories-next = "2.0.0"
flate2 = { version = "1.0.11", default-features = false }
futures = "0.3.21"
Expand Down Expand Up @@ -65,7 +65,7 @@ semver = "1.0.6"
tempfile = "3.3.0"
thiserror = "1.0.24"
time = "0.3.9"
tokio = "1.24.2"
tokio = "1.35"
url = "2.1.0"
walkdir = "2.3.2"

Expand Down
1 change: 0 additions & 1 deletion e2e/tests-dfx/basic-project.bash
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ teardown() {
17_724 = record { 153_986_224 = blob "\44\49\44\4c\00\01\7d\b9\0a" }
},
)'

}

@test "build + install + call -- counter_idl_mo" {
Expand Down
13 changes: 8 additions & 5 deletions src/canisters/frontend/ic-certified-assets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ base64.workspace = true
candid.workspace = true
hex.workspace = true
ic-cdk.workspace = true
ic-certification = "1.3.0"
ic-response-verification = "0.3.0"
ic-representation-independent-hash = "0.3.0"
ic-certification = "2.3.0"
ic-response-verification = "2.3.0"
ic-representation-independent-hash = "2.3.0"
itertools.workspace = true
num-traits.workspace = true
serde.workspace = true
Expand All @@ -27,6 +27,9 @@ serde_cbor.workspace = true
sha2.workspace = true

[dev-dependencies]
ic-http-certification = "2.3.0"
candid_parser.workspace = true
ic-response-verification-test-utils = { git = "https://github.com/dfinity/response-verification.git", rev = "4686895c6070ac36109a01f4bd642caf2369b97b" }
ic-crypto-tree-hash = { git = "https://github.com/dfinity/ic.git", rev = "a533346f63f4091eb64692891de0d5b2ffd5b22a" }
anyhow.workspace = true
ic-response-verification-test-utils = { git = "https://github.com/dfinity/response-verification.git", rev = "a65009624b61736df6d2dc17756bdbd02a84f599" }
ic-certification-testing = { git = "https://github.com/dfinity/response-verification.git", rev = "a65009624b61736df6d2dc17756bdbd02a84f599" }
ic-crypto-tree-hash = { git = "https://github.com/dfinity/ic.git", rev = "1290256484f59c3d950c5e9a098e97383b248ad6" }
4 changes: 3 additions & 1 deletion src/canisters/frontend/ic-certified-assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ fn is_controller() -> Result<(), String> {

pub fn init(args: Option<AssetCanisterArgs>) {
if let Some(upgrade_arg) = args {
let AssetCanisterArgs::Init(InitArgs {}) = upgrade_arg else { ic_cdk::trap("Cannot initialize the canister with an Upgrade argument. Please provide an Init argument.")};
let AssetCanisterArgs::Init(InitArgs {}) = upgrade_arg else {
ic_cdk::trap("Cannot initialize the canister with an Upgrade argument. Please provide an Init argument.")
};
}
STATE.with(|s| {
let mut s = s.borrow_mut();
Expand Down
34 changes: 17 additions & 17 deletions src/canisters/frontend/ic-certified-assets/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ use crate::types::{
};
use crate::url_decode::{url_decode, UrlDecodeError};
use candid::{Nat, Principal};
use ic_certification_testing::CertificateBuilder;
use ic_crypto_tree_hash::Digest;
use ic_response_verification::ResponseVerificationError;
use ic_response_verification_test_utils::{
base64_encode, create_canister_id, get_current_timestamp, CanisterData, CertificateBuilder,
CertificateData,
base64_encode, create_canister_id, get_current_timestamp,
};
use serde_bytes::ByteBuf;
use std::collections::HashMap;
Expand All @@ -34,21 +33,20 @@ pub fn verify_response(
state: &State,
request: &HttpRequest,
response: &HttpResponse,
) -> Result<bool, ResponseVerificationError> {
) -> anyhow::Result<bool> {
let mut response = response.clone();
let current_time = get_current_timestamp();
let canister_id = create_canister_id("rdmx6-jaaaa-aaaaa-aaadq-cai");
let min_requested_verification_version = request.get_certificate_version();

// inject certificate into IC-Certificate header with 'certificate=::'
let (_cert, root_key, cert_cbor) =
CertificateBuilder::new(CertificateData::CanisterData(CanisterData {
canister_id,
certified_data: Digest(state.root_hash()),
}))
.with_time(current_time)
.build();
let replacement_cert_value = base64_encode(&cert_cbor);
let data = CertificateBuilder::new(
&canister_id.to_string(),
Digest(state.root_hash()).as_bytes(),
)?
.with_time(current_time)
.build()?;
let replacement_cert_value = base64_encode(&data.cbor_encoded_certificate);
let (_, header_value) = response
.headers
.iter_mut()
Expand All @@ -60,26 +58,28 @@ pub fn verify_response(
);

// actual verification
let request = ic_response_verification::types::Request {
let request = ic_http_certification::http::HttpRequest {
method: request.method.clone(),
url: request.url.clone(),
headers: request.headers.clone(),
body: request.body[..].into(),
};
let response = ic_response_verification::types::Response {
let response = ic_http_certification::http::HttpResponse {
status_code: response.status_code,
headers: response.headers,
body: response.body[..].into(),
upgrade: None,
};
ic_response_verification::verify_request_response_pair(
Ok(ic_response_verification::verify_request_response_pair(
request,
response,
canister_id.as_ref(),
current_time,
MAX_CERT_TIME_OFFSET_NS,
&root_key,
&data.root_key,
min_requested_verification_version.try_into().unwrap(),
)
.map(|res| res.passed)
.map(|res| res.response.is_some())?)
}

fn certified_http_request(state: &State, request: HttpRequest) -> HttpResponse {
Expand Down
3 changes: 1 addition & 2 deletions src/dfx-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ bip32 = "0.4.0"
byte-unit = { workspace = true, features = ["serde"] }
bytes.workspace = true
candid = { workspace = true }
candid_parser = { workspace = true, features = ["random"] }
clap = { workspace = true, features = ["string"] }
dialoguer = "0.10.0"
dialoguer = { workspace = true }
directories-next.workspace = true
dunce = "1.0"
flate2 = { workspace = true, default-features = false, features = ["zlib-ng"] }
Expand Down
1 change: 0 additions & 1 deletion src/dfx-core/src/config/model/dfinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ pub enum WasmOptLevel {
Oz,
Os,
}

impl std::fmt::Display for WasmOptLevel {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
std::fmt::Debug::fmt(self, f)
Expand Down
2 changes: 1 addition & 1 deletion src/dfx-core/src/error/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum EncryptionError {
NonceGenerationFailed(ring::error::Unspecified),

#[error("Failed to read user input: {0}")]
ReadUserPasswordFailed(std::io::Error),
ReadUserPasswordFailed(dialoguer::Error),

#[error("Failed to generate salt: {0}")]
SaltGenerationFailed(ring::error::Unspecified),
Expand Down
Loading