diff --git a/CHANGELOG.md b/CHANGELOG.md index a6b2f662d6..c088086aa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,20 @@ # UNRELEASED +### feat: dfx deps: wasm_hash_url and loose the hash check + +Providers can provide the hash through `wasm_hash_url` instead of hard coding the hash directly. + +If the hash of downloaded wasm doesn’t match the provided hash (`wasm_hash`, `wasm_hash_url` or read from mainnet state tree), dfx deps won’t abort. Instead, it will print a warning message. + ### feat!: update `dfx cycles` commands with mainnet `cycles-ledger` canister ID The `dfx cycles` command no longer needs nor accepts the `--cycles-ledger-canister-id ` parameter. +### chore: removed the dfx start --emulator mode + +This was deprecated in dfx 0.15.1. + ### chore: removed ic-ref from the binary cache ### chore: updated dependencies for new rust projects @@ -25,7 +35,7 @@ Updated Motoko to [0.10.4](https://github.com/dfinity/motoko/releases/tag/0.10.4 ### Frontend canister -Module hash: b625e04115725038808dcd6db1e398def28e981f8d6de464bb8438b2656864c8 +Module hash: 3c86d912ead6de7133b9f787df4ca9feee07bea8835d3ed594b47ee89e6cb730 # 0.15.3 diff --git a/Cargo.lock b/Cargo.lock index f57c19b0d9..8936a6b315 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -329,6 +329,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + [[package]] name = "async-io" version = "1.13.0" @@ -433,12 +439,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa" -[[package]] -name = "base64" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" - [[package]] name = "base64" version = "0.13.1" @@ -734,34 +734,38 @@ dependencies = [ ] [[package]] -name = "candid" -version = "0.8.4" +name = "cached" +version = "0.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "244005a1917bb7614cd775ca8a5d59efeb5ac74397bb14ba29a19347ebd78591" +checksum = "69b0116662497bc24e4b177c90eaf8870e39e2714c3fcfa296327a93f593fc21" dependencies = [ - "anyhow", - "binread", - "byteorder", - "candid_derive 0.5.0", - "codespan-reporting", - "crc32fast", - "data-encoding", - "hex", - "lalrpop 0.19.12", - "lalrpop-util 0.19.12", - "leb128", - "logos 0.12.1", - "num-bigint 0.4.4", - "num-traits", - "num_enum", - "paste", - "pretty 0.10.0", - "serde", - "serde_bytes", - "sha2 0.10.8", + "ahash 0.8.6", + "cached_proc_macro", + "cached_proc_macro_types", + "hashbrown 0.14.2", + "instant", + "once_cell", "thiserror", ] +[[package]] +name = "cached_proc_macro" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c878c71c2821aa2058722038a59a67583a4240524687c6028571c9b395ded61f" +dependencies = [ + "darling 0.14.4", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cached_proc_macro_types" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663" + [[package]] name = "candid" version = "0.10.2" @@ -771,7 +775,7 @@ dependencies = [ "anyhow", "binread", "byteorder", - "candid_derive 0.6.5", + "candid_derive", "hex", "ic_principal", "leb128", @@ -785,18 +789,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "candid_derive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f1f4db7c7d04b87b70b3a35c5dc5c2c9dd73cef8bdf6760e2f18a0d45350dd" -dependencies = [ - "lazy_static", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "candid_derive" version = "0.6.5" @@ -817,14 +809,14 @@ checksum = "36381de3ba8a312deb028552c0d63f7c7fe6e204f44bae4c58a3643308cfa9d5" dependencies = [ "anyhow", "arbitrary", - "candid 0.10.2", + "candid", "codespan-reporting", "convert_case 0.6.0", "fake", "hex", - "lalrpop 0.20.0", - "lalrpop-util 0.20.0", - "logos 0.13.0", + "lalrpop", + "lalrpop-util", + "logos", "num-bigint 0.4.4", "num-traits", "pretty 0.12.3", @@ -872,6 +864,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", + "serde", "wasm-bindgen", "windows-targets 0.48.5", ] @@ -1039,6 +1032,16 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen", +] + [[package]] name = "const-oid" version = "0.9.5" @@ -1303,8 +1306,18 @@ version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.13.4", + "darling_macro 0.13.4", +] + +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core 0.14.4", + "darling_macro 0.14.4", ] [[package]] @@ -1321,13 +1334,38 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + [[package]] name = "darling_macro" version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ - "darling_core", + "darling_core 0.13.4", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core 0.14.4", "quote", "syn 1.0.109", ] @@ -1390,7 +1428,7 @@ dependencies = [ [[package]] name = "derive_more" version = "0.99.8-alpha.0" -source = "git+https://github.com/dfinity-lab/derive_more?branch=master#9f1b894e6fde640da4e9ea71a8fc0e4dd98d01da" +source = "git+https://github.com/dfinity-lab/derive_more?rev=9f1b894e6fde640da4e9ea71a8fc0e4dd98d01da#9f1b894e6fde640da4e9ea71a8fc0e4dd98d01da" dependencies = [ "proc-macro2", "quote", @@ -1417,7 +1455,7 @@ dependencies = [ "base64 0.13.1", "byte-unit", "bytes", - "candid 0.10.2", + "candid", "candid_parser", "ci_info", "clap", @@ -1502,8 +1540,7 @@ dependencies = [ "bip32", "byte-unit", "bytes", - "candid 0.10.2", - "candid_parser", + "candid", "clap", "dialoguer", "directories-next", @@ -1572,13 +1609,14 @@ dependencies = [ [[package]] name = "dialoguer" -version = "0.10.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59c6f2989294b9a498d3ad5491a79c6deb604617378e1cdc4bfc1c1361fe2f87" +checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" dependencies = [ "console", "shell-words", "tempfile", + "thiserror", "zeroize", ] @@ -1885,15 +1923,6 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" -[[package]] -name = "features" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83072b3c84e55f9d0c0ff36a4575d0fd2e543ae4a56e04e7f5a9222188d574e3" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "ff" version = "0.12.1" @@ -1943,15 +1972,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "float-cmp" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" -dependencies = [ - "num-traits", -] - [[package]] name = "fn-error-context" version = "0.2.1" @@ -2478,13 +2498,13 @@ source = "git+https://github.com/dfinity/agent-rs.git?rev=a7f44ad05e77fc89b8447d dependencies = [ "backoff", "cached 0.46.1", - "candid 0.10.2", + "candid", "ed25519-consensus", "futures-util", "hex", "http", "http-body", - "ic-certification 2.3.0", + "ic-certification 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "ic-transport-types", "ic-verify-bls-signature", "k256 0.13.1", @@ -2514,7 +2534,7 @@ name = "ic-asset" version = "0.20.0" dependencies = [ "backoff", - "candid 0.10.2", + "candid", "derivative", "dfx-core", "flate2", @@ -2543,53 +2563,68 @@ dependencies = [ [[package]] name = "ic-base-types" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ "base32", "byte-unit", "bytes", - "candid 0.8.4", + "candid", "comparable", "crc32fast", - "ic-crypto-sha", + "ic-crypto-sha2", "ic-protobuf", + "ic-stable-structures", "phantom_newtype", "prost", "serde", - "strum 0.23.0", - "strum_macros 0.23.1", + "strum 0.25.0", + "strum_macros 0.25.3", ] [[package]] -name = "ic-btc-types" +name = "ic-btc-interface" version = "0.1.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +source = "git+https://github.com/dfinity/bitcoin-canister?rev=9b239d1d67253eb14a35be6061e3967d5ec9db9d#9b239d1d67253eb14a35be6061e3967d5ec9db9d" dependencies = [ - "candid 0.8.4", + "candid", "serde", "serde_bytes", ] [[package]] name = "ic-btc-types-internal" -version = "0.1.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ - "candid 0.8.4", - "ic-btc-types", + "candid", + "ic-btc-interface", + "ic-error-types", "ic-protobuf", "serde", "serde_bytes", ] +[[package]] +name = "ic-cbor" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "027916ece94814fc7eebad43f91d691988ac8294121f54e8f22f4611c7d17f17" +dependencies = [ + "candid", + "ic-certification 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "leb128", + "nom", + "thiserror", +] + [[package]] name = "ic-cdk" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f3d204af0b11c45715169c997858edb58fa8407d08f4fae78a6b415dd39a362" dependencies = [ - "candid 0.10.2", + "candid", "ic-cdk-macros", "ic0", "serde", @@ -2602,7 +2637,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5a618e4020cea88e933d8d2f8c7f86d570ec06213506a80d4f2c520a9bba512" dependencies = [ - "candid 0.10.2", + "candid", "proc-macro2", "quote", "serde", @@ -2611,20 +2646,29 @@ dependencies = [ ] [[package]] -name = "ic-certification" -version = "0.23.2" +name = "ic-certificate-verification" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb68e0ea2fe6b533ddab6ae2142274f9669acacbacd83ac64bb1cd268d33104" +checksum = "74807b58655db518e68de1d65e1734da76af43949569b752aa27237e206bd4ad" dependencies = [ - "hex", + "cached 0.47.0", + "candid", + "ic-cbor", + "ic-certification 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", + "leb128", + "miracl_core_bls12381", + "nom", + "parking_lot 0.12.1", "sha2 0.10.8", + "thiserror", ] [[package]] name = "ic-certification" -version = "1.3.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c04340437a32c8b9c80d36f09715909c1e0a755327503a2e2906dcd662ba4e" +checksum = "b79fd38f674173bd0af3c80b9dab6fedd3391b81a2fc0f87a2e393fb723fe13b" dependencies = [ "hex", "serde", @@ -2635,8 +2679,7 @@ dependencies = [ [[package]] name = "ic-certification" version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b79fd38f674173bd0af3c80b9dab6fedd3391b81a2fc0f87a2e393fb723fe13b" +source = "git+https://github.com/dfinity/response-verification.git?rev=a65009624b61736df6d2dc17756bdbd02a84f599#a65009624b61736df6d2dc17756bdbd02a84f599" dependencies = [ "hex", "serde", @@ -2644,17 +2687,44 @@ dependencies = [ "sha2 0.10.8", ] +[[package]] +name = "ic-certification-testing" +version = "2.3.0" +source = "git+https://github.com/dfinity/response-verification.git?rev=a65009624b61736df6d2dc17756bdbd02a84f599#a65009624b61736df6d2dc17756bdbd02a84f599" +dependencies = [ + "console_error_panic_hook", + "getrandom", + "ic-crypto-internal-seed", + "ic-crypto-internal-threshold-sig-bls12381", + "ic-crypto-internal-types", + "ic-crypto-tree-hash", + "ic-types", + "js-sys", + "leb128", + "log", + "rand", + "serde", + "serde-wasm-bindgen", + "serde_cbor", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-console-logger", +] + [[package]] name = "ic-certified-assets" version = "0.2.5" dependencies = [ + "anyhow", "base64 0.13.1", - "candid 0.10.2", + "candid", "candid_parser", "hex", "ic-cdk", - "ic-certification 1.3.0", + "ic-certification 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ic-certification-testing", "ic-crypto-tree-hash", + "ic-http-certification", "ic-representation-independent-hash", "ic-response-verification", "ic-response-verification-test-utils", @@ -2666,38 +2736,28 @@ dependencies = [ "sha2 0.10.8", ] -[[package]] -name = "ic-certified-map" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6adc65afeffc619a7cd19553c66c79820908c12f42191af90cfb39e2e93c4431" -dependencies = [ - "serde", - "serde_bytes", - "sha2 0.10.8", -] - [[package]] name = "ic-constants" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" [[package]] name = "ic-crypto-getrandom-for-wasm" -version = "0.1.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ "getrandom", ] [[package]] name = "ic-crypto-internal-bls12-381-type" -version = "0.1.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ "hex", "ic-crypto-getrandom-for-wasm", "ic_bls12_381", + "itertools 0.12.0", "lazy_static", "pairing", "paste", @@ -2710,11 +2770,11 @@ dependencies = [ [[package]] name = "ic-crypto-internal-seed" -version = "0.1.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ "hex", - "ic-crypto-sha", + "ic-crypto-sha2", "ic-types", "rand", "rand_chacha", @@ -2724,27 +2784,26 @@ dependencies = [ [[package]] name = "ic-crypto-internal-sha2" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ - "openssl", - "sha2 0.9.9", + "sha2 0.10.8", ] [[package]] name = "ic-crypto-internal-threshold-sig-bls12381" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ - "arrayvec 0.5.2", - "base64 0.11.0", + "base64 0.13.1", "cached 0.41.0", "hex", "ic-crypto-internal-bls12-381-type", "ic-crypto-internal-seed", "ic-crypto-internal-threshold-sig-bls12381-der", "ic-crypto-internal-types", - "ic-crypto-sha", + "ic-crypto-secrets-containers", + "ic-crypto-sha2", "ic-types", "lazy_static", "parking_lot 0.12.1", @@ -2753,96 +2812,110 @@ dependencies = [ "serde", "serde_bytes", "serde_cbor", - "strum_macros 0.23.1", + "strum_macros 0.25.3", "subtle", "zeroize", ] [[package]] name = "ic-crypto-internal-threshold-sig-bls12381-der" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ "simple_asn1", ] [[package]] name = "ic-crypto-internal-types" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ - "arrayvec 0.5.2", - "base64 0.11.0", + "arrayvec 0.7.4", "hex", "ic-protobuf", "phantom_newtype", "serde", "serde_cbor", - "strum 0.23.0", - "strum_macros 0.23.1", + "strum 0.25.0", + "strum_macros 0.25.3", "thiserror", "zeroize", ] [[package]] -name = "ic-crypto-sha" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +name = "ic-crypto-secrets-containers" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" +dependencies = [ + "serde", + "zeroize", +] + +[[package]] +name = "ic-crypto-sha2" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ "ic-crypto-internal-sha2", ] [[package]] name = "ic-crypto-tree-hash" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ + "assert_matches", "ic-crypto-internal-types", - "ic-crypto-sha", + "ic-crypto-sha2", "ic-protobuf", "serde", "serde_bytes", -] - -[[package]] -name = "ic-crypto-utils-threshold-sig-der" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" -dependencies = [ - "base64 0.11.0", - "ic-crypto-internal-threshold-sig-bls12381-der", - "ic-crypto-internal-types", - "ic-types", + "thiserror", ] [[package]] name = "ic-error-types" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ + "ic-utils 0.9.0", "serde", - "strum 0.23.0", - "strum_macros 0.23.1", + "strum 0.25.0", + "strum_macros 0.25.3", ] [[package]] name = "ic-frontend-canister" version = "0.2.5" dependencies = [ - "candid 0.10.2", + "candid", "ic-cdk", "ic-certified-assets", ] +[[package]] +name = "ic-http-certification" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1920329afced339a770ca2a56b00fb8229a63ab0dcf1bb119bdeb54b5b70dbfd" +dependencies = [ + "candid", + "http", + "ic-certification 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ic-representation-independent-hash", + "serde", + "thiserror", + "urlencoding", +] + [[package]] name = "ic-ic00-types" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ - "candid 0.8.4", - "float-cmp", + "candid", "ic-base-types", - "ic-btc-types", + "ic-btc-interface", "ic-btc-types-internal", "ic-error-types", "ic-protobuf", @@ -2850,8 +2923,8 @@ dependencies = [ "serde", "serde_bytes", "serde_cbor", - "strum 0.23.0", - "strum_macros 0.23.1", + "strum 0.25.0", + "strum_macros 0.25.3", ] [[package]] @@ -2869,11 +2942,11 @@ dependencies = [ [[package]] name = "ic-protobuf" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ "bincode", - "candid 0.8.4", + "candid", "erased-serde", "maplit", "prost", @@ -2884,9 +2957,9 @@ dependencies = [ [[package]] name = "ic-representation-independent-hash" -version = "0.3.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5790ff4b3752ce648d83554b3b0df1039a94bea24119d29a0f9874d796075e" +checksum = "be48db2f8b954b9b2a0f46424ddedda2728703d7b361bc65328ed17dcacd1e21" dependencies = [ "leb128", "sha2 0.10.8", @@ -2894,59 +2967,63 @@ dependencies = [ [[package]] name = "ic-response-verification" -version = "0.3.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736044d69c526fa8a2a5e54d3debd878bbd4ec10c259fd21d9e6804aef67687b" +checksum = "dd4b20dcd2bc7b1098c79dd545fa9ff7cb8cdca4345e2a823ffa73ebaf542b2b" dependencies = [ - "base64 0.13.1", - "candid 0.8.4", + "base64 0.21.5", + "candid", "flate2", + "hex", "http", - "ic-certification 0.23.2", + "ic-cbor", + "ic-certificate-verification", + "ic-certification 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ic-http-certification", "ic-representation-independent-hash", "leb128", "log", - "miracl_core_bls12381", "nom", "sha2 0.10.8", "thiserror", + "urlencoding", ] [[package]] name = "ic-response-verification-test-utils" -version = "0.3.0" -source = "git+https://github.com/dfinity/response-verification.git?rev=4686895c6070ac36109a01f4bd642caf2369b97b#4686895c6070ac36109a01f4bd642caf2369b97b" +version = "2.3.0" +source = "git+https://github.com/dfinity/response-verification.git?rev=a65009624b61736df6d2dc17756bdbd02a84f599#a65009624b61736df6d2dc17756bdbd02a84f599" dependencies = [ "base64 0.21.5", "flate2", - "getrandom", "hex", - "ic-base-types", - "ic-certified-map", - "ic-crypto-internal-seed", - "ic-crypto-internal-threshold-sig-bls12381", - "ic-crypto-internal-types", - "ic-crypto-tree-hash", - "ic-crypto-utils-threshold-sig-der", + "ic-certification 2.3.0 (git+https://github.com/dfinity/response-verification.git?rev=a65009624b61736df6d2dc17756bdbd02a84f599)", + "ic-certification-testing", "ic-types", "leb128", - "rand", "serde", "serde_cbor", - "sha256", + "sha2 0.10.8", ] +[[package]] +name = "ic-stable-structures" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95dce29e3ceb0e6da3e78b305d95365530f2efd2146ca18590c0ef3aa6038568" + [[package]] name = "ic-sys" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ "hex", - "ic-crypto-sha", + "ic-crypto-sha2", "lazy_static", "libc", - "nix 0.23.2", + "nix 0.24.3", "phantom_newtype", + "tokio", "wsl", ] @@ -2955,9 +3032,9 @@ name = "ic-transport-types" version = "0.31.0" source = "git+https://github.com/dfinity/agent-rs.git?rev=a7f44ad05e77fc89b8447dd65b345e7a62fd1042#a7f44ad05e77fc89b8447dd65b345e7a62fd1042" dependencies = [ - "candid 0.10.2", + "candid", "hex", - "ic-certification 2.3.0", + "ic-certification 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "leb128", "serde", "serde_bytes", @@ -2968,29 +3045,26 @@ dependencies = [ [[package]] name = "ic-types" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ - "base32", - "base64 0.11.0", + "base64 0.13.1", "bincode", - "candid 0.8.4", + "candid", "chrono", "derive_more", "hex", - "http", "ic-base-types", "ic-btc-types-internal", "ic-constants", "ic-crypto-internal-types", - "ic-crypto-sha", + "ic-crypto-sha2", "ic-crypto-tree-hash", "ic-error-types", "ic-ic00-types", "ic-protobuf", - "ic-utils 0.8.0", + "ic-utils 0.9.0", "maplit", - "num-traits", "once_cell", "phantom_newtype", "prost", @@ -2999,25 +3073,22 @@ dependencies = [ "serde_cbor", "serde_json", "serde_with", - "strum 0.23.0", - "strum_macros 0.23.1", + "strum 0.25.0", + "strum_macros 0.25.3", "thiserror", "thousands", - "url", ] [[package]] name = "ic-utils" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ - "bitflags 1.3.2", "cvt", - "features", "hex", "ic-sys", "libc", - "nix 0.23.2", + "nix 0.24.3", "prost", "rand", "scoped_threadpool", @@ -3031,7 +3102,7 @@ version = "0.31.0" source = "git+https://github.com/dfinity/agent-rs.git?rev=a7f44ad05e77fc89b8447dd65b345e7a62fd1042#a7f44ad05e77fc89b8447dd65b345e7a62fd1042" dependencies = [ "async-trait", - "candid 0.10.2", + "candid", "ic-agent", "once_cell", "semver", @@ -3062,7 +3133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d2aa0d7deeb38f18fcec6e4c25c5004422e2e9f8c3fbad15bb795ebac37aca6" dependencies = [ "anyhow", - "candid 0.10.2", + "candid", "clap", "rustc-demangle", "serde", @@ -3081,9 +3152,9 @@ checksum = "a54b5297861c651551676e8c43df805dad175cc33bc97dbd992edbbb85dcbcdf" [[package]] name = "ic_bls12_381" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a180f02c79a71fcbc10b194406dbffd6a883c916f96be4f17ae3aeb96348c5" +checksum = "c682cb199cd8fcb582a6023325d571a6464edda26c8063fe04b6f6082a1a363c" dependencies = [ "digest 0.9.0", "ff 0.12.1", @@ -3115,7 +3186,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "804c892bf95652101660a25cea10f059f73eb8973f6b04e0349758fda1190447" dependencies = [ "base32", - "candid 0.10.2", + "candid", "crc32fast", "hex", "num-bigint 0.4.4", @@ -3131,7 +3202,7 @@ version = "0.20.0" dependencies = [ "anstyle", "anyhow", - "candid 0.10.2", + "candid", "clap", "delay", "humantime", @@ -3277,6 +3348,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" @@ -3382,28 +3462,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "lalrpop" -version = "0.19.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1cbf952127589f2851ab2046af368fd20645491bb4b376f04b7f94d7a9837b" -dependencies = [ - "ascii-canvas", - "bit-set", - "diff", - "ena", - "is-terminal", - "itertools 0.10.5", - "lalrpop-util 0.19.12", - "petgraph", - "regex", - "regex-syntax 0.6.29", - "string_cache", - "term", - "tiny-keccak", - "unicode-xid", -] - [[package]] name = "lalrpop" version = "0.20.0" @@ -3416,7 +3474,7 @@ dependencies = [ "ena", "is-terminal", "itertools 0.10.5", - "lalrpop-util 0.20.0", + "lalrpop-util", "petgraph", "pico-args", "regex", @@ -3427,15 +3485,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "lalrpop-util" -version = "0.19.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3c48237b9604c5a4702de6b824e02006c3214327564636aef27c1028a8fa0ed" -dependencies = [ - "regex", -] - [[package]] name = "lalrpop-util" version = "0.20.0" @@ -3546,22 +3595,13 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" -[[package]] -name = "logos" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8b031682c67a8e3d5446840f9573eb7fe26efe7ec8d195c9ac4c0647c502f1" -dependencies = [ - "logos-derive 0.12.1", -] - [[package]] name = "logos" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c000ca4d908ff18ac99b93a062cb8958d331c3220719c52e77cb19cc6ac5d2c1" dependencies = [ - "logos-derive 0.13.0", + "logos-derive", ] [[package]] @@ -3578,20 +3618,6 @@ dependencies = [ "syn 2.0.38", ] -[[package]] -name = "logos-derive" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c" -dependencies = [ - "beef", - "fnv", - "proc-macro2", - "quote", - "regex-syntax 0.6.29", - "syn 1.0.109", -] - [[package]] name = "logos-derive" version = "0.13.0" @@ -3757,12 +3783,11 @@ dependencies = [ [[package]] name = "nix" -version = "0.23.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ "bitflags 1.3.2", - "cc", "cfg-if 1.0.0", "libc", "memoffset 0.6.5", @@ -3908,27 +3933,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "num_threads" version = "0.1.6" @@ -4250,10 +4254,10 @@ dependencies = [ [[package]] name = "phantom_newtype" -version = "0.8.0" -source = "git+https://github.com/dfinity/ic.git?rev=a533346f63f4091eb64692891de0d5b2ffd5b22a#a533346f63f4091eb64692891de0d5b2ffd5b22a" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic.git?rev=1290256484f59c3d950c5e9a098e97383b248ad6#1290256484f59c3d950c5e9a098e97383b248ad6" dependencies = [ - "candid 0.8.4", + "candid", "serde", "slog", ] @@ -4367,16 +4371,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" -[[package]] -name = "pretty" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad9940b913ee56ddd94aec2d3cd179dd47068236f42a1a6415ccf9d880ce2a61" -dependencies = [ - "arrayvec 0.5.2", - "typed-arena", -] - [[package]] name = "pretty" version = "0.11.3" @@ -4492,9 +4486,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.9" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" dependencies = [ "bytes", "prost-derive", @@ -4502,15 +4496,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.9" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" dependencies = [ "anyhow", "itertools 0.10.5", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.38", ] [[package]] @@ -5147,6 +5141,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_bytes" version = "0.11.12" @@ -5271,7 +5276,7 @@ version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" dependencies = [ - "darling", + "darling 0.13.4", "proc-macro2", "quote", "syn 1.0.109", @@ -5301,19 +5306,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sha256" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7895c8ae88588ccead14ff438b939b0c569cd619116f14b4d13fdff7b8333386" -dependencies = [ - "async-trait", - "bytes", - "hex", - "sha2 0.10.8", - "tokio", -] - [[package]] name = "sha3" version = "0.10.8" @@ -5536,23 +5528,26 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae14b91c7d11c9a851d3fbc80a963198998c2a64eec840477fa92d8ce9b70bb" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" [[package]] name = "strum" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros 0.25.3", +] [[package]] name = "strum_macros" -version = "0.23.1" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb0dc7ee9c15cea6199cde9a127fa16a4c5819af85395457ad72d68edc85a38" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck 0.3.3", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -5561,15 +5556,15 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.24.3" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 1.0.109", + "syn 2.0.38", ] [[package]] @@ -6101,9 +6096,14 @@ dependencies = [ "form_urlencoded", "idna", "percent-encoding", - "serde", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf8-width" version = "0.1.6" @@ -6227,6 +6227,16 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-console-logger" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7530a275e7faf7b5b83aabdf78244fb8d9a68a2ec4b26935a05ecc0c9b0185ed" +dependencies = [ + "log", + "wasm-bindgen", +] + [[package]] name = "wasm-bindgen-futures" version = "0.4.38" diff --git a/Cargo.toml b/Cargo.toml index b3a9ad6814..f3e8925e6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,12 +9,13 @@ members = [ "src/canisters/frontend/ic-frontend-canister", ] default-members = ["src/dfx"] +resolver = "2" [workspace.package] authors = ["DFINITY Stiftung "] edition = "2021" repository = "https://github.com/dfinity/sdk" -rust-version = "1.71.1" +rust-version = "1.75.0" license = "Apache-2.0" [workspace.dependencies] @@ -35,7 +36,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" @@ -65,7 +66,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" diff --git a/docs/cli-reference/dfx-start.md b/docs/cli-reference/dfx-start.md index 3621c67bc2..2ec382bf9d 100644 --- a/docs/cli-reference/dfx-start.md +++ b/docs/cli-reference/dfx-start.md @@ -18,7 +18,6 @@ You can use the following optional flags with the `dfx start` command. |-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `--background` | Starts the local canister execution environment and web server processes in the background and waits for a reply before returning to the shell. | | `--clean` | Starts the local canister execution environment and web server processes in a clean state by removing checkpoints from your project cache. You can use this flag to set your project cache to a new state when troubleshooting or debugging. | -| `--emulator` | Starts the [IC reference emulator](https://github.com/dfinity/ic-hs) rather than the replica. (deprecated: will be discontinued soon) | | `--enable-bitcoin` | Enables bitcoin integration. | | `--enable-canister-http` | Enables canister HTTP requests. (deprecated: now enabled by default) | | `--use-old-metering` | Enables the old metering in the local canister execution environment. Please see the forum thread for more details or to report any issues: [forum.dfinity.org/t/new-wasm-instrumentation/](https://forum.dfinity.org/t/new-wasm-instrumentation/22080) | diff --git a/docs/concepts/pull-dependencies.md b/docs/concepts/pull-dependencies.md index d48dc0699c..70a077c34f 100644 --- a/docs/concepts/pull-dependencies.md +++ b/docs/concepts/pull-dependencies.md @@ -53,6 +53,14 @@ In most cases, the wasm module at `wasm_url` will be the same as the on-chain wa In other cases, the wasm module at `wasm_url` is not the same as the on-chain wasm module. For example, the Internet Identity canister provides Development flavor to be integrated locally. In these cases, `wasm_hash` provides the expected hash, and dfx verifies the downloaded wasm against this. +### `wasm_hash_url` + +A URL to get the SHA256 hash of the wasm module located at `wasm_url`. + +This field is optional. + +Aside from specifying SHA256 hash of the wasm module directly using `wasm_hash`, providers can also specify the hash with this URL. If both are defined, the `wasm_hash_url` field will be ignored. + ### `dependencies` An array of Canister IDs (`Principal`) of direct dependencies. diff --git a/docs/dfx-json-schema.json b/docs/dfx-json-schema.json index 40f4e890ac..728f48d0dc 100644 --- a/docs/dfx-json-schema.json +++ b/docs/dfx-json-schema.json @@ -982,7 +982,15 @@ }, "wasm_hash": { "title": "wasm_hash", - "description": "SHA256 hash of the wasm module located at wasm_url. Only define this if the on-chain canister wasm is expected not to match the wasm at wasm_url.", + "description": "SHA256 hash of the wasm module located at wasm_url. Only define this if the on-chain canister wasm is expected not to match the wasm at wasm_url. The hash can also be specified via a URL using the `wasm_hash_url` field. If both are defined, the `wasm_hash_url` field will be ignored.", + "type": [ + "string", + "null" + ] + }, + "wasm_hash_url": { + "title": "wasm_hash_url", + "description": "Specify the SHA256 hash of the wasm module via this URL. Only define this if the on-chain canister wasm is expected not to match the wasm at wasm_url. The hash can also be specified directly using the `wasm_hash` field. If both are defined, the `wasm_hash_url` field will be ignored.", "type": [ "string", "null" diff --git a/e2e/tests-dfx/basic-project.bash b/e2e/tests-dfx/basic-project.bash index 8e77ee3ec9..766a90f6fb 100644 --- a/e2e/tests-dfx/basic-project.bash +++ b/e2e/tests-dfx/basic-project.bash @@ -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" { diff --git a/e2e/tests-dfx/deps.bash b/e2e/tests-dfx/deps.bash index 5ef85acc16..c56aa217be 100644 --- a/e2e/tests-dfx/deps.bash +++ b/e2e/tests-dfx/deps.bash @@ -150,8 +150,6 @@ Failed to download from url: http://example.com/c.wasm." setup_onchain - # TODO: test gzipped wasm can be pulled when we have "gzip" option in dfx.json (SDK-1102) - # pull canisters in app project cd app assert_file_not_exists "deps/pulled.json" @@ -180,17 +178,16 @@ Failed to download from url: http://example.com/c.wasm." assert_command dfx deps pull --network local -vvv assert_contains "The canister wasm was found in the cache." # cache hit - # sad path 1: wasm hash doesn't match on chain + # warning: hash mismatch rm -r "${PULLED_DIR:?}/" cd ../onchain cp .dfx/local/canisters/c/c.wasm ../www/a.wasm cd ../app - assert_command_fail dfx deps pull --network local - assert_contains "Failed to pull canister $CANISTER_ID_A." - assert_contains "Hash mismatch." + assert_command dfx deps pull --network local + assert_contains "WARN: Canister $CANISTER_ID_A has different hash between on chain and download." - # sad path 2: url server doesn't have the file + # sad path: url server doesn't have the file rm -r "${PULLED_DIR:?}/" rm ../www/a.wasm @@ -199,8 +196,7 @@ Failed to download from url: http://example.com/c.wasm." assert_contains "Failed to download from url:" } - -@test "dfx deps pull can check hash when dfx:wasm_hash specified" { +@test "dfx deps pull works when wasm_hash or wasm_hash_url specified" { use_test_specific_cache_root # dfx deps pull will download files to cache # start a "mainnet" replica which host the onchain canisters @@ -228,11 +224,20 @@ Failed to download from url: http://example.com/c.wasm." cp .dfx/local/canisters/b/b.wasm.gz ../www/b.wasm.gz cp .dfx/local/canisters/c/c.wasm ../www/c.wasm - CUSTOM_HASH="$(sha256sum .dfx/local/canisters/a/a.wasm | cut -d " " -f 1)" - jq '.canisters.a.pullable.wasm_hash="'"$CUSTOM_HASH"'"' dfx.json | sponge dfx.json - dfx build a # .dfx/local/canisters/a/a.wasm is replaced. The new wasm has wasm_hash defined and will be installed. + # A: set dfx:wasm_hash + CUSTOM_HASH_A="$(sha256sum .dfx/local/canisters/a/a.wasm | cut -d " " -f 1)" + jq '.canisters.a.pullable.wasm_hash="'"$CUSTOM_HASH_A"'"' dfx.json | sponge dfx.json + # B: set dfx:wasm_hash_url + echo -n "$(sha256sum .dfx/local/canisters/b/b.wasm.gz | cut -d " " -f 1)" > ../www/b.wasm.gz.sha256 + jq '.canisters.b.pullable.wasm_hash_url="'"http://localhost:$E2E_WEB_SERVER_PORT/b.wasm.gz.sha256"'"' dfx.json | sponge dfx.json + # C: set both dfx:wasm_hash and dfx:wasm_hash_url. This should be avoided by providers. + CUSTOM_HASH_C="$(sha256sum .dfx/local/canisters/c/c.wasm | cut -d " " -f 1)" + jq '.canisters.c.pullable.wasm_hash="'"$CUSTOM_HASH_C"'"' dfx.json | sponge dfx.json + echo -n "$CUSTOM_HASH_C" > ../www/c.wasm.sha256 + jq '.canisters.c.pullable.wasm_hash_url="'"http://localhost:$E2E_WEB_SERVER_PORT/c.wasm.sha256"'"' dfx.json | sponge dfx.json + + dfx build - # cd ../../../ dfx canister install a --argument 1 dfx canister install b dfx canister install c --argument 3 @@ -243,18 +248,20 @@ Failed to download from url: http://example.com/c.wasm." assert_command dfx deps pull --network local -vvv assert_contains "Canister $CANISTER_ID_A specified a custom hash:" + assert_contains "Canister $CANISTER_ID_B specified a custom hash via url:" + assert_contains "WARN: Canister $CANISTER_ID_C specified both \`wasm_hash\` and \`wasm_hash_url\`. \`wasm_hash\` will be used." + assert_contains "Canister $CANISTER_ID_C specified a custom hash:" - # error case: hash mismatch + # warning: hash mismatch PULLED_DIR="$DFX_CACHE_ROOT/.cache/dfinity/pulled/" rm -r "${PULLED_DIR:?}/" cd ../onchain cp .dfx/local/canisters/a/a.wasm ../www/a.wasm # now the webserver has the onchain version of canister_a which won't match wasm_hash cd ../app - assert_command_fail dfx deps pull --network local -vvv + assert_command dfx deps pull --network local -vvv assert_contains "Canister $CANISTER_ID_A specified a custom hash:" - assert_contains "Failed to pull canister $CANISTER_ID_A." - assert_contains "Hash mismatch." + assert_contains "WARN: Canister $CANISTER_ID_A has different hash between on chain and download." } @test "dfx deps init works" { diff --git a/e2e/tests-dfx/schema.bash b/e2e/tests-dfx/schema.bash index 3886840934..8cdad36b6c 100644 --- a/e2e/tests-dfx/schema.bash +++ b/e2e/tests-dfx/schema.bash @@ -19,6 +19,6 @@ teardown() { } @test "dfx schema still works with broken dfx.json" { - jq '.broken_key="blahblahblah"' dfx.json | sponge dfx.json + echo '{}' | jq '.broken_key="blahblahblah"' > dfx.json assert_command dfx schema } diff --git a/e2e/utils/_.bash b/e2e/utils/_.bash index 391305a7ce..3b340a73ed 100644 --- a/e2e/utils/_.bash +++ b/e2e/utils/_.bash @@ -1,4 +1,4 @@ -set -e +set -eo pipefail load ../utils/bats-support/load load ../utils/assertions load ../utils/webserver diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ebd21eff3f..a0f945fbbb 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.71.1" +channel = "1.75.0" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/scripts/update-frontend-canister.Dockerfile b/scripts/update-frontend-canister.Dockerfile index e864086a39..36b1d00125 100644 --- a/scripts/update-frontend-canister.Dockerfile +++ b/scripts/update-frontend-canister.Dockerfile @@ -3,7 +3,7 @@ ARG RUST_VERSION FROM scratch AS registry FROM rust:${RUST_VERSION} AS builder COPY --from=registry . ${CARGO_HOME}/registry/index -RUN cargo install ic-wasm --version 0.2.0 +RUN cargo install ic-wasm --version 0.7.0 COPY . /build # defined in update-frontend-canister.sh WORKDIR /build diff --git a/src/canisters/frontend/ic-certified-assets/Cargo.toml b/src/canisters/frontend/ic-certified-assets/Cargo.toml index 4a96baca33..7f5028204a 100644 --- a/src/canisters/frontend/ic-certified-assets/Cargo.toml +++ b/src/canisters/frontend/ic-certified-assets/Cargo.toml @@ -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 @@ -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" } diff --git a/src/canisters/frontend/ic-certified-assets/src/asset_certification/tree.rs b/src/canisters/frontend/ic-certified-assets/src/asset_certification/tree.rs index d46c4dfec9..22b4af451a 100644 --- a/src/canisters/frontend/ic-certified-assets/src/asset_certification/tree.rs +++ b/src/canisters/frontend/ic-certified-assets/src/asset_certification/tree.rs @@ -36,7 +36,7 @@ impl AsHashTree fo impl NestedTree { #[allow(dead_code)] pub fn get(&self, path: &[K]) -> Option<&V> { - if let Some(key) = path.get(0) { + if let Some(key) = path.first() { match self { NestedTree::Leaf(_) => None, NestedTree::Nested(tree) => tree @@ -53,7 +53,7 @@ impl NestedTree bool { - if let Some(key) = path.get(0) { + if let Some(key) = path.first() { match self { NestedTree::Leaf(_) => false, NestedTree::Nested(tree) => tree @@ -68,7 +68,7 @@ impl NestedTree bool { - if let Some(key) = path.get(0) { + if let Some(key) = path.first() { match self { NestedTree::Leaf(_) => false, NestedTree::Nested(tree) => tree @@ -82,7 +82,7 @@ impl NestedTree { *self = NestedTree::default(); @@ -103,7 +103,7 @@ impl NestedTree {} NestedTree::Nested(tree) => { @@ -116,7 +116,7 @@ impl NestedTree HashTree { - if let Some(key) = path.get(0) { + if let Some(key) = path.first() { match self { NestedTree::Leaf(value) => value.as_hash_tree(), NestedTree::Nested(tree) => { diff --git a/src/canisters/frontend/ic-certified-assets/src/lib.rs b/src/canisters/frontend/ic-certified-assets/src/lib.rs index 087f81bc59..6a81fe6284 100644 --- a/src/canisters/frontend/ic-certified-assets/src/lib.rs +++ b/src/canisters/frontend/ic-certified-assets/src/lib.rs @@ -415,7 +415,9 @@ fn is_controller() -> Result<(), String> { pub fn init(args: Option) { 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(); diff --git a/src/canisters/frontend/ic-certified-assets/src/tests.rs b/src/canisters/frontend/ic-certified-assets/src/tests.rs index 7e77c6c9aa..033b289a37 100644 --- a/src/canisters/frontend/ic-certified-assets/src/tests.rs +++ b/src/canisters/frontend/ic-certified-assets/src/tests.rs @@ -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; @@ -34,21 +33,20 @@ pub fn verify_response( state: &State, request: &HttpRequest, response: &HttpResponse, -) -> Result { +) -> anyhow::Result { 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() @@ -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 { diff --git a/src/dfx-core/Cargo.toml b/src/dfx-core/Cargo.toml index 01b37aca02..2f7a12daff 100644 --- a/src/dfx-core/Cargo.toml +++ b/src/dfx-core/Cargo.toml @@ -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"] } diff --git a/src/dfx-core/src/config/model/dfinity.rs b/src/dfx-core/src/config/model/dfinity.rs index f4ffd78cc6..f2ebd389cb 100644 --- a/src/dfx-core/src/config/model/dfinity.rs +++ b/src/dfx-core/src/config/model/dfinity.rs @@ -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) @@ -170,7 +169,15 @@ pub struct Pullable { /// # wasm_hash /// SHA256 hash of the wasm module located at wasm_url. /// Only define this if the on-chain canister wasm is expected not to match the wasm at wasm_url. + /// The hash can also be specified via a URL using the `wasm_hash_url` field. + /// If both are defined, the `wasm_hash_url` field will be ignored. pub wasm_hash: Option, + /// # wasm_hash_url + /// Specify the SHA256 hash of the wasm module via this URL. + /// Only define this if the on-chain canister wasm is expected not to match the wasm at wasm_url. + /// The hash can also be specified directly using the `wasm_hash` field. + /// If both are defined, the `wasm_hash_url` field will be ignored. + pub wasm_hash_url: Option, /// # dependencies /// Canister IDs (Principal) of direct dependencies. #[schemars(with = "Vec::")] diff --git a/src/dfx-core/src/config/model/local_server_descriptor.rs b/src/dfx-core/src/config/model/local_server_descriptor.rs index 6d59829cfa..871da03dc7 100644 --- a/src/dfx-core/src/config/model/local_server_descriptor.rs +++ b/src/dfx-core/src/config/model/local_server_descriptor.rs @@ -98,11 +98,6 @@ impl LocalServerDescriptor { self.data_directory.join("icx-proxy-pid") } - /// This file contains the listening port of the ic-ref process - pub fn ic_ref_port_path(&self) -> PathBuf { - self.data_directory.join("ic-ref.port") - } - /// This file contains the pid of the ic-btc-adapter process pub fn btc_adapter_pid_path(&self) -> PathBuf { self.data_directory.join("ic-btc-adapter-pid") @@ -297,12 +292,11 @@ impl LocalServerDescriptor { /// Gets the port of a local replica. /// /// # Prerequisites - /// - A local replica or emulator needs to be running, e.g. with `dfx start`. + /// - A local replica needs to be running, e.g. with `dfx start`. pub fn get_running_replica_port( &self, logger: Option<&Logger>, ) -> Result, NetworkConfigError> { - let emulator_port_path = self.ic_ref_port_path(); let replica_port_path = self.replica_port_path(); match read_port_from(&replica_port_path)? { @@ -312,15 +306,7 @@ impl LocalServerDescriptor { } Ok(Some(port)) } - None => match read_port_from(&emulator_port_path)? { - Some(port) => { - if let Some(logger) = logger { - info!(logger, "Found local emulator running on port {}", port); - } - Ok(Some(port)) - } - None => Ok(self.replica.port), - }, + None => Ok(self.replica.port), } } } diff --git a/src/dfx-core/src/config/model/network_descriptor.rs b/src/dfx-core/src/config/model/network_descriptor.rs index 73c2e217a8..2565348353 100644 --- a/src/dfx-core/src/config/model/network_descriptor.rs +++ b/src/dfx-core/src/config/model/network_descriptor.rs @@ -85,7 +85,7 @@ impl NetworkDescriptor { let provider_match = { providers.len() == 1 && matches!( - providers.get(0).unwrap().as_str(), + providers.first().unwrap().as_str(), DEFAULT_IC_GATEWAY | DEFAULT_IC_GATEWAY_TRAILING_SLASH ) }; diff --git a/src/dfx-core/src/error/encryption.rs b/src/dfx-core/src/error/encryption.rs index fff651a7f3..d7cf2bee0d 100644 --- a/src/dfx-core/src/error/encryption.rs +++ b/src/dfx-core/src/error/encryption.rs @@ -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), diff --git a/src/dfx/src/actors/emulator.rs b/src/dfx/src/actors/emulator.rs deleted file mode 100644 index 241ad760d2..0000000000 --- a/src/dfx/src/actors/emulator.rs +++ /dev/null @@ -1,245 +0,0 @@ -use crate::actors::icx_proxy::signals::{PortReadySignal, PortReadySubscribe}; -use crate::actors::shutdown::{wait_for_child_or_receiver, ChildOrReceiver}; -use crate::actors::shutdown_controller::signals::outbound::Shutdown; -use crate::actors::shutdown_controller::signals::ShutdownSubscribe; -use crate::actors::shutdown_controller::ShutdownController; -use crate::lib::error::{DfxError, DfxResult}; -use actix::{ - Actor, ActorContext, ActorFutureExt, Addr, AsyncContext, Context, Handler, Recipient, - ResponseActFuture, Running, WrapFuture, -}; -use anyhow::bail; -use crossbeam::channel::{unbounded, Receiver, Sender}; -use slog::{debug, info, Logger}; -use std::path::{Path, PathBuf}; -use std::thread::JoinHandle; -use std::time::Duration; - -pub mod signals { - use actix::prelude::*; - - /// A message sent to the Emulator when the process is restarted. Since we're - /// restarting inside our own actor, this message should not be exposed. - #[derive(Message)] - #[rtype(result = "()")] - pub(super) struct EmulatorRestarted { - pub port: u16, - } -} - -/// The configuration for the emulator actor. -#[derive(Clone)] -pub struct Config { - pub ic_ref_path: PathBuf, - pub port: Option, - pub write_port_to: PathBuf, - pub shutdown_controller: Addr, - pub logger: Option, -} - -/// A emulator actor. Starts the emulator, can subscribe to a Ready signal and a -/// Killed signal. -/// This starts a thread that monitors the process and send signals to any subscriber -/// listening for restarts. The message contains the port the emulator is listening to. -/// -/// Signals -/// - PortReadySubscribe -/// Subscribe a recipient (address) to receive a EmulatorReadySignal message when -/// the emulator is ready to listen to a port. The message can be sent multiple -/// times (e.g. if the emulator crashes). -/// If a emulator is already started and another actor sends this message, a -/// EmulatorReadySignal will be sent free of charge in the same thread. -pub struct Emulator { - logger: Logger, - config: Config, - - // We keep the port to send to subscribers on subscription. - port: Option, - stop_sender: Option>, - thread_join: Option>, - - /// Ready Signal subscribers. - ready_subscribers: Vec>, -} - -impl Emulator { - pub fn new(config: Config) -> Self { - let logger = - (config.logger.clone()).unwrap_or_else(|| Logger::root(slog::Discard, slog::o!())); - Emulator { - config, - port: None, - stop_sender: None, - thread_join: None, - ready_subscribers: Vec::new(), - logger, - } - } - - fn wait_for_port_file(file_path: &Path) -> DfxResult { - let mut retries = 0; - loop { - if let Ok(content) = std::fs::read_to_string(file_path) { - if let Ok(port) = content.parse::() { - return Ok(port); - } - } - if retries >= 3000 { - bail!("Cannot start ic-ref: timed out"); - } - std::thread::sleep(Duration::from_millis(100)); - retries += 1; - } - } - - fn start_emulator(&mut self, addr: Addr) -> DfxResult { - let logger = self.logger.clone(); - - let (sender, receiver) = unbounded(); - - let handle = anyhow::Context::context( - emulator_start_thread(logger, self.config.clone(), addr, receiver), - "Failed to start emulator thread.", - )?; - - self.thread_join = Some(handle); - self.stop_sender = Some(sender); - Ok(()) - } - - fn send_ready_signal(&self, port: u16) { - for sub in &self.ready_subscribers { - sub.do_send(PortReadySignal { port }); - } - } -} - -impl Actor for Emulator { - type Context = Context; - - fn started(&mut self, ctx: &mut Self::Context) { - self.start_emulator(ctx.address()) - .expect("Could not start the emulator"); - - self.config - .shutdown_controller - .do_send(ShutdownSubscribe(ctx.address().recipient::())); - } - - fn stopping(&mut self, _ctx: &mut Self::Context) -> Running { - info!(self.logger, "Stopping ic-ref..."); - if let Some(sender) = self.stop_sender.take() { - let _ = sender.send(()); - } - - if let Some(join) = self.thread_join.take() { - let _ = join.join(); - } - - info!(self.logger, "Stopped."); - Running::Stop - } -} - -impl Handler for Emulator { - type Result = (); - - fn handle(&mut self, msg: PortReadySubscribe, _: &mut Self::Context) { - // If we have a port, send that we're already ready! Yeah! - if let Some(port) = self.port { - msg.0.do_send(PortReadySignal { port }); - } - - self.ready_subscribers.push(msg.0); - } -} - -impl Handler for Emulator { - type Result = (); - - fn handle( - &mut self, - msg: signals::EmulatorRestarted, - _ctx: &mut Self::Context, - ) -> Self::Result { - self.port = Some(msg.port); - self.send_ready_signal(msg.port); - } -} - -impl Handler for Emulator { - type Result = ResponseActFuture>; - - fn handle(&mut self, _msg: Shutdown, _ctx: &mut Self::Context) -> Self::Result { - // This is just the example for ResponseActFuture but stopping the context - Box::pin( - async {} - .into_actor(self) // converts future to ActorFuture - .map(|_, _act, ctx| { - ctx.stop(); - Ok(()) - }), - ) - } -} - -fn emulator_start_thread( - logger: Logger, - config: Config, - addr: Addr, - receiver: Receiver<()>, -) -> DfxResult> { - let thread_handler = move || { - // Start the process, then wait for the file. - let ic_ref_path = config.ic_ref_path.as_os_str(); - - // form the ic-start command here similar to emulator command - let mut cmd = std::process::Command::new(ic_ref_path); - match config.port { - Some(port) if port != 0 => cmd.args(["--listen-port", &port.to_string()]), - _ => cmd.args(["--pick-port"]), - }; - cmd.args(["--write-port-to", &config.write_port_to.to_string_lossy()]); - cmd.stdout(std::process::Stdio::inherit()); - cmd.stderr(std::process::Stdio::inherit()); - - loop { - let _ = std::fs::remove_file(&config.write_port_to); - let last_start = std::time::Instant::now(); - debug!(logger, "Starting emulator..."); - let mut child = cmd.spawn().expect("Could not start emulator."); - - let port = Emulator::wait_for_port_file(&config.write_port_to).unwrap(); - addr.do_send(signals::EmulatorRestarted { port }); - - // This waits for the child to stop, or the receiver to receive a message. - // We don't restart the emulator if done = true. - match wait_for_child_or_receiver(&mut child, &receiver) { - ChildOrReceiver::Receiver => { - debug!(logger, "Got signal to stop. Killing emulator process..."); - let _ = child.kill(); - let _ = child.wait(); - break; - } - ChildOrReceiver::Child => { - debug!(logger, "Emulator process failed."); - // If it took less than two seconds to exit, wait a bit before trying again. - if std::time::Instant::now().duration_since(last_start) < Duration::from_secs(2) - { - std::thread::sleep(Duration::from_secs(2)); - } else { - debug!( - logger, - "Last emulator seemed to have been healthy, not waiting..." - ); - } - } - } - } - }; - - std::thread::Builder::new() - .name("emulator-actor".to_owned()) - .spawn(thread_handler) - .map_err(DfxError::from) -} diff --git a/src/dfx/src/actors/mod.rs b/src/dfx/src/actors/mod.rs index ea3d5675c9..0d32bc0e55 100644 --- a/src/dfx/src/actors/mod.rs +++ b/src/dfx/src/actors/mod.rs @@ -1,9 +1,7 @@ -use crate::actors; use crate::actors::btc_adapter::signals::BtcAdapterReadySubscribe; use crate::actors::btc_adapter::BtcAdapter; use crate::actors::canister_http_adapter::signals::CanisterHttpAdapterReadySubscribe; use crate::actors::canister_http_adapter::CanisterHttpAdapter; -use crate::actors::emulator::Emulator; use crate::actors::icx_proxy::signals::PortReadySubscribe; use crate::actors::icx_proxy::{IcxProxy, IcxProxyConfig}; use crate::actors::replica::{BitcoinIntegrationConfig, Replica}; @@ -20,7 +18,6 @@ use std::path::PathBuf; pub mod btc_adapter; pub mod canister_http_adapter; -pub mod emulator; pub mod icx_proxy; pub mod replica; mod shutdown; @@ -82,36 +79,6 @@ pub fn start_canister_http_adapter_actor( Ok(CanisterHttpAdapter::new(actor_config).start().recipient()) } -#[context("Failed to start emulator actor.")] -pub fn start_emulator_actor( - env: &dyn Environment, - local_server_descriptor: &LocalServerDescriptor, - shutdown_controller: Addr, - emulator_port_path: PathBuf, -) -> DfxResult> { - let ic_ref_path = env.get_cache().get_binary_command_path("ic-ref")?; - - // Touch the port file. This ensures it is empty prior to - // handing it over to ic-ref. If we read the file and it has - // contents we shall assume it is due to our spawned ic-ref - // process. - std::fs::write(&emulator_port_path, "").with_context(|| { - format!( - "Failed to write/clear emulator port file {}.", - emulator_port_path.to_string_lossy() - ) - })?; - - let actor_config = actors::emulator::Config { - ic_ref_path, - port: local_server_descriptor.replica.port, - write_port_to: emulator_port_path, - shutdown_controller, - logger: Some(env.get_logger().clone()), - }; - Ok(actors::emulator::Emulator::new(actor_config).start()) -} - #[context("Failed to setup replica environment.")] fn setup_replica_env( local_server_descriptor: &LocalServerDescriptor, diff --git a/src/dfx/src/actors/shutdown.rs b/src/dfx/src/actors/shutdown.rs index 9610c36c83..b33668114d 100644 --- a/src/dfx/src/actors/shutdown.rs +++ b/src/dfx/src/actors/shutdown.rs @@ -17,7 +17,7 @@ pub fn wait_for_child_or_receiver( loop { // Check if either the child exited or a shutdown has been requested. // These can happen in either order in response to Ctrl-C, so increase the chance - // to notice a shutdown request even if the emulator exited quickly. + // to notice a shutdown request even if the replica exited quickly. let child_try_wait = child.try_wait(); let receiver_signalled = receiver.recv_timeout(std::time::Duration::from_millis(100)); diff --git a/src/dfx/src/commands/build.rs b/src/dfx/src/commands/build.rs index 22d58f3dcf..c8aef8c17c 100644 --- a/src/dfx/src/commands/build.rs +++ b/src/dfx/src/commands/build.rs @@ -112,8 +112,8 @@ fn collect_extra_canisters(env: &AgentEnvironment, config: &Config) -> Vec>() }) .unwrap_or_default() diff --git a/src/dfx/src/commands/canister/delete.rs b/src/dfx/src/commands/canister/delete.rs index af19f9937c..3cd04a9faa 100644 --- a/src/dfx/src/commands/canister/delete.rs +++ b/src/dfx/src/commands/canister/delete.rs @@ -138,7 +138,10 @@ async fn delete_canister( match wallet_canister_id(network, &identity_name)? { Some(canister_id) => WithdrawTarget::Canister { canister_id }, None if CYCLES_LEDGER_ENABLED => { - let Some(my_principal) = env.get_selected_identity_principal() else { bail!("Identity has no principal attached") }; + let Some(my_principal) = env.get_selected_identity_principal() + else { + bail!("Identity has no principal attached") + }; WithdrawTarget::CyclesLedger { to: Account { owner: my_principal, diff --git a/src/dfx/src/commands/deps/pull.rs b/src/dfx/src/commands/deps/pull.rs index 1f53471207..db92b3cb6f 100644 --- a/src/dfx/src/commands/deps/pull.rs +++ b/src/dfx/src/commands/deps/pull.rs @@ -16,12 +16,13 @@ use crate::util::download_file; use anyhow::{anyhow, bail, Context}; use candid::Principal; use clap::Parser; +use dfx_core::config::model::dfinity::Pullable; use dfx_core::fs::composite::{ensure_dir_exists, ensure_parent_dir_exists}; use fn_error_context::context; use ic_agent::{Agent, AgentError}; use ic_wasm::metadata::get_metadata; use sha2::{Digest, Sha256}; -use slog::{error, info, trace, Logger}; +use slog::{error, info, trace, warn, Logger}; use std::collections::{BTreeMap, BTreeSet, VecDeque}; use std::io::Write; use std::path::Path; @@ -150,24 +151,7 @@ async fn download_and_generate_pulled_canister( let dfx_metadata = fetch_dfx_metadata(agent, &canister_id).await?; let pullable = dfx_metadata.get_pullable()?; - // lookup `wasm_hash` in dfx metadata. If not available, get the hash of the on chain canister. - let hash_on_chain = match &pullable.wasm_hash { - Some(wasm_hash_str) => { - trace!( - logger, - "Canister {canister_id} specified a custom hash: {wasm_hash_str}" - ); - hex::decode(wasm_hash_str)? - } - None => { - match read_state_tree_canister_module_hash(agent, canister_id).await? { - Some(hash_on_chain) => hash_on_chain, - None => { - bail!("Canister {canister_id} doesn't have module hash. Perhaps it's not installed."); - } - } - } - }; + let hash_on_chain = get_hash_on_chain(agent, logger, canister_id, pullable).await?; pulled_canister.wasm_hash = hex::encode(&hash_on_chain); @@ -205,10 +189,12 @@ async fn download_and_generate_pulled_canister( // hash check let hash_download = Sha256::digest(&content); if hash_download.as_slice() != hash_on_chain { - bail!( - "Hash mismatch. + warn!( + logger, + "Canister {} has different hash between on chain and download. on chain: {} download: {}", + canister_id, hex::encode(hash_on_chain), hex::encode(hash_download.as_slice()) ); @@ -289,6 +275,52 @@ async fn fetch_metadata( } } +// Get expected hash of the canister wasm. +// If `wasm_hash` is specified in dfx metadata, use it. +// If `wasm_hash_url` is specified in dfx metadata, download the hash from the url. +// Otherwise, get the hash of the on chain canister. +async fn get_hash_on_chain( + agent: &Agent, + logger: &Logger, + canister_id: Principal, + pullable: &Pullable, +) -> DfxResult> { + if pullable.wasm_hash.is_some() && pullable.wasm_hash_url.is_some() { + warn!(logger, "Canister {canister_id} specified both `wasm_hash` and `wasm_hash_url`. `wasm_hash` will be used."); + }; + if let Some(wasm_hash_str) = &pullable.wasm_hash { + trace!( + logger, + "Canister {canister_id} specified a custom hash: {wasm_hash_str}" + ); + Ok(hex::decode(wasm_hash_str) + .with_context(|| format!("Failed to decode {wasm_hash_str} as sha256 hash."))?) + } else if let Some(wasm_hash_url) = &pullable.wasm_hash_url { + trace!( + logger, + "Canister {canister_id} specified a custom hash via url: {wasm_hash_url}" + ); + let wasm_hash_url = reqwest::Url::parse(wasm_hash_url) + .with_context(|| format!("{wasm_hash_url} is not a valid URL."))?; + let wasm_hash_content = download_file(&wasm_hash_url) + .await + .with_context(|| format!("Failed to download wasm_hash from {wasm_hash_url}."))?; + let wasm_hash_encoded = String::from_utf8(wasm_hash_content) + .with_context(|| format!("Content from {wasm_hash_url} is not valid text."))?; + Ok(hex::decode(&wasm_hash_encoded) + .with_context(|| format!("Failed to decode {wasm_hash_encoded} as sha256 hash."))?) + } else { + match read_state_tree_canister_module_hash(agent, canister_id).await? { + Some(hash_on_chain) => Ok(hash_on_chain), + None => { + bail!( + "Canister {canister_id} doesn't have module hash. Perhaps it's not installed." + ); + } + } + } +} + #[context("Failed to write to a tempfile then rename it to {}", path.display())] fn write_to_tempfile_then_rename(content: &[u8], path: &Path) -> DfxResult { assert!(path.is_absolute()); diff --git a/src/dfx/src/commands/start.rs b/src/dfx/src/commands/start.rs index 1fdcd36230..3f0fb5c907 100644 --- a/src/dfx/src/commands/start.rs +++ b/src/dfx/src/commands/start.rs @@ -1,8 +1,8 @@ use crate::actors::icx_proxy::signals::PortReadySubscribe; use crate::actors::icx_proxy::IcxProxyConfig; use crate::actors::{ - start_btc_adapter_actor, start_canister_http_adapter_actor, start_emulator_actor, - start_icx_proxy_actor, start_replica_actor, start_shutdown_controller, + start_btc_adapter_actor, start_canister_http_adapter_actor, start_icx_proxy_actor, + start_replica_actor, start_shutdown_controller, }; use crate::config::dfx_version_str; use crate::error_invalid_argument; @@ -53,24 +53,20 @@ pub struct StartOpts { #[arg(long)] clean: bool, - /// Runs a dedicated emulator instead of the replica - #[arg(long)] - emulator: bool, - /// Address of bitcoind node. Implies --enable-bitcoin. - #[arg(long, conflicts_with("emulator"), action = ArgAction::Append)] + #[arg(long, action = ArgAction::Append)] bitcoin_node: Vec, /// enable bitcoin integration - #[arg(long, conflicts_with("emulator"))] + #[arg(long)] enable_bitcoin: bool, /// enable canister http requests - #[arg(long, conflicts_with("emulator"))] + #[arg(long)] enable_canister_http: bool, /// The delay (in milliseconds) an update call should take. Lower values may be expedient in CI. - #[arg(long, conflicts_with("emulator"), default_value_t = 600)] + #[arg(long, default_value_t = 600)] artificial_delay: u32, /// Start even if the network config was modified. @@ -142,7 +138,6 @@ pub fn exec( StartOpts { host, background, - emulator, clean, force, bitcoin_node, @@ -183,7 +178,6 @@ pub fn exec( enable_bitcoin, bitcoin_node, enable_canister_http, - emulator, domain, )?; @@ -244,7 +238,6 @@ pub fn exec( })?; let replica_port_path = empty_writable_path(local_server_descriptor.replica_port_path())?; - let emulator_port_path = empty_writable_path(local_server_descriptor.ic_ref_port_path())?; if background { send_background()?; @@ -328,11 +321,8 @@ pub fn exec( replica_config }; - let effective_config = if emulator { - CachedConfig::emulator() - } else { - CachedConfig::replica(&replica_config) - }; + let effective_config = CachedConfig::replica(&replica_config); + if !clean && !force && previous_config_path.exists() { let previous_config = load_json_file(&previous_config_path) .context("Failed to read replica configuration. Rerun with `--clean`.")?; @@ -349,15 +339,7 @@ pub fn exec( let _proxy = system.block_on(async move { let shutdown_controller = start_shutdown_controller(env)?; - let port_ready_subscribe: Recipient = if emulator { - let emulator = start_emulator_actor( - env, - local_server_descriptor, - shutdown_controller.clone(), - emulator_port_path, - )?; - emulator.recipient() - } else { + let port_ready_subscribe: Recipient = { let btc_adapter_ready_subscribe = btc_adapter_config .map(|btc_adapter_config| { start_btc_adapter_actor( @@ -426,7 +408,6 @@ pub fn exec( #[allow(clippy::large_enum_variant)] pub enum CachedReplicaConfig<'a> { Replica { config: Cow<'a, ReplicaConfig> }, - Emulator, } #[derive(Serialize, Deserialize, PartialEq, Eq)] @@ -445,12 +426,6 @@ impl<'a> CachedConfig<'a> { }, } } - pub fn emulator() -> Self { - Self { - replica_rev: replica_rev().into(), - config: CachedReplicaConfig::Emulator, - } - } } pub fn apply_command_line_parameters( @@ -461,7 +436,6 @@ pub fn apply_command_line_parameters( enable_bitcoin: bool, bitcoin_nodes: Vec, enable_canister_http: bool, - emulator: bool, domain: Vec, ) -> DfxResult { if enable_canister_http { @@ -472,13 +446,6 @@ pub fn apply_command_line_parameters( warn!(logger, "Canister HTTP suppport is enabled by default. It can be disabled through dfx.json or networks.json."); } - if emulator { - warn!( - logger, - "The --emulator parameter is deprecated and will be discontinued soon." - ); - } - let _ = network_descriptor.local_server_descriptor()?; let mut local_server_descriptor = network_descriptor.local_server_descriptor.unwrap(); diff --git a/src/dfx/src/config/cache.rs b/src/dfx/src/config/cache.rs index 7491d8e701..401b8597ae 100644 --- a/src/dfx/src/config/cache.rs +++ b/src/dfx/src/config/cache.rs @@ -130,7 +130,7 @@ pub fn install_version(v: &str, force: bool) -> Result { // Copy our own binary in the cache. let dfx = temp_p.join("dfx"); - #[allow(clippy::needless_borrow)] + #[allow(clippy::needless_borrows_for_generic_args)] dfx_core::fs::write( &dfx, dfx_core::fs::read(¤t_exe).map_err(UnifiedIoError::from)?, diff --git a/src/dfx/src/lib/builders/assets.rs b/src/dfx/src/lib/builders/assets.rs index 701075a4df..eff29745ac 100644 --- a/src/dfx/src/lib/builders/assets.rs +++ b/src/dfx/src/lib/builders/assets.rs @@ -56,6 +56,8 @@ pub struct AssetsBuilder { _cache: Arc, logger: Logger, } +unsafe impl Send for AssetsBuilder {} +unsafe impl Sync for AssetsBuilder {} impl AssetsBuilder { #[context("Failed to create AssetBuilder.")] diff --git a/src/dfx/src/lib/builders/mod.rs b/src/dfx/src/lib/builders/mod.rs index 88b95e9abc..59846b8a39 100644 --- a/src/dfx/src/lib/builders/mod.rs +++ b/src/dfx/src/lib/builders/mod.rs @@ -328,7 +328,7 @@ pub fn run_command(args: Vec, vars: &[Env<'_>], cwd: &Path) -> DfxResult let canonicalized = dfx_core::fs::canonicalize(&cwd.join(command_name)) .or_else(|_| which::which(command_name)) .map_err(|_| anyhow!("Cannot find command or file {command_name}"))?; - let mut cmd = Command::new(&canonicalized); + let mut cmd = Command::new(canonicalized); cmd.args(arguments) .current_dir(cwd) diff --git a/src/dfx/src/lib/builders/motoko.rs b/src/dfx/src/lib/builders/motoko.rs index 3b3f526d38..6934f0a61e 100644 --- a/src/dfx/src/lib/builders/motoko.rs +++ b/src/dfx/src/lib/builders/motoko.rs @@ -26,6 +26,8 @@ pub struct MotokoBuilder { logger: slog::Logger, cache: Arc, } +unsafe impl Send for MotokoBuilder {} +unsafe impl Sync for MotokoBuilder {} impl MotokoBuilder { #[context("Failed to create MotokoBuilder.")] diff --git a/src/dfx/src/lib/error/mod.rs b/src/dfx/src/lib/error/mod.rs index 576c74fa65..90bd8d984f 100644 --- a/src/dfx/src/lib/error/mod.rs +++ b/src/dfx/src/lib/error/mod.rs @@ -4,7 +4,6 @@ pub mod notify_top_up; pub mod project; pub use build::BuildError; -pub use dfx_core::error::extension::ExtensionError; pub use notify_create_canister::NotifyCreateCanisterError; pub use notify_top_up::NotifyTopUpError; pub use project::ProjectError; diff --git a/src/dfx/src/lib/models/canister.rs b/src/dfx/src/lib/models/canister.rs index 5f435683d9..002445de10 100644 --- a/src/dfx/src/lib/models/canister.rs +++ b/src/dfx/src/lib/models/canister.rs @@ -41,6 +41,8 @@ pub struct Canister { builder: Arc, output: RefCell>, } +unsafe impl Send for Canister {} +unsafe impl Sync for Canister {} impl Canister { /// Create a new canister. diff --git a/src/dfx/src/lib/operations/canister/install_canister.rs b/src/dfx/src/lib/operations/canister/install_canister.rs index 3f94596cec..fe9b034f89 100644 --- a/src/dfx/src/lib/operations/canister/install_canister.rs +++ b/src/dfx/src/lib/operations/canister/install_canister.rs @@ -417,7 +417,7 @@ fn run_post_install_task( let canonicalized = dfx_core::fs::canonicalize(&cwd.join(&words[0])) .or_else(|_| which::which(&words[0])) .map_err(|_| anyhow!("Cannot find command or file {}", &words[0]))?; - let mut command = Command::new(&canonicalized); + let mut command = Command::new(canonicalized); command.args(&words[1..]); let vars = get_and_write_environment_variables(canister, &network.name, pool, dependencies, env_file)?; diff --git a/src/dfx/src/lib/operations/canister/mod.rs b/src/dfx/src/lib/operations/canister/mod.rs index 9e01743f42..a5af1e7ce2 100644 --- a/src/dfx/src/lib/operations/canister/mod.rs +++ b/src/dfx/src/lib/operations/canister/mod.rs @@ -12,17 +12,14 @@ use candid::utils::ArgumentDecoder; use candid::CandidType; use candid::Principal as CanisterId; use candid::Principal; -pub use deploy_canisters::deploy_canisters; -pub use deploy_canisters::DeployMode; use dfx_core::canister::build_wallet_canister; -pub use dfx_core::canister::install_canister_wasm; use dfx_core::identity::CallSender; use fn_error_context::context; use ic_utils::interfaces::management_canister::builders::CanisterSettings; use ic_utils::interfaces::management_canister::{MgmtMethod, StatusCallResult}; use ic_utils::interfaces::ManagementCanister; use ic_utils::Argument; -pub use install_canister::{install_canister, install_wallet}; +pub use install_canister::install_wallet; use std::path::PathBuf; pub mod motoko_playground; diff --git a/src/dfx/src/lib/replica/status.rs b/src/dfx/src/lib/replica/status.rs index 3efc7ee84f..9b896aa045 100644 --- a/src/dfx/src/lib/replica/status.rs +++ b/src/dfx/src/lib/replica/status.rs @@ -17,12 +17,7 @@ pub async fn ping_and_wait(url: &str) -> DfxResult { let status = agent.status().await; match status { Ok(status) => { - let healthy = match &status.replica_health_status { - Some(status) if status == "healthy" => true, - None => true, // emulator doesn't report replica_health_status - _ => false, - }; - if healthy { + if matches!(&status.replica_health_status, Some(status) if status == "healthy") { break; } } diff --git a/src/dfx/src/main.rs b/src/dfx/src/main.rs index 712d2df3f3..24543ad355 100644 --- a/src/dfx/src/main.rs +++ b/src/dfx/src/main.rs @@ -193,7 +193,8 @@ fn main() { let command = cli_opts.command; let result = match EnvironmentImpl::new() { Ok(env) => { - maybe_redirect_dfx(env.get_version()).map_or((), |_| unreachable!()); + #[allow(clippy::let_unit_value)] + let _ = maybe_redirect_dfx(env.get_version()).map_or((), |_| unreachable!()); match EnvironmentImpl::new().map(|env| { env.with_logger(log) .with_identity_override(identity) diff --git a/src/distributed/assetstorage.wasm.gz b/src/distributed/assetstorage.wasm.gz index 08649715e2..2796c34f49 100755 Binary files a/src/distributed/assetstorage.wasm.gz and b/src/distributed/assetstorage.wasm.gz differ