From da81171734bf7d7842ac6a6d48006a916ddfca78 Mon Sep 17 00:00:00 2001 From: Diego Prats Date: Wed, 4 Dec 2024 14:29:34 -0800 Subject: [PATCH] Revert "fix: auto-updater bug fixes (#75)" This reverts commit f26774a366ed232bb29be2ee8bb3c70eaca4d820. --- .gitignore | 3 - clients/cli/.gitignore | 2 - clients/cli/Cargo.lock | 814 ++++++++------------------- clients/cli/Cargo.toml | 13 +- clients/cli/README.md | 32 +- clients/cli/src/prover.rs | 22 +- clients/cli/src/prover_id_manager.rs | 2 +- clients/cli/src/updater.rs | 125 ++-- clients/cli/src/utils/updater.rs | 537 +++++++++--------- tests/test_updater.sh | 153 +++++ tests/updater.sh | 98 ---- 11 files changed, 728 insertions(+), 1073 deletions(-) create mode 100755 tests/test_updater.sh delete mode 100755 tests/updater.sh diff --git a/.gitignore b/.gitignore index 8e7b93c..789555c 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,3 @@ node_modules/ .dataconnect .vscode/ - -# macOS system files -.DS_Store \ No newline at end of file diff --git a/clients/cli/.gitignore b/clients/cli/.gitignore index b1ecd0d..bca6f9b 100644 --- a/clients/cli/.gitignore +++ b/clients/cli/.gitignore @@ -5,5 +5,3 @@ target/ # These are backup files generated by rustfmt **/*.rs.bk - -.env diff --git a/clients/cli/Cargo.lock b/clients/cli/Cargo.lock index ed2d016..3a10cc5 100644 --- a/clients/cli/Cargo.lock +++ b/clients/cli/Cargo.lock @@ -17,23 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "adler2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" - -[[package]] -name = "aes" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", -] - [[package]] name = "ahash" version = "0.8.11" @@ -147,15 +130,6 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arbitrary" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" -dependencies = [ - "derive_arbitrary", -] - [[package]] name = "ark-bls12-381" version = "0.4.0" @@ -241,7 +215,7 @@ version = "0.4.2" source = "git+https://github.com/arkworks-rs/algebra/?rev=2a80c54#2a80c54687582f49cbbe9a27b94071e1a500f056" dependencies = [ "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -253,7 +227,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -353,7 +327,7 @@ source = "git+https://github.com/arkworks-rs/algebra/?rev=2a80c54#2a80c54687582f dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -389,7 +363,7 @@ dependencies = [ "rand_chacha 0.3.1", "rayon", "sha3 0.8.2", - "thiserror 1.0.63", + "thiserror", ] [[package]] @@ -455,7 +429,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -466,9 +440,15 @@ checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.3.0" @@ -485,29 +465,17 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide 0.7.4", + "miniz_oxide", "object", "rustc-demangle", ] -[[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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bitflags" version = "1.3.2" @@ -643,27 +611,6 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" -[[package]] -name = "bzip2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" -dependencies = [ - "bzip2-sys", - "libc", -] - -[[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "cc" version = "1.1.5" @@ -694,16 +641,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", -] - [[package]] name = "clap" version = "4.5.9" @@ -735,7 +672,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -786,12 +723,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "constant_time_eq" version = "0.3.1" @@ -823,30 +754,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crc" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" - -[[package]] -name = "crc32fast" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" -dependencies = [ - "cfg-if", -] - [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -882,64 +789,12 @@ dependencies = [ "typenum", ] -[[package]] -name = "curve25519-dalek" -version = "4.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" -dependencies = [ - "cfg-if", - "cpufeatures", - "curve25519-dalek-derive", - "digest 0.10.7", - "fiat-crypto", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.90", -] - [[package]] name = "data-encoding" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" -[[package]] -name = "deflate64" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b" - -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "deranged" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", -] - [[package]] name = "derivative" version = "2.2.0" @@ -951,17 +806,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive_arbitrary" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.90", -] - [[package]] name = "digest" version = "0.8.1" @@ -1012,48 +856,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.90", -] - -[[package]] -name = "dotenv" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" - -[[package]] -name = "ed25519" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" -dependencies = [ - "pkcs8", - "signature", -] - -[[package]] -name = "ed25519-dalek" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" -dependencies = [ - "curve25519-dalek", - "ed25519", - "serde", - "sha2", - "signature", - "subtle", - "zeroize", -] - [[package]] name = "either" version = "1.13.0" @@ -1124,40 +926,12 @@ dependencies = [ "subtle", ] -[[package]] -name = "fiat-crypto" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" - -[[package]] -name = "filetime" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" -dependencies = [ - "cfg-if", - "libc", - "libredox", - "windows-sys 0.59.0", -] - [[package]] name = "fixedbitset" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" -[[package]] -name = "flate2" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" -dependencies = [ - "crc32fast", - "miniz_oxide 0.8.0", -] - [[package]] name = "fnv" version = "1.0.7" @@ -1188,16 +962,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "funty" version = "2.0.0" @@ -1260,7 +1024,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -1355,16 +1119,16 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.26" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" dependencies = [ + "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", - "http 0.2.12", + "http", "indexmap", "slab", "tokio", @@ -1452,15 +1216,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - [[package]] name = "home" version = "0.5.9" @@ -1472,9 +1227,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -1482,24 +1237,25 @@ dependencies = [ ] [[package]] -name = "http" -version = "1.1.0" +name = "http-body" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "fnv", - "itoa", + "http", ] [[package]] -name = "http-body" -version = "0.4.6" +name = "http-body-util" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "http 0.2.12", + "futures-util", + "http", + "http-body", "pin-project-lite", ] @@ -1509,47 +1265,77 @@ version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - [[package]] name = "hyper" -version = "0.14.31" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", "h2", - "http 0.2.12", + "http", "http-body", "httparse", - "httpdate", "itoa", "pin-project-lite", - "socket2", + "smallvec", "tokio", - "tower-service", - "tracing", "want", ] +[[package]] +name = "hyper-rustls" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + [[package]] name = "hyper-tls" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", + "http-body-util", "hyper", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", +] + +[[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]] @@ -1608,15 +1394,6 @@ dependencies = [ "web-time", ] -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array 0.14.7", -] - [[package]] name = "ipnet" version = "2.9.0" @@ -1709,7 +1486,6 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.6.0", "libc", - "redox_syscall", ] [[package]] @@ -1728,28 +1504,12 @@ dependencies = [ "scopeguard", ] -[[package]] -name = "lockfree-object-pool" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" - [[package]] name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" -[[package]] -name = "lzma-rs" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e" -dependencies = [ - "byteorder", - "crc", -] - [[package]] name = "matchers" version = "0.1.0" @@ -1798,15 +1558,6 @@ dependencies = [ "adler", ] -[[package]] -name = "miniz_oxide" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" -dependencies = [ - "adler2", -] - [[package]] name = "mio" version = "0.8.11" @@ -1879,7 +1630,7 @@ dependencies = [ [[package]] name = "nexus-network" -version = "0.3.7" +version = "0.3.6" dependencies = [ "ark-bn254", "ark-crypto-primitives", @@ -1900,10 +1651,7 @@ dependencies = [ "clap", "colored", "dirs", - "dotenv", "elf", - "flate2", - "fs2", "futures", "getrandom 0.2.15", "hex", @@ -1923,16 +1671,13 @@ dependencies = [ "serde_json", "serial_test", "sha3 0.10.8", - "tar", "tempfile", "tokio", "tokio-tungstenite", "tracing", "tracing-subscriber 0.3.18", "uuid", - "version", - "zip", - "zstd 0.13.2 (git+https://github.com/gyscos/zstd-rs)", + "zstd 0.13.2", ] [[package]] @@ -1976,7 +1721,7 @@ dependencies = [ "clap", "elf", "serde", - "thiserror 1.0.63", + "thiserror", ] [[package]] @@ -2009,12 +1754,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-conv" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" - [[package]] name = "num-integer" version = "0.1.46" @@ -2099,7 +1838,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -2182,16 +1921,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" -[[package]] -name = "pbkdf2" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" -dependencies = [ - "digest 0.10.7", - "hmac", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -2208,6 +1937,26 @@ dependencies = [ "indexmap", ] +[[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.71", +] + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -2220,16 +1969,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "pkg-config" version = "0.3.30" @@ -2242,12 +1981,6 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2261,14 +1994,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -2300,7 +2033,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.90", + "syn 2.0.71", "tempfile", ] @@ -2314,7 +2047,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -2472,7 +2205,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom 0.2.15", "libredox", - "thiserror 1.0.63", + "thiserror", ] [[package]] @@ -2521,20 +2254,24 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[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", "bytes", "encoding_rs", + "futures-channel", "futures-core", "futures-util", "h2", - "http 0.2.12", + "http", "http-body", + "http-body-util", "hyper", + "hyper-rustls", "hyper-tls", + "hyper-util", "ipnet", "js-sys", "log", @@ -2560,19 +2297,25 @@ dependencies = [ ] [[package]] -name = "rustc-demangle" -version = "0.1.24" +name = "ring" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.15", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] [[package]] -name = "rustc_version" -version = "0.4.1" +name = "rustc-demangle" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" @@ -2587,13 +2330,44 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.23.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "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 = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +dependencies = [ + "base64", + "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.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ - "base64 0.21.7", + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -2668,12 +2442,10 @@ dependencies = [ [[package]] name = "self_update" -version = "0.39.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a34ad8e4a86884ab42e9b8690e9343abdcfe5fa38a0318cfe1565ba9ad437b4" +checksum = "469a3970061380c19852269f393e74c0fe607a4e23d85267382cf25486aa8de5" dependencies = [ - "either", - "flate2", "hyper", "indicatif", "log", @@ -2683,10 +2455,8 @@ dependencies = [ "self-replace", "semver", "serde_json", - "tar", "tempfile", "urlencoding", - "zipsign-api", ] [[package]] @@ -2723,7 +2493,7 @@ checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -2781,7 +2551,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -2859,22 +2629,6 @@ dependencies = [ "libc", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "simd-adler32" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" - [[package]] name = "slab" version = "0.4.9" @@ -2906,16 +2660,6 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -2947,9 +2691,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.90" +version = "2.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" dependencies = [ "proc-macro2", "quote", @@ -2958,9 +2702,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 = "system-configuration" @@ -2989,17 +2733,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "tar" -version = "0.4.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c65998313f8e17d0d553d28f91a0df93e4dbbbf770279c7bc21ca0f09ea1a1f6" -dependencies = [ - "filetime", - "libc", - "xattr", -] - [[package]] name = "tempfile" version = "3.14.0" @@ -3010,7 +2743,7 @@ dependencies = [ "fastrand", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -3019,16 +2752,7 @@ version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ - "thiserror-impl 1.0.63", -] - -[[package]] -name = "thiserror" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" -dependencies = [ - "thiserror-impl 2.0.3", + "thiserror-impl", ] [[package]] @@ -3039,18 +2763,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -3063,25 +2776,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "time" -version = "0.3.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" -dependencies = [ - "deranged", - "num-conv", - "powerfmt", - "serde", - "time-core", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - [[package]] name = "tinyvec" version = "1.8.0" @@ -3124,7 +2818,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -3137,6 +2831,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-tungstenite" version = "0.23.1" @@ -3164,6 +2869,27 @@ dependencies = [ "tokio", ] +[[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.3" @@ -3189,7 +2915,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -3255,13 +2981,13 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.1.0", + "http", "httparse", "log", "native-tls", "rand 0.8.5", "sha1", - "thiserror 1.0.63", + "thiserror", "utf-8", ] @@ -3319,6 +3045,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.2" @@ -3371,12 +3103,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "version" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a449064fee414fcc201356a3e6c1510f6c8829ed28bb06b91c54ebe208ce065" - [[package]] name = "version_check" version = "0.9.5" @@ -3426,7 +3152,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", "wasm-bindgen-shared", ] @@ -3460,7 +3186,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3540,15 +3266,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-targets" version = "0.48.5" @@ -3672,9 +3389,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[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", @@ -3689,17 +3406,6 @@ dependencies = [ "tap", ] -[[package]] -name = "xattr" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" -dependencies = [ - "libc", - "linux-raw-sys", - "rustix", -] - [[package]] name = "zerocopy" version = "0.7.35" @@ -3717,7 +3423,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.71", ] [[package]] @@ -3737,61 +3443,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", -] - -[[package]] -name = "zip" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" -dependencies = [ - "aes", - "arbitrary", - "bzip2", - "constant_time_eq", - "crc32fast", - "crossbeam-utils", - "deflate64", - "displaydoc", - "flate2", - "hmac", - "indexmap", - "lzma-rs", - "memchr", - "pbkdf2", - "rand 0.8.5", - "sha1", - "thiserror 2.0.3", - "time", - "zeroize", - "zopfli", - "zstd 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "zipsign-api" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6413a546ada9dbcd0b9a3e0b0880581279e35047bce9797e523b3408e1df607c" -dependencies = [ - "base64 0.22.1", - "ed25519-dalek", - "thiserror 1.0.63", -] - -[[package]] -name = "zopfli" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946" -dependencies = [ - "bumpalo", - "crc32fast", - "lockfree-object-pool", - "log", - "once_cell", - "simd-adler32", + "syn 2.0.71", ] [[package]] @@ -3803,21 +3455,12 @@ dependencies = [ "zstd-safe 6.0.6", ] -[[package]] -name = "zstd" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" -dependencies = [ - "zstd-safe 7.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "zstd" version = "0.13.2" source = "git+https://github.com/gyscos/zstd-rs#59e1da7f2a1c0c3d10b796e059fd4193ea74c62e" dependencies = [ - "zstd-safe 7.2.1 (git+https://github.com/gyscos/zstd-rs)", + "zstd-safe 7.2.1", ] [[package]] @@ -3830,15 +3473,6 @@ dependencies = [ "zstd-sys", ] -[[package]] -name = "zstd-safe" -version = "7.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" -dependencies = [ - "zstd-sys", -] - [[package]] name = "zstd-safe" version = "7.2.1" diff --git a/clients/cli/Cargo.toml b/clients/cli/Cargo.toml index e17faf6..23b218b 100644 --- a/clients/cli/Cargo.toml +++ b/clients/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nexus-network" -version = "0.3.7" +version = "0.3.6" edition = "2021" [[bin]] @@ -33,7 +33,7 @@ clap = { version = "4.5", features = ["derive"] } futures = "0.3" prost = "0.13" rand = "0.8.5" -reqwest = { version = "0.11", features = ["blocking"] } +reqwest = { version = "0.12", features = ["json"] } tokio = { version = "1.38", features = ["full"] } tokio-tungstenite = { version = "0.23", features = ["native-tls"] } tracing = "0.1" @@ -78,18 +78,11 @@ ark-vesta = "0.4.0" ark-test-curves = { version = "0.4.2", features = ["bls12_381_curve"] } iana-time-zone = "0.1.60" chrono = "0.4.38" -self_update = { version = "0.39", features = ["archive-tar", "compression-flate2"] } +self_update = "0.41.0" dirs = "5.0.1" semver = "1.0.23" parking_lot = "0.12.3" colored = "2.1.0" -version = "3.0.0" -tempfile = "3.14.0" -dotenv = "0.15.0" -fs2 = "0.4.3" -flate2 = "1.0.35" -tar = "0.4.43" -zip = "2.2.1" [patch.crates-io] ark-crypto-primitives = { git = "https://github.com/arkworks-rs/crypto-primitives", rev = "d27a5c8" } diff --git a/clients/cli/README.md b/clients/cli/README.md index d2fe917..81fd07c 100644 --- a/clients/cli/README.md +++ b/clients/cli/README.md @@ -47,6 +47,7 @@ add `NONINTERACTIVE=1` before `sh`. ## Known issues * Only the latest version of the CLI is currently supported. +* Prebuilt binaries are not yet available. * Linking email to prover id is currently available on the web version only. * Counting cycles proved is not yet available in the CLI. * Only proving is supported. Submitting programs to the network is in private beta. @@ -70,37 +71,6 @@ To run the CLI with tracing enabled, run: cargo run -- beta.orchestrator.nexus.xyz ``` -### Building a release binary - -```sh -# Build a release binary for Apple Silicon (M1/M2) Mac -cargo build --release --target aarch64-apple-darwin - -# Build a release binary for Intel Mac -cargo build --release --target x86_64-apple-darwin - -# Create a tarball for Apple Silicon (M1/M2) Mac binary and return to original directory -cd target/aarch64-apple-darwin/release && tar -czf aarch64-apple-darwin.tar.gz ./prover && cd - - -# Create a tarball for Intel Mac binary and return to original directory -cd target/x86_64-apple-darwin/release && tar -czf x86_64-apple-darwin.tar.gz ./prover && cd - - -# Test the binary (use appropriate path based on target) -./target/aarch64-apple-darwin/release/prover --version - -# Run the binary (use appropriate path based on target) -./target/aarch64-apple-darwin/release/prover beta.orchestrator.nexus.xyz -``` - -Note: Make sure you have the appropriate target installed via rustup: -```sh -# Add required target(s) -rustup target add aarch64-apple-darwin -rustup target add x86_64-apple-darwin -rustup target add x86_64-unknown-linux-gnu -rustup target add aarch64-unknown-linux-gnu -``` - ## Resources * [Network FAQ](https://nexus.xyz/network#network-faqs) diff --git a/clients/cli/src/prover.rs b/clients/cli/src/prover.rs index 4ea1c46..fb9b181 100644 --- a/clients/cli/src/prover.rs +++ b/clients/cli/src/prover.rs @@ -1,7 +1,5 @@ // Copyright (c) 2024 Nexus. All rights reserved. -pub const VERSION: &str = env!("CARGO_PKG_VERSION"); - mod analytics; mod config; mod connection; @@ -53,13 +51,12 @@ use std::fs::File; use std::io::Read; use zstd::stream::Encoder; -use crate::utils::updater::UpdaterConfig; +use crate::utils::updater::{AutoUpdaterMode, UpdaterConfig}; // The interval at which to send updates to the orchestrator const PROOF_PROGRESS_UPDATE_INTERVAL_IN_SECONDS: u64 = 180; // 3 minutes #[derive(Parser, Debug)] -#[command(author, version, about, long_about = None)] struct Args { /// Hostname at which Orchestrator can be reached hostname: String, @@ -71,16 +68,13 @@ struct Args { /// Whether to hang up after the first proof #[arg(short, long, default_value_t = false)] just_once: bool, + + /// Mode for the auto updater (production/test) + #[arg(short, long, value_enum, default_value_t = AutoUpdaterMode::Production)] + updater_mode: AutoUpdaterMode, } fn get_file_as_byte_vec(filename: &str) -> Vec { - // First try to load from binary - let binary_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join(filename); - if let Ok(bytes) = std::fs::read(&binary_path) { - return bytes; - } - - // Fall back to filesystem if binary load fails let mut f = File::open(filename).expect("no file found"); let metadata = fs::metadata(filename).expect("unable to read metadata"); let mut buffer = vec![0; metadata.len() as usize]; @@ -116,10 +110,10 @@ async fn main() -> Result<(), Box> { // Initialize the CLI auto-updater that checks for and applies updates to the CLI: // a. Create the updater config - let updater_config = UpdaterConfig::new(args.hostname.clone()); + let updater_config = UpdaterConfig::new(args.updater_mode, args.hostname); - // Start a new thread for the auto-updater checker that periodically checks for and applies updates - updater::spawn_auto_update_thread(&updater_config)?; + // b. runs the CLI's auto updater in a separate thread continuously in intervals + updater::spawn_auto_update_thread(&updater_config).expect("Failed to spawn auto-update thread"); let k = 4; // TODO(collinjackson): Get parameters from a file or URL. diff --git a/clients/cli/src/prover_id_manager.rs b/clients/cli/src/prover_id_manager.rs index 83598fc..32a71da 100644 --- a/clients/cli/src/prover_id_manager.rs +++ b/clients/cli/src/prover_id_manager.rs @@ -33,7 +33,7 @@ pub fn get_or_generate_prover_id() -> String { Err(e) => { eprintln!( "{}: {}", - "\nWarning: Could not read prover-id file" + "Warning: Could not read prover-id file" .to_string() .yellow(), e diff --git a/clients/cli/src/updater.rs b/clients/cli/src/updater.rs index d8cad8e..9d3c7ea 100644 --- a/clients/cli/src/updater.rs +++ b/clients/cli/src/updater.rs @@ -1,86 +1,83 @@ //! Auto-updater implementation for the CLI //! -//! This module provides two main functions: -//! - `check_and_use_binary`: Validates the binary location and handles process spawning -//! - `spawn_auto_update_thread`: Manages the background update process +//! This module handles automatic updates by running a background thread that: +//! - Periodically checks for new versions +//! - Downloads and applies updates when available +//! - Restarts the CLI with the new version //! -//! The update process: -//! 1. Verifies the binary location and handles process respawning if needed -//! 2. Runs version checks in a background thread at configured intervals -//! 3. Downloads and applies updates automatically when new versions are found -//! 4. Handles process replacement with the new version -//! -//! The updater uses environment flags to prevent recursive spawning and supports -//! both default and custom binary locations. +//! The updater runs in a separate thread to avoid blocking the main CLI operations, +//! allowing users to continue using the CLI while update checks happen in the background. -use semver::Version; -// use std::process::Command; use std::sync::Arc; use std::{thread, time::Duration}; -use tracing::error; -use crate::utils::updater::{ - // get_binary_path, - UpdaterConfig, - VersionManager, - VersionStatus, - RESET, - UPDATER_COLOR, -}; +use crate::utils::updater::{UpdaterConfig, VersionManager, VersionStatus, BLUE, RESET}; + +// We spawn a separate thread for periodic update checks because the auto-updater runs in an infinite loop +// that would otherwise block the main CLI process. By running in a background thread: -/// Spawns a background thread to check for and apply updates +// 1. The update checker can continuously monitor for new versions without interrupting the main CLI operations +// 2. The main thread remains free to handle its primary responsibility (proving transactions) +// 3. Users don't have to wait for update checks to complete before using the CLI pub fn spawn_auto_update_thread( updater_config: &UpdaterConfig, ) -> Result<(), Box> { - let version_manager = Arc::new(VersionManager::new(updater_config.clone())?); - let version_manager_thread = version_manager.clone(); - let update_interval = updater_config.update_interval; + println!( + "{}[auto-updater]{} Starting periodic CLI updates...", + BLUE, RESET + ); + + // Create a thread-safe version manager that can be shared across threads + let version_manager: Arc = Arc::new( + VersionManager::new(updater_config.clone()).expect("Failed to initialize version manager"), + ); - // Spawn a new thread to periodically check for and apply updates - // This thread will run indefinitely until the process is killed - thread::spawn(move || loop { - match version_manager_thread.update_version_status() { - // If a new version is available, download and apply it... - Ok(VersionStatus::UpdateAvailable(new_version)) => { - // get the current version running - let current_version = match version_manager_thread.get_current_version() { - Ok(version) => version, - Err(_) => Version::parse(crate::VERSION).unwrap(), - }; + // Create a reference for the new thread (original stays with main thread) + let version_manager_thread: Arc = version_manager.clone(); - println!( - "{}[auto-updater]{} New version {} available (current: {}) - downloading new binary...\n", - UPDATER_COLOR, RESET, new_version, current_version - ); + let update_interval = updater_config.update_interval; + + // Spawn the update checker thread + thread::spawn(move || { + println!( + "{}[auto-updater]{} Update checker thread started!", + BLUE, RESET + ); - // Apply the update - if let Err(e) = version_manager_thread.apply_update(&new_version) { - error!("Failed to update CLI: {}", e); - } else { - println!( - "{}[auto-updater]{}\t\t 6. ✅ Successfully updated CLI to version {}", - UPDATER_COLOR, RESET, new_version + // Infinite loop to check for updates + loop { + match version_manager_thread.as_ref().update_version_status() { + // Got the latest version info with no error.... + Ok(version_info) => match version_info { + // ... there is an update available, try to apply it + VersionStatus::UpdateAvailable(new_version) => { + if let Err(e) = version_manager_thread.apply_update(&new_version) { + println!( + "{}[auto-updater]{} Failed to update CLI: {}", + BLUE, RESET, e + ) + } + } + // ... No update needed + VersionStatus::UpToDate => { + println!("{}[auto-updater]{} CLI is up to date", BLUE, RESET); + } + }, + Err(e) => { + eprintln!( + "{}[auto-updater]{} Failed to check version: {}", + BLUE, RESET, e ); } } - // If we're up to date, just print a message - Ok(VersionStatus::UpToDate) => { - let current_version = match version_manager_thread.get_current_version() { - Ok(version) => version, - Err(_) => Version::parse(crate::VERSION).unwrap(), - }; - println!( - "{}[auto-updater]{} CLI is up to date (version: {})", - UPDATER_COLOR, RESET, current_version - ); - } - // If there's an error, print it - Err(e) => error!("Failed to check version: {}", e), + // Wait for the next update check + println!( + "{}[auto-updater]{} Next update check in {} seconds...\n", + BLUE, RESET, update_interval + ); + thread::sleep(Duration::from_secs(update_interval)); } - - // Sleep for the update interval - thread::sleep(Duration::from_secs(update_interval)); }); Ok(()) diff --git a/clients/cli/src/utils/updater.rs b/clients/cli/src/utils/updater.rs index 3e572e0..0c4d00f 100644 --- a/clients/cli/src/utils/updater.rs +++ b/clients/cli/src/utils/updater.rs @@ -1,23 +1,41 @@ //! Core auto-updater functionality and version management //! -//! This module provides the underlying implementation for version checking and updates -//! using the self_update crate to handle version management and updates from GitHub releases. +//! This module provides the underlying implementation for: +//! - Version tracking and persistence +//! - Git-based version detection +//! - Update application logic +//! - Process management for CLI restarts +//! +//! The code here is used by the auto-updater thread (./updater.rs) to handle the mechanics of +//! checking versions and applying updates in both test and production environments. -use self_update::{cargo_crate_version, self_replace, ArchiveKind, Compression, Extract}; +use parking_lot::RwLock; use semver::Version; use std::os::unix::process::CommandExt; -use std::path::Path; -// use std::process::Command; +use std::sync::Arc; +use std::{fs, process::Command}; -// ANSI escape codes for colors for pretty printing -pub const GREEN: &str = "\x1b[32m"; // Used to test if binary is replaced -pub const BLUE: &str = "\x1b[34m"; -pub const UPDATER_COLOR: &str = BLUE; +// Constants -pub const RESET: &str = "\x1b[0m"; +// ANSI escape codes for colors for pretty printing +pub const BLUE: &str = "\x1b[34m"; // Normal blue +pub const RESET: &str = "\x1b[0m"; // Reset color + +// The file to store the current version in +pub const VERSION_FILE: &str = ".current_version"; +pub const REMOTE_REPO: &str = "https://github.com/nexus-xyz/network-api"; +pub const FALLBACK_VERSION: Version = Version::new(0, 3, 6); // 0.3.6 + +#[derive(Debug, Clone, Copy, PartialEq, clap::ValueEnum)] +pub enum AutoUpdaterMode { + Production, + Test, +} +/// Struct to manage the updater configuration #[derive(Clone)] pub struct UpdaterConfig { + pub mode: AutoUpdaterMode, pub update_interval: u64, pub repo_path: String, pub remote_repo: String, @@ -25,303 +43,302 @@ pub struct UpdaterConfig { } impl UpdaterConfig { - pub fn new(hostname: String) -> Self { - #[cfg(debug_assertions)] - let config = Self { - repo_path: std::env::current_dir() - .expect("Failed to get current directory") - .to_string_lossy() - .into_owned(), - remote_repo: String::from("."), - update_interval: 30, // 30 seconds in debug mode - hostname, - }; - - #[cfg(not(debug_assertions))] - let config = Self { - repo_path: format!( - "{}/.nexus/network-api", - std::env::var("HOME").unwrap_or_default() - ), - remote_repo: String::from("https://github.com/nexus-xyz/network-api.git"), - update_interval: 3600, // 1 hour in release mode - hostname, - }; - - println!( - "{}[auto-updater]{} Checking for updates in {} seconds", - UPDATER_COLOR, RESET, config.update_interval - ); - - config + pub fn new(mode: AutoUpdaterMode, hostname: String) -> Self { + match mode { + AutoUpdaterMode::Production => Self { + mode, + repo_path: format!( + "{}/.nexus/network-api", + std::env::var("HOME").unwrap_or_default() + ), + remote_repo: String::from("https://github.com/nexus-xyz/network-api.git"), + update_interval: 3600, // check for updates every 1 hour (3600 seconds) + hostname, + }, + AutoUpdaterMode::Test => Self { + mode, + repo_path: std::env::current_dir() + .expect("Failed to get current directory") + .to_string_lossy() + .into_owned(), + remote_repo: String::from("."), + update_interval: 30, // check for updates every 30 seconds + hostname, + }, + } } } pub enum VersionStatus { - UpdateAvailable(Version), + UpdateAvailable(Version), // in case there is an update available, there is a semver `Version` type UpToDate, } +// Struct to manage the version of the CLI it is running at all times +// This is also used to check for updates and apply them pub struct VersionManager { - // version_file: std::path::PathBuf, + current_version: Arc>, + config: UpdaterConfig, } impl VersionManager { - pub fn new(_config: UpdaterConfig) -> Result> { - // Return an instance - Ok(Self {}) + /// Initialize the version manager + pub fn new(config: UpdaterConfig) -> Result> { + let current_version = Arc::new(RwLock::new( + read_version_from_file().unwrap_or(FALLBACK_VERSION), + )); + Ok(Self { + current_version, + config, + }) } - // Checks GitHub for available updates by comparing the current version against the latest target release - pub fn update_version_status(&self) -> Result> { - println!( - "{}[auto-updater]{} Checking for updates...", - UPDATER_COLOR, RESET - ); + /// Fetch the current version of the CLI and persist it to a file + pub fn fetch_and_persist_cli_version(&self) -> Result> { + // 1. Get the current git tag version (which depends on the updater mode) + let current_git_version = self.get_cli_release_version(false)?; - let current_version = self.get_current_version()?; + // 2. Convert the semver to a number and write it to a file (so it can persist across updates) + write_version_to_file(¤t_git_version)?; - let latest_release = tokio::task::block_in_place(|| { - let mut config = self_update::backends::github::Update::configure(); - let target = self_update::get_target(); + println!( + "{}[auto-updater]{} Wrote version to file: {}", + BLUE, RESET, current_git_version + ); - let update_builder = config - .repo_owner("nexus-xyz") - .repo_name("network-api") - .bin_name("prover") - .current_version(cargo_crate_version!()) - .target(target) - .no_confirm(true); + Ok(current_git_version) + } - match update_builder.build()?.get_latest_release() { - Ok(release) => Ok(release), - Err(e) => { - println!( - "{}[auto-updater]{} No updates available for your platform ({}).\nError: {}", - UPDATER_COLOR, RESET, target, e - ); - println!( - "{}[auto-updater]{} Please stop the CLI and run `curl https://cli.nexus.xyz/ | sh` to update the CLI manually", - UPDATER_COLOR, RESET - ); - Err(e) - } + /// Get the latest release version of the CLI + fn get_cli_release_version( + &self, + should_write: bool, + ) -> Result> { + let version = match self.config.mode { + AutoUpdaterMode::Test => { + let output = Command::new("git") + .args(["describe", "--tags", "--abbrev=0"]) + .current_dir(&self.config.repo_path) + .output()?; + Version::parse(String::from_utf8(output.stdout)?.trim())? } - })?; + AutoUpdaterMode::Production => { + // Get only version tags (X.Y.Z format) from remote + // This filters out non-release tags using git's pattern matching + // Example matches: "1.2.3", "0.3.5" + // Won't match: "latest", "stable", or other non-version tags + let output = Command::new("git") + .args([ + "ls-remote", + "--refs", + &self.config.remote_repo, + "refs/tags/[0-9]*.[0-9]*.[0-9]*", // Only match semantic version tags + ]) + .output()?; + + let tags = String::from_utf8(output.stdout)?; + + // Process the version tags: + // 1. Split each line and get the tag name + // 2. Parse into semver Version type (validates format) + // 3. Find the highest version number + tags.lines() + .filter_map(|line| line.split('/').last()) + .filter_map(|tag| Version::parse(tag).ok()) + .max() + .ok_or("No release versions found")? + } + }; - // Compare versions - if current_version.to_string() == latest_release.version { + // Optionally persist the version to disk + if should_write { + write_version_to_file(&version)?; println!( - "{}[auto-updater]{} Versions match - no update needed", - UPDATER_COLOR, RESET + "{}[auto-updater]{} Wrote version to file: {}", + BLUE, RESET, version ); - Ok(VersionStatus::UpToDate) - } else { - println!( - "{}[auto-updater]{} Update available: {} -> {}", - UPDATER_COLOR, RESET, current_version, latest_release.version - ); - Ok(VersionStatus::UpdateAvailable(Version::parse( - &latest_release.version, - )?)) } - } - pub fn apply_update( - &self, - new_version: &Version, - ) -> Result<(), Box> { - println!( - "{}[auto-updater]{} \t\t 1. Inspecting update version {}...", - UPDATER_COLOR, RESET, new_version - ); - - // Create a temporary directory for extraction - let temp_dir = tempfile::Builder::new() - .prefix("prover-update") - .tempdir() - .map_err(|e| Box::new(e) as Box)?; - - // Download the new precompiled binary from GitHub - let mut config = self_update::backends::github::Update::configure(); - let mut update_builder = config.repo_owner("nexus-xyz"); - update_builder = update_builder - .repo_name("network-api") - .bin_name("prover") - .current_version(cargo_crate_version!()) - .target(self_update::get_target()) - .no_confirm(true); - - // Get the latest release from GitHub - let release = update_builder - .build() - .map_err(|e| Box::new(e) as Box)? - .get_latest_release() - .map_err(|e| Box::new(e) as Box)?; - - // Get the asset that matches the target platform - let target = self_update::get_target(); - let asset = release - .assets - .iter() - .find(|a| a.name == format!("{}.tar.gz", target)) - .ok_or_else(|| { - Box::new(std::io::Error::new( - std::io::ErrorKind::NotFound, - format!( - "No binary available for your platform ({}). Please check https://github.com/nexus-xyz/network-api/releases for supported platforms.", - target - ), - )) as Box - })?; + Ok(version) + } + /// Apply an update to the CLI given a new version + pub fn apply_update(&self, new_version: &Version) -> Result<(), Box> { println!( - "{}[auto-updater]{}\t\t 2. Downloading archive: {}", - UPDATER_COLOR, RESET, asset.name + "{}[auto-updater]{} Using repo path: {}", + BLUE, RESET, self.config.repo_path ); - // Download to temp file - let download_path = temp_dir.path().join(&asset.name); - let request = reqwest::blocking::Client::new() - .get(&asset.download_url) - .header("Accept", "application/octet-stream") - // Add a user agent to identify the updater (necessary for GitHub API not throttling requests) - .header("User-Agent", "NexusUpdater/0.3.7"); - - let response = request.send().map_err(|e| { - eprintln!("Failed to send request: {:?}", e); - Box::new(e) as Box - })?; - - // Check if the response is successful - if !response.status().is_success() { - eprintln!("Failed to download file: HTTP {}", response.status()); - let error_body = response - .text() - .unwrap_or_else(|_| "Unable to read error body".to_string()); - eprintln!("Error body: {}", error_body); - return Err(Box::new(std::io::Error::new( - std::io::ErrorKind::Other, - "Failed to download file", - )) as Box); + let repo_path = std::path::Path::new(&self.config.repo_path); + if !repo_path.exists() { + return Err(format!("Repository not found at: {}", self.config.repo_path).into()); } - let mut file = std::fs::File::create(&download_path).map_err(|e| { - eprintln!("Failed to create file: {:?}", e); - Box::new(e) as Box - })?; - std::io::copy( - &mut response - .bytes() - .map_err(|e| { - eprintln!("Failed to read response bytes: {:?}", e); - Box::new(e) as Box - })? - .as_ref(), - &mut file, - ) - .map_err(|e| { - eprintln!("Failed to write to file: {:?}", e); - Box::new(e) as Box - })?; - - // Get the file size - let file_size = std::fs::metadata(&download_path) - .map_err(|e| Box::new(e) as Box)? - .len(); - - println!( - "{}[auto-updater]{}\t\t 3. Archive downloaded to: {:?} (size: {} bytes)", - UPDATER_COLOR, RESET, download_path, file_size - ); - - // Use the existing temporary directory for extraction - let extract_path = temp_dir.path(); - - // Extract and inspect the contents - match extract_and_prepare_update(&download_path, extract_path) { - Ok(_) => { - // Define the path to the new executable - let new_exe_path = extract_path.join("prover"); // Adjust "prover" to the actual executable name - - // Apply the update + match self.config.mode { + AutoUpdaterMode::Test => { println!( - "{}[auto-updater]{}\t\t 4.Attempting to replace binary at {:?}", - UPDATER_COLOR, - RESET, - std::env::current_exe().unwrap_or_default() + "{}[auto-updater]{} Building version {} from local repository...", + BLUE, RESET, new_version ); - - if let Err(e) = self_replace::self_replace(&new_exe_path) { - eprintln!( - "{}[auto-updater]{} Failed to apply update: {}", - UPDATER_COLOR, RESET, e - ); - return Err(Box::new(e) as Box); + let build_output = Command::new("cargo") + .args(["build", "--release"]) + .current_dir(repo_path) + .output()?; + + if !build_output.status.success() { + return Err(format!( + "Build failed: {}", + String::from_utf8_lossy(&build_output.stderr) + ) + .into()); } - - // Replace current process with new binary - if let Ok(current_exe) = std::env::current_exe() { - let args: Vec = std::env::args().skip(1).collect(); + } + AutoUpdaterMode::Production => { + if repo_path.read_dir()?.next().is_none() { println!( - "{}[auto-updater]{}\t\t 5.Replacing current process with a new one using the args: {:?}", - UPDATER_COLOR, RESET, args + "{}[auto-updater]{} Cloning remote repository...", + BLUE, RESET ); + Command::new("git") + .args(["clone", &self.config.remote_repo, &self.config.repo_path]) + .output()?; + } + + println!("{}[auto-updater]{} Fetching updates...", BLUE, RESET); + Command::new("git") + .args(["fetch", "--all", "--tags", "--prune"]) + .current_dir(repo_path) + .output()?; - std::process::Command::new(current_exe).args(args).exec(); // Replace current process entirely + println!( + "{}[auto-updater]{} Checking out version {}...", + BLUE, RESET, new_version + ); + let checkout_output = Command::new("git") + .args(["checkout", &format!("tags/{}", new_version)]) + .current_dir(repo_path) + .output()?; + + if !checkout_output.status.success() { + return Err(format!( + "Failed to checkout version: {}", + String::from_utf8_lossy(&checkout_output.stderr) + ) + .into()); } - // This line will only be reached if exec fails - std::process::exit(1); - } - Err(e) => { - eprintln!( - "{}[auto-updater]{} Failed to extract and inspect: {}", - UPDATER_COLOR, RESET, e + println!( + "{}[auto-updater]{} Building version {} from remote repository...", + BLUE, RESET, new_version ); - Err(e) + let build_output = Command::new("cargo") + .args(["build", "--release"]) + .current_dir(repo_path) + .output()?; + + if !build_output.status.success() { + return Err(format!( + "Build failed: {}", + String::from_utf8_lossy(&build_output.stderr) + ) + .into()); + } } } - } - pub fn get_current_version(&self) -> Result> { - let version = cargo_crate_version!(); - Ok(Version::parse(version)?) + restart_cli_process_with_new_version(new_version, &self.current_version, &self.config) } -} -pub fn get_binary_path() -> std::path::PathBuf { - let home = std::env::var("HOME").unwrap_or_default(); - std::path::PathBuf::from(format!("{}/.nexus/bin", home)) -} + /// update the version status of the CLI. is there an update available? + pub fn update_version_status(&self) -> Result> { + let this_repo_version = self.current_version.read().clone(); -fn extract_and_prepare_update( - archive_path: &Path, - extract_path: &Path, -) -> Result<(), Box> { - // Attempt to extract the archive - match Extract::from_source(archive_path) - .archive(ArchiveKind::Tar(Some(Compression::Gz))) - .extract_into(extract_path) - { - Ok(_) => { - // Print the extracted files for inspection - for entry in std::fs::read_dir(extract_path) - .map_err(|e| Box::new(e) as Box)? - { - let entry = entry.map_err(|e| Box::new(e) as Box)?; + // debug output + println!( + "{}[auto-updater thread]{} Checking for updates from: {}", + BLUE, RESET, self.config.remote_repo + ); + + let latest_version = match self.get_cli_release_version(false) { + Ok(version) => version, + Err(e) => { println!( - "{}[auto-updater]{} \t\t\tExtracted file: {:?}", - UPDATER_COLOR, - RESET, - entry.path() + "{}[auto-updater thread]{} Version check failed: {}", + BLUE, RESET, e ); + return Ok(VersionStatus::UpToDate); // Gracefully handle error by assuming up-to-date } - Ok(()) - } - Err(e) => { - eprintln!("Failed to extract archive: {:?}", e); - Err(Box::new(e) as Box) + }; + + println!( + "{}[auto-updater]{} Current version of CLI: {} | Latest version of CLI: {}", + BLUE, RESET, this_repo_version, latest_version + ); + + if this_repo_version == latest_version { + Ok(VersionStatus::UpToDate) + } else { + Ok(VersionStatus::UpdateAvailable(latest_version)) } } } + +/// function to read the current git tag version from a file +pub fn read_version_from_file() -> Result> { + let version_str = fs::read_to_string(VERSION_FILE)?; + Ok(Version::parse(&version_str)?) +} + +/// function to write the current git tag version to a file so it can be read by the updater thread +/// We write to a file because storing the version in memory is not persistent across updates +pub fn write_version_to_file(version: &Version) -> Result<(), Box> { + fs::write(VERSION_FILE, version.to_string())?; + Ok(()) +} + +/// Restart the CLI process with a new version +pub fn restart_cli_process_with_new_version( + new_version: &Version, + current_version: &Arc>, + config: &UpdaterConfig, +) -> Result<(), Box> { + // Update version tracking + *current_version.write() = new_version.clone(); + write_version_to_file(new_version)?; + + let cli_path = std::path::Path::new(&config.repo_path); + + let mode_arg = match config.mode { + AutoUpdaterMode::Test => "test", + AutoUpdaterMode::Production => "production", + }; + + let child = Command::new("cargo") + .args([ + "run", + "--release", + "--", + &config.hostname, + "--updater-mode", + mode_arg, + ]) + .current_dir(cli_path) + .process_group(0) + .spawn()?; + + // Write the new PID to a file + std::fs::write(".prover.pid", child.id().to_string())?; + + println!( + "{}[auto-updater]{} Started new process with PID: {}", + BLUE, + RESET, + child.id() + ); + println!( + "{}[auto-updater]{} Restarting with new version...", + BLUE, RESET + ); + + std::process::exit(0); +} diff --git a/tests/test_updater.sh b/tests/test_updater.sh new file mode 100755 index 0000000..300b9bc --- /dev/null +++ b/tests/test_updater.sh @@ -0,0 +1,153 @@ +#!/bin/bash + +# Test Auto-updater Functionality +# +# This script tests the CLI's auto-update mechanism by: +# 1. Setting up a clean test environment +# 2. Starting CLI with initial version +# 3. Simulating a new version release +# 4. Verifying update and process handoff +# 5. Cleaning up processes and test files +# +# Usage: ./test_updater.sh +# Requires: git, cargo +# Cleanup: Automatically kills processes and removes test directory on exit +# +# Note: Uses trap to ensure cleanup even if script is interrupted + +set -e # Exit on any error + +# Configuration +ORCHESTRATOR_HOST="beta.orchestrator.nexus.xyz" +# The new version number used to test the updater +TEST_NEW_VERSION="0.9.9" + +# Variables used for pretty printing in colors +ORANGE='\033[1;33m' +NC='\033[0m' # No Color + +# Find project root (assuming script is in tests/) +PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +# Setup cleanup trap +cleanup() { + echo -e "${ORANGE}[test-updater script] (14 / 18) Cleaning up...${NC}" + + if [ -n "$NEW_PID" ]; then + # Kill the new prover process if it exists + echo -e "${ORANGE}[test-updater script] (15 / 18) Killing newest prover process...${NC}" + kill $NEW_PID 2>/dev/null || true + fi + if [ -n "$ORIGINAL_PID" ]; then + # Kill the original prover process if it exists + echo -e "${ORANGE}[test-updater script] (16 / 18) Killing original prover process...${NC}" + kill $ORIGINAL_PID 2>/dev/null || true + fi + # Wait a moment for processes to terminate + echo -e "${ORANGE}[test-updater script] (17 / 18) Waiting for processes to terminate...${NC}" + sleep 2 + # Remove test directory + if [ -n "$TEST_DIR" ]; then + echo -e "${ORANGE}[test-updater script] (18 / 18) Removing test directory...${NC}" + rm -rf "$TEST_DIR" + fi + # Return to original directory + cd "$PROJECT_ROOT" + echo "Cleanup complete" + exit 0 +} + +# Trap cleanup on script exit, interrupts (Ctrl+C), and termination +# This ensures that the cleanup is called even if the script is interrupted or terminated +trap cleanup EXIT +trap cleanup INT +trap cleanup TERM + +# Create clean test directory +TEST_DIR=$(mktemp -d) +echo " " +echo -e "${ORANGE}[test-updater script] (1 / 18) Starting test for auto-updater...${NC}" +echo -e "${ORANGE}[test-updater script] (2 / 18) Setting up test directory in $TEST_DIR${NC}" +echo -e "${ORANGE}[test-updater script] (3 / 18) Setting up git and files...${NC}" + +echo " " + + +# Copy your local files to test directory +cd $PROJECT_ROOT +cp -r . $TEST_DIR/ +cd $TEST_DIR + +# Remove existing .git and start fresh +rm -rf .git +git init +git add . +git commit -m "Initial commit" +git tag 0.3.5 # Start with old version + +# Build and start the CLI +cd clients/cli +echo " " +echo -e "${ORANGE}[test-updater script] (4 / 18) Building project from local source code (no git pull) with cargo...${NC}" +CARGO_CMD="cargo build --release" +$CARGO_CMD || exit 1 + +INSTALL_PATH="$TEST_DIR/clients/cli/target/release/prover" +echo -e "${ORANGE}[test-updater script] (5 / 18) Binary path: $INSTALL_PATH ${NC}" + +# Start CLI and store its PID in the memory of this bash script +# note: the PID is ALSO stored in the .prover.pid file by the updater.rs, but this one is just for in-memory testing/validating +echo " " +echo -e "${ORANGE}[test-updater script] (6 / 18) Starting CLI v1.0...${NC}" +echo " " +STARTING_COMMIT=$(git rev-parse HEAD) +$INSTALL_PATH --updater-mode test $ORCHESTRATOR_HOST & # Start CLI with updater mode test +ORIGINAL_PID=$! +echo -e "${ORANGE}[test-updater script] (7 / 18) Original PID for the CLI main process: $ORIGINAL_PID${NC}" +echo " " + +# Give CLI some timee to start the proving by starting the main thread at prover.rs +sleep 30 + +# Create new version with higher number than 0.3.5 +# This section represents what may happen in the wild: the code is updated on github with a new tag +echo " " +echo -e "${ORANGE}[test-updater script] (8 / 18) Adding new code to test auto-update...${NC}" +echo "updated" > test.txt +git add test.txt +git commit -m "Update" +git tag $TEST_NEW_VERSION # Use a version higher than current +echo -e "${ORANGE}[test-updater script] new code added and committed. New tag version: $TEST_NEW_VERSION${NC}" + +# Wait for auto-update to happen +echo -e "${ORANGE}[test-updater script] (9 / 18) Waiting 60 seconds for auto-update to catch the new version...${NC}" +echo " " +sleep 60 # Give the updater time to detect and apply update (it checks every 20 seconds) +echo -e "${ORANGE}[test-updater script] (10 / 18) Checking if the updater applied the update...${NC}" +echo " " + +# { During this time, he updater should have updated the code and restarted with a new process } + +# The updater should have written the new version to the file +NEW_VERSION=$(cat .current_version) +echo -e "${ORANGE}[test-updater script] New version: $NEW_VERSION${NC}" + + +# Verify that the new version is running in a new process (e.g. CLI restarted) +NEW_PID="$(cat .prover.pid 2>/dev/null || echo "")" # Read PID from file +echo -e "${ORANGE}[test-updater script] New PID: $NEW_PID${NC}" + +# if the new PID is empty, the CLI is not running +if [ -z "$NEW_PID" ] || ! ps -p "$NEW_PID" > /dev/null; then + echo -e "${ORANGE}❌ CLI is not running!${NC}" + exit 1 +fi + +# If the new PID is the same as the original PID, the CLI was not restarted (same process) +if [ "$NEW_PID" == "$ORIGINAL_PID" ]; then + echo -e "${ORANGE}[test-updater script] (12 / 18) ❌ CLI was not restarted \(PID unchanged\)${NC}" + echo -e "${ORANGE}[test-updater script] (13 / 18) Original version: $(git describe --tags $STARTING_COMMIT)${NC}. Expected version: $TEST_NEW_VERSION${NC}" + exit 1 +fi + +echo -e "${ORANGE}[test-updater script] (14 / 18) ✅ CLI auto-updated and restarted successfully${NC}" \ No newline at end of file diff --git a/tests/updater.sh b/tests/updater.sh deleted file mode 100755 index d74bd63..0000000 --- a/tests/updater.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash - -set -e # Exit on any error - -# Configuration -ORCHESTRATOR_HOST="beta.orchestrator.nexus.xyz" -OLD_VERSION="0.3.6" -EXPECTED_NEW_VERSION="0.3.7" -TEST_DIR="" - -# Colors for output -ORANGE='\033[1;33m' -NC='\033[0m' # No Color -GREEN='\033[0;32m' -BLUE='\033[0;34m' - -cleanup() { - # Kill any running prover processes started by this test - if [ -n "$INITIAL_PID" ]; then - echo -e "${ORANGE}Killing prover process...${NC}" - pkill -P $INITIAL_PID 2>/dev/null || true - kill $INITIAL_PID 2>/dev/null || true - fi - - # Clean up test directory - if [ -n "$TEST_DIR" ]; then - echo -e "${ORANGE}Cleaning up test directory...${NC}" - rm -rf "$TEST_DIR" - fi - - # Clean up any existing version files in the development directory - echo -e "${ORANGE}Cleaning up version files...${NC}" - rm -f "$(pwd)/.nexus/bin/version" 2>/dev/null || true - rm -f ".nexus/bin/version" 2>/dev/null || true -} - -trap cleanup EXIT INT TERM - -# Create test directory and setup -TEST_DIR=$(mktemp -d) -echo -e "${ORANGE}1. Setting up test in $TEST_DIR${NC}\n" - -# Create .nexus directory structure -mkdir -p "$TEST_DIR/.nexus/bin" -echo -e "${ORANGE}2. Created directory structure: $TEST_DIR/.nexus/bin${NC}\n" - -# Force the initial version -echo -e "${ORANGE}3. Setting initial version $OLD_VERSION${NC}\n" -echo "$OLD_VERSION" > "$TEST_DIR/.nexus/bin/version" - -# Build the source code -echo -e "${ORANGE}4. Building source code...${NC}\n" -cd clients/cli # Change to CLI directory - -# Build and run the binary -if command -v cargo >/dev/null 2>&1; then - CARGO_PATH=$(which cargo) - echo -e "${ORANGE}\t\t Using cargo at: $CARGO_PATH${NC}\n" - - # Build the binary - $CARGO_PATH build || { - echo -e "${ORANGE}❌ Failed to build binary${NC}\n" - exit 1 - } - - # Get the path to the built binary - BINARY_PATH="$(pwd)/target/debug/prover" - echo -e "${ORANGE}5. Binary built at: $BINARY_PATH${NC}" - - # Run the binary directly with modified environment - echo -e "${ORANGE}6. Running binary with test environment...${NC}\n" - HOME="$TEST_DIR" NEXUS_HOME="$TEST_DIR" \ - $BINARY_PATH $ORCHESTRATOR_HOST & -else - echo -e "${ORANGE}❌ Cargo not found in PATH${NC}" - exit 1 -fi - -INITIAL_PID=$! -echo -e "${ORANGE}7. Initial process PID: $INITIAL_PID${NC}\n" - -echo -e "${ORANGE}Test will pass if you see messages change from ${GREEN}[auto-updater]${ORANGE} to ${BLUE}[auto-updater]${ORANGE} color${NC}" -echo -e "${ORANGE}This color change indicates the binary was successfully replaced${NC}" - - -# Wait a moment for the process to start -sleep 5 - -# (During this time the process starts) - -# Wait for update to happen and verify binary download -echo -e "${ORANGE}\nWaiting for update check (30s)...${NC}" -sleep 30 - -# Update version check location -echo -e "${ORANGE}Checking binary version${NC}" - -echo -e "${ORANGE}DID YOU SEE THE COLOR CHANGE?${NC}"