diff --git a/CHANGELOG.md b/CHANGELOG.md index f5f5ed1849..2d331f095b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,63 @@ # UNRELEASED +### feat: large canister modules now supported + +When using `dfx deploy` or `dfx canister install`, previously WASM modules larger than 2MiB would be rejected. +They are now automatically submitted via the chunking API if they are large enough. +From a user perspective the limitation will simply have been lifted. + +### 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 + +Updated to candid 0.10, ic-cdk 0.12, and ic-cdk-timers 0.6 + +### fix: store playground canister acquisition timestamps with nanosecond precision on all platforms + +They've always been stored with nanosecond precisions on Linux and Macos. +Now they are stored with nanosecond precision on Windows too. + +## Dependencies + +### Motoko + +Updated Motoko to [0.10.4](https://github.com/dfinity/motoko/releases/tag/0.10.4) + +### Frontend canister + +Module hash: 3c86d912ead6de7133b9f787df4ca9feee07bea8835d3ed594b47ee89e6cb730 + +### Replica + +Updated replica to elected commit 072b2a6586c409efa88f2244d658307ff3a645d8. +This incorporates the following executed proposals: + +- [127034](https://dashboard.internetcomputer.org/proposal/127034) +- [127031](https://dashboard.internetcomputer.org/proposal/127031) +- [126879](https://dashboard.internetcomputer.org/proposal/126879) +- [126878](https://dashboard.internetcomputer.org/proposal/126878) +- [126730](https://dashboard.internetcomputer.org/proposal/126730) +- [126729](https://dashboard.internetcomputer.org/proposal/126729) +- [126727](https://dashboard.internetcomputer.org/proposal/126727) +- [126366](https://dashboard.internetcomputer.org/proposal/126366) +- [126365](https://dashboard.internetcomputer.org/proposal/126365) +- [126293](https://dashboard.internetcomputer.org/proposal/126293) + # 0.15.3 ### fix: allow `http://localhost:*` as `connect-src` in the asset canister's CSP @@ -1337,7 +1388,7 @@ Additionally, after build step, the `.wasm` file is archived with `gzip`. ### chore: Move all `frontend canister`-related code into the SDK repo | from (`repository` `path`) | to (path in `dfinity/sdk` repository) | summary | -| :------------------------------------------ | :--------------------------------------------- | :------------------------------------------------------------------------------------------ | +|:--------------------------------------------|:-----------------------------------------------|:--------------------------------------------------------------------------------------------| | `dfinity/cdk-rs` `/src/ic-certified-assets` | `/src/canisters/frontend/ic-certified-asset` | the core of the frontend canister | | `dfinity/certified-assets` `/` | `/src/canisters/frontend/ic-frontend-canister` | wraps `ic-certified-assets` to build the canister wasm | | `dfinity/agent-rs` `/ic-asset` | `/src/canisters/frontend/ic-asset` | library facilitating interactions with frontend canister (e.g. uploading or listing assets) | diff --git a/Cargo.lock b/Cargo.lock index 0a57aa5be0..23d6adc800 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,10 +112,11 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "aead" -version = "0.4.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ + "crypto-common", "generic-array", ] @@ -126,20 +127,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if 1.0.0", - "cipher", + "cipher 0.3.0", "cpufeatures", "opaque-debug", ] +[[package]] +name = "aes" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +dependencies = [ + "cfg-if 1.0.0", + "cipher 0.4.4", + "cpufeatures", +] + [[package]] name = "aes-gcm" -version = "0.9.4" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ "aead", - "aes", - "cipher", + "aes 0.8.3", + "cipher 0.4.4", "ctr", "ghash", "subtle", @@ -317,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" @@ -421,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" @@ -574,7 +586,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e" dependencies = [ "block-padding", - "cipher", + "cipher 0.3.0", ] [[package]] @@ -599,47 +611,26 @@ dependencies = [ [[package]] name = "borsh" -version = "0.10.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" dependencies = [ "borsh-derive", - "hashbrown 0.13.2", + "cfg_aliases", ] [[package]] name = "borsh-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" -dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", - "proc-macro-crate 0.1.5", - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" dependencies = [ + "once_cell", + "proc-macro-crate 3.0.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.38", + "syn_derive", ] [[package]] @@ -743,91 +734,96 @@ 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 0.5.11", - "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.9.11" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465c1ce01d8089ee5b49ba20d3a9da15a28bba64c35cdff2aa256d37e319625d" +checksum = "39be580be172631a35cac2fc6c765f365709de459edb88121b3e7a80cce6c1ec" dependencies = [ "anyhow", - "arbitrary", "binread", "byteorder", - "candid_derive 0.6.4", - "codespan-reporting", - "convert_case 0.6.0", - "crc32fast", - "data-encoding", - "fake", + "candid_derive", "hex", - "lalrpop 0.20.0", - "lalrpop-util 0.20.0", + "ic_principal", "leb128", - "logos 0.13.0", "num-bigint 0.4.4", "num-traits", - "num_enum 0.6.1", "paste", "pretty 0.12.3", - "rand", "serde", "serde_bytes", - "serde_dhall", - "sha2 0.10.8", "stacker", "thiserror", ] [[package]] name = "candid_derive" -version = "0.5.0" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f1f4db7c7d04b87b70b3a35c5dc5c2c9dd73cef8bdf6760e2f18a0d45350dd" +checksum = "970c220da8aa2fa6f7ef5dbbf3ea5b620a59eb3ac107cfb95ae8c6eebdfb7a08" dependencies = [ "lazy_static", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.38", ] [[package]] -name = "candid_derive" -version = "0.6.4" +name = "candid_parser" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201ea498d901add0822653ac94cb0f8a92f9b1758a5273f4dafbb6673c9a5020" +checksum = "36381de3ba8a312deb028552c0d63f7c7fe6e204f44bae4c58a3643308cfa9d5" dependencies = [ - "lazy_static", - "proc-macro2", - "quote", - "syn 2.0.38", + "anyhow", + "arbitrary", + "candid", + "codespan-reporting", + "convert_case 0.6.0", + "fake", + "hex", + "lalrpop", + "lalrpop-util", + "logos", + "num-bigint 0.4.4", + "num-traits", + "pretty 0.12.3", + "rand", + "serde", + "serde_dhall", + "thiserror", ] [[package]] @@ -852,6 +848,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "chrono" version = "0.4.31" @@ -862,6 +864,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", + "serde", "wasm-bindgen", "windows-targets 0.48.5", ] @@ -884,6 +887,16 @@ dependencies = [ "generic-array", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + [[package]] name = "clap" version = "4.4.7" @@ -1019,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" @@ -1178,6 +1201,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", + "rand_core", "typenum", ] @@ -1193,11 +1217,11 @@ dependencies = [ [[package]] name = "ctr" -version = "0.8.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher", + "cipher 0.4.4", ] [[package]] @@ -1282,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]] @@ -1300,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", ] @@ -1369,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", @@ -1392,12 +1451,12 @@ dependencies = [ "anyhow", "apply-patch", "argon2", - "atty", "backoff", "base64 0.13.1", "byte-unit", "bytes", - "candid 0.9.11", + "candid", + "candid_parser", "ci_info", "clap", "console", @@ -1420,7 +1479,7 @@ dependencies = [ "ic-asset", "ic-cdk", "ic-identity-hsm", - "ic-utils 0.30.2", + "ic-utils 0.31.0", "ic-wasm", "icrc-ledger-types", "indicatif", @@ -1481,16 +1540,17 @@ dependencies = [ "bip32", "byte-unit", "bytes", - "candid 0.9.11", + "candid", "clap", "dialoguer", "directories-next", + "dunce", "flate2", "hex", "humantime-serde", "ic-agent", "ic-identity-hsm", - "ic-utils 0.30.2", + "ic-utils 0.31.0", "k256 0.11.6", "keyring", "lazy_static", @@ -1549,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", ] @@ -1862,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" @@ -1920,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" @@ -2126,9 +2169,9 @@ dependencies = [ [[package]] name = "ghash" -version = "0.4.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" dependencies = [ "opaque-debug", "polyval", @@ -2234,15 +2277,6 @@ dependencies = [ "ahash 0.7.7", ] -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.6", -] - [[package]] name = "hashbrown" version = "0.14.2" @@ -2459,18 +2493,18 @@ dependencies = [ [[package]] name = "ic-agent" -version = "0.30.2" -source = "git+https://github.com/dfinity/agent-rs.git?rev=ed0862a45d5973ff123cbabc4ac40a89821b18c6#ed0862a45d5973ff123cbabc4ac40a89821b18c6" +version = "0.31.0" +source = "git+https://github.com/dfinity/agent-rs.git?rev=6b02f649a569f354a0a1b370368ba28d31dd8702#6b02f649a569f354a0a1b370368ba28d31dd8702" dependencies = [ "backoff", "cached 0.46.1", - "candid 0.9.11", + "candid", "ed25519-consensus", "futures-util", "hex", "http", "http-body", - "ic-certification 1.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", @@ -2500,7 +2534,7 @@ name = "ic-asset" version = "0.20.0" dependencies = [ "backoff", - "candid 0.9.11", + "candid", "derivative", "dfx-core", "flate2", @@ -2509,7 +2543,7 @@ dependencies = [ "globset", "hex", "ic-agent", - "ic-utils 0.30.2", + "ic-utils 0.31.0", "itertools 0.10.5", "json5", "mime", @@ -2529,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.10.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d4c0b932bf454d5d60e61e13c3c944972fcfd74dc82b9ed5c8b0a75979cf50" +checksum = "9f3d204af0b11c45715169c997858edb58fa8407d08f4fae78a6b415dd39a362" dependencies = [ - "candid 0.9.11", + "candid", "ic-cdk-macros", "ic0", "serde", @@ -2584,11 +2633,11 @@ dependencies = [ [[package]] name = "ic-cdk-macros" -version = "0.7.1" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "411c0dd4c149132b68e679274d397053332ee29996c6a541075895881916333b" +checksum = "a5a618e4020cea88e933d8d2f8c7f86d570ec06213506a80d4f2c520a9bba512" dependencies = [ - "candid 0.9.11", + "candid", "proc-macro2", "quote", "serde", @@ -2596,21 +2645,41 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "ic-certificate-verification" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74807b58655db518e68de1d65e1734da76af43949569b752aa27237e206bd4ad" +dependencies = [ + "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 = "0.23.2" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb68e0ea2fe6b533ddab6ae2142274f9669acacbacd83ac64bb1cd268d33104" +checksum = "b79fd38f674173bd0af3c80b9dab6fedd3391b81a2fc0f87a2e393fb723fe13b" dependencies = [ "hex", + "serde", + "serde_bytes", "sha2 0.10.8", ] [[package]] name = "ic-certification" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c04340437a32c8b9c80d36f09715909c1e0a755327503a2e2906dcd662ba4e" +version = "2.3.0" +source = "git+https://github.com/dfinity/response-verification.git?rev=a65009624b61736df6d2dc17756bdbd02a84f599#a65009624b61736df6d2dc17756bdbd02a84f599" dependencies = [ "hex", "serde", @@ -2618,16 +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.9.11", + "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", @@ -2639,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", @@ -2683,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", @@ -2697,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", @@ -2726,95 +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", "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", @@ -2822,14 +2923,14 @@ 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]] name = "ic-identity-hsm" -version = "0.30.2" -source = "git+https://github.com/dfinity/agent-rs.git?rev=ed0862a45d5973ff123cbabc4ac40a89821b18c6#ed0862a45d5973ff123cbabc4ac40a89821b18c6" +version = "0.31.0" +source = "git+https://github.com/dfinity/agent-rs.git?rev=6b02f649a569f354a0a1b370368ba28d31dd8702#6b02f649a569f354a0a1b370368ba28d31dd8702" dependencies = [ "hex", "ic-agent", @@ -2841,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", @@ -2856,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", @@ -2866,70 +2967,74 @@ 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", ] [[package]] name = "ic-transport-types" -version = "0.30.2" -source = "git+https://github.com/dfinity/agent-rs.git?rev=ed0862a45d5973ff123cbabc4ac40a89821b18c6#ed0862a45d5973ff123cbabc4ac40a89821b18c6" +version = "0.31.0" +source = "git+https://github.com/dfinity/agent-rs.git?rev=6b02f649a569f354a0a1b370368ba28d31dd8702#6b02f649a569f354a0a1b370368ba28d31dd8702" dependencies = [ - "candid 0.9.11", + "candid", "hex", - "ic-certification 1.3.0", + "ic-certification 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "leb128", "serde", "serde_bytes", @@ -2940,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", @@ -2971,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", @@ -2999,16 +3098,18 @@ dependencies = [ [[package]] name = "ic-utils" -version = "0.30.2" -source = "git+https://github.com/dfinity/agent-rs.git?rev=ed0862a45d5973ff123cbabc4ac40a89821b18c6#ed0862a45d5973ff123cbabc4ac40a89821b18c6" +version = "0.31.0" +source = "git+https://github.com/dfinity/agent-rs.git?rev=6b02f649a569f354a0a1b370368ba28d31dd8702#6b02f649a569f354a0a1b370368ba28d31dd8702" dependencies = [ "async-trait", - "candid 0.9.11", + "candid", + "futures-util", "ic-agent", "once_cell", "semver", "serde", "serde_bytes", + "sha2 0.10.8", "strum 0.24.1", "strum_macros 0.24.3", "thiserror", @@ -3029,14 +3130,16 @@ dependencies = [ [[package]] name = "ic-wasm" -version = "0.4.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e360e45c2bf406a867c35ec5daee433f2c3bbbaf013469e6a386a322a9713885" +checksum = "9d2aa0d7deeb38f18fcec6e4c25c5004422e2e9f8c3fbad15bb795ebac37aca6" dependencies = [ "anyhow", - "candid 0.9.11", + "candid", "clap", "rustc-demangle", + "serde", + "serde_json", "tempfile", "thiserror", "walrus", @@ -3045,15 +3148,15 @@ dependencies = [ [[package]] name = "ic0" -version = "0.18.11" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576c539151d4769fb4d1a0c25c4108dd18facd04c5695b02cf2d226ab4e43aa5" +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", @@ -3064,14 +3167,28 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ic_principal" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1762deb6f7c8d8c2bdee4b6c5a47b60195b74e9b5280faa5ba29692f8e17429c" +dependencies = [ + "arbitrary", + "crc32fast", + "data-encoding", + "serde", + "sha2 0.10.8", + "thiserror", +] + [[package]] name = "icrc-ledger-types" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad46da2124f4d7bf5c079eca568786b87bd60fc962bef404ff44207077961c" +checksum = "804c892bf95652101660a25cea10f059f73eb8973f6b04e0349758fda1190447" dependencies = [ "base32", - "candid 0.9.11", + "candid", "crc32fast", "hex", "num-bigint 0.4.4", @@ -3087,13 +3204,13 @@ version = "0.20.0" dependencies = [ "anstyle", "anyhow", - "candid 0.9.11", + "candid", "clap", "delay", "humantime", "ic-agent", "ic-asset", - "ic-utils 0.30.2", + "ic-utils 0.31.0", "libflate", "num-traits", "pem 1.1.1", @@ -3163,6 +3280,15 @@ dependencies = [ "regex", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + [[package]] name = "instant" version = "0.1.12" @@ -3224,6 +3350,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" @@ -3329,28 +3464,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" @@ -3363,7 +3476,7 @@ dependencies = [ "ena", "is-terminal", "itertools 0.10.5", - "lalrpop-util 0.20.0", + "lalrpop-util", "petgraph", "pico-args", "regex", @@ -3374,15 +3487,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" @@ -3493,22 +3597,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]] @@ -3525,20 +3620,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" @@ -3704,12 +3785,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", @@ -3855,48 +3935,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 0.5.11", -] - -[[package]] -name = "num_enum" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" -dependencies = [ - "num_enum_derive 0.6.1", -] - -[[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_enum_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 2.0.38", -] - [[package]] name = "num_threads" version = "0.1.6" @@ -4218,10 +4256,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", ] @@ -4307,9 +4345,9 @@ dependencies = [ [[package]] name = "polyval" -version = "0.5.3" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" dependencies = [ "cfg-if 1.0.0", "cpufeatures", @@ -4335,16 +4373,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" @@ -4394,7 +4422,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b2685dd208a3771337d8d386a89840f0f43cd68be8dae90a5f8c2384effc9cd" +dependencies = [ + "toml_edit 0.21.0", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", ] [[package]] @@ -4428,9 +4488,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", @@ -4438,15 +4498,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]] @@ -4792,9 +4852,9 @@ checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" [[package]] name = "rust_decimal" -version = "1.32.0" +version = "1.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c4216490d5a413bc6d10fa4742bd7d4955941d062c0ef873141d6b0e7b30fd" +checksum = "06676aec5ccb8fc1da723cc8c0f9a46549f21ebb8753d3915c6c41db1e7f1dc4" dependencies = [ "arrayvec 0.7.4", "borsh", @@ -5028,7 +5088,7 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1da5c423b8783185fd3fecd1c8796c267d2c089d894ce5a93c280a5d3f780a2" dependencies = [ - "aes", + "aes 0.7.5", "block-modes", "hkdf", "lazy_static", @@ -5076,13 +5136,24 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.190" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" 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" @@ -5104,9 +5175,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -5207,7 +5278,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", @@ -5237,19 +5308,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" @@ -5472,23 +5530,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", @@ -5497,15 +5558,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]] @@ -5522,11 +5583,11 @@ checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" [[package]] name = "supports-color" -version = "1.3.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" dependencies = [ - "atty", + "is-terminal", "is_ci", ] @@ -5552,6 +5613,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "sysinfo" version = "0.28.4" @@ -5766,9 +5839,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -5785,9 +5858,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", @@ -5846,7 +5919,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.19.15", ] [[package]] @@ -5871,6 +5944,17 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +dependencies = [ + "indexmap 2.1.0", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -5985,11 +6069,11 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "universal-hash" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ - "generic-array", + "crypto-common", "subtle", ] @@ -6014,9 +6098,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" @@ -6140,6 +6229,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 8a42a64df0..2b00b9bc87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,23 +9,25 @@ 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] -candid = { version = "0.9.0", features = ["parser"] } -ic-agent = "0.30.2" +candid = "0.10.0" +candid_parser = "0.1.2" +ic-agent = { git = "https://github.com/dfinity/agent-rs.git", rev = "6b02f649a569f354a0a1b370368ba28d31dd8702" } ic-asset = { path = "src/canisters/frontend/ic-asset" } -ic-cdk = "0.10.0" -ic-identity-hsm = "0.30.2" -ic-utils = "0.30.2" +ic-cdk = "0.12.0" +ic-identity-hsm = { git = "https://github.com/dfinity/agent-rs.git", rev = "6b02f649a569f354a0a1b370368ba28d31dd8702" } +ic-utils = { git = "https://github.com/dfinity/agent-rs.git", rev = "6b02f649a569f354a0a1b370368ba28d31dd8702" } -aes-gcm = "0.9.4" +aes-gcm = "0.10.3" anyhow = "1.0.56" anstyle = "1.0.0" argon2 = "0.4.0" @@ -34,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" @@ -64,25 +66,10 @@ 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" -[patch.crates-io.ic-agent] -version = "0.30.2" -git = "https://github.com/dfinity/agent-rs.git" -rev = "ed0862a45d5973ff123cbabc4ac40a89821b18c6" - -[patch.crates-io.ic-identity-hsm] -version = "0.30.2" -git = "https://github.com/dfinity/agent-rs.git" -rev = "ed0862a45d5973ff123cbabc4ac40a89821b18c6" - -[patch.crates-io.ic-utils] -version = "0.30.2" -git = "https://github.com/dfinity/agent-rs.git" -rev = "ed0862a45d5973ff123cbabc4ac40a89821b18c6" - [profile.release] panic = 'abort' lto = true 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/assets/large_canister/Cargo.toml b/e2e/assets/large_canister/Cargo.toml new file mode 100644 index 0000000000..63c2f1a2ae --- /dev/null +++ b/e2e/assets/large_canister/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "large" +version = "0.0.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[workspace] diff --git a/e2e/assets/large_canister/dfx.json b/e2e/assets/large_canister/dfx.json new file mode 100644 index 0000000000..ad4d443cf6 --- /dev/null +++ b/e2e/assets/large_canister/dfx.json @@ -0,0 +1,9 @@ +{ + "canisters": { + "large": { + "type": "rust", + "package": "large", + "candid": "large.did" + } + } +} diff --git a/e2e/assets/large_canister/large.did b/e2e/assets/large_canister/large.did new file mode 100644 index 0000000000..f424d81e86 --- /dev/null +++ b/e2e/assets/large_canister/large.did @@ -0,0 +1 @@ +service : {} diff --git a/e2e/assets/large_canister/patch.bash b/e2e/assets/large_canister/patch.bash new file mode 100644 index 0000000000..7f6fccde43 --- /dev/null +++ b/e2e/assets/large_canister/patch.bash @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +head -c $((1024 * 1024 * 8)) /dev/urandom >garbage.bin diff --git a/e2e/assets/large_canister/rust-toolchain.toml b/e2e/assets/large_canister/rust-toolchain.toml new file mode 100644 index 0000000000..e918eb3dbf --- /dev/null +++ b/e2e/assets/large_canister/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +targets = ["wasm32-unknown-unknown"] diff --git a/e2e/assets/large_canister/src/lib.rs b/e2e/assets/large_canister/src/lib.rs new file mode 100644 index 0000000000..3ef35d26ab --- /dev/null +++ b/e2e/assets/large_canister/src/lib.rs @@ -0,0 +1,3 @@ +#[used] +#[no_mangle] +pub static LARGE: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/garbage.bin")); diff --git a/e2e/tests-dfx/assetscanister.bash b/e2e/tests-dfx/assetscanister.bash index 2a5aaf6083..6656c6849b 100644 --- a/e2e/tests-dfx/assetscanister.bash +++ b/e2e/tests-dfx/assetscanister.bash @@ -884,13 +884,12 @@ check_permission_failure() { assert_command dfx canister call --query e2e_project_frontend get '(record{key="/text-with-newlines.txt";accept_encodings=vec{"identity"}})' - assert_command dfx canister call --query e2e_project_frontend get_chunk '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt vec { 243; 191; 114; 177; 83; 18; 144; 121; 131; 38; 109; 183; 89; 244; 120; 136; 53; 187; 14; 74; 8; 112; 86; 100; 115; 8; 179; 155; 69; 78; 95; 160; }})' + assert_command dfx canister call --query e2e_project_frontend get_chunk '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt blob "\f3\bf\72\b1\53\12\90\79\83\26\6d\b7\59\f4\78\88\35\bb\0e\4a\08\70\56\64\73\08\b3\9b\45\4e\5f\a0" })' assert_command_fail dfx canister call --query e2e_project_frontend get_chunk '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0})' assert_match 'sha256 required' - assert_command_fail dfx canister call --query e2e_project_frontend get_chunk '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt vec { 88; 87; 86; }})' + assert_command_fail dfx canister call --query e2e_project_frontend get_chunk '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt blob "XWV" })' assert_match 'sha256 mismatch' - assert_command dfx canister call --query e2e_project_frontend http_request_streaming_callback '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt vec { 243; 191; 114; 177; 83; 18; 144; 121; 131; 38; 109; 183; 89; 244; 120; 136; 53; 187; 14; 74; 8; 112; 86; 100; 115; 8; 179; 155; 69; 78; 95; 160; }})' assert_command dfx canister call --query e2e_project_frontend http_request_streaming_callback '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt blob "\f3\bf\72\b1\53\12\90\79\83\26\6d\b7\59\f4\78\88\35\bb\0e\4a\08\70\56\64\73\08\b3\9b\45\4e\5f\a0"})' assert_command_fail dfx canister call --query e2e_project_frontend http_request_streaming_callback '(record{key="/text-with-newlines.txt";content_encoding="identity";index=0;sha256=opt vec { 88; 87; 86; }})' assert_match 'sha256 mismatch' @@ -906,14 +905,14 @@ check_permission_failure() { dfx canister install e2e_project_frontend assert_command dfx canister call --query e2e_project_frontend retrieve '("/binary/noise.txt")' --output idl - assert_eq '(blob "\b8\01 \80\0aw12 \00xy\0aKL\0b\0ajk")' + assert_eq '(blob "\b8\01\20\80\0a\77\31\32\20\00\78\79\0a\4b\4c\0b\0a\6a\6b")' assert_command dfx canister call --query e2e_project_frontend retrieve '("/text-with-newlines.txt")' --output idl assert_eq '(blob "cherries\0ait\27s cherry season\0aCHERRIES")' assert_command dfx canister call --update e2e_project_frontend store '(record{key="AA"; content_type="text/plain"; content_encoding="identity"; content=blob "hello, world!"})' assert_eq '()' - assert_command dfx canister call --update e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=vec { 88; 87; 86; }})' + assert_command dfx canister call --update e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})' assert_eq '()' assert_command dfx canister call --query e2e_project_frontend retrieve '("B")' --output idl diff --git a/e2e/tests-dfx/basic-project.bash b/e2e/tests-dfx/basic-project.bash index 6dd4ab76f8..766a90f6fb 100644 --- a/e2e/tests-dfx/basic-project.bash +++ b/e2e/tests-dfx/basic-project.bash @@ -47,7 +47,9 @@ teardown() { assert_eq \ '( variant { - 17_724 = record { 153_986_224 = blob "DIDL\00\01q\11Hello, Blueberry!" } + 17_724 = record { + 153_986_224 = blob "\44\49\44\4c\00\01\71\11\48\65\6c\6c\6f\2c\20\42\6c\75\65\62\65\72\72\79\21"; + } }, )' } @@ -100,8 +102,12 @@ teardown() { # Call using the wallet's call forwarding assert_command dfx canister call hello_backend read --async --wallet="$(dfx identity get-wallet)" assert_command dfx canister request-status "$stdout" "$(dfx identity get-wallet)" - assert_eq '(variant { 17_724 = record { 153_986_224 = blob "DIDL\00\01}\b9\0a" } })' - + assert_eq \ +'( + variant { + 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/build_granular.bash b/e2e/tests-dfx/build_granular.bash index d60b824b53..3b50ec9d94 100644 --- a/e2e/tests-dfx/build_granular.bash +++ b/e2e/tests-dfx/build_granular.bash @@ -67,7 +67,7 @@ teardown() { dfx canister install e2e_project_frontend assert_command dfx canister call --query e2e_project_frontend retrieve '("/binary/noise.txt")' --output idl - assert_eq '(blob "\b8\01 \80\0aw12 \00xy\0aKL\0b\0ajk")' + assert_eq '(blob "\b8\01\20\80\0a\77\31\32\20\00\78\79\0a\4b\4c\0b\0a\6a\6b")' assert_command dfx canister call --query e2e_project_frontend retrieve '("/text-with-newlines.txt")' --output idl assert_eq '(blob "cherries\0ait\27s cherry season\0aCHERRIES")' diff --git a/e2e/tests-dfx/cycles-ledger.bash b/e2e/tests-dfx/cycles-ledger.bash index f015872900..0d12dd70a0 100644 --- a/e2e/tests-dfx/cycles-ledger.bash +++ b/e2e/tests-dfx/cycles-ledger.bash @@ -444,6 +444,7 @@ current_time_nanoseconds() { # using dfx canister create dfx identity use alice + # shellcheck disable=SC2030 export DFX_DISABLE_AUTO_WALLET=1 t=$(current_time_nanoseconds) assert_command dfx canister create e2e_project_backend --with-cycles 1T --created-at-time "$t" @@ -501,3 +502,46 @@ current_time_nanoseconds() { assert_command dfx cycles balance --precise assert_eq "9399600000000 cycles." } + +@test "canister deletion" { + skip "can't be properly tested with feature flag turned off (CYCLES_LEDGER_ENABLED). TODO(SDK-1331): re-enable this test" + dfx_new temporary + add_cycles_ledger_canisters_to_project + install_cycles_ledger_canisters + + ALICE=$(dfx identity get-principal --identity alice) + + assert_command deploy_cycles_ledger + CYCLES_LEDGER_ID=$(dfx canister id cycles-ledger) + echo "Cycles ledger deployed at id $CYCLES_LEDGER_ID" + assert_command dfx deploy cycles-depositor --argument "(record {ledger_id = principal \"$(dfx canister id cycles-ledger)\"})" + echo "Cycles depositor deployed at id $(dfx canister id cycles-depositor)" + assert_command dfx ledger fabricate-cycles --canister cycles-depositor --t 9999 + assert_command dfx deploy + assert_command dfx canister call cycles-depositor deposit "(record {to = record{owner = principal \"$ALICE\";};cycles = 22_400_000_000_000;})" --identity cycle-giver + + cd .. + dfx_new + # setup done + + dfx identity use alice + # shellcheck disable=SC2031 + export DFX_DISABLE_AUTO_WALLET=1 + assert_command dfx canister create --all --with-cycles 10T + assert_command dfx cycles balance --precise + assert_eq "2399800000000 cycles." + + # delete by name + assert_command dfx canister stop --all + assert_command dfx canister delete e2e_project_backend + assert_command dfx cycles balance + assert_eq "12.389 TC (trillion cycles)." + + # delete by id + FRONTEND_ID=$(dfx canister id e2e_project_frontend) + rm .dfx/local/canister_ids.json + assert_command dfx canister stop "${FRONTEND_ID}" + assert_command dfx canister delete "${FRONTEND_ID}" + assert_command dfx cycles balance + assert_eq "22.379 TC (trillion cycles)." +} \ No newline at end of file diff --git a/e2e/tests-dfx/deps.bash b/e2e/tests-dfx/deps.bash index 540aa1329a..c56aa217be 100644 --- a/e2e/tests-dfx/deps.bash +++ b/e2e/tests-dfx/deps.bash @@ -127,7 +127,7 @@ Failed to download from url: http://example.com/c.wasm." cd ../onchain dfx canister stop a - dfx canister delete a + dfx canister delete a --no-withdrawal cd ../app assert_command_fail dfx deps pull --network local @@ -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" { @@ -325,11 +332,11 @@ candid:args => (nat)" # delete onchain canisters so that the replica has no canisters as a clean local replica cd ../onchain dfx canister stop a - dfx canister delete a + dfx canister delete a --no-withdrawal dfx canister stop b - dfx canister delete b + dfx canister delete b --no-withdrawal dfx canister stop c - dfx canister delete c + dfx canister delete c --no-withdrawal cd ../app assert_command dfx deps init # b is set here @@ -355,10 +362,10 @@ Installing canister: $CANISTER_ID_C (dep_c)" # deployed pull dependencies can be stopped and deleted assert_command dfx canister stop dep_b --identity anonymous - assert_command dfx canister delete dep_b --identity anonymous + assert_command dfx canister delete dep_b --identity anonymous --no-withdrawal assert_command dfx canister stop $CANISTER_ID_A --identity anonymous - assert_command dfx canister delete $CANISTER_ID_A --identity anonymous + assert_command dfx canister delete $CANISTER_ID_A --identity anonymous --no-withdrawal # error cases ## set wrong init argument @@ -397,11 +404,11 @@ Installing canister: $CANISTER_ID_C (dep_c)" # delete onchain canisters so that the replica has no canisters as a clean local replica cd ../onchain dfx canister stop a - dfx canister delete a + dfx canister delete a --no-withdrawal dfx canister stop b - dfx canister delete b + dfx canister delete b --no-withdrawal dfx canister stop c - dfx canister delete c + dfx canister delete c --no-withdrawal cd ../app assert_command_fail dfx canister create dep_b @@ -434,7 +441,7 @@ Installing canister: $CANISTER_ID_C (dep_c)" # start a clean local replica dfx canister stop app - dfx canister delete app + dfx canister delete app --no-withdrawal assert_command dfx deploy # only deploy app canister } @@ -443,8 +450,8 @@ Installing canister: $CANISTER_ID_C (dep_c)" # verify the help message assert_command dfx deps pull -h - assert_contains "Pull canisters upon which the project depends. This command connects to the \"ic\" mainnet by default. -You can still choose other network by setting \`--network\`" + assert_contains "Pull canisters upon which the project depends. This command connects to the \"ic\" mainnet by default." + assert_contains "You can still choose other network by setting \`--network\`" assert_command dfx deps pull assert_contains "There are no pull dependencies defined in dfx.json" diff --git a/e2e/tests-dfx/identity.bash b/e2e/tests-dfx/identity.bash index a39681152f..4550368a5a 100644 --- a/e2e/tests-dfx/identity.bash +++ b/e2e/tests-dfx/identity.bash @@ -146,13 +146,13 @@ teardown() { assert_eq '(false)' # these all fail (other identities are not initializer; cannot store assets): - assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=vec { 88; 87; 86; }})' --identity bob - assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=vec { 88; 87; 86; }})' --identity default - assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=vec { 88; 87; 86; }})' + assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})' --identity bob + assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})' --identity default + assert_command_fail dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})' assert_command_fail dfx canister call e2e_project_frontend retrieve '("B")' # but alice, the initializer, can store assets: - assert_command dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=vec { 88; 87; 86; }})' --identity alice + assert_command dfx canister call e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})' --identity alice assert_eq '()' assert_command dfx canister call --output idl e2e_project_frontend retrieve '("B")' assert_eq '(blob "XWV")' diff --git a/e2e/tests-dfx/install.bash b/e2e/tests-dfx/install.bash index bd4a4f3d02..966c02e0da 100644 --- a/e2e/tests-dfx/install.bash +++ b/e2e/tests-dfx/install.bash @@ -152,6 +152,17 @@ teardown() { assert_eq "$BUILD_HASH" "$ONCHAIN_HASH" } +@test "can install >2MiB wasm" { + install_asset large_canister + dfx_start + dfx canister create --all + assert_command dfx build + assert_command dfx canister install --all + assert_command dfx canister info large + HASH="$(sha256sum .dfx/local/canisters/large/large.wasm | head -c 64)" + assert_match "Module hash: 0x$HASH" +} + @test "--mode=auto selects install or upgrade automatically" { dfx_start assert_command dfx canister create e2e_project_backend 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/tests-dfx/wallet.bash b/e2e/tests-dfx/wallet.bash index b2c134f758..66bd979f98 100644 --- a/e2e/tests-dfx/wallet.bash +++ b/e2e/tests-dfx/wallet.bash @@ -131,7 +131,7 @@ teardown() { assert_command dfx canister call "$WALLET" wallet_call \ "(record { canister = principal \"$(dfx canister id e2e_project_backend)\"; method_name = \"amInitializer\"; args = blob \"DIDL\00\00\"; cycles = (0:nat64)})" - assert_eq '(variant { 17_724 = record { 153_986_224 = blob "DIDL\00\01~\01" } })' # True in DIDL. + assert_eq '(variant { 17_724 = record { 153_986_224 = blob "\44\49\44\4c\00\01\7e\01" } })' # True in DIDL. } @test "forward user call through wallet: deploy" { @@ -147,7 +147,7 @@ teardown() { assert_command dfx canister call e2e_project_backend amInitializer assert_command dfx canister call "$WALLET" wallet_call \ "(record { canister = principal \"$(dfx canister id e2e_project_backend)\"; method_name = \"amInitializer\"; args = blob \"DIDL\00\00\"; cycles = (0:nat64)})" - assert_eq '(variant { 17_724 = record { 153_986_224 = blob "DIDL\00\01~\01" } })' # True in DIDL. + assert_eq '(variant { 17_724 = record { 153_986_224 = blob "\44\49\44\4c\00\01\7e\01" } })' # True in DIDL. } @test "a 64-bit wallet can still be called in the 128-bit context" { 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/nix/sources.json b/nix/sources.json index e0c9af5fe6..1cf2b4af60 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -15,54 +15,54 @@ "canister_sandbox-x86_64-darwin": { "builtin": false, "description": "The canister_sandbox binary. It must be updated together with the replica binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "049hfmpi7njn439hry1z5qb3k45z300jvrvcgycbxrdiz5nd9kaa", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "0b6ykxs3cfzp0dr4b3ahcl2ps9g6paw55rmgmcr38wljqfw4r03r", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/canister_sandbox.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/canister_sandbox.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/canister_sandbox.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-darwin/canister_sandbox.gz" }, "canister_sandbox-x86_64-linux": { "builtin": false, "description": "The canister_sandbox binary. It must be updated together with the replica binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "04r9rs47ky6715jwia5qzpj5983y2xyg246wncjhybqn79a9m10i", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "06j0i8v690az5p7v7wj1gmrxhggmr1bas05dk8d6mdx5fxq2sxf6", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/canister_sandbox.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/canister_sandbox.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/canister_sandbox.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-linux/canister_sandbox.gz" }, "ic-admin-x86_64-darwin": { "builtin": false, "description": "The ic-admin binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "15r1ymcrhb1z859cpjhg3y9nswskh94sxr8l1gqbw5lsf6y8ygsb", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "08537h5g92in58142g4cjwj0g7nvhl5bpi4b9d0p0liim9brzzq3", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/ic-admin.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/ic-admin.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/ic-admin.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-darwin/ic-admin.gz" }, "ic-admin-x86_64-linux": { "builtin": false, "description": "The ic-admin binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "00hry4mjramd8dwx88v8crrzjj0rzkvd23ckqig3bglvaisnsspf", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "1xb2g2gib89rnhblqa05mhwiblkq08vcdfpr4hqzpfv0ik4m8kqn", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/ic-admin.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/ic-admin.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/ic-admin.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-linux/ic-admin.gz" }, "ic-btc-adapter-x86_64-darwin": { "builtin": false, - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "0y79j7rzi12896808sai0nhfzslmgrg1gvm7kfprf89jrikh1v9w", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "1xj5h7bgpnagrhfckr0zdjvndh2ckdfjg6vpyxyf7l0jsvx8l0w1", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/ic-btc-adapter.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/ic-btc-adapter.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/ic-btc-adapter.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-darwin/ic-btc-adapter.gz" }, "ic-btc-adapter-x86_64-linux": { "builtin": false, - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "1silh7jx2i6ln7r1k49ndgddm4fm10f9f3f822lyz90vz7dml6yk", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "1l2ya82kd01j9c9v3vkjh8wzqwqkd206n3d4azv6ffrcjk2byj07", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/ic-btc-adapter.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/ic-btc-adapter.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/ic-btc-adapter.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-linux/ic-btc-adapter.gz" }, "ic-btc-canister": { "owner": "dfinity", @@ -74,69 +74,69 @@ }, "ic-https-outcalls-adapter-x86_64-darwin": { "builtin": false, - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "14nivx59ww4y0phpwxfcisc4an2sny5r4f3qrmalqk4vi445mszy", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "019cfp108qgqz4bdvsp92jd02yc33srlq4qs1kfslng2d7367594", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/ic-https-outcalls-adapter.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/ic-https-outcalls-adapter.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/ic-https-outcalls-adapter.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-darwin/ic-https-outcalls-adapter.gz" }, "ic-https-outcalls-adapter-x86_64-linux": { "builtin": false, - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "0qgxzfzym8gh91bsg5krmlrh39anlcgnff330w4jgiwql95ayvr7", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "1y5zzi4255wp2zqghgkyhwy7acqc3g54pwqnn96lnvqfz80kbvk5", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/ic-https-outcalls-adapter.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/ic-https-outcalls-adapter.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/ic-https-outcalls-adapter.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-linux/ic-https-outcalls-adapter.gz" }, "ic-nns-init-x86_64-darwin": { "builtin": false, "description": "The ic-nns-init binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "0c59dsi9gwxzj9l2d94k48yk2vdz0gb1yjfh58ky1sx4w28hxzc5", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "192i56x37j04r1z1znrkvkg5jjs5bs2jmlm7lb2b95sx1idz0y0y", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/ic-nns-init.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/ic-nns-init.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/ic-nns-init.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-darwin/ic-nns-init.gz" }, "ic-nns-init-x86_64-linux": { "builtin": false, "description": "The ic-nns-init binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "15v8a6d71rg7xgl3nvy5l839qxyvkig1mlldpdr4bmmwp3yqx3nm", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "1591praw6q1allnpfw9fiz6arjr108wfzwv71kq8224v9p8vj2mh", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/ic-nns-init.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/ic-nns-init.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/ic-nns-init.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-linux/ic-nns-init.gz" }, "ic-starter-x86_64-darwin": { "builtin": false, - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "1ar30xi3vnrwpyl0cir3m4dvdzdwm09xji33w25krj5n9503acqz", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "0519yfk1phbwj5iplcbjphs48lacshy5bi3zrv084hf1y1ylm0w6", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/ic-starter.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/ic-starter.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/ic-starter.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-darwin/ic-starter.gz" }, "ic-starter-x86_64-linux": { "builtin": false, - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "1ddgxd9pnybnjiqhgggxlkbq8ml99ca4iq54kh221kdj7h1m334d", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "0qc2q0r0bi05qd8jfr1j0ngghll80cg8fb7nzg7bffj4zbrlqp76", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/ic-starter.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/ic-starter.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/ic-starter.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-linux/ic-starter.gz" }, "icx-proxy-x86_64-darwin": { "builtin": false, - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "1p9gmlz85j514s6da189hwaghg18p62pbknkn3q59jyxmf22fzxh", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "0grdnw67yvi82rx91dqsqy2hvbbp9nn7ca8j2bsdrwfwys528js0", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/icx-proxy-dev.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/icx-proxy-dev.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/icx-proxy-dev.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-darwin/icx-proxy-dev.gz" }, "icx-proxy-x86_64-linux": { "builtin": false, - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "105jm3px6ky88jc86am8dkxz1vnhzcxy0p7skzs98baylr96kzrb", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "05w34miq9hzzn5nfjhcvk56ihcgs90cmqdciwqgnh9sqr2j8wcci", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/icx-proxy-dev.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/icx-proxy-dev.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/icx-proxy-dev.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-linux/icx-proxy-dev.gz" }, "motoko-base": { "builtin": false, @@ -144,78 +144,78 @@ "owner": "dfinity", "sha256": "0x78h0xy31jdsinrhfa0hb9xyggs3cbn5jfxxy30gfjc4a6j04p1", "type": "tarball", - "url": "https://github.com/dfinity/motoko/releases/download/0.10.3/motoko-base-library.tar.gz", + "url": "https://github.com/dfinity/motoko/releases/download/0.10.4/motoko-base-library.tar.gz", "url_template": "https://github.com/dfinity/motoko/releases/download//motoko-base-library.tar.gz", - "version": "0.10.3" + "version": "0.10.4" }, "motoko-x86_64-darwin": { "builtin": false, - "sha256": "0ws8i03fvq42zkjrlwlmz67p2dfm7wzng3ilm3gg5igfpqrvvf2w", + "sha256": "0mv708lj4hzr3c6ld9mr25l0anvanx6agfrmad7ccw29dnbixjr1", "type": "file", - "url": "https://github.com/dfinity/motoko/releases/download/0.10.3/motoko-Darwin-x86_64-0.10.3.tar.gz", + "url": "https://github.com/dfinity/motoko/releases/download/0.10.4/motoko-Darwin-x86_64-0.10.4.tar.gz", "url_template": "https://github.com/dfinity/motoko/releases/download//motoko-Darwin-x86_64-.tar.gz", - "version": "0.10.3" + "version": "0.10.4" }, "motoko-x86_64-linux": { "builtin": false, - "sha256": "1h19zkw49qwi8q9sllizpyy84ibgaq85i6p0jc6n8fr5gdy0bs7q", + "sha256": "0ml813b4108h3dxcz7lhpcihn4vp1yg9g66chc767hagzsabkgj8", "type": "file", - "url": "https://github.com/dfinity/motoko/releases/download/0.10.3/motoko-Linux-x86_64-0.10.3.tar.gz", + "url": "https://github.com/dfinity/motoko/releases/download/0.10.4/motoko-Linux-x86_64-0.10.4.tar.gz", "url_template": "https://github.com/dfinity/motoko/releases/download//motoko-Linux-x86_64-.tar.gz", - "version": "0.10.3" + "version": "0.10.4" }, "replica-x86_64-darwin": { "builtin": false, "description": "The replica binary. It must be updated together with the canister_sandbox binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "12z1lvhv257ywf1b4gknywdimh5yqnfx20yxn37f30iifg2zw87k", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "1z71dglwchqj9gj3vkrmg86dg7bw2b5h7n4mh395l2pzg56am246", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/replica.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/replica.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/replica.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-darwin/replica.gz" }, "replica-x86_64-linux": { "builtin": false, "description": "The replica binary. It must be updated together with the canister_sandbox binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "120iinjcybvc346wf1iq6r964a3w5dhhif6rnf2ngf0q3350rlrc", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "1k5gpvqzw30y5g3pdxixqvbsx3jrkdwn9wqc2wp2p4rf38h79hix", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/replica.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/replica.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/replica.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-linux/replica.gz" }, "sandbox_launcher-x86_64-darwin": { "builtin": false, "description": "The sandbox_launcher binary. It must be updated together with the replica binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "12pz2i2yhfl2saab3rc5sf0dr24l6siirpsx8z414818mzpc42zd", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "1pvv0b83p3jh7h41rw0kq9wgv44bspakv75aisxs7shc5hjqf51p", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/sandbox_launcher.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/sandbox_launcher.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/sandbox_launcher.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-darwin/sandbox_launcher.gz" }, "sandbox_launcher-x86_64-linux": { "builtin": false, "description": "The sandbox_launcher binary. It must be updated together with the replica binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "0zzpr02vc14ibx1qzd31a9jzh1zhb7ahcg85fazs6jkjk2zidi4n", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "1a8cicb2xaha4b4dm5cwq886r5izxc3akkg3gz13gf385x2pbx95", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/sandbox_launcher.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/sandbox_launcher.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/sandbox_launcher.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-linux/sandbox_launcher.gz" }, "sns-x86_64-darwin": { "builtin": false, "description": "The sns binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "12xkvxp3jprxw0205ml4ad3gdksi0x5c3kf7skcmkvqk744nml04", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "0gvvxkhc9bznc7w3jj4vinr62ms9j8wk6s9iwx0xwh9a6s2maixc", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/sns.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/sns.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/sns.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-darwin/sns.gz" }, "sns-x86_64-linux": { "builtin": false, "description": "The sns binary.", - "rev": "69e1408347723dbaa7a6cd2faa9b65c42abbe861", - "sha256": "02aqj9qcpvk216sdvkz25q1pf32bwb6wnf8v704rw133wpqq8sln", + "rev": "072b2a6586c409efa88f2244d658307ff3a645d8", + "sha256": "1ppkipx2zbvak7kl3hrw9c143dkfh5jhmxb50c7bv0q4w6x08vyf", "type": "file", - "url": "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/sns.gz", - "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/sns.gz" + "url": "https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/sns.gz", + "url_template": "https://download.dfinity.systems/ic//binaries/x86_64-linux/sns.gz" } } 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-asset/src/sync.rs b/src/canisters/frontend/ic-asset/src/sync.rs index 2962c2f75d..b927d1513e 100644 --- a/src/canisters/frontend/ic-asset/src/sync.rs +++ b/src/canisters/frontend/ic-asset/src/sync.rs @@ -138,7 +138,7 @@ async fn commit_in_stages( commit_batch( canister, CommitBatchArguments { - batch_id: Nat::from(0), + batch_id: Nat::from(0_u8), operations: operations.into(), }, ) @@ -156,7 +156,7 @@ async fn commit_in_stages( commit_batch( canister, CommitBatchArguments { - batch_id: Nat::from(0), + batch_id: Nat::from(0_u8), operations: operations.into(), }, ) @@ -239,7 +239,7 @@ pub(crate) fn gather_asset_descriptors( let entries = WalkDir::new(&dir) .into_iter() .filter_entry(|entry| { - if let Ok(canonical_path) = &entry.path().canonicalize() { + if let Ok(canonical_path) = &dfx_core::fs::canonicalize(entry.path()) { let config = configuration .get_asset_config(canonical_path) .unwrap_or_default(); diff --git a/src/canisters/frontend/ic-certified-assets/Cargo.toml b/src/canisters/frontend/ic-certified-assets/Cargo.toml index 0aa6639bbc..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,5 +27,9 @@ serde_cbor.workspace = true sha2.workspace = true [dev-dependencies] -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" } +ic-http-certification = "2.3.0" +candid_parser.workspace = true +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 336a0106a9..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(); @@ -445,7 +447,7 @@ pub fn post_upgrade(stable_state: StableState, args: Option) #[test] fn candid_interface_compatibility() { - use candid::utils::{service_compatible, CandidSource}; + use candid_parser::utils::{service_compatible, CandidSource}; use std::path::PathBuf; candid::export_service!(); diff --git a/src/canisters/frontend/ic-certified-assets/src/state_machine.rs b/src/canisters/frontend/ic-certified-assets/src/state_machine.rs index 3a41f358a6..01d8d36e8e 100644 --- a/src/canisters/frontend/ic-certified-assets/src/state_machine.rs +++ b/src/canisters/frontend/ic-certified-assets/src/state_machine.rs @@ -472,8 +472,8 @@ impl State { self.assets.clear(); self.batches.clear(); self.chunks.clear(); - self.next_batch_id = Nat::from(1); - self.next_chunk_id = Nat::from(1); + self.next_batch_id = Nat::from(1_u8); + self.next_chunk_id = Nat::from(1_u8); } pub fn has_permission(&self, principal: &Principal, permission: &Permission) -> bool { @@ -566,7 +566,7 @@ impl State { } } let batch_id = self.next_batch_id.clone(); - self.next_batch_id += 1; + self.next_batch_id += 1_u8; self.batches.insert( batch_id.clone(), @@ -607,7 +607,7 @@ impl State { batch.expires_at = Int::from(now + BATCH_EXPIRY_NANOS); let chunk_id = self.next_chunk_id.clone(); - self.next_chunk_id += 1; + self.next_chunk_id += 1_u8; batch.chunk_content_total_size += arg.content.as_ref().len(); self.chunks.insert( @@ -1093,7 +1093,9 @@ impl From for State { prepare_principals, manage_permissions_principals, assets: stable_state.stable_assets, - next_batch_id: stable_state.next_batch_id.unwrap_or_else(|| Nat::from(1)), + next_batch_id: stable_state + .next_batch_id + .unwrap_or_else(|| Nat::from(1_u8)), configuration: stable_state.configuration.unwrap_or_default(), ..Self::default() }; diff --git a/src/canisters/frontend/ic-certified-assets/src/tests.rs b/src/canisters/frontend/ic-certified-assets/src/tests.rs index 88fb797277..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 { @@ -962,7 +962,7 @@ fn uses_streaming_for_multichunk_assets() { .http_request_streaming_callback(StreamingCallbackToken { key: "/index.html".to_string(), content_encoding: "identity".to_string(), - index: Nat::from(1), + index: Nat::from(1_u8), sha256: None, }) .unwrap_err(), @@ -1005,7 +1005,7 @@ fn get_and_get_chunk_for_multichunk_assets() { .get_chunk(GetChunkArg { key: "/index.html".to_string(), content_encoding: "identity".to_string(), - index: Nat::from(1), + index: Nat::from(1_u8), sha256: chunk_0.sha256, }) .unwrap(); @@ -1017,7 +1017,7 @@ fn get_and_get_chunk_for_multichunk_assets() { .get_chunk(GetChunkArg { key: "/index.html".to_string(), content_encoding: "identity".to_string(), - index: Nat::from(1), + index: Nat::from(1_u8), sha256: None, }) .unwrap_err(), @@ -3347,7 +3347,7 @@ mod validate_commit_proposed_batch { let time_now = 100_000_000_000; match state.validate_commit_proposed_batch(CommitProposedBatchArguments { - batch_id: 1.into(), + batch_id: 1_u8.into(), evidence: Default::default(), }) { Err(err) if err.contains("batch not found") => (), @@ -3356,7 +3356,7 @@ mod validate_commit_proposed_batch { match state.commit_proposed_batch( CommitProposedBatchArguments { - batch_id: 1.into(), + batch_id: 1_u8.into(), evidence: Default::default(), }, time_now, diff --git a/src/canisters/frontend/ic-frontend-canister/Cargo.toml b/src/canisters/frontend/ic-frontend-canister/Cargo.toml index 5947ab793d..cc1119adac 100644 --- a/src/canisters/frontend/ic-frontend-canister/Cargo.toml +++ b/src/canisters/frontend/ic-frontend-canister/Cargo.toml @@ -16,3 +16,4 @@ crate-type = ["cdylib"] [dependencies] ic-certified-assets = { path = "../ic-certified-assets" } ic-cdk.workspace = true +candid.workspace = true diff --git a/src/dfx-core/Cargo.toml b/src/dfx-core/Cargo.toml index f1b9fef3f3..2f7a12daff 100644 --- a/src/dfx-core/Cargo.toml +++ b/src/dfx-core/Cargo.toml @@ -13,10 +13,11 @@ argon2.workspace = true bip32 = "0.4.0" byte-unit = { workspace = true, features = ["serde"] } bytes.workspace = true -candid = { workspace = true, features = ["random"] } +candid = { workspace = true } 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"] } hex = { workspace = true, features = ["serde"] } humantime-serde = "1.1.1" diff --git a/src/dfx-core/src/canister/mod.rs b/src/dfx-core/src/canister/mod.rs index 032f578915..9ef051589a 100644 --- a/src/dfx-core/src/canister/mod.rs +++ b/src/dfx-core/src/canister/mod.rs @@ -6,7 +6,6 @@ use crate::{ use candid::Principal; use ic_agent::Agent; use ic_utils::{ - call::AsyncCall, interfaces::{ management_canister::builders::{CanisterInstall, InstallMode}, ManagementCanister, WalletCanister, @@ -58,7 +57,7 @@ YOU WILL LOSE ALL DATA IN THE CANISTER. let mode_str = match mode { InstallMode::Install => "Installing", InstallMode::Reinstall => "Reinstalling", - InstallMode::Upgrade => "Upgrading", + InstallMode::Upgrade { .. } => "Upgrading", }; if let Some(name) = canister_name { info!( @@ -71,12 +70,10 @@ YOU WILL LOSE ALL DATA IN THE CANISTER. match call_sender { CallSender::SelectedId => { let install_builder = mgr - .install_code(&canister_id, &wasm_module) + .install(&canister_id, &wasm_module) .with_raw_arg(args.to_vec()) .with_mode(mode); install_builder - .build() - .map_err(CanisterBuilderError::CallSenderBuildError)? .call_and_wait() .await .map_err(CanisterInstallError::InstallWasmError) diff --git a/src/dfx-core/src/config/model/canister_id_store.rs b/src/dfx-core/src/config/model/canister_id_store.rs index 76485bef5a..68693ac0f1 100644 --- a/src/dfx-core/src/config/model/canister_id_store.rs +++ b/src/dfx-core/src/config/model/canister_id_store.rs @@ -23,11 +23,14 @@ pub type CanisterIds = BTreeMap; pub type CanisterTimestamps = BTreeMap; +// OffsetDateTime has nanosecond precision, while SystemTime is OS-dependent (100ns on Windows) +pub type AcquisitionDateTime = OffsetDateTime; + #[derive(Debug, Clone, Default)] -pub struct NetworkNametoCanisterTimestamp(BTreeMap); +pub struct NetworkNametoCanisterTimestamp(BTreeMap); impl Deref for NetworkNametoCanisterTimestamp { - type Target = BTreeMap; + type Target = BTreeMap; fn deref(&self) -> &Self::Target { &self.0 @@ -48,7 +51,7 @@ impl Serialize for NetworkNametoCanisterTimestamp { let out = self.0.iter().map(|(key, time)| { ( key, - OffsetDateTime::from(*time) + AcquisitionDateTime::from(*time) .format(&Rfc3339) .expect("Failed to serialise timestamp"), ) @@ -63,12 +66,12 @@ impl<'de> Deserialize<'de> for NetworkNametoCanisterTimestamp { D: serde::Deserializer<'de>, { let map: BTreeMap = Deserialize::deserialize(deserializer)?; - let btree: BTreeMap = map + let btree: BTreeMap = map .into_iter() - .map(|(key, timestamp)| (key, OffsetDateTime::parse(×tamp, &Rfc3339))) + .map(|(key, timestamp)| (key, AcquisitionDateTime::parse(×tamp, &Rfc3339))) .try_fold(BTreeMap::new(), |mut map, (key, result)| match result { Ok(value) => { - map.insert(key, SystemTime::from(value)); + map.insert(key, value); Ok(map) } Err(err) => Err(err), @@ -178,7 +181,7 @@ impl CanisterIdStore { Ok(store) } - pub fn get_timestamp(&self, canister_name: &str) -> Option<&SystemTime> { + pub fn get_timestamp(&self, canister_name: &str) -> Option<&AcquisitionDateTime> { self.acquisition_timestamps .get(canister_name) .and_then(|timestamp_map| timestamp_map.get(&self.network_descriptor.name)) @@ -277,7 +280,7 @@ impl CanisterIdStore { &mut self, canister_name: &str, canister_id: &str, - timestamp: Option, + timestamp: Option, ) -> Result<(), CanisterIdStoreError> { let network_name = &self.network_descriptor.name; match self.ids.get_mut(canister_name) { 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-core/src/fs/mod.rs b/src/dfx-core/src/fs/mod.rs index 83eb3d412c..adddaf3d49 100644 --- a/src/dfx-core/src/fs/mod.rs +++ b/src/dfx-core/src/fs/mod.rs @@ -11,7 +11,7 @@ use std::fs::{Metadata, Permissions, ReadDir}; use std::path::{Path, PathBuf}; pub fn canonicalize(path: &Path) -> Result { - path.canonicalize() + dunce::canonicalize(path) .map_err(|err| FsError::new(CanonicalizePathFailed(path.to_path_buf(), err))) } diff --git a/src/dfx-core/src/identity/pem_safekeeping.rs b/src/dfx-core/src/identity/pem_safekeeping.rs index ca520114a5..baa5f10b59 100644 --- a/src/dfx-core/src/identity/pem_safekeeping.rs +++ b/src/dfx-core/src/identity/pem_safekeeping.rs @@ -20,7 +20,7 @@ use crate::error::identity::write_pem_to_file::WritePemToFileError::{ use crate::identity::identity_file_locations::IdentityFileLocations; use crate::identity::keyring_mock; use crate::identity::pem_safekeeping::PromptMode::{DecryptingToUse, EncryptingToCreate}; -use aes_gcm::aead::{Aead, NewAead}; +use aes_gcm::aead::{Aead, KeyInit}; use aes_gcm::{Aes256Gcm, Key, Nonce}; use argon2::{password_hash::PasswordHasher, Argon2}; use slog::{debug, trace, Logger}; @@ -201,7 +201,7 @@ fn encrypt( let hash = argon2 .hash_password(password.as_bytes(), &config.pw_salt) .map_err(EncryptionError::HashPasswordFailed)?; - let key = Key::clone_from_slice(hash.hash.unwrap().as_ref()); + let key = Key::::clone_from_slice(hash.hash.unwrap().as_ref()); let cipher = Aes256Gcm::new(&key); let nonce = Nonce::from_slice(config.file_nonce.as_slice()); @@ -225,7 +225,7 @@ fn decrypt( let hash = argon2 .hash_password(password.as_bytes(), &config.pw_salt) .map_err(HashPasswordFailed)?; - let key = Key::clone_from_slice(hash.hash.unwrap().as_ref()); + let key = Key::::clone_from_slice(hash.hash.unwrap().as_ref()); let cipher = Aes256Gcm::new(&key); let nonce = Nonce::from_slice(config.file_nonce.as_slice()); diff --git a/src/dfx/Cargo.toml b/src/dfx/Cargo.toml index 9626792d0d..5927305ff4 100644 --- a/src/dfx/Cargo.toml +++ b/src/dfx/Cargo.toml @@ -34,12 +34,12 @@ anstyle.workspace = true anyhow.workspace = true apply-patch.path = "../lib/apply-patch" argon2.workspace = true -atty = "0.2.13" backoff.workspace = true base64.workspace = true byte-unit = { workspace = true, features = ["serde"] } bytes.workspace = true -candid = { workspace = true, features = ["random"] } +candid = { workspace = true } +candid_parser = { workspace = true, features = ["random"] } clap = { workspace = true, features = [ "derive", "env", @@ -66,8 +66,8 @@ ic-asset.workspace = true ic-cdk.workspace = true ic-identity-hsm = { workspace = true } ic-utils = { workspace = true } -ic-wasm = "0.4.0" -icrc-ledger-types = "0.1.1" +ic-wasm = "0.7.0" +icrc-ledger-types = "0.1.5" indicatif = "0.16.0" itertools.workspace = true json-patch = "1.0.0" @@ -104,7 +104,7 @@ shell-words = "1.1.0" slog = { workspace = true, features = ["max_level_trace"] } slog-async.workspace = true slog-term.workspace = true -supports-color = "1.3.0" +supports-color = "2.1.0" sysinfo = "0.28.4" tar.workspace = true tempfile.workspace = true diff --git a/src/dfx/assets/dfx-asset-sources.toml b/src/dfx/assets/dfx-asset-sources.toml index 607a569c23..2e3047e0c2 100644 --- a/src/dfx/assets/dfx-asset-sources.toml +++ b/src/dfx/assets/dfx-asset-sources.toml @@ -1,54 +1,54 @@ # generated by write-dfx-asset-sources.sh -replica-rev = '69e1408347723dbaa7a6cd2faa9b65c42abbe861' +replica-rev = '072b2a6586c409efa88f2244d658307ff3a645d8' [x86_64-darwin.icx-proxy] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/icx-proxy-dev.gz' -sha256 = 'b07f2784abddcb54f0b0d3ce7585b9283cf814870905d58c26a1c8823ead2fdd' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/icx-proxy-dev.gz' +sha256 = '404b248af6dcf1dcf412122976ac4d77ad0d85c71ab7907a16286e7f0cb72d3f' [x86_64-darwin.ic-admin] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/ic-admin.gz' -sha256 = '4b3f8fbc719a16bef00b14e5ae498253736d931f0fcacb52413f2c9859f52197' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/ic-admin.gz' +sha256 = '03ff9f57aa315270414b8bc4bb0a85db9e0724978c3c41022a368af40a3ca320' [x86_64-darwin.ic-btc-adapter] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/ic-btc-adapter.gz' -sha256 = '3ced0067cc322197af9ba7ee175e7e95eaefa00551690490494884f8f391e978' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/ic-btc-adapter.gz' +sha256 = '81038afad612d0e37cf7779b275d9b4cc066b76c1fe4c91ccc4fd9fbd68145f6' [x86_64-darwin.ic-https-outcalls-adapter] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/ic-https-outcalls-adapter.gz' -sha256 = 'feeb5a08899b4c4c55cd7838928bb75a5845988ecc757ee1059e709e4adfd192' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/ic-https-outcalls-adapter.gz' +sha256 = '249563c669e259aadd0c1a134cb31e8379019a14e9eadd16f9f86104c2752c05' [x86_64-darwin.ic-nns-init] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/ic-nns-init.gz' -sha256 = '85fd0e91e0a4ebe0272ad0491fd603bf6d313d2293a4266892bff397a26ea930' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/ic-nns-init.gz' +sha256 = '1e78f05b0c5d97b4c4a2a7d22a855e454b59dedc33db1f7ec804c833ba2951a4' [x86_64-darwin.ic-starter] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/ic-starter.gz' -sha256 = '1f33354049b6c83c8be06344d913a8bcfdb61ba9234706a8bf3cdb3d620723ab' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/ic-starter.gz' +sha256 = '86834a7df0c14182c0ce7fc4553cd44c514434bc72317a63917cc11ba6f32914' [x86_64-darwin.motoko] -url = 'https://github.com/dfinity/motoko/releases/download/0.10.3/motoko-Darwin-x86_64-0.10.3.tar.gz' -sha256 = '5cb8bd33beeec5f2dea8348e673f3fd535718ff995729ae5fc82e0ed06884873' +url = 'https://github.com/dfinity/motoko/releases/download/0.10.4/motoko-Darwin-x86_64-0.10.4.tar.gz' +sha256 = '21cb1e976d4970c64e5335bba74cb76a5b056811b9a6460d1bf9432229026757' # The replica and canister_sandbox binaries must have the same revision. [x86_64-darwin.replica] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/replica.gz' -sha256 = 'f320fec5733182e1ceb0dd03d19dc5bec01a1bf7763eb282e3fe14b1e1a6e18b' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/replica.gz' +sha256 = '8688aa4c79ff0a5ad28095d803cb127c9dd70c7a35cf3de44b1243c6e96be1fc' # The replica and canister_sandbox binaries must have the same revision. [x86_64-darwin.canister_sandbox] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/canister_sandbox.gz' -sha256 = '4acdd46cf9b1e5be987f6ce72d0118bf9039162e3ff80cd32056da136f753011' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/canister_sandbox.gz' +sha256 = '79804cb8c392723432abafe652b8bae6257d0565508d457203f73b36749fde2c' [x86_64-darwin.sandbox_launcher] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/sandbox_launcher.gz' -sha256 = 'ed0bc2eeaf282012c8475ddf1ca3369488dc80d385e5b194d2823ae84514ff8a' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/sandbox_launcher.gz' +sha256 = '371487252c0ceaa3bb8eaa9c3dd5d58b90fd78c213f01c083c508e3bd0027bdf' [x86_64-darwin.sns] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/sns.gz' -sha256 = '04d06a093913ef59d9d4c7cdc14a0751cff6465384d60204e03d5f396edfb38b' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-darwin/sns.gz' +sha256 = 'ac475585362a41de41e73169333992495761b28d9b4839f861f6afc4e0ec7b3f' [x86_64-darwin.motoko-base] -url = 'https://github.com/dfinity/motoko/releases/download/0.10.3/motoko-base-library.tar.gz' +url = 'https://github.com/dfinity/motoko/releases/download/0.10.4/motoko-base-library.tar.gz' sha256 = '3ee345fb0357ee9305e911d8aa30a00675114c3247af79bb16b8c21f8477dc3c' [x86_64-darwin.ic-btc-canister] @@ -56,53 +56,53 @@ url = 'https://github.com/dfinity/bitcoin-canister/releases/download/release%2F2 sha256 = '09f5647a45ff6d5d05b2b0ed48613fb2365b5fe6573ba0e901509c39fb9564ac' [x86_64-linux.icx-proxy] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/icx-proxy-dev.gz' -sha256 = '2bff6952a65e2d94f49ffa5ce03bfbd0eef0fb6ca82a839844c84fd3efa8b280' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/icx-proxy-dev.gz' +sha256 = '91318ea4c85827681fe691355c1948fa31184d999b41e96cb1ffc38463258317' [x86_64-linux.ic-admin] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/ic-admin.gz' -sha256 = 'ee6a6d75549bbe355ec4930dd1f6fc1948f973666823d47943adaa2c2bf11902' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/ic-admin.gz' +sha256 = '164f54c98c60bbfb3124f9bac6360278d21539ac05284c17b439a1159f7862f5' [x86_64-linux.ic-btc-adapter] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/ic-btc-adapter.gz' -sha256 = 'd31b5adbf91ba4efa910c80d971c08d591dada6b369119f2b1d444d1e58134ea' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/ic-btc-adapter.gz' +sha256 = '0748bfc4942c3b67f657a40d6b80681373fc398272eeb1134b32803605525ed0' [x86_64-linux.ic-https-outcalls-adapter] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/ic-https-outcalls-adapter.gz' -sha256 = '276faf4aa298c72709076338671fa356a50133ad7996a75748f0a1eabffbfd61' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/ic-https-outcalls-adapter.gz' +sha256 = '65ee3501fa0e6f4b4db216f34bca1b0c33753c877e3ef8f01797972248fcbff8' [x86_64-linux.ic-nns-init] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/ic-nns-init.gz' -sha256 = 'd58e8efdb8bcd64572bb8dd21a5e9cdb779c06a2c56f3be8ebe7e5709a516897' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/ic-nns-init.gz' +sha256 = 'b00ab9d14d9b0881f00c67f3ef380221cbaccc8f2e71772da52a60c355be2195' [x86_64-linux.ic-starter] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/ic-starter.gz' -sha256 = '8d8c51033cb2cd20049ca4e048144b895684d7a4fdbd07719476797b53ebafb5' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/ic-starter.gz' +sha256 = 'e65c4cf3fa443ab7cefbf62c871e038852f89e0532642751c305c40532c08261' [x86_64-linux.motoko] -url = 'https://github.com/dfinity/motoko/releases/download/0.10.3/motoko-Linux-x86_64-0.10.3.tar.gz' -sha256 = 'f8e8057c7b253b640d93e09a5810566f4582bcbf3f52aa134691e344f8fc29c0' +url = 'https://github.com/dfinity/motoko/releases/download/0.10.4/motoko-Linux-x86_64-0.10.4.tar.gz' +sha256 = '48beb994fe4fc1630e83cc98979e0f77130b23bb909ecf7a1b108140d6088856' # The replica and canister_sandbox binaries must have the same revision. [x86_64-linux.replica] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/replica.gz' -sha256 = '2cd30cca1818b86785b3d9b808612b7c286252363806c70d196c2fcfa48d1188' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/replica.gz' +sha256 = '3dc274201a2e932b2e170cf364799b598eaed7c63df676c72b1e0cfef1beafcc' # The replica and canister_sandbox binaries must have the same revision. [x86_64-linux.canister_sandbox] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/canister_sandbox.gz' -sha256 = '11849a543a162f0f25b3dc10f17c177ea054e4fdb8a8c86509c7f87988ce2913' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/canister_sandbox.gz' +sha256 = 'c6752d7077a5b76a1a9aad00ad56c8f53dd8737d41f2b3cf2d5f8164368a401a' [x86_64-linux.sandbox_launcher] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/sandbox_launcher.gz' -sha256 = '96c416bf98724aa3bf72053d06d559f007f8655261b48f435f9104b605c8f77f' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/sandbox_launcher.gz' +sha256 = '25f575452f68b837c27fe3cda906eb3f966c10c29c95dac8220aaa2e168b0ca9' [x86_64-linux.sns] -url = 'https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/sns.gz' -sha256 = '966a84f1e563049e09381b39cbcde24b0c77032ee2cfddb40962eecb70925809' +url = 'https://download.dfinity.systems/ic/072b2a6586c409efa88f2244d658307ff3a645d8/binaries/x86_64-linux/sns.gz' +sha256 = 'ce6f04bae10483bd0e0365f50a65816eb641024b3cc341e7996aaf2ffa8df3de' [x86_64-linux.motoko-base] -url = 'https://github.com/dfinity/motoko/releases/download/0.10.3/motoko-base-library.tar.gz' +url = 'https://github.com/dfinity/motoko/releases/download/0.10.4/motoko-base-library.tar.gz' sha256 = '3ee345fb0357ee9305e911d8aa30a00675114c3247af79bb16b8c21f8477dc3c' [x86_64-linux.ic-btc-canister] diff --git a/src/dfx/assets/new_project_rust_files/src/__project_name___backend/Cargo.toml b/src/dfx/assets/new_project_rust_files/src/__project_name___backend/Cargo.toml index d0ce206213..6118f8f08e 100644 --- a/src/dfx/assets/new_project_rust_files/src/__project_name___backend/Cargo.toml +++ b/src/dfx/assets/new_project_rust_files/src/__project_name___backend/Cargo.toml @@ -9,6 +9,6 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -candid = "0.8" -ic-cdk = "0.7" -ic-cdk-timers = "0.1" # Feel free to remove this dependency if you don't need timers +candid = "0.10" +ic-cdk = "0.12" +ic-cdk-timers = "0.6" # Feel free to remove this dependency if you don't need timers 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/call.rs b/src/dfx/src/commands/canister/call.rs index eb034120f6..cda115a398 100644 --- a/src/dfx/src/commands/canister/call.rs +++ b/src/dfx/src/commands/canister/call.rs @@ -183,7 +183,10 @@ pub fn get_effective_canister_id( | MgmtMethod::DeleteCanister | MgmtMethod::DepositCycles | MgmtMethod::UninstallCode - | MgmtMethod::ProvisionalTopUpCanister => { + | MgmtMethod::ProvisionalTopUpCanister + | MgmtMethod::UploadChunk + | MgmtMethod::ClearChunkStore + | MgmtMethod::StoredChunks => { #[derive(CandidType, Deserialize)] struct In { canister_id: CanisterId, @@ -195,6 +198,15 @@ pub fn get_effective_canister_id( MgmtMethod::ProvisionalCreateCanisterWithCycles => { Ok(CanisterId::management_canister()) } + MgmtMethod::InstallChunkedCode => { + #[derive(CandidType, Deserialize)] + struct In { + target_canister: Principal, + } + let in_args = Decode!(arg_value, In) + .context("Argument is not valid for InstallChunkedCode")?; + Ok(in_args.target_canister) + } } } else { Ok(canister_id) diff --git a/src/dfx/src/commands/canister/delete.rs b/src/dfx/src/commands/canister/delete.rs index cb29aff404..3cd04a9faa 100644 --- a/src/dfx/src/commands/canister/delete.rs +++ b/src/dfx/src/commands/canister/delete.rs @@ -7,10 +7,14 @@ use crate::lib::operations::canister; use crate::lib::operations::canister::{ deposit_cycles, start_canister, stop_canister, update_settings, }; +use crate::lib::operations::cycles_ledger::{ + wallet_deposit_to_cycles_ledger, CYCLES_LEDGER_ENABLED, +}; use crate::lib::root_key::fetch_root_key_if_needed; use crate::util::assets::wallet_wasm; use crate::util::blob_from_arguments; -use anyhow::Context; +use crate::util::clap::parsers::icrc_subaccount_parser; +use anyhow::{bail, Context}; use candid::Principal; use clap::Parser; use dfx_core::canister::build_wallet_canister; @@ -23,6 +27,7 @@ use ic_utils::interfaces::management_canister::builders::InstallMode; use ic_utils::interfaces::management_canister::CanisterStatus; use ic_utils::interfaces::ManagementCanister; use ic_utils::Argument; +use icrc_ledger_types::icrc1::account::{Account, Subaccount}; use num_traits::cast::ToPrimitive; use slog::info; use std::convert::TryFrom; @@ -71,6 +76,11 @@ pub struct CanisterDeleteOpts { /// Auto-confirm deletion for a non-stopped canister. #[arg(long, short)] yes: bool, + + /// Subaccount of the selected identity to deposit cycles to. + //TODO(SDK-1331): unhide + #[arg(long, value_parser = icrc_subaccount_parser, hide = true)] + to_subaccount: Option, } #[context("Failed to delete canister '{}'.", canister)] @@ -83,6 +93,7 @@ async fn delete_canister( withdraw_cycles_to_canister: Option, withdraw_cycles_to_dank: bool, withdraw_cycles_to_dank_principal: Option, + to_cycles_ledger_subaccount: Option, ) -> DfxResult { let log = env.get_logger(); let mut canister_id_store = env.get_canister_id_store()?; @@ -99,19 +110,23 @@ async fn delete_canister( let to_dank = withdraw_cycles_to_dank || withdraw_cycles_to_dank_principal.is_some(); // Get the canister to transfer the cycles to. - let target_canister_id = if no_withdrawal { - None + let withdraw_target = if no_withdrawal { + WithdrawTarget::NoWithdrawal } else if to_dank { - Some(DANK_PRINCIPAL) + WithdrawTarget::Dank } else { match withdraw_cycles_to_canister { Some(ref target_canister_id) => { - Some(Principal::from_text(target_canister_id).with_context(|| { - format!("Failed to read canister id {:?}.", target_canister_id) - })?) + let canister_id = + Principal::from_text(target_canister_id).with_context(|| { + format!("Failed to read canister id {:?}.", target_canister_id) + })?; + WithdrawTarget::Canister { canister_id } } None => match call_sender { - CallSender::Wallet(wallet_id) => Some(*wallet_id), + CallSender::Wallet(wallet_id) => WithdrawTarget::Canister { + canister_id: *wallet_id, + }, CallSender::SelectedId => { let network = env.get_network_descriptor(); let agent_env = create_agent_environment(env, Some(network.name.clone()))?; @@ -120,7 +135,22 @@ async fn delete_canister( .expect("No selected identity.") .to_string(); // If there is no wallet, then do not attempt to withdraw the cycles. - wallet_canister_id(network, &identity_name)? + 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") + }; + WithdrawTarget::CyclesLedger { + to: Account { + owner: my_principal, + subaccount: to_cycles_ledger_subaccount, + }, + } + } + _ => WithdrawTarget::NoWithdrawal, + } } }, } @@ -135,11 +165,10 @@ async fn delete_canister( }; fetch_root_key_if_needed(env).await?; - if let Some(target_canister_id) = target_canister_id { + if withdraw_target != WithdrawTarget::NoWithdrawal { info!( log, - "Beginning withdrawal of cycles to canister {}; on failure try --no-wallet --no-withdrawal.", - target_canister_id + "Beginning withdrawal of cycles; on failure try --no-wallet --no-withdrawal." ); // Determine how many cycles we can withdraw. @@ -197,40 +226,55 @@ async fn delete_canister( break; } let cycles_to_withdraw = cycles - margin; - let result = if !to_dank { - info!( - log, - "Attempting to transfer {} cycles to canister {}.", - cycles_to_withdraw, - target_canister_id - ); - // Transfer cycles from the source canister to the target canister using the temporary wallet. - deposit_cycles( - env, - target_canister_id, - &CallSender::Wallet(canister_id), - cycles_to_withdraw, - ) - .await - } else { - info!( - log, - "Attempting to transfer {} cycles to dank principal {}.", - cycles_to_withdraw, - dank_target_principal - ); - let wallet = build_wallet_canister(canister_id, agent).await?; - let opt_principal = Some(dank_target_principal); - wallet - .call( + let result = match withdraw_target { + WithdrawTarget::NoWithdrawal => Ok(()), + WithdrawTarget::Dank => { + info!( + log, + "Attempting to transfer {} cycles to dank principal {}.", + cycles_to_withdraw, + dank_target_principal + ); + let wallet = build_wallet_canister(canister_id, agent).await?; + let opt_principal = Some(dank_target_principal); + wallet + .call( + DANK_PRINCIPAL, + "mint", + Argument::from_candid((opt_principal,)), + cycles_to_withdraw, + ) + .call_and_wait() + .await + .context("Failed mint call.") + } + WithdrawTarget::Canister { + canister_id: target_canister_id, + } => { + info!( + log, + "Attempting to transfer {} cycles to canister {}.", + cycles_to_withdraw, + target_canister_id + ); + // Transfer cycles from the source canister to the target canister using the temporary wallet. + deposit_cycles( + env, target_canister_id, - "mint", - Argument::from_candid((opt_principal,)), + &CallSender::Wallet(canister_id), cycles_to_withdraw, ) - .call_and_wait() .await - .context("Failed mint call.") + } + WithdrawTarget::CyclesLedger { to } => { + wallet_deposit_to_cycles_ledger( + agent, + canister_id, + cycles_to_withdraw, + to, + ) + .await + } }; if result.is_ok() { info!(log, "Successfully withdrew {} cycles.", cycles_to_withdraw); @@ -239,7 +283,7 @@ async fn delete_canister( info!(log, "Not enough margin. Trying again with more margin."); attempts += 1; } else { - // Unforseen error. Report it back to user + // Unforeseen error. Report it back to user result?; } } @@ -293,6 +337,7 @@ pub async fn exec( opts.withdraw_cycles_to_canister, opts.withdraw_cycles_to_dank, opts.withdraw_cycles_to_dank_principal, + opts.to_subaccount, ) .await } else if opts.all { @@ -307,6 +352,7 @@ pub async fn exec( opts.withdraw_cycles_to_canister.clone(), opts.withdraw_cycles_to_dank, opts.withdraw_cycles_to_dank_principal.clone(), + opts.to_subaccount, ) .await?; } @@ -316,3 +362,11 @@ pub async fn exec( unreachable!() } } + +#[derive(Debug, Clone, Copy, Eq, PartialEq)] +enum WithdrawTarget { + NoWithdrawal, + Dank, + CyclesLedger { to: Account }, + Canister { canister_id: Principal }, +} diff --git a/src/dfx/src/commands/deps/init.rs b/src/dfx/src/commands/deps/init.rs index 0de294a203..05e0b81172 100644 --- a/src/dfx/src/commands/deps/init.rs +++ b/src/dfx/src/commands/deps/init.rs @@ -7,8 +7,8 @@ use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::util::{check_candid_file, fuzzy_parse_argument}; use anyhow::{anyhow, bail}; -use candid::parser::types::IDLTypes; use candid::Principal; +use candid_parser::{types::IDLTypes, typing::ast_to_type}; use clap::Parser; use slog::{info, warn, Logger}; @@ -73,7 +73,7 @@ fn set_init( let candid_args_idl_types: IDLTypes = candid_args.parse()?; let mut types = vec![]; for ty in candid_args_idl_types.args.iter() { - types.push(env.ast_to_type(ty)?); + types.push(ast_to_type(&env, ty)?); } let arguments = opts.argument.as_deref(); 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/language_service.rs b/src/dfx/src/commands/language_service.rs index ed927f5040..fe25382a55 100644 --- a/src/dfx/src/commands/language_service.rs +++ b/src/dfx/src/commands/language_service.rs @@ -12,6 +12,7 @@ use dfx_core::config::model::dfinity::{ }; use dfx_core::network::provider::{create_network_descriptor, LocalBindDetermination}; use fn_error_context::context; +use std::io::{stdout, IsTerminal}; use std::path::PathBuf; use std::process::Stdio; @@ -36,7 +37,7 @@ pub struct LanguageServiceOpts { pub fn exec(env: &dyn Environment, opts: LanguageServiceOpts) -> DfxResult { let force_tty = opts.force_tty; // Are we being run from a terminal? That's most likely not what we want - if atty::is(atty::Stream::Stdout) && !force_tty { + if stdout().is_terminal() && !force_tty { Err(anyhow!("The `_language-service` command is meant to be run by editors to start a language service. You probably don't want to run it from a terminal.\nIf you _really_ want to, you can pass the --force-tty flag.")) } else if let Some(config) = env.get_config() { let main_path = get_main_path(config.get_config(), opts.canister)?; diff --git a/src/dfx/src/commands/new.rs b/src/dfx/src/commands/new.rs index 99f205b162..708adff9b6 100644 --- a/src/dfx/src/commands/new.rs +++ b/src/dfx/src/commands/new.rs @@ -2,6 +2,7 @@ use crate::config::cache::DiskBasedCache; use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::manifest::{get_latest_version, is_upgrade_necessary}; +use crate::lib::program; use crate::util::assets; use crate::util::clap::parsers::project_name_parser; use anyhow::{anyhow, bail, ensure, Context}; @@ -249,12 +250,12 @@ fn write_files_from_entries( #[context("Failed to run 'npm install'.")] fn npm_install(location: &Path) -> DfxResult { - std::process::Command::new("npm") + Command::new(program::NPM) .arg("install") .arg("--quiet") .arg("--no-progress") - .stdout(std::process::Stdio::inherit()) - .stderr(std::process::Stdio::inherit()) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) .current_dir(location) .spawn() .map_err(DfxError::from) @@ -271,7 +272,7 @@ fn scaffold_frontend_code( variables: &BTreeMap, ) -> DfxResult { let log = env.get_logger(); - let node_installed = std::process::Command::new("node") + let node_installed = Command::new(program::NODE) .arg("--version") .output() .is_ok(); @@ -383,12 +384,12 @@ fn scaffold_frontend_code( } fn get_agent_js_version_from_npm(dist_tag: &str) -> DfxResult { - std::process::Command::new("npm") + Command::new(program::NPM) .arg("show") .arg("@dfinity/agent") .arg(&format!("dist-tags.{}", dist_tag)) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::inherit()) + .stdout(Stdio::piped()) + .stderr(Stdio::inherit()) .spawn() .map_err(DfxError::from) .and_then(|child| { diff --git a/src/dfx/src/commands/remote/generate_binding.rs b/src/dfx/src/commands/remote/generate_binding.rs index 6cc835c9a7..947b5b852a 100644 --- a/src/dfx/src/commands/remote/generate_binding.rs +++ b/src/dfx/src/commands/remote/generate_binding.rs @@ -73,16 +73,22 @@ pub fn exec(env: &dyn Environment, opts: GenerateBindingOpts) -> DfxResult { let (type_env, did_types) = check_candid_file(&candid)?; let extension = main.extension().unwrap_or_default(); let bindings = if extension == "mo" { - Some(candid::bindings::motoko::compile(&type_env, &did_types)) + Some(candid_parser::bindings::motoko::compile( + &type_env, &did_types, + )) } else if extension == "rs" { - let config = candid::bindings::rust::Config::new(); - Some(candid::bindings::rust::compile( + let config = candid_parser::bindings::rust::Config::new(); + Some(candid_parser::bindings::rust::compile( &config, &type_env, &did_types, )) } else if extension == "js" { - Some(candid::bindings::javascript::compile(&type_env, &did_types)) + Some(candid_parser::bindings::javascript::compile( + &type_env, &did_types, + )) } else if extension == "ts" { - Some(candid::bindings::typescript::compile(&type_env, &did_types)) + Some(candid_parser::bindings::typescript::compile( + &type_env, &did_types, + )) } else { info!( log, 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/commands/wallet/upgrade.rs b/src/dfx/src/commands/wallet/upgrade.rs index a0d36b3076..229738cd8a 100644 --- a/src/dfx/src/commands/wallet/upgrade.rs +++ b/src/dfx/src/commands/wallet/upgrade.rs @@ -43,7 +43,15 @@ pub async fn exec(env: &dyn Environment, _opts: UpgradeOpts) -> DfxResult { let agent = env.get_agent(); - install_wallet(env, agent, canister_id, InstallMode::Upgrade).await?; + install_wallet( + env, + agent, + canister_id, + InstallMode::Upgrade { + skip_pre_upgrade: false, + }, + ) + .await?; println!("Upgraded the wallet wasm module."); Ok(()) diff --git a/src/dfx/src/config/cache.rs b/src/dfx/src/config/cache.rs index 9ab80c47dd..401b8597ae 100644 --- a/src/dfx/src/config/cache.rs +++ b/src/dfx/src/config/cache.rs @@ -11,6 +11,7 @@ use indicatif::{ProgressBar, ProgressDrawTarget}; use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use semver::Version; +use std::io::{stderr, IsTerminal}; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; use std::path::PathBuf; @@ -77,7 +78,7 @@ pub fn install_version(v: &str, force: bool) -> Result { // expensive step, and if this fails we can't continue anyway. let current_exe = dfx_core::foundation::get_current_exe()?; - let b: Option = if atty::is(atty::Stream::Stderr) { + let b: Option = if stderr().is_terminal() { let b = ProgressBar::new_spinner(); b.set_draw_target(ProgressDrawTarget::stderr()); b.set_message(format!("Installing version {} of dfx...", v)); @@ -129,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 f6c6afe68f..eff29745ac 100644 --- a/src/dfx/src/lib/builders/assets.rs +++ b/src/dfx/src/lib/builders/assets.rs @@ -6,6 +6,7 @@ use crate::lib::canister_info::CanisterInfo; use crate::lib::environment::Environment; use crate::lib::error::{BuildError, DfxError, DfxResult}; use crate::lib::models::canister::CanisterPool; +use crate::lib::program; use crate::util; use anyhow::{anyhow, Context}; use candid::Principal as CanisterId; @@ -55,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.")] @@ -218,7 +221,7 @@ fn build_frontend( } else if build_frontend { // Frontend build. slog::info!(logger, "Building frontend..."); - let mut cmd = std::process::Command::new("npm"); + let mut cmd = std::process::Command::new(program::NPM); // Provide DFX_NETWORK at build time cmd.env("DFX_NETWORK", network_name); diff --git a/src/dfx/src/lib/builders/mod.rs b/src/dfx/src/lib/builders/mod.rs index 231192b513..59846b8a39 100644 --- a/src/dfx/src/lib/builders/mod.rs +++ b/src/dfx/src/lib/builders/mod.rs @@ -104,12 +104,13 @@ pub trait CanisterBuilder { .context("`output` must not be None")?; if generate_output_dir.exists() { - let generate_output_dir = generate_output_dir.canonicalize().with_context(|| { - format!( - "Failed to canonicalize output dir {}.", - generate_output_dir.to_string_lossy() - ) - })?; + let generate_output_dir = dfx_core::fs::canonicalize(generate_output_dir) + .with_context(|| { + format!( + "Failed to canonicalize output dir {}.", + generate_output_dir.to_string_lossy() + ) + })?; if !generate_output_dir.starts_with(info.get_workspace_root()) { bail!( "Directory at '{}' is outside the workspace root.", @@ -156,7 +157,8 @@ pub trait CanisterBuilder { let output_did_ts_path = generate_output_dir .join(info.get_name()) .with_extension("did.d.ts"); - let content = ensure_trailing_newline(candid::bindings::typescript::compile(&env, &ty)); + let content = + ensure_trailing_newline(candid_parser::bindings::typescript::compile(&env, &ty)); std::fs::write(&output_did_ts_path, content).with_context(|| { format!( "Failed to write to {}.", @@ -174,7 +176,8 @@ pub trait CanisterBuilder { let output_did_js_path = generate_output_dir .join(info.get_name()) .with_extension("did.js"); - let content = ensure_trailing_newline(candid::bindings::javascript::compile(&env, &ty)); + let content = + ensure_trailing_newline(candid_parser::bindings::javascript::compile(&env, &ty)); std::fs::write(&output_did_js_path, content).with_context(|| { format!( "Failed to write to {}.", @@ -191,7 +194,8 @@ pub trait CanisterBuilder { let output_mo_path = generate_output_dir .join(info.get_name()) .with_extension("mo"); - let content = ensure_trailing_newline(candid::bindings::motoko::compile(&env, &ty)); + let content = + ensure_trailing_newline(candid_parser::bindings::motoko::compile(&env, &ty)); std::fs::write(&output_mo_path, content).with_context(|| { format!("Failed to write to {}.", output_mo_path.to_string_lossy()) })?; @@ -321,12 +325,10 @@ fn ensure_trailing_newline(s: String) -> String { pub fn run_command(args: Vec, vars: &[Env<'_>], cwd: &Path) -> DfxResult<()> { let (command_name, arguments) = args.split_first().unwrap(); - let canonicalized = cwd - .join(command_name) - .canonicalize() + 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/canister_info/assets.rs b/src/dfx/src/lib/canister_info/assets.rs index bde5259d7f..e00e675cbf 100644 --- a/src/dfx/src/lib/canister_info/assets.rs +++ b/src/dfx/src/lib/canister_info/assets.rs @@ -34,7 +34,7 @@ impl AssetsCanisterInfo { let input_root = &self.input_root; let source_paths: Vec = source_paths.iter().map(|x| input_root.join(x)).collect(); for source_path in &source_paths { - let canonical = source_path.canonicalize().with_context(|| { + let canonical = dfx_core::fs::canonicalize(source_path).with_context(|| { format!( "Unable to determine canonical location of asset source path {}", source_path.to_string_lossy() 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/migrate.rs b/src/dfx/src/lib/migrate.rs index 16642be28a..a1bb2085a9 100644 --- a/src/dfx/src/lib/migrate.rs +++ b/src/dfx/src/lib/migrate.rs @@ -65,7 +65,15 @@ async fn migrate_wallet( if !wallet.version_supports_u128_cycles() { if fix { println!("Upgrading wallet... "); - install_wallet(env, agent, *wallet.canister_id_(), InstallMode::Upgrade).await? + install_wallet( + env, + agent, + *wallet.canister_id_(), + InstallMode::Upgrade { + skip_pre_upgrade: false, + }, + ) + .await? } else { println!("The wallet is outdated; run `dfx wallet upgrade`"); } diff --git a/src/dfx/src/lib/mod.rs b/src/dfx/src/lib/mod.rs index 2de6df22db..62d9502403 100644 --- a/src/dfx/src/lib/mod.rs +++ b/src/dfx/src/lib/mod.rs @@ -24,6 +24,7 @@ pub mod network; pub mod nns_types; pub mod operations; pub mod package_arguments; +pub mod program; pub mod progress_bar; pub mod project; pub mod replica; diff --git a/src/dfx/src/lib/models/canister.rs b/src/dfx/src/lib/models/canister.rs index 3903adf513..002445de10 100644 --- a/src/dfx/src/lib/models/canister.rs +++ b/src/dfx/src/lib/models/canister.rs @@ -12,9 +12,12 @@ use crate::util::{assets, check_candid_file}; use anyhow::{anyhow, bail, Context}; use candid::Principal as CanisterId; use dfx_core::config::model::canister_id_store::CanisterIdStore; -use dfx_core::config::model::dfinity::{CanisterMetadataSection, Config, MetadataVisibility}; +use dfx_core::config::model::dfinity::{ + CanisterMetadataSection, Config, MetadataVisibility, WasmOptLevel, +}; use fn_error_context::context; use ic_wasm::metadata::{add_metadata, remove_metadata, Kind}; +use ic_wasm::optimize::OptLevel; use itertools::Itertools; use petgraph::graph::{DiGraph, NodeIndex}; use rand::{thread_rng, RngCore}; @@ -38,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. @@ -128,8 +133,14 @@ impl Canister { // optimize or shrink if let Some(level) = info.get_optimize() { trace!(logger, "Optimizing WASM at level {}", level); - ic_wasm::shrink::shrink_with_wasm_opt(&mut m, &level.to_string(), false) - .context("Failed to optimize the WASM module.")?; + ic_wasm::optimize::optimize( + &mut m, + &wasm_opt_level_convert(level), + false, + &None, + false, + ) + .context("Failed to optimize the WASM module.")?; modified = true; } else if info.get_shrink() == Some(true) || (info.get_shrink().is_none() && (info.is_rust() || info.is_motoko())) @@ -311,15 +322,32 @@ impl Canister { } } +fn wasm_opt_level_convert(opt_level: WasmOptLevel) -> OptLevel { + use WasmOptLevel::*; + match opt_level { + O0 => OptLevel::O0, + O1 => OptLevel::O1, + O2 => OptLevel::O2, + O3 => OptLevel::O3, + O4 => OptLevel::O4, + Os => OptLevel::Os, + Oz => OptLevel::Oz, + Size => OptLevel::Oz, + Cycles => OptLevel::O3, + } +} + fn separate_candid(path: &Path) -> DfxResult<(String, String)> { let (env, actor) = check_candid_file(path)?; let actor = actor.ok_or_else(|| anyhow!("provided candid file contains no main service"))?; if let candid::types::internal::TypeInner::Class(args, ty) = actor.as_ref() { - use candid::bindings::candid::pp_ty; - use candid::pretty::{concat, enclose}; + use candid_parser::pretty::{ + candid::{compile, pp_ty}, + utils::{concat, enclose}, + }; let actor = Some(ty.clone()); - let service_did = candid::bindings::candid::compile(&env, &actor); + let service_did = compile(&env, &actor); let doc = concat(args.iter().map(pp_ty), ","); let init_args = enclose("(", doc, ")").pretty(80).to_string(); Ok((service_did, init_args)) @@ -785,14 +813,14 @@ fn build_canister_js(canister_id: &CanisterId, canister_info: &CanisterInfo) -> .with_extension("did.d.ts"); let (env, ty) = check_candid_file(&canister_info.get_service_idl_path())?; - let content = ensure_trailing_newline(candid::bindings::javascript::compile(&env, &ty)); + let content = ensure_trailing_newline(candid_parser::bindings::javascript::compile(&env, &ty)); std::fs::write(&output_did_js_path, content).with_context(|| { format!( "Failed to write to {}.", output_did_js_path.to_string_lossy() ) })?; - let content = ensure_trailing_newline(candid::bindings::typescript::compile(&env, &ty)); + let content = ensure_trailing_newline(candid_parser::bindings::typescript::compile(&env, &ty)); std::fs::write(&output_did_ts_path, content).with_context(|| { format!( "Failed to write to {}.", diff --git a/src/dfx/src/lib/operations/canister/install_canister.rs b/src/dfx/src/lib/operations/canister/install_canister.rs index 1bd13cd42b..03c30fba67 100644 --- a/src/dfx/src/lib/operations/canister/install_canister.rs +++ b/src/dfx/src/lib/operations/canister/install_canister.rs @@ -63,13 +63,15 @@ pub async fn install_canister( ); let mode = mode.unwrap_or_else(|| { if installed_module_hash.is_some() { - InstallMode::Upgrade + InstallMode::Upgrade { + skip_pre_upgrade: false, + } } else { InstallMode::Install } }); if let Some(canister_info) = canister_info { - if !skip_consent && matches!(mode, InstallMode::Reinstall | InstallMode::Upgrade) { + if !skip_consent && matches!(mode, InstallMode::Reinstall | InstallMode::Upgrade { .. }) { let candid = read_module_metadata(agent, canister_id, "candid:service").await; if let Some(candid) = &candid { match check_candid_compatibility(canister_info, candid) { @@ -85,7 +87,8 @@ pub async fn install_canister( } } } - if !skip_consent && canister_info.is_motoko() && matches!(mode, InstallMode::Upgrade) { + if !skip_consent && canister_info.is_motoko() && matches!(mode, InstallMode::Upgrade { .. }) + { let stable_types = read_module_metadata(agent, canister_id, "motoko:stable-types").await; if let Some(stable_types) = &stable_types { @@ -120,7 +123,7 @@ pub async fn install_canister( let new_hash = Sha256::digest(&wasm_module); debug!(log, "New wasm module hash: {}", hex::encode(new_hash)); - if mode == InstallMode::Upgrade + if matches!(mode, InstallMode::Upgrade { .. }) && matches!(&installed_module_hash, Some(old_hash) if old_hash[..] == new_hash[..]) && !upgrade_unchanged { @@ -414,12 +417,10 @@ fn run_post_install_task( let cwd = canister.get_workspace_root(); let words = shell_words::split(task) .with_context(|| format!("Error interpreting post-install task `{task}`"))?; - let canonicalized = cwd - .join(&words[0]) - .canonicalize() + 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/operations/canister/motoko_playground.rs b/src/dfx/src/lib/operations/canister/motoko_playground.rs index e9f4d33dd4..22dd90afe6 100644 --- a/src/dfx/src/lib/operations/canister/motoko_playground.rs +++ b/src/dfx/src/lib/operations/canister/motoko_playground.rs @@ -1,17 +1,16 @@ +use crate::lib::{environment::Environment, error::DfxResult}; +use anyhow::{bail, Context}; +use candid::{encode_args, CandidType, Decode, Deserialize, Encode, Principal}; +use dfx_core::config::model::canister_id_store::AcquisitionDateTime; use dfx_core::config::model::network_descriptor::{ NetworkTypeDescriptor, MAINNET_MOTOKO_PLAYGROUND_CANISTER_ID, }; -use num_traits::ToPrimitive; -use std::time::{Duration, SystemTime, UNIX_EPOCH}; - -use anyhow::{bail, Context}; -use candid::{encode_args, CandidType, Decode, Deserialize, Encode, Principal}; use fn_error_context::context; use ic_utils::interfaces::management_canister::builders::InstallMode; +use num_traits::ToPrimitive; use rand::Rng; use slog::{debug, info}; - -use crate::lib::{environment::Environment, error::DfxResult}; +use std::time::SystemTime; /// Arguments for the `getCanisterId` call. #[derive(CandidType)] @@ -28,19 +27,17 @@ pub struct CanisterInfo { } impl CanisterInfo { - #[context("Failed to construct playground canister info.")] - pub fn from(id: Principal, timestamp: &SystemTime) -> DfxResult { - let timestamp = candid::Int::from(timestamp.duration_since(UNIX_EPOCH)?.as_nanos()); - Ok(Self { id, timestamp }) + pub fn from(id: Principal, timestamp: &AcquisitionDateTime) -> Self { + let timestamp = candid::Int::from(timestamp.unix_timestamp_nanos()); + Self { id, timestamp } } - #[context("Failed to turn CanisterInfo into SystemTime")] - pub fn get_timestamp(&self) -> DfxResult { - UNIX_EPOCH - .checked_add(Duration::from_nanos( - self.timestamp.0.to_u64().context("u64 overflow")?, - )) - .context("Failed to make absolute time from offset") + #[context("Failed to get timestamp from CanisterInfo")] + pub fn get_timestamp(&self) -> DfxResult { + AcquisitionDateTime::from_unix_timestamp_nanos( + self.timestamp.0.to_i128().context("i128 overflow")?, + ) + .context("Failed to make unix timestamp from nanos") } } @@ -48,9 +45,36 @@ impl CanisterInfo { pub struct InstallArgs<'a> { pub arg: &'a [u8], pub wasm_module: &'a [u8], - pub mode: InstallMode, + pub mode: PlaygroundInstallMode, pub canister_id: Principal, } + +#[derive(CandidType, Deserialize, Debug)] +pub enum PlaygroundInstallMode { + #[serde(rename = "install")] + Install, + #[serde(rename = "upgrade")] + Upgrade, + #[serde(rename = "reinstall")] + Reinstall, +} + +impl TryFrom for PlaygroundInstallMode { + type Error = anyhow::Error; + fn try_from(m: InstallMode) -> DfxResult { + match m { + InstallMode::Install => Ok(Self::Install), + InstallMode::Reinstall => Ok(Self::Reinstall), + InstallMode::Upgrade { + skip_pre_upgrade: false, + } => Ok(Self::Upgrade), + InstallMode::Upgrade { + skip_pre_upgrade: true, + } => bail!("Cannot skip pre-upgrade on the playground"), + } + } +} + #[derive(CandidType)] struct InstallConfig<'a> { profiling: bool, @@ -122,7 +146,7 @@ pub async fn reserve_canister_with_playground( pub async fn authorize_asset_uploader( env: &dyn Environment, canister_id: Principal, - canister_timestamp: &SystemTime, + canister_timestamp: &AcquisitionDateTime, principal_to_authorize: &Principal, ) -> DfxResult { let agent = env.get_agent(); @@ -135,7 +159,7 @@ pub async fn authorize_asset_uploader( } else { bail!("Trying to authorize asset uploader on non-playground network.") }; - let canister_info = CanisterInfo::from(canister_id, canister_timestamp)?; + let canister_info = CanisterInfo::from(canister_id, canister_timestamp); let nested_arg = Encode!(&principal_to_authorize)?; let call_arg = Encode!(&canister_info, &"authorize", &nested_arg)?; @@ -152,13 +176,13 @@ pub async fn authorize_asset_uploader( pub async fn playground_install_code( env: &dyn Environment, canister_id: Principal, - canister_timestamp: &SystemTime, + canister_timestamp: &AcquisitionDateTime, arg: &[u8], wasm_module: &[u8], mode: InstallMode, is_asset_canister: bool, -) -> DfxResult { - let canister_info = CanisterInfo::from(canister_id, canister_timestamp)?; +) -> DfxResult { + let canister_info = CanisterInfo::from(canister_id, canister_timestamp); let agent = env.get_agent(); let playground_canister = match env.get_network_descriptor().r#type { NetworkTypeDescriptor::Playground { @@ -170,7 +194,7 @@ pub async fn playground_install_code( let install_arg = InstallArgs { arg, wasm_module, - mode, + mode: mode.try_into()?, canister_id: canister_info.id, }; let install_config = InstallConfig { @@ -196,7 +220,7 @@ fn create_nonce() -> (candid::Int, candid::Nat) { .as_nanos(); let timestamp = candid::Int::from(now); let mut rng = rand::thread_rng(); - let mut nonce = candid::Nat::from(rng.gen::()); + let mut nonce = candid::Nat::from(rng.gen::()); let prefix = format!("{}{}", POW_DOMAIN, timestamp); loop { let to_hash = format!("{}{}", prefix, nonce).replace('_', ""); @@ -204,7 +228,7 @@ fn create_nonce() -> (candid::Int, candid::Nat) { if (hash & 0xc0000000) == 0 { return (timestamp, nonce); } - nonce += 1; + nonce += 1_u8; } } diff --git a/src/dfx/src/lib/operations/cycles_ledger.rs b/src/dfx/src/lib/operations/cycles_ledger.rs index cc2cb45cce..265e476323 100644 --- a/src/dfx/src/lib/operations/cycles_ledger.rs +++ b/src/dfx/src/lib/operations/cycles_ledger.rs @@ -9,17 +9,18 @@ use crate::lib::operations::canister::create_canister::{ CANISTER_CREATE_FEE, CANISTER_INITIAL_CYCLE_BALANCE, }; use crate::lib::retryable::retryable; -use anyhow::{anyhow, bail}; +use anyhow::{anyhow, bail, Context}; use backoff::future::retry; use backoff::ExponentialBackoff; use candid::{CandidType, Decode, Encode, Nat, Principal}; +use dfx_core::canister::build_wallet_canister; use fn_error_context::context; use ic_agent::Agent; use ic_utils::call::SyncCall; use ic_utils::interfaces::management_canister::builders::CanisterSettings; -use ic_utils::Canister; +use ic_utils::{Argument, Canister}; use icrc_ledger_types::icrc1; -use icrc_ledger_types::icrc1::account::Subaccount; +use icrc_ledger_types::icrc1::account::{Account, Subaccount}; use icrc_ledger_types::icrc1::transfer::{BlockIndex, TransferError}; use serde::Deserialize; use slog::{info, Logger}; @@ -33,6 +34,7 @@ const ICRC1_BALANCE_OF_METHOD: &str = "icrc1_balance_of"; const ICRC1_TRANSFER_METHOD: &str = "icrc1_transfer"; const SEND_METHOD: &str = "send"; const CREATE_CANISTER_METHOD: &str = "create_canister"; +const CYCLES_LEDGER_DEPOSIT_METHOD: &str = "deposit"; const CYCLES_LEDGER_CANISTER_ID: Principal = Principal::from_slice(&[0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x02, 0x01, 0x01]); @@ -320,6 +322,32 @@ pub async fn create_with_cycles_ledger( } } +pub async fn wallet_deposit_to_cycles_ledger( + agent: &Agent, + wallet_id: Principal, + cycles_to_withdraw: u128, + to: Account, +) -> DfxResult { + // TODO(FI-1022): Import types from cycles ledger crate once available + #[derive(CandidType)] + pub struct DepositArg { + pub to: Account, + pub memo: Option>, + } + + build_wallet_canister(wallet_id, agent) + .await? + .call128( + CYCLES_LEDGER_CANISTER_ID, + CYCLES_LEDGER_DEPOSIT_METHOD, + Argument::from_candid((DepositArg { to, memo: None },)), + cycles_to_withdraw, + ) + .call_and_wait() + .await + .context("Failed deposit call.") +} + #[test] fn ledger_canister_id_text_representation() { assert_eq!( diff --git a/src/dfx/src/lib/program.rs b/src/dfx/src/lib/program.rs new file mode 100644 index 0000000000..d853413992 --- /dev/null +++ b/src/dfx/src/lib/program.rs @@ -0,0 +1,9 @@ +#[cfg(target_os = "windows")] +pub const NPM: &str = "npm.cmd"; +#[cfg(unix)] +pub const NPM: &str = "npm"; + +#[cfg(target_os = "windows")] +pub const NODE: &str = "node.exe"; +#[cfg(unix)] +pub const NODE: &str = "node"; 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/dfx/src/util/assets.rs b/src/dfx/src/util/assets.rs index d4a417368a..a5e87ba165 100644 --- a/src/dfx/src/util/assets.rs +++ b/src/dfx/src/util/assets.rs @@ -7,7 +7,7 @@ use std::io::Read; include!(concat!(env!("OUT_DIR"), "/load_assets.rs")); pub fn dfinity_logo() -> String { - let colors = supports_color::on(atty::Stream::Stdout); + let colors = supports_color::on(supports_color::Stream::Stdout); if let Some(colors) = colors { //Some terminals, notably MacOS's Terminal.app, do not support Truecolor (RGB-colored characters) properly. //Therefore we use xterm256 coloring when the program is running in such a terminal. diff --git a/src/dfx/src/util/mod.rs b/src/dfx/src/util/mod.rs index 98787ea76e..e0afdecea3 100644 --- a/src/dfx/src/util/mod.rs +++ b/src/dfx/src/util/mod.rs @@ -4,9 +4,10 @@ use anyhow::{bail, Context}; use backoff::backoff::Backoff; use backoff::ExponentialBackoff; use bytes::Bytes; -use candid::parser::typing::pretty_check_file; use candid::types::{value::IDLValue, Function, Type, TypeEnv, TypeInner}; use candid::IDLArgs; +use candid_parser::error::pretty_diagnose; +use candid_parser::typing::pretty_check_file; use dfx_core::fs::create_dir_all; use fn_error_context::context; #[cfg(unix)] @@ -178,7 +179,8 @@ pub fn blob_from_arguments( let typed_args = match method_type { None => { let arguments = arguments.unwrap_or("()"); - candid::pretty_parse::("Candid argument", arguments) + candid_parser::parse_idl_args(arguments) + .or_else(|e| pretty_wrap("Candid argument", arguments, e)) .map_err(|e| error_invalid_argument!("Invalid Candid values: {}", e))? .to_bytes() } @@ -208,9 +210,9 @@ pub fn blob_from_arguments( use rand::Rng; let mut rng = rand::thread_rng(); let seed: Vec = (0..2048).map(|_| rng.gen::()).collect(); - let config = candid::parser::configs::Configs::from_dhall(random) + let config = candid_parser::configs::Configs::from_dhall(random) .context("Failed to create candid parser config.")?; - let args = IDLArgs::any(&seed, &config, env, &func.args) + let args = candid_parser::random::any(&seed, &config, env, &func.args) .context("Failed to create idl args.")?; eprintln!("Sending the following random argument:\n{}\n", args); args.to_bytes_with_types(env, &func.args) @@ -235,17 +237,19 @@ pub fn fuzzy_parse_argument( let is_candid_format = first_char.map_or(false, |c| c == '('); // If parsing fails and method expects a single value, try parsing as IDLValue. // If it still fails, and method expects a text type, send arguments as text. - let args = arg_str.parse::().or_else(|_| { + let args = candid_parser::parse_idl_args(arg_str).or_else(|_| { if types.len() == 1 && !is_candid_format { let is_quote = first_char.map_or(false, |c| c == '"'); if &TypeInner::Text == types[0].as_ref() && !is_quote { Ok(IDLValue::Text(arg_str.to_string())) } else { - candid::pretty_parse::("Candid argument", arg_str) + candid_parser::parse_idl_value(arg_str) + .or_else(|e| pretty_wrap("Candid argument", arg_str, e)) } .map(|v| IDLArgs::new(&[v])) } else { - candid::pretty_parse::("Candid argument", arg_str) + candid_parser::parse_idl_args(arg_str) + .or_else(|e| pretty_wrap("Candid argument", arg_str, e)) } }); let bytes = args @@ -255,6 +259,15 @@ pub fn fuzzy_parse_argument( Ok(bytes) } +fn pretty_wrap( + file_name: &str, + source: &str, + e: candid_parser::Error, +) -> Result { + pretty_diagnose(file_name, source, &e)?; + Err(e) +} + pub fn format_as_trillions(amount: u128) -> String { const SCALE: u32 = 12; // trillion = 10^12 const FRACTIONAL_PRECISION: u32 = 3; diff --git a/src/distributed/assetstorage.wasm.gz b/src/distributed/assetstorage.wasm.gz index eb402f7605..2796c34f49 100755 Binary files a/src/distributed/assetstorage.wasm.gz and b/src/distributed/assetstorage.wasm.gz differ