diff --git a/Cargo.lock b/Cargo.lock index f969e285bc..4d4a70c696 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,9 +307,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "068a33520e21c1eea89726be4d6b3ce2e6b81046904367e1677287695a043abb" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -411,13 +411,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caae68055714ff28740f310927e04f2eba76ff580b16fb18ed90073ee71646f7" +checksum = "687c230d85c0a52504709705fc8a53e4a692b83a2184f03dae73e38e1e93a783" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -439,9 +439,9 @@ checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" [[package]] name = "autocfg" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "awc" @@ -632,9 +632,9 @@ checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" [[package]] name = "candid" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f6e879d53af7853a2d8ec7fd7d786bbf363a1535296542b957e67592f229dc" +checksum = "2b32722710ebebb2a9c1a0db9398de78cdc83de96da505ca3f47de5d3b75f8b4" dependencies = [ "byteorder", "candid_derive", @@ -659,16 +659,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab31ccaf3ab1184bab4a139afb0d23c3aa54144d4a92ef0d0de7653cad4f679f" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] name = "cc" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" +checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381" [[package]] name = "cfg-if" @@ -678,9 +678,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "chrono" -version = "0.4.13" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c74d84029116787153e02106bf53e66828452a4b325cc8652b788b5967c0a0b6" +checksum = "942f72db697d8767c22d46a598e01f2d3b475501ea43d0db4f16d90259182d0b" dependencies = [ "num-integer", "num-traits", @@ -875,7 +875,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" dependencies = [ "cfg-if", - "crossbeam-channel 0.4.3", + "crossbeam-channel 0.4.4", "crossbeam-deque", "crossbeam-epoch", "crossbeam-queue", @@ -893,12 +893,12 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ee0cc8804d5393478d743b035099520087a5186f3b93fa58cec08fa62407b6" +checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" dependencies = [ - "cfg-if", "crossbeam-utils 0.7.2", + "maybe-uninit", ] [[package]] @@ -918,7 +918,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", "cfg-if", "crossbeam-utils 0.7.2", "lazy_static", @@ -954,7 +954,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", "cfg-if", "lazy_static", ] @@ -971,9 +971,9 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -1026,6 +1026,7 @@ dependencies = [ "futures", "hex", "hotwatch", + "humanize-rs", "ic-agent", "ic-types", "indicatif", @@ -1189,9 +1190,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.23" +version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171" +checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2" dependencies = [ "cfg-if", ] @@ -1236,9 +1237,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f47da3a72ec598d9c8937a7ebca8962a5c7a1f28444e38c2b33c771ba3f55f05" dependencies = [ "proc-macro-error", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -1257,9 +1258,9 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", "synstructure", ] @@ -1289,9 +1290,9 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" [[package]] name = "flate2" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68c90b0fc46cf89d227cc78b40e494ff81287a92dd07631e5af0d06fe3cf885e" +checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" dependencies = [ "cfg-if", "crc32fast", @@ -1411,9 +1412,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" dependencies = [ "proc-macro-hack", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -1470,13 +1471,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] @@ -1546,12 +1547,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" -dependencies = [ - "autocfg 1.0.0", -] +checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7" [[package]] name = "hermit-abi" @@ -1627,6 +1625,12 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +[[package]] +name = "humanize-rs" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "016b02deb8b0c415d8d56a6f0ab265e50c22df61194e37f9be75ed3a722de8a6" + [[package]] name = "humantime" version = "1.3.0" @@ -1692,7 +1696,7 @@ dependencies = [ [[package]] name = "ic-agent" version = "0.1.0" -source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=next#35a0f9851cf8cceea34acf405ba50c84ab5fbc5e" +source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=pshahi/ingress-expiry-two#b57f659d431198feaca98f7ef9adf9b1fdff7807" dependencies = [ "async-trait", "base32", @@ -1720,7 +1724,7 @@ dependencies = [ [[package]] name = "ic-types" version = "0.1.1" -source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=next#35a0f9851cf8cceea34acf405ba50c84ab5fbc5e" +source = "git+ssh://git@github.com/dfinity-lab/agent-rust.git?branch=pshahi/ingress-expiry-two#b57f659d431198feaca98f7ef9adf9b1fdff7807" dependencies = [ "base32", "crc32fast", @@ -1753,12 +1757,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b45e59b16c76b11bf9738fd5d38879d3bd28ad292d7b313608becb17ae2df9" +checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" dependencies = [ - "autocfg 1.0.0", - "hashbrown 0.8.2", + "autocfg 1.0.1", + "hashbrown 0.9.0", ] [[package]] @@ -1843,9 +1847,9 @@ checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" [[package]] name = "js-sys" -version = "0.3.44" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85a7e2c92a4804dd459b86c339278d0fe87cf93757fae222c3fa3ae75458bc73" +checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8" dependencies = [ "wasm-bindgen", ] @@ -1862,9 +1866,9 @@ dependencies = [ [[package]] name = "lalrpop" -version = "0.19.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f55673d283313791404be21209bb433f128f7e5c451986df107eb5fdbd68d2" +checksum = "60fb56191fb8ed5311597e5750debe6779c9fdb487dbaa5ff302592897d7a2c8" dependencies = [ "ascii-canvas", "atty", @@ -1887,9 +1891,9 @@ dependencies = [ [[package]] name = "lalrpop-util" -version = "0.19.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e88f15a7d31dfa8fb607986819039127f0161058a3b248a146142d276cbd28" +checksum = "6771161eff561647fad8bb7e745e002c304864fb8f436b52b30acda51fca4408" [[package]] name = "language-tags" @@ -1923,9 +1927,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.74" +version = "0.2.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" +checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" [[package]] name = "libflate" @@ -1998,10 +2002,10 @@ checksum = "797b1f8a0571b331c1b47e7db245af3dc634838da7a92b3bef4e30376ae1c347" dependencies = [ "beef", "fnv", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", "regex-syntax", - "syn 1.0.38", + "syn 1.0.40", "utf8-ranges", ] @@ -2044,7 +2048,7 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", ] [[package]] @@ -2075,9 +2079,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" +checksum = "4d7559a8a40d0f97e1edea3220f698f78b1c5ab67532e49f68fde3910323b722" dependencies = [ "adler", ] @@ -2158,9 +2162,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5a615a1ad92048ad5d9633251edb7492b8abc057d7a679a9898476aef173935" dependencies = [ "cfg-if", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -2201,9 +2205,9 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.34" +version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" dependencies = [ "cfg-if", "libc", @@ -2256,7 +2260,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f3fc75e3697059fb1bc465e3d8cca6cf92f56854f201158b3f9c77d5a3cfa0" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", "num-integer", "num-traits", ] @@ -2267,7 +2271,7 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", "num-traits", ] @@ -2277,7 +2281,7 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", ] [[package]] @@ -2307,9 +2311,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c0fd9eba1d5db0994a239e09c1be402d35622277e35468ba891aa5e3188ce7e" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -2326,9 +2330,9 @@ checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" [[package]] name = "once_cell" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" +checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" [[package]] name = "opaque-debug" @@ -2368,7 +2372,7 @@ version = "0.9.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", "cc", "libc", "pkg-config", @@ -2528,9 +2532,9 @@ version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c0e815c3ee9a031fdf5af21c10aa17c573c9c6a566328d99e3936c34e36461f" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -2553,9 +2557,9 @@ checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" [[package]] name = "ppv-lite86" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" +checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" [[package]] name = "precomputed-hash" @@ -2618,9 +2622,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", "version_check 0.9.2", ] @@ -2630,7 +2634,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", "version_check 0.9.2", ] @@ -2658,9 +2662,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.19" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" +checksum = "36e28516df94f3dd551a587da5357459d9b36d945a7c37c3557928c1c2ff2a2c" dependencies = [ "unicode-xid 0.2.1", ] @@ -2706,7 +2710,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", ] [[package]] @@ -2858,11 +2862,11 @@ dependencies = [ [[package]] name = "rayon" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" +checksum = "cfd016f0c045ad38b5251be2c9c0ab806917f82da4d36b2a327e5166adad9270" dependencies = [ - "autocfg 1.0.0", + "autocfg 1.0.1", "crossbeam-deque", "either", "rayon-core", @@ -2870,12 +2874,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" +checksum = "91739a34c4355b5434ce54c9086c5895604a9c278586d1f1aa95e04f66b525a0" dependencies = [ + "crossbeam-channel 0.4.4", "crossbeam-deque", - "crossbeam-queue", "crossbeam-utils 0.7.2", "lazy_static", "num_cpus", @@ -2898,9 +2902,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_users" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ "getrandom", "redox_syscall", @@ -2936,9 +2940,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12427a5577082c24419c9c417db35cfeb65962efc7675bb6b0d5f1f9d315bfe6" +checksum = "e9eaa17ac5d7b838b7503d118fa16ad88f440498bf9ffe5424e621f93190d61e" dependencies = [ "base64 0.12.3", "bytes 0.5.6", @@ -3007,11 +3011,11 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" [[package]] name = "rust-argon2" -version = "0.7.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" +checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" dependencies = [ - "base64 0.11.0", + "base64 0.12.3", "blake2b_simd", "constant_time_eq", "crossbeam-utils 0.7.2", @@ -3034,9 +3038,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cac94b333ee2aac3284c5b8a1b7fb4dd11cba88c244e3fe33cdbd047af0eb693" +checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81" dependencies = [ "base64 0.12.3", "log", @@ -3170,9 +3174,9 @@ version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -3192,9 +3196,9 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dc6b7951b17b051f3210b063f12cc17320e2fe30ae05b0fe2a3abb068551c76" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -3290,7 +3294,7 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b3336ce47ce2f96673499fc07eb85e3472727b9a7a2959964b002c2ce8fbbb" dependencies = [ - "crossbeam-channel 0.4.3", + "crossbeam-channel 0.4.4", "slog", "take_mut", "thread_local", @@ -3326,9 +3330,9 @@ checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" [[package]] name = "socket2" -version = "0.3.12" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" dependencies = [ "cfg-if", "libc", @@ -3389,11 +3393,11 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4" +checksum = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", "unicode-xid 0.2.1", ] @@ -3404,9 +3408,9 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", "unicode-xid 0.2.1", ] @@ -3431,9 +3435,9 @@ checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" [[package]] name = "tar" -version = "0.4.29" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8a4c1d0bee3230179544336c15eefb563cf0302955d962e456542323e8c2e8a" +checksum = "489997b7557e9a43e192c527face4feacc78bfbe6eed67fd55c4c9e381cba290" dependencies = [ "filetime", "libc", @@ -3528,9 +3532,9 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -3553,19 +3557,20 @@ dependencies = [ [[package]] name = "time" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ "libc", + "wasi 0.10.0+wasi-snapshot-preview1", "winapi 0.3.9", ] [[package]] name = "tinyvec" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" +checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" [[package]] name = "tokio" @@ -3659,9 +3664,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "228139ddd4fea3fa345a29233009635235833e52807af7ea6448ead03890d6a9" +checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" dependencies = [ "futures-core", "rustls", @@ -3789,9 +3794,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db63662723c316b43ca36d833707cc93dff82a02ba3d7e354f342682cc8b3545" +checksum = "5bcf46c1f1f06aeea2d6b81f3c863d0930a596c86ad1920d4e5bad6dd1d7119a" dependencies = [ "lazy_static", ] @@ -3959,9 +3964,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2ca2a14bc3fc5b64d188b087a7d3a927df87b152e941ccfbc66672e20c467ae" dependencies = [ "nom", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", ] [[package]] @@ -4034,11 +4039,17 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasm-bindgen" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0563a9a4b071746dd5aedbc3a28c6fe9be4586fb3fbadb67c400d4f53c6b16c" +checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" dependencies = [ "cfg-if", "serde", @@ -4048,24 +4059,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc71e4c5efa60fb9e74160e89b93353bc24059999c0ae0fb03affc39770310b0" +checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68" dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95f8d235a77f880bcef268d379810ea6c0af2eacfa90b1ad5af731776e0c4699" +checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da" dependencies = [ "cfg-if", "js-sys", @@ -4075,9 +4086,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97c57cefa5fa80e2ba15641578b44d36e7a64279bc5ed43c6dbaf329457a2ed2" +checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038" dependencies = [ "quote 1.0.7", "wasm-bindgen-macro-support", @@ -4085,22 +4096,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841a6d1c35c6f596ccea1f82504a192a60378f64b3bb0261904ad8f2f5657556" +checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe" dependencies = [ - "proc-macro2 1.0.19", + "proc-macro2 1.0.21", "quote 1.0.7", - "syn 1.0.38", + "syn 1.0.40", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93b162580e34310e5931c4b792560108b10fd14d64915d7fff8ff00180e70092" +checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" [[package]] name = "wasmparser" @@ -4110,9 +4121,9 @@ checksum = "8b4eab1d9971d0803729cba3617b56eb04fcb4bd25361cb63880ed41a42f20d5" [[package]] name = "web-sys" -version = "0.3.44" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda38f4e5ca63eda02c059d243aa25b5f35ab98451e518c51612cd0f1bd19a47" +checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index eaa1d3163d..faa8aa9215 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,4 +4,4 @@ members = [ ] [patch.crates-io] -ic-types = { git = "ssh://git@github.com/dfinity-lab/agent-rust.git", branch = "next", version = "0.1.1" } +ic-types = { git = "ssh://git@github.com/dfinity-lab/agent-rust.git", branch = "pshahi/ingress-expiry-two", version = "0.1.1" } diff --git a/nix/sources.json b/nix/sources.json index 9d39370420..93cd25e749 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -39,14 +39,14 @@ }, "dfinity": { "repo": "ssh://git@github.com/dfinity-lab/dfinity", - "rev": "70434f1ecac5227dc8e5d30635f7aceb7c257e3f", - "tag": "release-2020-09-04.RC00", + "rev": "d0856d8d60b5a2d2a7b6f50fa0fa1d68db9264dc", + "branch": "akhi3030/expiry-time", "type": "git" }, "ic-ref": { "repo": "ssh://git@github.com/dfinity-lab/ic-ref", - "rev": "493f0862ddd9970b8fb09e4e97f95fab1764b18e", - "tag": "release-0.9", + "rev": "7c1e8bae654588790374ec1a23f40f579405b31c", + "tag": "0.10.2", "type": "git" }, "motoko": { diff --git a/src/dfx/Cargo.toml b/src/dfx/Cargo.toml index e301954379..5a3b3bd1db 100644 --- a/src/dfx/Cargo.toml +++ b/src/dfx/Cargo.toml @@ -31,6 +31,7 @@ dialoguer = "0.6.2" erased-serde = "0.3.10" flate2 = "1.0.11" futures = "0.1.28" +humanize-rs = "0.1.5" hex = "0.4.2" indicatif = "0.13.0" lazy-init = "0.3.0" @@ -68,14 +69,14 @@ wasmparser = "0.45.0" [dependencies.ic-agent] version = "0.1.0" git = "ssh://git@github.com/dfinity-lab/agent-rust.git" -branch = "next" -rev = "35a0f9851cf8cceea34acf405ba50c84ab5fbc5e" +branch = "pshahi/ingress-expiry-two" +rev = "b57f659d431198feaca98f7ef9adf9b1fdff7807" [dependencies.ic-types] version = "0.1.1" git = "ssh://git@github.com/dfinity-lab/agent-rust.git" -branch = "next" -rev = "35a0f9851cf8cceea34acf405ba50c84ab5fbc5e" +branch = "pshahi/ingress-expiry-two" +rev = "b57f659d431198feaca98f7ef9adf9b1fdff7807" [dev-dependencies] env_logger = "0.6" diff --git a/src/dfx/src/commands/canister/call.rs b/src/dfx/src/commands/canister/call.rs index be26401aba..40a658a4dc 100644 --- a/src/dfx/src/commands/canister/call.rs +++ b/src/dfx/src/commands/canister/call.rs @@ -3,8 +3,8 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::waiter::create_waiter; -use crate::util::{blob_from_arguments, get_candid_type, print_idl_blob}; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::{blob_from_arguments, expiry_duration, get_candid_type, print_idl_blob}; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_types::principal::Principal as CanisterId; use std::option::Option; @@ -125,26 +125,35 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { // Get the argument, get the type, convert the argument to the type and return // an error if any of it doesn't work. let arg_value = blob_from_arguments(arguments, arg_type, &method_type)?; - let client = env + let agent = env .get_agent() .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); + + let timeout = args.value_of("expiry_duration"); + let duration = expiry_duration(timeout)?; + if is_query { - let blob = runtime.block_on(client.query_raw(&canister_id, method_name, &arg_value))?; + let blob = + runtime.block_on(agent.query_raw(&canister_id, method_name, &arg_value, None))?; print_idl_blob(&blob, output_type, &method_type) .map_err(|e| DfxError::InvalidData(format!("Invalid IDL blob: {}", e)))?; } else if args.is_present("async") { - let request_id = - runtime.block_on(client.update_raw(&canister_id, method_name, &arg_value))?; - + let request_id = runtime.block_on( + agent + .update(&canister_id, &method_name) + .with_arg(&arg_value) + .call(), + )?; eprint!("Request ID: "); println!("0x{}", String::from(request_id)); } else { let blob = runtime.block_on( - client + agent .update(&canister_id, &method_name) .with_arg(&arg_value) - .call_and_wait(create_waiter()), + .expire_after(duration) + .call_and_wait(waiter_with_timeout(duration)), )?; print_idl_blob(&blob, output_type, &method_type) diff --git a/src/dfx/src/commands/canister/create.rs b/src/dfx/src/commands/canister/create.rs index 9954edff2b..cabfbf744d 100644 --- a/src/dfx/src/commands/canister/create.rs +++ b/src/dfx/src/commands/canister/create.rs @@ -29,14 +29,16 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; + let timeout = args.value_of("expiry_duration"); + if let Some(canister_name) = args.value_of("canister_name") { - create_canister(env, canister_name)?; + create_canister(env, canister_name, timeout)?; Ok(()) } else if args.is_present("all") { // Create all canisters. if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - create_canister(env, canister_name)?; + create_canister(env, canister_name, timeout)?; } } Ok(()) diff --git a/src/dfx/src/commands/canister/delete.rs b/src/dfx/src/commands/canister/delete.rs index 008428779b..06cc95f88b 100644 --- a/src/dfx/src/commands/canister/delete.rs +++ b/src/dfx/src/commands/canister/delete.rs @@ -2,7 +2,8 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; @@ -28,7 +29,12 @@ pub fn construct() -> App<'static, 'static> { ) } -async fn delete_canister(env: &dyn Environment, agent: &Agent, canister_name: &str) -> DfxResult { +async fn delete_canister( + env: &dyn Environment, + agent: &Agent, + canister_name: &str, + timeout: Option<&str>, +) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let mut canister_id_store = CanisterIdStore::for_env(env)?; @@ -39,8 +45,9 @@ async fn delete_canister(env: &dyn Environment, agent: &Agent, canister_name: &s canister_name, canister_id.to_text(), ); + let duration = expiry_duration(timeout)?; - mgr.delete_canister(create_waiter(), &canister_id) + mgr.delete_canister(waiter_with_timeout(duration), &canister_id) .await .map_err(DfxError::from)?; @@ -57,15 +64,17 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .get_agent() .ok_or(DfxError::CommandMustBeRunInAProject)?; + let timeout = args.value_of("expiry_duration"); + let mut runtime = Runtime::new().expect("Unable to create a runtime"); if let Some(canister_name) = args.value_of("canister_name") { - runtime.block_on(delete_canister(env, &agent, &canister_name))?; + runtime.block_on(delete_canister(env, &agent, &canister_name, timeout))?; Ok(()) } else if args.is_present("all") { if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - runtime.block_on(delete_canister(env, &agent, &canister_name))?; + runtime.block_on(delete_canister(env, &agent, &canister_name, timeout))?; } } Ok(()) diff --git a/src/dfx/src/commands/canister/install.rs b/src/dfx/src/commands/canister/install.rs index 79217af9b5..963f8823a9 100644 --- a/src/dfx/src/commands/canister/install.rs +++ b/src/dfx/src/commands/canister/install.rs @@ -6,7 +6,9 @@ use crate::lib::models::canister_id_store::CanisterIdStore; use crate::lib::operations::canister::install_canister; use clap::{App, Arg, ArgMatches, SubCommand}; -use ic_agent::{ComputeAllocation, InstallMode}; +use humanize_rs::bytes::{Bytes, Unit}; +use ic_agent::{ComputeAllocation, InstallMode, MemoryAllocation}; + use std::convert::TryFrom; use std::str::FromStr; use tokio::runtime::Runtime; @@ -51,6 +53,13 @@ pub fn construct() -> App<'static, 'static> { .takes_value(true) .validator(compute_allocation_validator), ) + .arg( + Arg::with_name("memory-allocation") + .help(UserMessage::InstallMemoryAllocation.to_str()) + .long("memory-allocation") + .takes_value(true) + .validator(memory_allocation_validator), + ) } fn compute_allocation_validator(compute_allocation: String) -> Result<(), String> { @@ -62,18 +71,38 @@ fn compute_allocation_validator(compute_allocation: String) -> Result<(), String Err("Must be a percent between 0 and 100".to_string()) } +fn memory_allocation_validator(memory_allocation: String) -> Result<(), String> { + let limit = Bytes::new(256, Unit::TByte).map_err(|_| "Parse Overflow.")?; + if let Ok(bytes) = memory_allocation.parse::() { + if bytes.size() <= limit.size() { + return Ok(()); + } + } + Err("Must be a value between 0..256 TB inclusive.".to_string()) +} + pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let config = env .get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; + + let timeout = args.value_of("expiry_duration"); + let agent = env .get_agent() .ok_or(DfxError::CommandMustBeRunInAProject)?; + let compute_allocation = args.value_of("compute-allocation").map(|arg| { ComputeAllocation::try_from(arg.parse::().unwrap()) .expect("Compute Allocation must be a percentage.") }); + let memory_allocation: Option = + args.value_of("memory_allocation").map(|arg| { + MemoryAllocation::try_from(u64::try_from(arg.parse::().unwrap().size()).unwrap()) + .expect("Memory allocation must be between 0 and 2^48 (i.e 256TB), inclusively.") + }); + let mode = InstallMode::from_str(args.value_of("mode").unwrap())?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); @@ -90,6 +119,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { &canister_info, compute_allocation, mode, + memory_allocation, + timeout, ))?; Ok(()) } else if args.is_present("all") { @@ -105,6 +136,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { &canister_info, compute_allocation, mode.clone(), + memory_allocation, + timeout, ))?; } } diff --git a/src/dfx/src/commands/canister/mod.rs b/src/dfx/src/commands/canister/mod.rs index c7f4f3d818..8c18ee3ac1 100644 --- a/src/dfx/src/commands/canister/mod.rs +++ b/src/dfx/src/commands/canister/mod.rs @@ -4,6 +4,7 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::provider::create_agent_environment; use clap::{App, Arg, ArgMatches, SubCommand}; +use humanize_rs::duration::parse; mod call; mod create; @@ -38,9 +39,28 @@ pub fn construct() -> App<'static, 'static> { .long("network") .takes_value(true), ) + .arg( + Arg::with_name("expiry-duration") + .long("expiry-duration") + .help(UserMessage::CanisterCallExpiryDuration.to_str()) + .takes_value(true) + .default_value("5m") + .validator(expiry_duration_validator), + ) .subcommands(builtins().into_iter().map(|x| x.get_subcommand().clone())) } +fn expiry_duration_validator(expiry_duration: String) -> Result<(), String> { + if let Ok(_ed) = parse(&expiry_duration) { + return Ok(()); + } + let err = format!( + r#""Invalid input: {}. Expected a duration-type string e.g. "1h", "1h 30m""#, + expiry_duration + ); + Err(err) +} + pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let subcommand = args.subcommand(); diff --git a/src/dfx/src/commands/canister/request_status.rs b/src/dfx/src/commands/canister/request_status.rs index 44f31e9e4e..28a47c0e07 100644 --- a/src/dfx/src/commands/canister/request_status.rs +++ b/src/dfx/src/commands/canister/request_status.rs @@ -1,9 +1,9 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; use crate::util::clap::validators; -use crate::util::print_idl_blob; +use crate::util::{expiry_duration, print_idl_blob}; use clap::{App, Arg, ArgMatches, SubCommand}; use delay::Waiter; use ic_agent::{AgentError, Replied, RequestId, RequestStatusResponse}; @@ -35,13 +35,17 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let mut waiter = create_waiter(); + let timeout = args.value_of("expiry_duration"); + + let duration = expiry_duration(timeout)?; + + let mut waiter = waiter_with_timeout(duration); let Replied::CallReplied(blob) = runtime .block_on(async { waiter.start(); loop { - match agent.request_status_raw(&request_id).await? { + match agent.request_status_raw(&request_id, None).await? { RequestStatusResponse::Replied { reply } => return Ok(reply), RequestStatusResponse::Rejected { reject_code, @@ -55,6 +59,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { RequestStatusResponse::Unknown => (), RequestStatusResponse::Received => (), RequestStatusResponse::Processing => (), + RequestStatusResponse::Done => (), }; waiter diff --git a/src/dfx/src/commands/canister/start.rs b/src/dfx/src/commands/canister/start.rs index 3becc2c92c..40b638ae58 100644 --- a/src/dfx/src/commands/canister/start.rs +++ b/src/dfx/src/commands/canister/start.rs @@ -2,7 +2,8 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; @@ -28,12 +29,19 @@ pub fn construct() -> App<'static, 'static> { ) } -async fn start_canister(env: &dyn Environment, agent: &Agent, canister_name: &str) -> DfxResult { +async fn start_canister( + env: &dyn Environment, + agent: &Agent, + canister_name: &str, + timeout: Option<&str>, +) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let canister_id_store = CanisterIdStore::for_env(env)?; let canister_id = canister_id_store.get(canister_name)?; + let duration = expiry_duration(timeout)?; + info!( log, "Starting code for canister {}, with canister_id {}", @@ -41,7 +49,7 @@ async fn start_canister(env: &dyn Environment, agent: &Agent, canister_name: &st canister_id.to_text(), ); - mgr.start_canister(create_waiter(), &canister_id) + mgr.start_canister(waiter_with_timeout(duration), &canister_id) .await .map_err(DfxError::from)?; @@ -58,13 +66,15 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let mut runtime = Runtime::new().expect("Unable to create a runtime"); + let timeout = args.value_of("expiry_duration"); + if let Some(canister_name) = args.value_of("canister_name") { - runtime.block_on(start_canister(env, &agent, &canister_name))?; + runtime.block_on(start_canister(env, &agent, &canister_name, timeout))?; Ok(()) } else if args.is_present("all") { if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - runtime.block_on(start_canister(env, &agent, &canister_name))?; + runtime.block_on(start_canister(env, &agent, &canister_name, timeout))?; } } Ok(()) diff --git a/src/dfx/src/commands/canister/status.rs b/src/dfx/src/commands/canister/status.rs index 938ae1279f..3d018b439f 100644 --- a/src/dfx/src/commands/canister/status.rs +++ b/src/dfx/src/commands/canister/status.rs @@ -2,7 +2,8 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; @@ -28,14 +29,21 @@ pub fn construct() -> App<'static, 'static> { ) } -async fn canister_status(env: &dyn Environment, agent: &Agent, canister_name: &str) -> DfxResult { +async fn canister_status( + env: &dyn Environment, + agent: &Agent, + canister_name: &str, + timeout: Option<&str>, +) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let canister_id_store = CanisterIdStore::for_env(env)?; let canister_id = canister_id_store.get(canister_name)?; + let duration = expiry_duration(timeout)?; + let status = mgr - .canister_status(create_waiter(), &canister_id) + .canister_status(waiter_with_timeout(duration), &canister_id) .await .map_err(DfxError::from)?; info!(log, "Canister {}'s status is {}.", canister_name, status); @@ -53,13 +61,15 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let mut runtime = Runtime::new().expect("Unable to create a runtime"); + let timeout = args.value_of("expiry_duration"); + if let Some(canister_name) = args.value_of("canister_name") { - runtime.block_on(canister_status(env, &agent, &canister_name))?; + runtime.block_on(canister_status(env, &agent, &canister_name, timeout))?; Ok(()) } else if args.is_present("all") { if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - runtime.block_on(canister_status(env, &agent, &canister_name))?; + runtime.block_on(canister_status(env, &agent, &canister_name, timeout))?; } } Ok(()) diff --git a/src/dfx/src/commands/canister/stop.rs b/src/dfx/src/commands/canister/stop.rs index 016e88495d..d2df7d5784 100644 --- a/src/dfx/src/commands/canister/stop.rs +++ b/src/dfx/src/commands/canister/stop.rs @@ -2,7 +2,8 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::message::UserMessage; use crate::lib::models::canister_id_store::CanisterIdStore; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; use clap::{App, Arg, ArgMatches, SubCommand}; use ic_agent::{Agent, ManagementCanister}; @@ -28,12 +29,19 @@ pub fn construct() -> App<'static, 'static> { ) } -async fn stop_canister(env: &dyn Environment, agent: &Agent, canister_name: &str) -> DfxResult { +async fn stop_canister( + env: &dyn Environment, + agent: &Agent, + canister_name: &str, + timeout: Option<&str>, +) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); let canister_id_store = CanisterIdStore::for_env(env)?; let canister_id = canister_id_store.get(canister_name)?; + let duration = expiry_duration(timeout)?; + info!( log, "Stopping code for canister {}, with canister_id {}", @@ -41,7 +49,7 @@ async fn stop_canister(env: &dyn Environment, agent: &Agent, canister_name: &str canister_id.to_text(), ); - mgr.stop_canister(create_waiter(), &canister_id) + mgr.stop_canister(waiter_with_timeout(duration), &canister_id) .await .map_err(DfxError::from)?; @@ -57,14 +65,15 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { .ok_or(DfxError::CommandMustBeRunInAProject)?; let mut runtime = Runtime::new().expect("Unable to create a runtime"); + let timeout = args.value_of("expiry_duration"); if let Some(canister_name) = args.value_of("canister_name") { - runtime.block_on(stop_canister(env, &agent, &canister_name))?; + runtime.block_on(stop_canister(env, &agent, &canister_name, timeout))?; Ok(()) } else if args.is_present("all") { if let Some(canisters) = &config.get_config().canisters { for canister_name in canisters.keys() { - runtime.block_on(stop_canister(env, &agent, &canister_name))?; + runtime.block_on(stop_canister(env, &agent, &canister_name, timeout))?; } } Ok(()) diff --git a/src/dfx/src/commands/deploy.rs b/src/dfx/src/commands/deploy.rs index 5cbccdfe1b..5800f327c7 100644 --- a/src/dfx/src/commands/deploy.rs +++ b/src/dfx/src/commands/deploy.rs @@ -25,7 +25,8 @@ pub fn construct() -> App<'static, 'static> { pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let env = create_agent_environment(env, args)?; + let timeout = args.value_of("expiry_duration"); let canister = args.value_of("canister_name"); - deploy_canisters(&env, canister) + deploy_canisters(&env, canister, timeout) } diff --git a/src/dfx/src/commands/ping.rs b/src/dfx/src/commands/ping.rs index 4d38ba5afb..bb11ee92e2 100644 --- a/src/dfx/src/commands/ping.rs +++ b/src/dfx/src/commands/ping.rs @@ -37,7 +37,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { other => Err(other), })?; - let env = AgentEnvironment::new(env, network_descriptor)?; + let env = AgentEnvironment::new(env, network_descriptor, args)?; let agent = env .get_agent() diff --git a/src/dfx/src/lib/environment.rs b/src/dfx/src/lib/environment.rs index 50b1a5ff8b..50ac024b20 100644 --- a/src/dfx/src/lib/environment.rs +++ b/src/dfx/src/lib/environment.rs @@ -5,7 +5,9 @@ use crate::lib::error::{DfxError, DfxResult}; use crate::lib::identity::identity_manager::IdentityManager; use crate::lib::network::network_descriptor::NetworkDescriptor; use crate::lib::progress_bar::ProgressBar; +use crate::util::expiry_duration; +use clap::ArgMatches; use ic_agent::{Agent, AgentConfig, Identity}; use semver::Version; use slog::{Logger, Record}; @@ -13,6 +15,7 @@ use std::collections::BTreeMap; use std::fs::create_dir_all; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; +use std::time::Duration; #[cfg(test)] use mockall::automock; @@ -210,13 +213,17 @@ impl<'a> AgentEnvironment<'a> { pub fn new( backend: &'a dyn Environment, network_descriptor: NetworkDescriptor, + args: &ArgMatches<'_>, ) -> DfxResult { let identity = IdentityManager::new(backend)?.instantiate_selected_identity()?; + let timeout = args.value_of("expiry_duration"); + let duration = expiry_duration(timeout)?; + let agent_url = network_descriptor.providers.first().unwrap(); Ok(AgentEnvironment { backend, - agent: create_agent(backend.get_logger().clone(), agent_url, identity) + agent: create_agent(backend.get_logger().clone(), agent_url, identity, duration) .expect("Failed to construct agent."), network_descriptor, }) @@ -407,7 +414,12 @@ impl ic_agent::PasswordManager for AgentClient { } } -fn create_agent(logger: Logger, url: &str, identity: Box) -> Option { +fn create_agent( + logger: Logger, + url: &str, + identity: Box, + duration: Duration, +) -> Option { AgentClient::new(logger, url.to_string()) .ok() .and_then(|executor| { @@ -415,6 +427,7 @@ fn create_agent(logger: Logger, url: &str, identity: Box) -> Optio url: url.to_string(), identity, password_manager: Some(Box::new(executor)), + ing_exp_duration: Some(duration), ..AgentConfig::default() }) .ok() diff --git a/src/dfx/src/lib/error/mod.rs b/src/dfx/src/lib/error/mod.rs index a4b8293af7..562dfa9b2a 100644 --- a/src/dfx/src/lib/error/mod.rs +++ b/src/dfx/src/lib/error/mod.rs @@ -143,6 +143,8 @@ pub enum DfxError { /// Could not save the contents of the file CouldNotSaveCanisterIds(String, std::io::Error), + + HumanizeParseError(humanize_rs::ParseError), } /// The result of running a DFX command. @@ -306,3 +308,9 @@ impl From for DfxError { DfxError::Unknown(err) } } + +impl From for DfxError { + fn from(err: humanize_rs::ParseError) -> DfxError { + DfxError::HumanizeParseError(err) + } +} diff --git a/src/dfx/src/lib/installers/assets.rs b/src/dfx/src/lib/installers/assets.rs index 3c73e0633d..3b2a94f597 100644 --- a/src/dfx/src/lib/installers/assets.rs +++ b/src/dfx/src/lib/installers/assets.rs @@ -1,13 +1,19 @@ use crate::lib::canister_info::assets::AssetsCanisterInfo; use crate::lib::canister_info::CanisterInfo; use crate::lib::error::DfxResult; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; use candid::Encode; + use ic_agent::Agent; use std::path::Path; +use std::time::Duration; use walkdir::WalkDir; -pub async fn post_install_store_assets(info: &CanisterInfo, agent: &Agent) -> DfxResult { +pub async fn post_install_store_assets( + info: &CanisterInfo, + agent: &Agent, + duration: Duration, +) -> DfxResult { let assets_canister_info = info.as_info::()?; let output_assets_path = assets_canister_info.get_output_assets_path(); @@ -25,10 +31,12 @@ pub async fn post_install_store_assets(info: &CanisterInfo, agent: &Agent) -> Df let canister_id = info.get_canister_id().expect("Could not find canister ID."); let method_name = String::from("store"); + agent .update(&canister_id, &method_name) .with_arg(&blob) - .call_and_wait(create_waiter()) + .expire_after(duration) + .call_and_wait(waiter_with_timeout(duration)) .await?; } } diff --git a/src/dfx/src/lib/message.rs b/src/dfx/src/lib/message.rs index e35e9ff128..832cba0543 100644 --- a/src/dfx/src/lib/message.rs +++ b/src/dfx/src/lib/message.rs @@ -54,10 +54,12 @@ user_message!( InstallAll => "Deploys all canisters configured in the project dfx.json files.", InstallCanisterName => "Specifies the canister name to deploy. You must specify either canister name or the --all option.", InstallComputeAllocation => "Specifies the canister's compute allocation. This should be a percent in the range [0..100]", + InstallMemoryAllocation => "Specifies how much memory the canister is allowed to use in total. This should be a value in the range [0..256 TB]", InstallMode => "Specifies the type of deployment. You can set the canister deployment modes to install, reinstall, or upgrade.", // dfx canister mod ManageCanister => "Manages canisters deployed on a network replica.", + CanisterCallExpiryDuration => "The duration of time for which the message will considered valid and processed by the Internet Computer. Default value is set to 5 minutes.", // dfx canister delete DeleteCanister => "Deletes a canister on the Internet Computer network.", diff --git a/src/dfx/src/lib/operations/canister/create_canister.rs b/src/dfx/src/lib/operations/canister/create_canister.rs index 1f7c4904ff..797c2366c2 100644 --- a/src/dfx/src/lib/operations/canister/create_canister.rs +++ b/src/dfx/src/lib/operations/canister/create_canister.rs @@ -2,26 +2,25 @@ use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::models::canister_id_store::CanisterIdStore; use crate::lib::provider::get_network_context; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; use ic_agent::ManagementCanister; use slog::info; use std::format; use tokio::runtime::Runtime; -pub fn create_canister(env: &dyn Environment, canister_name: &str) -> DfxResult { +pub fn create_canister( + env: &dyn Environment, + canister_name: &str, + timeout: Option<&str>, +) -> DfxResult { let log = env.get_logger(); info!(log, "Creating canister {:?}...", canister_name); env.get_config() .ok_or(DfxError::CommandMustBeRunInAProject)?; - let mgr = ManagementCanister::new( - env.get_agent() - .ok_or(DfxError::CommandMustBeRunInAProject)?, - ); - let mut runtime = Runtime::new().expect("Unable to create a runtime"); - let mut canister_id_store = CanisterIdStore::for_env(env)?; let network_name = get_network_context()?; @@ -44,7 +43,15 @@ pub fn create_canister(env: &dyn Environment, canister_name: &str) -> DfxResult Ok(()) } None => { - let cid = runtime.block_on(mgr.create_canister(create_waiter()))?; + let mgr = ManagementCanister::new( + env.get_agent() + .ok_or(DfxError::CommandMustBeRunInAProject)?, + ); + + let duration = expiry_duration(timeout)?; + + let mut runtime = Runtime::new().expect("Unable to create a runtime"); + let cid = runtime.block_on(mgr.create_canister(waiter_with_timeout(duration)))?; let canister_id = cid.to_text(); info!( log, diff --git a/src/dfx/src/lib/operations/canister/deploy_canisters.rs b/src/dfx/src/lib/operations/canister/deploy_canisters.rs index 71c1b99220..d2dac9695c 100644 --- a/src/dfx/src/lib/operations/canister/deploy_canisters.rs +++ b/src/dfx/src/lib/operations/canister/deploy_canisters.rs @@ -11,7 +11,11 @@ use ic_agent::{AgentError, InstallMode}; use slog::{info, warn}; use tokio::runtime::Runtime; -pub fn deploy_canisters(env: &dyn Environment, some_canister: Option<&str>) -> DfxResult { +pub fn deploy_canisters( + env: &dyn Environment, + some_canister: Option<&str>, + timeout: Option<&str>, +) -> DfxResult { let log = env.get_logger(); let config = env @@ -26,11 +30,17 @@ pub fn deploy_canisters(env: &dyn Environment, some_canister: Option<&str>) -> D info!(log, "Deploying all canisters."); } - register_canisters(env, &canister_names, &initial_canister_id_store)?; + register_canisters(env, &canister_names, &initial_canister_id_store, timeout)?; build_canisters(env, &canister_names, &config)?; - install_canisters(env, &canister_names, &initial_canister_id_store, &config)?; + install_canisters( + env, + &canister_names, + &initial_canister_id_store, + &config, + timeout, + )?; info!(log, "Deployed canisters."); @@ -49,6 +59,7 @@ fn register_canisters( env: &dyn Environment, canister_names: &[String], canister_id_store: &CanisterIdStore, + timeout: Option<&str>, ) -> DfxResult { let canisters_to_create = canister_names .iter() @@ -60,7 +71,7 @@ fn register_canisters( } else { info!(env.get_logger(), "Creating canisters..."); for canister_name in &canisters_to_create { - create_canister(env, &canister_name)?; + create_canister(env, &canister_name, timeout)?; } } Ok(()) @@ -79,6 +90,7 @@ fn install_canisters( canister_names: &[String], initial_canister_id_store: &CanisterIdStore, config: &Config, + timeout: Option<&str>, ) -> DfxResult { info!(env.get_logger(), "Installing canisters..."); @@ -99,12 +111,15 @@ fn install_canisters( let canister_id = canister_id_store.get(&canister_name)?; let canister_info = CanisterInfo::load(&config, &canister_name, Some(canister_id))?; let compute_allocation = None; + let memory_allocation = None; let result = runtime.block_on(install_canister( env, &agent, &canister_info, compute_allocation, first_mode, + memory_allocation, + timeout, )); match result { Err(DfxError::AgentError(AgentError::ReplicaError { @@ -127,6 +142,8 @@ fn install_canisters( &canister_info, compute_allocation, second_mode, + memory_allocation, + timeout, )) } other => other, diff --git a/src/dfx/src/lib/operations/canister/install_canister.rs b/src/dfx/src/lib/operations/canister/install_canister.rs index 455cea56b9..b79621dcde 100644 --- a/src/dfx/src/lib/operations/canister/install_canister.rs +++ b/src/dfx/src/lib/operations/canister/install_canister.rs @@ -2,9 +2,12 @@ use crate::lib::canister_info::CanisterInfo; use crate::lib::environment::Environment; use crate::lib::error::{DfxError, DfxResult}; use crate::lib::installers::assets::post_install_store_assets; -use crate::lib::waiter::create_waiter; +use crate::lib::waiter::waiter_with_timeout; +use crate::util::expiry_duration; -use ic_agent::{Agent, CanisterAttributes, ComputeAllocation, InstallMode, ManagementCanister}; +use ic_agent::{ + Agent, CanisterAttributes, ComputeAllocation, InstallMode, ManagementCanister, MemoryAllocation, +}; use slog::info; pub async fn install_canister( @@ -13,6 +16,8 @@ pub async fn install_canister( canister_info: &CanisterInfo, compute_allocation: Option, mode: InstallMode, + memory_allocation: Option, + timeout: Option<&str>, ) -> DfxResult { let mgr = ManagementCanister::new(agent); let log = env.get_logger(); @@ -32,19 +37,24 @@ pub async fn install_canister( .expect("Cannot get WASM output path."); let wasm = std::fs::read(wasm_path)?; + let duration = expiry_duration(timeout)?; + mgr.install_code( - create_waiter(), + waiter_with_timeout(duration), &canister_id, mode, &wasm, &[], - &CanisterAttributes { compute_allocation }, + &CanisterAttributes { + compute_allocation, + memory_allocation, + }, ) .await .map_err(DfxError::from)?; if canister_info.get_type() == "assets" { - post_install_store_assets(&canister_info, &agent).await?; + post_install_store_assets(&canister_info, &agent, duration).await?; } Ok(()) diff --git a/src/dfx/src/lib/provider.rs b/src/dfx/src/lib/provider.rs index fc1f59958b..e089db6368 100644 --- a/src/dfx/src/lib/provider.rs +++ b/src/dfx/src/lib/provider.rs @@ -81,7 +81,7 @@ pub fn create_agent_environment<'a>( ) -> DfxResult> { let network_descriptor = get_network_descriptor(env, args)?; - AgentEnvironment::new(env, network_descriptor) + AgentEnvironment::new(env, network_descriptor, args) } pub fn command_line_provider_to_url(s: &str) -> DfxResult { diff --git a/src/dfx/src/lib/waiter.rs b/src/dfx/src/lib/waiter.rs index 32d5e5ad78..3e322d4f75 100644 --- a/src/dfx/src/lib/waiter.rs +++ b/src/dfx/src/lib/waiter.rs @@ -3,11 +3,10 @@ use std::time::Duration; const RETRY_PAUSE: Duration = Duration::from_millis(200); const MAX_RETRY_PAUSE: Duration = Duration::from_secs(1); -const REQUEST_TIMEOUT: Duration = Duration::from_secs(120); -pub fn create_waiter() -> Delay { +pub fn waiter_with_timeout(duration: Duration) -> Delay { Delay::builder() .exponential_backoff_capped(RETRY_PAUSE, 1.4, MAX_RETRY_PAUSE) - .timeout(REQUEST_TIMEOUT) + .timeout(duration) .build() } diff --git a/src/dfx/src/util/mod.rs b/src/dfx/src/util/mod.rs index 09260e13ed..62e8ad3118 100644 --- a/src/dfx/src/util/mod.rs +++ b/src/dfx/src/util/mod.rs @@ -2,10 +2,20 @@ use crate::lib::error::{DfxError, DfxResult}; use candid::parser::typing::{check_prog, TypeEnv}; use candid::types::{Function, Type}; use candid::{parser::value::IDLValue, IDLArgs, IDLProg}; +use humanize_rs::duration::parse; +use std::time::Duration; pub mod assets; pub mod clap; +pub fn expiry_duration(timeout: Option<&str>) -> DfxResult { + let dur = match timeout { + Some(expiry_duration) => parse(expiry_duration), + None => Ok(Duration::from_secs(60 * 5)), // 5 minutes is max ingress timeout + }?; + Ok(dur) +} + /// Deserialize and print return values from canister method. pub fn print_idl_blob( blob: &[u8],