Skip to content

Commit

Permalink
Merge pull request #59 from spacemeshos/rename_partial_incremental
Browse files Browse the repository at this point in the history
  • Loading branch information
pigmej authored Oct 17, 2024
2 parents ef05c1b + 7182a36 commit add01fd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ Listed below are the exit codes and what they mean:
- `8` - Cannot validate archive checksum.


# Partial quicksync
# Incremental quicksync

It is also possible to download and apply delta-based quicksync. Assuming that the `state.sql` is already present, it's worth considering applying only deltas on top of that.
Please note that syncing large portions will be faster with full quicksync, but if you are already synced and just need to catch up with the latest state, partial quicksync is the way to go.
Please note that syncing large portions will be faster with full quicksync, but if you are already synced and just need to catch up with the latest state, incrementa quicksync is the way to go.

Partial quicksync works by checking the latest verified layer in the database and then downloading small files (usually about 50MB but up to 200MB) and applying them on top of the existing `state.sql`. Each batch can be interrupted.
Incremental quicksync works by checking the latest verified layer in the database and then downloading small files (usually about 50MB but up to 200MB) and applying them on top of the existing `state.sql`. Each batch can be interrupted.

Restoring the same batch twice is considered a no-op and will not affect the database.

Expand All @@ -73,6 +73,6 @@ The list of available commands for the `quicksync` utility is presented below. N
- `./quicksync download`: Downloads the latest `state.sql` file.
- `./quicksync check`: Checks if the current `state.sql` is up to date.
- `./quicksync help`: Displays all operations that `quicksync` can perform.
- `./quicksync partial`: Allows to work with delta based quicksync.
- `./quicksync incremental`: Allows to work with delta based quicksync.
- `./quicksync --version`: Displays the quicksync version.
- `cargo run -- help`: Displays helpful commands for running the package. Relevant for developers.
16 changes: 8 additions & 8 deletions src/partial_quicksync.rs → src/incremental_quicksync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ fn get_restore_points(
Ok((start_points, remote_metadata, user_version))
}

