From 88158f521f5f777bfe3ce68e5b21e1f2bc9fcadd Mon Sep 17 00:00:00 2001 From: Adam Spofford <93943719+adamspofford-dfinity@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:15:15 -0700 Subject: [PATCH] chore: Update agent for Transport changes (#240) --- Cargo.lock | 486 +++++++++++++++++++-------------- Cargo.toml | 32 +-- src/commands/request_status.rs | 84 +----- src/commands/send.rs | 46 ++-- src/lib/mod.rs | 32 --- 5 files changed, 329 insertions(+), 351 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e461fd..681d77f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -260,6 +260,17 @@ dependencies = [ "syn 2.0.65", ] +[[package]] +name = "async-lock" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + [[package]] name = "async-trait" version = "0.1.80" @@ -338,6 +349,12 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "base64ct" version = "1.6.0" @@ -494,20 +511,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bls12_381" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3c196a77437e7cc2fb515ce413a6401291578b5afc8ecb29a3c7ab957f05941" -dependencies = [ - "digest 0.9.0", - "ff 0.12.1", - "group 0.12.1", - "pairing 0.22.0", - "rand_core", - "subtle", -] - [[package]] name = "borsh" version = "1.5.0" @@ -659,11 +662,10 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cached" -version = "0.46.1" +version = "0.49.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c8c50262271cdf5abc979a5f76515c234e764fa025d1ba4862c0f0bcda0e95" +checksum = "8e8e463fceca5674287f32d252fb1d94083758b8709c160efae66d263e5f4eba" dependencies = [ - "ahash 0.8.11", "hashbrown 0.14.5", "instant", "once_cell", @@ -672,10 +674,11 @@ dependencies = [ [[package]] name = "cached" -version = "0.49.3" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8e463fceca5674287f32d252fb1d94083758b8709c160efae66d263e5f4eba" +checksum = "a8466736fe5dbcaf8b8ee24f9bbefe43c884dc3e9ff7178da70f55bffca1133c" dependencies = [ + "ahash 0.8.11", "hashbrown 0.14.5", "instant", "once_cell", @@ -977,6 +980,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console" version = "0.15.8" @@ -1011,16 +1023,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -1054,6 +1056,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + [[package]] name = "crunchy" version = "0.2.2" @@ -1114,7 +1122,7 @@ dependencies = [ "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "group 0.13.0", + "group", "rand_core", "rustc_version", "subtle", @@ -1508,9 +1516,9 @@ dependencies = [ "base16ct", "crypto-bigint", "digest 0.10.7", - "ff 0.13.0", + "ff", "generic-array", - "group 0.13.0", + "group", "pem-rfc7468", "pkcs8", "rand_core", @@ -1534,15 +1542,6 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1568,6 +1567,27 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "event-listener" +version = "5.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" +dependencies = [ + "event-listener", + "pin-project-lite", +] + [[package]] name = "fallible-iterator" version = "0.2.0" @@ -1593,16 +1613,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core", - "subtle", -] - [[package]] name = "ff" version = "0.13.0" @@ -1796,47 +1806,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff 0.12.1", - "rand_core", - "subtle", -] - [[package]] name = "group" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ - "ff 0.13.0", + "ff", "rand_core", "subtle", ] -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.12", - "indexmap 2.2.6", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "half" version = "1.8.3" @@ -1962,17 +1942,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http" version = "1.1.0" @@ -1986,23 +1955,25 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" dependencies = [ "bytes", - "http 0.2.12", - "pin-project-lite", + "http", ] [[package]] -name = "http-body" -version = "1.0.0" +name = "http-body-util" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "http 1.1.0", + "futures-util", + "http", + "http-body", + "pin-project-lite", ] [[package]] @@ -2011,12 +1982,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - [[package]] name = "humansize" version = "2.1.3" @@ -2028,40 +1993,59 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.28" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", - "h2", - "http 0.2.12", - "http-body 0.4.6", + "http", + "http-body", "httparse", - "httpdate", "itoa", "pin-project-lite", - "socket2", + "smallvec", "tokio", - "tower-service", - "tracing", "want", ] [[package]] name = "hyper-rustls" -version = "0.24.2" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", - "http 0.2.12", + "http", "hyper", + "hyper-util", "rustls", + "rustls-pki-types", "tokio", "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -2089,24 +2073,25 @@ dependencies = [ [[package]] name = "ic-agent" -version = "0.34.0" -source = "git+https://github.com/dfinity/agent-rs?rev=8c39e26236e3e3db6db51ffa71e34140c19d207e#8c39e26236e3e3db6db51ffa71e34140c19d207e" +version = "0.37.1" +source = "git+https://github.com/dfinity/agent-rs?rev=6e11a350112f9b907c4d590d8217f340e153d898#6e11a350112f9b907c4d590d8217f340e153d898" dependencies = [ + "async-lock", "backoff", - "cached 0.46.1", + "cached 0.52.0", "candid", "ed25519-consensus", "futures-util", "hex", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "ic-certification", "ic-transport-types", "ic-verify-bls-signature", "k256", "leb128", "p256", - "pem 2.0.1", + "pem 3.0.4", "pkcs8", "rand", "rangemap", @@ -2436,7 +2421,7 @@ dependencies = [ "ic_bls12_381", "itertools 0.12.1", "lazy_static", - "pairing 0.23.0", + "pairing", "paste", "rand", "rand_chacha", @@ -2526,7 +2511,7 @@ source = "git+https://github.com/dfinity/ic?rev=2f9ae6bf5eafed03599fd29475100aca dependencies = [ "curve25519-dalek", "fe-derive", - "group 0.13.0", + "group", "hex", "hex-literal", "ic-crypto-internal-hmac", @@ -2751,8 +2736,8 @@ dependencies = [ [[package]] name = "ic-identity-hsm" -version = "0.34.0" -source = "git+https://github.com/dfinity/agent-rs?rev=8c39e26236e3e3db6db51ffa71e34140c19d207e#8c39e26236e3e3db6db51ffa71e34140c19d207e" +version = "0.37.1" +source = "git+https://github.com/dfinity/agent-rs?rev=6e11a350112f9b907c4d590d8217f340e153d898#6e11a350112f9b907c4d590d8217f340e153d898" dependencies = [ "hex", "ic-agent", @@ -3489,8 +3474,8 @@ dependencies = [ [[package]] name = "ic-transport-types" -version = "0.34.0" -source = "git+https://github.com/dfinity/agent-rs?rev=8c39e26236e3e3db6db51ffa71e34140c19d207e#8c39e26236e3e3db6db51ffa71e34140c19d207e" +version = "0.37.1" +source = "git+https://github.com/dfinity/agent-rs?rev=6e11a350112f9b907c4d590d8217f340e153d898#6e11a350112f9b907c4d590d8217f340e153d898" dependencies = [ "candid", "hex", @@ -3556,14 +3541,16 @@ source = "git+https://github.com/dfinity/ic?rev=2f9ae6bf5eafed03599fd29475100aca [[package]] name = "ic-verify-bls-signature" -version = "0.1.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583b1c03380cf86059160cc6c91dcbf56c7b5f141bf3a4f06bc79762d775fac4" +checksum = "d420b25c0091059f6c3c23a21427a81915e6e0aca3b79e0d403ed767f286a3b9" dependencies = [ - "bls12_381", + "hex", + "ic_bls12_381", "lazy_static", - "pairing 0.22.0", - "sha2 0.9.9", + "pairing", + "rand", + "sha2 0.10.8", ] [[package]] @@ -3612,9 +3599,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22c65787944f32af084dffd0c68c1e544237b76e215654ddea8cd9f527dd8b69" dependencies = [ "digest 0.10.7", - "ff 0.13.0", - "group 0.13.0", - "pairing 0.23.0", + "ff", + "group", + "pairing", "rand_core", "subtle", "zeroize", @@ -4565,21 +4552,18 @@ dependencies = [ [[package]] name = "pairing" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "135590d8bdba2b31346f9cd1fb2a912329f5135e832a4f422942eb6ead8b6b3b" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" dependencies = [ - "group 0.12.1", + "group", ] [[package]] -name = "pairing" -version = "0.23.0" +name = "parking" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" -dependencies = [ - "group 0.13.0", -] +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" @@ -4648,6 +4632,16 @@ dependencies = [ "serde", ] +[[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64 0.22.1", + "serde", +] + [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -4743,6 +4737,26 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -5110,6 +5124,54 @@ dependencies = [ "tokio", ] +[[package]] +name = "quinn" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash 2.0.0", + "rustls", + "socket2", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" +dependencies = [ + "bytes", + "rand", + "ring", + "rustc-hash 2.0.0", + "rustls", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.36" @@ -5269,20 +5331,21 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.27" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "bytes", - "encoding_rs", + "futures-channel", "futures-core", "futures-util", - "h2", - "http 0.2.12", - "http-body 0.4.6", + "http", + "http-body", + "http-body-util", "hyper", "hyper-rustls", + "hyper-util", "ipnet", "js-sys", "log", @@ -5290,13 +5353,14 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "quinn", "rustls", "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", "tokio-rustls", "tokio-util", @@ -5429,6 +5493,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc_version" version = "0.4.0" @@ -5462,32 +5532,42 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.12" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ - "log", + "once_cell", "ring", + "rustls-pki-types", "rustls-webpki", - "sct", + "subtle", + "zeroize", ] [[package]] name = "rustls-pemfile" -version = "1.0.4" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", + "rustls-pki-types", ] +[[package]] +name = "rustls-pki-types" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" + [[package]] name = "rustls-webpki" -version = "0.101.7" +version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring", + "rustls-pki-types", "untrusted", ] @@ -5544,16 +5624,6 @@ dependencies = [ "sha2 0.10.8", ] -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "seahash" version = "4.1.0" @@ -6021,9 +6091,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "synstructure" @@ -6036,27 +6106,6 @@ dependencies = [ "syn 2.0.65", ] -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tap" version = "1.0.1" @@ -6175,7 +6224,7 @@ dependencies = [ "once_cell", "pbkdf2 0.11.0", "rand", - "rustc-hash", + "rustc-hash 1.1.0", "sha2 0.10.8", "thiserror", "unicode-normalization", @@ -6249,11 +6298,12 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", + "rustls-pki-types", "tokio", ] @@ -6287,6 +6337,27 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" version = "0.3.2" @@ -6603,9 +6674,12 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.4" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +dependencies = [ + "rustls-pki-types", +] [[package]] name = "which" @@ -6809,9 +6883,9 @@ dependencies = [ [[package]] name = "winreg" -version = "0.50.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" dependencies = [ "cfg-if", "windows-sys 0.48.0", diff --git a/Cargo.toml b/Cargo.toml index d1e0f0e..8453036 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,25 +13,25 @@ license = "Apache-2.0" # ./scripts/point-to-ic-repo-commit-id.sh be used. That also updates the files # in the candid directory. (This core would be unnecessary if this code also # lived in the ic repo.) -ic-base-types = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ic-ckbtc-minter = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ic-management-canister-types = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ic-nervous-system-common = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ic-nns-common = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ic-nns-constants = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ic-nns-governance = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ic-sns-governance = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ic-sns-root = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ic-sns-swap = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ic-sns-wasm = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -icp-ledger = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -icrc-ledger-types = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } -ledger-canister = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-base-types = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-ckbtc-minter = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-management-canister-types = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-nervous-system-common = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-nns-common = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-nns-constants = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-nns-governance = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-sns-governance = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-sns-root = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-sns-swap = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ic-sns-wasm = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +icp-ledger = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +icrc-ledger-types = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } +ledger-canister = { git = "https://github.com/dfinity/ic", rev = "2f9ae6bf5eafed03599fd29475100aca9f78ae81" } candid = "0.10.2" candid_parser = "0.1.2" -ic-agent = { git = "https://github.com/dfinity/agent-rs", rev = "8c39e26236e3e3db6db51ffa71e34140c19d207e" } -ic-identity-hsm = { git = "https://github.com/dfinity/agent-rs", rev = "8c39e26236e3e3db6db51ffa71e34140c19d207e", optional = true } +ic-agent = { git = "https://github.com/dfinity/agent-rs", rev = "6e11a350112f9b907c4d590d8217f340e153d898" } +ic-identity-hsm = { git = "https://github.com/dfinity/agent-rs", rev = "6e11a350112f9b907c4d590d8217f340e153d898", optional = true } anyhow = "1.0.34" base64 = "0.13.0" diff --git a/src/commands/request_status.rs b/src/commands/request_status.rs index 1c2cdfd..fa4b901 100644 --- a/src/commands/request_status.rs +++ b/src/commands/request_status.rs @@ -1,17 +1,11 @@ -use crate::lib::get_ic_url; use crate::lib::{ display_response, get_agent, get_idl_string, signing::RequestStatus, AnyhowResult, AuthInfo, }; use anyhow::{anyhow, Context}; use candid::Principal; -use ic_agent::agent::http_transport::ReqwestTransport; -use ic_agent::agent::{ReplyResponse, RequestStatusResponse, Transport}; -use ic_agent::AgentError::MessageError; +use ic_agent::agent::{ReplyResponse, RequestStatusResponse}; use ic_agent::{AgentError, RequestId}; -use std::future::Future; -use std::pin::Pin; use std::str::FromStr; -use std::sync::Arc; pub async fn submit( req: &RequestStatus, @@ -24,20 +18,18 @@ pub async fn submit( Principal::from_text(&req.canister_id).context("Couldn't parse canister id")?; let request_id = RequestId::from_str(&req.request_id).context("Invalid argument: request_id")?; - let mut agent = get_agent(&AuthInfo::NoAuth)?; - // fetching root key before replacing the transport layer because the proxy layer does not support the necessary functions + let agent = get_agent(&AuthInfo::NoAuth)?; if fetch_root_key { agent.fetch_root_key().await?; } - agent.set_transport(ProxySignTransport { - req: req.clone(), - http_transport: Arc::new( - ReqwestTransport::create(get_ic_url()).context("Failed to create an agent")?, - ), - }); + let envelope = hex::decode(&req.content) + .context("Unable to decode request content (should be hexadecimal encoded)")?; let ReplyResponse { arg: blob } = async { loop { - match agent.request_status_raw(&request_id, canister_id).await? { + match agent + .request_status_signed(&request_id, canister_id, envelope.clone()) + .await? + { RequestStatusResponse::Replied(reply) => return Ok(reply), RequestStatusResponse::Rejected(response) => { return Err(anyhow!(AgentError::CertifiedReject(response))) @@ -70,63 +62,3 @@ pub async fn submit( } .context("Invalid IDL blob.") } - -pub(crate) struct ProxySignTransport { - req: RequestStatus, - http_transport: Arc, -} - -impl Transport for ProxySignTransport { - fn read_state<'a>( - &'a self, - _canister_id: Principal, - _content: Vec, - ) -> Pin, AgentError>> + Send + 'a>> { - async fn run(transport: &ProxySignTransport) -> Result, AgentError> { - let canister_id = Principal::from_text(transport.req.canister_id.clone()) - .map_err(|err| MessageError(format!("Unable to parse canister_id: {err}")))?; - let envelope = hex::decode(transport.req.content.clone()).map_err(|err| { - MessageError(format!( - "Unable to decode request content (should be hexadecimal encoded): {err}", - )) - })?; - transport - .http_transport - .read_state(canister_id, envelope) - .await - } - - Box::pin(run(self)) - } - - fn read_subnet_state( - &self, - subnet_id: Principal, - envelope: Vec, - ) -> Pin, AgentError>> + Send + '_>> { - self.http_transport.read_subnet_state(subnet_id, envelope) - } - - fn call<'a>( - &'a self, - _effective_canister_id: Principal, - _envelope: Vec, - _request_id: RequestId, - ) -> Pin> + Send + 'a>> { - unimplemented!() - } - - fn query<'a>( - &'a self, - _effective_canister_id: Principal, - _envelope: Vec, - ) -> Pin, AgentError>> + Send + 'a>> { - unimplemented!() - } - - fn status<'a>( - &'a self, - ) -> Pin, AgentError>> + Send + 'a>> { - unimplemented!() - } -} diff --git a/src/commands/send.rs b/src/commands/send.rs index e9f0488..ae545a8 100644 --- a/src/commands/send.rs +++ b/src/commands/send.rs @@ -1,17 +1,17 @@ use crate::commands::request_status; +use crate::lib::get_idl_string; use crate::lib::{ - get_ic_url, parse_query_response, read_from_file, + get_ic_url, read_from_file, signing::{Ingress, IngressWithRequestId}, AnyhowResult, AuthInfo, }; -use anyhow::{anyhow, bail, Context}; +use anyhow::{anyhow, bail}; use candid::Principal; use clap::Parser; -use ic_agent::agent::Transport; -use ic_agent::{agent::http_transport::ReqwestTransport, RequestId}; +use ic_agent::agent::CallResponse; +use ic_agent::{Agent, AgentError}; use std::io::IsTerminal; use std::path::PathBuf; -use std::str::FromStr; use super::SendingOpts; @@ -131,29 +131,33 @@ async fn send(message: &Ingress, opts: &SendOpts) -> AnyhowResult { } } - let transport = ReqwestTransport::create(get_ic_url())?; + let agent = Agent::builder().with_url(get_ic_url()).build().unwrap(); + let content = hex::decode(&message.content)?; match message.call_type.as_str() { "query" => { - let response = parse_query_response( - ic_agent::agent::Transport::query(&transport, canister_id, content).await?, - canister_id, - &role, - &method_name, - )?; + let result = agent.query_signed(canister_id, content).await; + let response = match result { + Ok(bytes) => get_idl_string(&bytes, canister_id, &role, &method_name, "rets")?, + Err(AgentError::UncertifiedReject(resp)) => format!( + "Rejected (code {:?}): {}", + resp.reject_code, resp.reject_message, + ), + Err(e) => bail!(e), + }; println!("Response: {response}"); } "update" => { - let request_id = RequestId::from_str( - &message - .clone() - .request_id - .context("Cannot get request_id from the update message")?, - )?; - transport.call(canister_id, content, request_id).await?; - let request_id = format!("0x{}", String::from(request_id)); - println!("Request ID: {request_id}"); + let result = agent.update_signed(canister_id, content).await; + let request_id = match result { + Ok(CallResponse::Poll(id)) => id, + Ok(CallResponse::Response(_)) => { + bail!("This version of quill does not support synchronous calls") + } + Err(e) => bail!(e), + }; + println!("Request ID: 0x{}", String::from(request_id)); } _ => unreachable!(), } diff --git a/src/lib/mod.rs b/src/lib/mod.rs index faf1cf2..3993a24 100644 --- a/src/lib/mod.rs +++ b/src/lib/mod.rs @@ -24,7 +24,6 @@ use icrc_ledger_types::icrc1::account::Account; use k256::SecretKey; use pkcs8::pkcs5::{pbes2::Parameters, scrypt::Params}; use ring::signature::Ed25519KeyPair; -use serde_cbor::Value; use std::{ env, @@ -511,37 +510,6 @@ pub fn get_identity(auth: &AuthInfo) -> AnyhowResult> { } } -pub fn parse_query_response( - response: Vec, - canister_id: Principal, - role: &str, - method_name: &str, -) -> AnyhowResult { - let cbor: Value = serde_cbor::from_slice(&response) - .context("Invalid cbor data in the content of the message.")?; - if let Value::Map(m) = cbor { - // Try to decode a rejected response. - if let (_, Some(Value::Integer(reject_code)), Some(Value::Text(reject_message))) = ( - m.get(&Value::Text("status".to_string())), - m.get(&Value::Text("reject_code".to_string())), - m.get(&Value::Text("reject_message".to_string())), - ) { - return Ok(format!("Rejected (code {reject_code}): {reject_message}",)); - } - - // Try to decode a successful response. - if let (_, Some(Value::Map(m))) = ( - m.get(&Value::Text("status".to_string())), - m.get(&Value::Text("reply".to_string())), - ) { - if let Some(Value::Bytes(reply)) = m.get(&Value::Text("arg".to_string())) { - return get_idl_string(reply, canister_id, role, method_name, "rets"); - } - } - } - Err(anyhow!("Invalid cbor content")) -} - /// Returns the account id and the principal id if the private key was provided. pub fn get_principal(auth: &AuthInfo) -> AnyhowResult { let principal_id = get_identity(auth)?.sender().map_err(|e| anyhow!(e))?;