diff --git a/Cargo.lock b/Cargo.lock index 5b4bcb241..beda34c1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -391,7 +391,7 @@ dependencies = [ "lru", "parking_lot", "pin-project", - "reqwest 0.12.14", + "reqwest", "serde", "serde_json", "thiserror 2.0.12", @@ -436,7 +436,7 @@ dependencies = [ "async-stream", "futures", "pin-project", - "reqwest 0.12.14", + "reqwest", "serde", "serde_json", "tokio", @@ -615,7 +615,7 @@ checksum = "c30aa026c88924cfa89ddfa77ad77aec05d2153c6838422dcdaf559a6e9e3175" dependencies = [ "alloy-json-rpc", "alloy-primitives", - "base64 0.22.1", + "base64", "derive_more 2.0.1", "futures", "futures-utils-wasm", @@ -638,7 +638,7 @@ checksum = "3259b177d89bb02599bddb4cd3c11ec5a1ffdaaa01a2706e8298e08433f205f0" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.14", + "reqwest", "serde_json", "tower", "tracing", @@ -1030,8 +1030,8 @@ dependencies = [ "axum-core", "bytes", "futures-util", - "http 1.3.1", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", "itoa", "matchit", @@ -1041,7 +1041,7 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper 1.0.1", + "sync_wrapper", "tower", "tower-layer", "tower-service", @@ -1055,13 +1055,13 @@ checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" dependencies = [ "bytes", "futures-core", - "http 1.3.1", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.1", + "sync_wrapper", "tower-layer", "tower-service", ] @@ -1087,12 +1087,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -1254,15 +1248,15 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97ccca1260af6a459d75994ad5acc1651bcabcbdbc41467cc9786519ab854c30" dependencies = [ - "base64 0.22.1", + "base64", "bollard-stubs", "bytes", "futures-core", "futures-util", "hex", - "http 1.3.1", + "http", "http-body-util", - "hyper 1.6.0", + "hyper", "hyper-named-pipe", "hyper-util", "hyperlocal", @@ -1429,7 +1423,7 @@ dependencies = [ "path-absolutize", "rand 0.8.5", "rcgen", - "reqwest 0.12.14", + "reqwest", "serde", "serde_json", "time", @@ -1448,7 +1442,7 @@ dependencies = [ "clap", "documented", "fs-err", - "rustls 0.23.23", + "rustls", "serde", "tokio", "toml_edit", @@ -1768,7 +1762,7 @@ dependencies = [ "hex_fmt", "ra-rpc", "regex", - "reqwest 0.12.14", + "reqwest", "serde", "serde_json", "tokio", @@ -1879,36 +1873,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" -[[package]] -name = "dcap-qvl" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e024d399632fb2e97a9501e79779ae9f150118a17ad06333de3bbd42834b84" -dependencies = [ - "anyhow", - "asn1_der", - "base64 0.21.7", - "byteorder", - "chrono", - "const-oid", - "der", - "futures", - "hex", - "log", - "parity-scale-codec", - "pem", - "reqwest 0.11.27", - "ring", - "rustls-webpki 0.102.8", - "scale-info", - "serde", - "serde_bytes", - "serde_json", - "tracing", - "urlencoding", - "x509-cert", -] - [[package]] name = "dcap-qvl" version = "0.2.4" @@ -1917,7 +1881,7 @@ checksum = "7c8049b28b1fe35e94bd52f4c20edf7b80b6eeb378faccdd685d5cd82cbc192e" dependencies = [ "anyhow", "asn1_der", - "base64 0.22.1", + "base64", "byteorder", "chrono", "const-oid", @@ -1927,9 +1891,9 @@ dependencies = [ "log", "parity-scale-codec", "pem", - "reqwest 0.12.14", + "reqwest", "ring", - "rustls-webpki 0.102.8", + "rustls-webpki", "scale-info", "serde", "serde-human-bytes", @@ -2222,7 +2186,7 @@ dependencies = [ "rand 0.8.5", "rinja", "rocket", - "rustls 0.23.23", + "rustls", "safe-write", "serde", "serde_json", @@ -2230,7 +2194,7 @@ dependencies = [ "shared_child", "smallvec", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls", "tracing", "tracing-subscriber", ] @@ -2253,7 +2217,7 @@ name = "dstack-guest-agent" version = "0.4.2" dependencies = [ "anyhow", - "base64 0.22.1", + "base64", "bollard", "cert-client", "chrono", @@ -2273,7 +2237,7 @@ dependencies = [ "ra-rpc", "ra-tls", "rcgen", - "reqwest 0.12.14", + "reqwest", "ring", "rinja", "rocket", @@ -2325,7 +2289,7 @@ dependencies = [ "ra-rpc", "ra-tls", "rand 0.8.5", - "reqwest 0.12.14", + "reqwest", "ring", "rocket", "safe-write", @@ -2356,15 +2320,16 @@ dependencies = [ ] [[package]] -name = "dstack-rust" +name = "dstack-sdk" version = "0.1.0" dependencies = [ "alloy", - "dcap-qvl 0.1.6", + "anyhow", + "dcap-qvl", "hex", - "http 0.2.12", + "http", "http-client-unix-domain-socket", - "reqwest 0.11.27", + "reqwest", "serde", "serde_json", "sha2", @@ -2969,25 +2934,6 @@ dependencies = [ "serde_json", ] -[[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.5.0", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "h2" version = "0.4.6" @@ -2999,7 +2945,7 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.3.1", + "http", "indexmap 2.5.0", "slab", "tokio", @@ -3016,7 +2962,7 @@ dependencies = [ "bytes", "fastrand", "futures-util", - "http 1.3.1", + "http", "pin-project-lite", "tokio", ] @@ -3217,17 +3163,6 @@ dependencies = [ "winapi", ] -[[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.3.1" @@ -3239,17 +3174,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.12", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.1" @@ -3257,7 +3181,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.3.1", + "http", ] [[package]] @@ -3268,8 +3192,8 @@ checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", "futures-core", - "http 1.3.1", - "http-body 1.0.1", + "http", + "http-body", "pin-project-lite", ] @@ -3279,13 +3203,13 @@ version = "0.4.2" dependencies = [ "anyhow", "http-body-util", - "hyper 1.6.0", + "hyper", "hyper-util", "hyperlocal", "log", "pin-project-lite", "prpc", - "reqwest 0.12.14", + "reqwest", "serde", "tokio", "tokio-vsock", @@ -3301,7 +3225,7 @@ dependencies = [ "axum", "axum-core", "http-body-util", - "hyper 1.6.0", + "hyper", "hyper-util", "serde", "serde_json", @@ -3335,30 +3259,6 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" -[[package]] -name = "hyper" -version = "0.14.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - [[package]] name = "hyper" version = "1.6.0" @@ -3368,9 +3268,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.6", - "http 1.3.1", - "http-body 1.0.1", + "h2", + "http", + "http-body", "httparse", "httpdate", "itoa", @@ -3387,7 +3287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73b7d8abf35697b81a825e386fc151e0d503e8cb5fcb93cc8669c376dfd6f278" dependencies = [ "hex", - "hyper 1.6.0", + "hyper", "hyper-util", "pin-project-lite", "tokio", @@ -3395,20 +3295,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "hyper-rustls" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" -dependencies = [ - "futures-util", - "http 0.2.12", - "hyper 0.14.32", - "rustls 0.21.12", - "tokio", - "tokio-rustls 0.24.1", -] - [[package]] name = "hyper-rustls" version = "0.27.3" @@ -3416,29 +3302,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", - "http 1.3.1", - "hyper 1.6.0", + "http", + "hyper", "hyper-util", - "rustls 0.23.23", + "rustls", "rustls-native-certs", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls", "tower-service", - "webpki-roots 0.26.6", -] - -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.32", - "native-tls", - "tokio", - "tokio-native-tls", + "webpki-roots", ] [[package]] @@ -3449,7 +3322,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.6.0", + "hyper", "hyper-util", "native-tls", "tokio", @@ -3466,9 +3339,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.3.1", - "http-body 1.0.1", - "hyper 1.6.0", + "http", + "http-body", + "hyper", "pin-project-lite", "socket2", "tokio", @@ -3484,7 +3357,7 @@ checksum = "986c5ce3b994526b3cd75578e62554abd09f0899d6206de48b3e96ab34ccc8c7" dependencies = [ "hex", "http-body-util", - "hyper 1.6.0", + "hyper", "hyper-util", "pin-project-lite", "tokio", @@ -3637,13 +3510,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37221e690dcc5d0ea7c1f70decda6ae3495e72e8af06bca15e982193ffdf4fc4" dependencies = [ "async-trait", - "base64 0.22.1", + "base64", "bytes", - "http 1.3.1", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", - "hyper 1.6.0", - "hyper-rustls 0.27.3", + "hyper", + "hyper-rustls", "hyper-util", "ring", "rustls-pki-types", @@ -4089,7 +3962,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-util", - "http 1.3.1", + "http", "httparse", "log", "memchr", @@ -4581,7 +4454,7 @@ version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64 0.22.1", + "base64", "serde", ] @@ -5039,7 +4912,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 2.1.0", - "rustls 0.23.23", + "rustls", "socket2", "thiserror 1.0.65", "tokio", @@ -5056,7 +4929,7 @@ dependencies = [ "rand 0.8.5", "ring", "rustc-hash 2.1.0", - "rustls 0.23.23", + "rustls", "slab", "thiserror 1.0.65", "tinyvec", @@ -5094,7 +4967,7 @@ dependencies = [ "bon", "prpc", "ra-tls", - "reqwest 0.12.14", + "reqwest", "rocket", "rocket-vsock-listener", "serde", @@ -5110,7 +4983,7 @@ dependencies = [ "anyhow", "bon", "cc-eventlog", - "dcap-qvl 0.2.4", + "dcap-qvl", "elliptic-curve", "fs-err", "hex", @@ -5373,70 +5246,25 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2 0.3.26", - "hickory-resolver", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.32", - "hyper-rustls 0.24.2", - "hyper-tls 0.5.0", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls 0.21.12", - "rustls-pemfile 1.0.4", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration", - "tokio", - "tokio-native-tls", - "tokio-rustls 0.24.1", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots 0.25.4", - "winreg", -] - [[package]] name = "reqwest" version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "989e327e510263980e231de548a33e63d34962d29ae61b467389a1a09627a254" dependencies = [ - "base64 0.22.1", + "base64", "bytes", "encoding_rs", "futures-channel", "futures-core", "futures-util", "hickory-resolver", - "http 1.3.1", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", - "hyper 1.6.0", - "hyper-rustls 0.27.3", - "hyper-tls 0.6.0", + "hyper", + "hyper-rustls", + "hyper-tls", "hyper-util", "ipnet", "js-sys", @@ -5447,23 +5275,23 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.23", - "rustls-pemfile 2.1.3", + "rustls", + "rustls-pemfile", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper", "tokio", "tokio-native-tls", - "tokio-rustls 0.26.2", + "tokio-rustls", "tower", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.26.6", + "webpki-roots", "windows-registry", ] @@ -5565,8 +5393,8 @@ dependencies = [ "either", "figment", "futures", - "http 1.3.1", - "hyper 1.6.0", + "http", + "hyper", "hyper-util", "indexmap 2.5.0", "libc", @@ -5580,8 +5408,8 @@ dependencies = [ "ref-swap", "rocket_codegen", "rocket_http", - "rustls 0.23.23", - "rustls-pemfile 2.1.3", + "rustls", + "rustls-pemfile", "s2n-quic-h3", "serde", "serde_json", @@ -5591,7 +5419,7 @@ dependencies = [ "time", "tinyvec", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls", "tokio-stream", "tokio-util", "tracing", @@ -5770,18 +5598,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "rustls" -version = "0.21.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" -dependencies = [ - "log", - "ring", - "rustls-webpki 0.101.7", - "sct", -] - [[package]] name = "rustls" version = "0.23.23" @@ -5793,7 +5609,7 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.102.8", + "rustls-webpki", "subtle", "zeroize", ] @@ -5805,28 +5621,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.3", + "rustls-pemfile", "rustls-pki-types", "schannel", "security-framework", ] -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - [[package]] name = "rustls-pemfile" version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ - "base64 0.22.1", + "base64", "rustls-pki-types", ] @@ -5836,16 +5643,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" -[[package]] -name = "rustls-webpki" -version = "0.101.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring", - "untrusted 0.9.0", -] - [[package]] name = "rustls-webpki" version = "0.102.8" @@ -6016,8 +5813,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c973d29e9b6669473f205b47d015480d7e79b103dfbd1c789184d9adc31af05" dependencies = [ "bytes", - "rustls 0.23.23", - "rustls-pemfile 2.1.3", + "rustls", + "rustls-pemfile", "s2n-codec 0.46.0", "s2n-quic-core 0.46.0", "s2n-quic-crypto", @@ -6124,16 +5921,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted 0.9.0", -] - [[package]] name = "sd-notify" version = "0.4.5" @@ -6327,7 +6114,7 @@ version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" dependencies = [ - "base64 0.22.1", + "base64", "chrono", "hex", "indexmap 1.9.3", @@ -6645,10 +6432,10 @@ dependencies = [ "clap", "fs-err", "futures", - "http 1.3.1", + "http", "http-body-util", "http-client", - "hyper 1.6.0", + "hyper", "hyper-util", "hyperlocal", "log", @@ -6693,12 +6480,6 @@ dependencies = [ "syn 2.0.100", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.1" @@ -6808,7 +6589,7 @@ dependencies = [ "clap", "cmd_lib", "curve25519-dalek", - "dcap-qvl 0.2.4", + "dcap-qvl", "dstack-gateway-rpc", "dstack-kms-rpc", "dstack-types", @@ -7038,23 +6819,13 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls 0.21.12", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" dependencies = [ - "rustls 0.23.23", + "rustls", "tokio", ] @@ -7139,7 +6910,7 @@ dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 1.0.1", + "sync_wrapper", "tokio", "tower-layer", "tower-service", @@ -7562,12 +7333,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.25.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" - [[package]] name = "webpki-roots" version = "0.26.6" diff --git a/sdk/rust/Cargo.toml b/sdk/rust/Cargo.toml index e019b2bae..b9499b037 100644 --- a/sdk/rust/Cargo.toml +++ b/sdk/rust/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "dstack-rust" +name = "dstack-sdk" version = "0.1.0" edition = "2021" license = "MIT" @@ -8,14 +8,15 @@ authors = ["Encifher "] [dependencies] alloy = { version = "0.15", features = ["signers", "signer-local"] } -hex = "0.4" -http = "0.2" +anyhow.workspace = true +hex.workspace = true +http.workspace = true http-client-unix-domain-socket = "0.1.1" -reqwest = { version = "0.11", features = ["json"] } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -sha2 = "0.10.9" +reqwest = { workspace = true, features = ["json"] } +serde.workspace = true +serde_json.workspace = true +sha2.workspace = true [dev-dependencies] -dcap-qvl = "0.1.0" -tokio = { version = "1", features = ["full"] } +dcap-qvl = "0.2.4" +tokio = { workspace = true, features = ["full"] } diff --git a/sdk/rust/README.md b/sdk/rust/README.md index 0ee8c0d82..bd2308541 100644 --- a/sdk/rust/README.md +++ b/sdk/rust/README.md @@ -12,7 +12,7 @@ dstack-rust = { git = "https://github.com/Dstack-TEE/dstack.git", package = "dst ## Basic Usage ```rust -use dstack_client::DstackClient; +use dstack_sdk::DstackClient; #[tokio::main] async fn main() -> Result<(), Box> { diff --git a/sdk/rust/src/dstack_client.rs b/sdk/rust/src/dstack_client.rs index 479260b15..1d994da7b 100644 --- a/sdk/rust/src/dstack_client.rs +++ b/sdk/rust/src/dstack_client.rs @@ -1,12 +1,12 @@ -use hex::{FromHexError, encode as hex_encode}; +use anyhow::{anyhow, Result}; +use hex::{encode as hex_encode, FromHexError}; use http_client_unix_domain_socket::{ClientUnix, Method}; use reqwest::Client; -use serde::{Deserialize, Serialize}; -use serde_json::{Value, from_str, json}; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; +use serde_json::{from_str, json, Value}; use sha2::Digest; use std::collections::HashMap; use std::env; -use std::error::Error; const INIT_MR: &str = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; @@ -82,7 +82,7 @@ impl GetQuoteResponse { serde_json::from_str(&self.event_log) } - pub fn replay_rtmrs(&self) -> Result, Box> { + pub fn replay_rtmrs(&self) -> Result> { let parsed_event_log: Vec = self.decode_event_log()?; let mut rtmrs = HashMap::new(); for idx in 0..4 { @@ -169,7 +169,11 @@ impl DstackClient { } } - async fn send_rpc_request(&self, path: &str, payload: &Value) -> Result> { + async fn send_rpc_request( + &self, + path: &str, + payload: &S, + ) -> anyhow::Result { match &self.client { ClientKind::Http => { let client = Client::new(); @@ -189,15 +193,16 @@ impl DstackClient { } ClientKind::Unix => { let mut unix_client = ClientUnix::try_new(&self.endpoint).await?; + let json_payload = serde_json::to_value(payload)?; let res = unix_client .send_request_json::( path, Method::POST, &[("Content-Type", "application/json")], - Some(payload), + Some(&json_payload), ) .await?; - Ok(res.1) + Ok(serde_json::from_value(res.1)?) } } } @@ -206,7 +211,7 @@ impl DstackClient { &self, path: Option, purpose: Option, - ) -> Result> { + ) -> Result { let data = json!({ "path": path.unwrap_or_default(), "purpose": purpose.unwrap_or_default(), @@ -217,12 +222,9 @@ impl DstackClient { Ok(response) } - pub async fn get_quote( - &self, - report_data: Vec, - ) -> Result> { + pub async fn get_quote(&self, report_data: Vec) -> Result { if report_data.is_empty() || report_data.len() > 64 { - return Err("Invalid report data length".into()); + return Err(anyhow!("Invalid report data length")); } let hex_data = hex_encode(report_data); let data = json!({ "report_data": hex_data }); @@ -232,18 +234,18 @@ impl DstackClient { Ok(response) } - pub async fn info(&self) -> Result> { + pub async fn info(&self) -> Result { let response = self.send_rpc_request("/Info", &json!({})).await?; Ok(InfoResponse::validated_from_value(response)?) } - pub async fn emit_event(&self, event: String, payload: Vec) -> Result<(), Box> { + pub async fn emit_event(&self, event: String, payload: Vec) -> Result<()> { if event.is_empty() { - return Err("Event name cannot be empty".into()); + return Err(anyhow!("Event name cannot be empty")); } let hex_payload = hex_encode(payload); let data = json!({ "event": event, "payload": hex_payload }); - self.send_rpc_request("/EmitEvent", &data).await?; + self.send_rpc_request::<_, ()>("/EmitEvent", &data).await?; Ok(()) } @@ -254,7 +256,7 @@ impl DstackClient { usage_ra_tls: bool, usage_server_auth: bool, usage_client_auth: bool, - ) -> Result> { + ) -> Result { let data = json!({ "subject": subject.unwrap_or_default(), "usage_ra_tls": usage_ra_tls, diff --git a/sdk/rust/tests/test_client.rs b/sdk/rust/tests/test_client.rs index 2b650f979..ce557927c 100644 --- a/sdk/rust/tests/test_client.rs +++ b/sdk/rust/tests/test_client.rs @@ -1,6 +1,5 @@ use dcap_qvl::quote::Quote; -use dstack_rust::dstack_client::DstackClient as AsyncDstackClient; -use tokio; +use dstack_sdk::dstack_client::DstackClient as AsyncDstackClient; #[tokio::test] async fn test_async_client_get_key() {