pub fn partial_restore(
pub fn incremental_restore(
base_url: &str,
target_db_path: &Path,
download_path: &Path,
Expand Down Expand Up @@ -445,7 +445,7 @@ mod tests {
}

#[test]
fn partial_restore() {
fn incremental_restore() {
let dir = tempdir().unwrap();
let db_path = dir.path().join("state.db");
{
Expand Down Expand Up @@ -518,7 +518,7 @@ mod tests {
})
.collect::<Vec<_>>();

super::partial_restore(&server.url(), &db_path, dir.path(), 0, 0).unwrap();
super::incremental_restore(&server.url(), &db_path, dir.path(), 0, 0).unwrap();

mock_metadata.assert();
mock_query.assert();
Expand All @@ -535,7 +535,7 @@ mod tests {
}

#[test]
fn partial_restore_with_untrusted_layers() {
fn incremental_restore_with_untrusted_layers() {
let dir = tempdir().unwrap();
let db_path = dir.path().join("state.db");
{
Expand Down Expand Up @@ -608,7 +608,7 @@ mod tests {
.collect::<Vec<_>>();

let untrusted_layers = 10;
super::partial_restore(&server.url(), &db_path, dir.path(), untrusted_layers, 0).unwrap();
super::incremental_restore(&server.url(), &db_path, dir.path(), untrusted_layers, 0).unwrap();

mock_metadata.assert();
mock_query.assert();
Expand Down Expand Up @@ -653,7 +653,7 @@ mod tests {
.with_body(".import backup_source.db layers")
.create();

let err = super::partial_restore(&server.url(), &db_path, dir.path(), 0, 0).unwrap_err();
let err = super::incremental_restore(&server.url(), &db_path, dir.path(), 0, 0).unwrap_err();
assert!(err.to_string().contains("unexpected hash"));
mock_metadata.assert();
mock_query.assert();
Expand All @@ -679,7 +679,7 @@ mod tests {
.with_body(metadata)
.create();

let err = super::partial_restore(&server.url(), &db_path, dir.path(), 0, 0).unwrap_err();
let err = super::incremental_restore(&server.url(), &db_path, dir.path(), 0, 0).unwrap_err();
assert!(err
.to_string()
.contains("No suitable restore points found, seems that state.sql is too old"));
Expand All @@ -705,7 +705,7 @@ mod tests {
.with_status(404)
.with_body("Not Found")
.create();
let err = super::partial_restore(&server.url(), &db_path, dir.path(), 0, 0).unwrap_err();
let err = super::incremental_restore(&server.url(), &db_path, dir.path(), 0, 0).unwrap_err();
println!("{}", err);
assert!(err
.to_string()
Expand Down
24 changes: 12 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ mod checksum;
mod download;
mod eta;
mod go_spacemesh;
mod incremental_quicksync;
mod parsers;
mod partial_quicksync;
mod read_error_response;
mod reader_with_bytes;
mod sql;
Expand All @@ -24,8 +24,8 @@ use anyhow::{anyhow, Context};
use checksum::*;
use download::download_with_retries;
use go_spacemesh::get_version;
use incremental_quicksync::{check_for_restore_points, incremental_restore};
use parsers::*;
use partial_quicksync::{check_for_restore_points, partial_restore};
use sql::get_last_layer_from_db;
use utils::*;

Expand Down Expand Up @@ -81,8 +81,8 @@ enum Commands {
#[clap(short = 'r', long, default_value = "10")]
max_retries: u32,
},
/// Uses partial recovery quicksync method
Partial {
/// Uses incremental recovery quicksync method
Incremental {
/// Path to the node state.sql
#[clap(short = 's', long)]
state_sql: PathBuf,
Expand All @@ -94,11 +94,11 @@ enum Commands {
#[clap(short = 'j', long, default_value_t = 0)]
jump_back: usize,
/// URL to download parts from
#[clap(short = 'u', long, default_value = partial_quicksync::DEFAULT_BASE_URL)]
#[clap(short = 'u', long, default_value = incremental_quicksync::DEFAULT_BASE_URL)]
base_url: String,
},
/// Partial check availability
PartialCheck {
/// Incremental check availability
IncrementalCheck {
/// Path to the node state.sql
#[clap(short = 's', long)]
state_sql: PathBuf,
Expand All @@ -110,7 +110,7 @@ enum Commands {
#[clap(short = 'j', long, default_value_t = 0)]
jump_back: usize,
/// URL to download parts from
#[clap(short = 'u', long, default_value = partial_quicksync::DEFAULT_BASE_URL)]
#[clap(short = 'u', long, default_value = incremental_quicksync::DEFAULT_BASE_URL)]
base_url: String,
},
}
Expand Down Expand Up @@ -345,13 +345,13 @@ fn main() -> anyhow::Result<()> {

Ok(())
}
Commands::Partial {
Commands::Incremental {
state_sql,
untrusted_layers,
jump_back,
base_url,
} => {
println!("Warning: partial quicksync is considered to be beta feature for now");
println!("Warning: incremental quicksync is considered to be beta feature for now");
let state_sql_path = resolve_path(&state_sql).context("resolving state.sql path")?;
if !state_sql_path
.try_exists()
Expand All @@ -360,15 +360,15 @@ fn main() -> anyhow::Result<()> {
return Err(anyhow!("state file not found: {:?}", state_sql_path));
}
let download_path = resolve_path(Path::new(".")).unwrap();
partial_restore(
incremental_restore(
&base_url,
&state_sql_path,
&download_path,
untrusted_layers,
jump_back,
)
}
Commands::PartialCheck {
Commands::IncrementalCheck {
state_sql,
base_url,
untrusted_layers,
Expand Down

0 comments on commit add01fd

Please sign in to comment.