Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CLI can self-update when there is a new version and properly continue proving #62

Merged
merged 62 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9bde462
test script for updating
dprats Nov 22, 2024
d086080
modify prover timing
dprats Nov 22, 2024
2808780
update dummy versions
dprats Nov 22, 2024
8d0f195
update tester
dprats Nov 22, 2024
cac86c7
update script
dprats Nov 22, 2024
d3059f8
update script 2
dprats Nov 22, 2024
d6d873a
update script 4
dprats Nov 22, 2024
42b7acc
update script 5
dprats Nov 22, 2024
3d265c6
update script 6
dprats Nov 22, 2024
dab0023
update script 7
dprats Nov 22, 2024
ba321fc
update script 8
dprats Nov 22, 2024
cf73e52
update script 9
dprats Nov 23, 2024
cb8bb75
update script 10
dprats Nov 23, 2024
7e6f4f4
update script 11
dprats Nov 23, 2024
fda4441
update script 12
dprats Nov 23, 2024
eab1b0f
update script 13
dprats Nov 23, 2024
8187a0c
update script 14
dprats Nov 23, 2024
c9e6568
update script 15
dprats Nov 23, 2024
852f54e
update script 16
dprats Nov 23, 2024
078051f
update script 17
dprats Nov 23, 2024
e193262
update script 18
dprats Nov 23, 2024
c3b7825
create detached thread so CLI can restart
dprats Nov 23, 2024
05d6ee3
properly read the PID from a local file
dprats Nov 23, 2024
476c44f
update the logging and updater
dprats Nov 23, 2024
9c4d2ed
update the logging and updater 2
dprats Nov 23, 2024
c99a8d3
update the test files so that it cleans up properly
dprats Nov 23, 2024
6139ee2
update test logging
dprats Nov 23, 2024
55b8527
update the logging
dprats Nov 23, 2024
6d844a8
refactor for test-mode
dprats Nov 26, 2024
39dc697
refactor for test mode 2
dprats Nov 26, 2024
70ac794
simplify code for updater config for test andd prod
dprats Nov 26, 2024
e36a13b
simplify code for updater config for test andd prod 2
dprats Nov 26, 2024
37c5719
fix bash test script
dprats Nov 26, 2024
15795f7
update the code for clarity and structure
dprats Nov 26, 2024
edf9f2a
pass hostbame and use cargo run
dprats Nov 26, 2024
0ede245
rename functions
dprats Nov 26, 2024
c81325a
fetch logic updated
dprats Nov 26, 2024
d2ad626
fix cli code path
dprats Nov 26, 2024
56dbaeb
fix cli code path 2
dprats Nov 26, 2024
444f283
fix cli code path 3
dprats Nov 26, 2024
99f230d
fix cli code path 4
dprats Nov 26, 2024
29c5314
replace type with Semver version type
dprats Nov 26, 2024
efa768a
update so it restarts in the right updater mode
dprats Nov 26, 2024
4ab77dc
fix update cargo run
dprats Nov 26, 2024
3b6ca9f
fix clippy errors
dprats Nov 26, 2024
4d92a30
Merge branch 'main' of https://github.com/nexus-xyz/network-api into …
dprats Nov 26, 2024
8ea25eb
remove unnecessary functions
dprats Nov 26, 2024
0325371
remove dupe functions and merge them
dprats Nov 26, 2024
d066d9b
refactor build logic for test mode
dprats Nov 26, 2024
ebec0ec
updates
dprats Nov 26, 2024
f2384c2
pull releases
dprats Nov 26, 2024
4947c4a
change poll time to 5 min for prod
dprats Nov 26, 2024
0dbfd1a
fix clippy errors
dprats Nov 26, 2024
af31759
Merge branch 'main' of https://github.com/nexus-xyz/network-api into …
dprats Nov 26, 2024
bc3fd64
update cargo toml
dprats Nov 26, 2024
465386f
update comments
dprats Nov 26, 2024
010b67d
file-level comments
dprats Nov 26, 2024
57d0088
add comments on functions
dprats Nov 26, 2024
5fd5097
rename function
dprats Nov 26, 2024
50de24a
update test updater copy
dprats Nov 26, 2024
6caaf60
rename const
dprats Nov 26, 2024
487a6fc
clean up version_manager instantiation
dprats Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
172 changes: 171 additions & 1 deletion clients/cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions clients/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ 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 = "0.41.0"
dirs = "5.0.1"
semver = "1.0.23"
parking_lot = "0.12.3"

[patch.crates-io]
ark-crypto-primitives = { git = "https://github.com/arkworks-rs/crypto-primitives", rev = "d27a5c8" }
Expand Down
24 changes: 21 additions & 3 deletions clients/cli/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ mod config;
mod connection;
mod generated;
mod prover_id_manager;
mod updater;
pub mod utils;
mod websocket;

use crate::analytics::track;
Expand Down Expand Up @@ -48,8 +50,10 @@ use std::fs::File;
use std::io::Read;
use zstd::stream::Encoder;

use crate::utils::updater::{AutoUpdaterMode, UpdaterConfig};

// The interval at which to send updates to the orchestrator
const UPDATE_INTERVAL_IN_SECONDS: u64 = 180; // 3 minutes
const PROOF_PROGRESS_UPDATE_INTERVAL_IN_SECONDS: u64 = 180; // 3 minutes

#[derive(Parser, Debug)]
struct Args {
Expand All @@ -63,6 +67,10 @@ 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<u8> {
Expand All @@ -76,6 +84,8 @@ fn get_file_as_byte_vec(filename: &str) -> Vec<u8> {

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Check for CLI updates periodically

// Configure the tracing subscriber
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
Expand All @@ -91,6 +101,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
args.port
);

// 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.updater_mode, args.hostname);

// 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.
let pp = gen_vm_pp::<C1, seq::SetupParams<(G1, G2, C1, C2, RO, SC)>>(k as usize, &())
Expand Down Expand Up @@ -213,7 +230,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
progress_time = Instant::now();

//If it has been three minutes since the last orchestrator update, send the orchestator the update
if timer_since_last_orchestrator_update.elapsed().as_secs() > UPDATE_INTERVAL_IN_SECONDS
if timer_since_last_orchestrator_update.elapsed().as_secs()
> PROOF_PROGRESS_UPDATE_INTERVAL_IN_SECONDS
{
println!(
"\tWill try sending update to orchestrator with interval queued_steps_proven: {}",
Expand Down Expand Up @@ -319,7 +337,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
if args.just_once {
break;
} else {
println!("Waiting for another program to prove...");
println!("\n\nWaiting for a new program to prove...");
}
}

Expand Down
Loading