Skip to content

Commit

Permalink
chore: remove the unused --chain-import flag (#4624)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmih authored Aug 6, 2024
1 parent d4408ae commit 5919593
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 37 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@

### Removed

- [#4624](https://github.com/ChainSafe/forest/pull/4624) Remove the
`--chain-import` flag. Its functionality can be accessed through the more
flexible `--height` flag.

### Fixed

- [#4603](https://github.com/ChainSafe/forest/pull/4603) Fixed incorrect
Expand Down
1 change: 0 additions & 1 deletion documentation/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use of the following flags:
| --mdns | Boolean | Determines whether MDNS is allowed |
| --import-snapshot | OS File Path | Path to snapshot CAR file |
| --consume-snapshot | OS File Path | Path to snapshot CAR file (delete after importing) |
| --import-chain | OS File Path | Path to chain CAR file |
| --skip-load | Boolean | Skips loading CAR File and uses header to index chain |
| --req-window | Integer | Sets the number of tipsets requested over chain exchange |
| --tipset-sample-size | Integer | Number of tipsets to include in the sample which determines the network head during synchronization |
Expand Down
4 changes: 0 additions & 4 deletions src/cli_shared/cli/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ pub struct Client {
pub enable_rpc: bool,
pub enable_metrics_endpoint: bool,
pub enable_health_check: bool,
/// If this is true, then we do not validate the imported snapshot.
/// Otherwise, we validate and compute the states.
pub snapshot: bool,
/// If this is true, delete the snapshot at `snapshot_path` if it's a local file.
pub consume_snapshot: bool,
pub snapshot_height: Option<i64>,
Expand Down Expand Up @@ -80,7 +77,6 @@ impl Default for Client {
enable_metrics_endpoint: true,
enable_health_check: true,
snapshot_path: None,
snapshot: false,
consume_snapshot: false,
snapshot_height: None,
snapshot_head: None,
Expand Down
30 changes: 1 addition & 29 deletions src/cli_shared/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ pub struct CliOpts {
/// Halt with exit code 0 after successfully importing a snapshot
#[arg(long)]
pub halt_after_import: bool,
/// Import a chain from a local CAR file or URL
#[arg(long)]
pub import_chain: Option<String>,
/// Skips loading CAR file and uses header to index chain. Assumes a
/// pre-loaded database
#[arg(long)]
Expand Down Expand Up @@ -197,27 +194,17 @@ impl CliOpts {
cfg.network.listening_multiaddrs.clone_from(addresses);
}

if self.import_snapshot.is_some() && self.import_chain.is_some() {
anyhow::bail!("Can't set import_snapshot and import_chain at the same time!")
} else if self.import_snapshot.is_some() && self.consume_snapshot.is_some() {
if self.import_snapshot.is_some() && self.consume_snapshot.is_some() {
anyhow::bail!("Can't set import_snapshot and consume_snapshot at the same time!")
} else if self.consume_snapshot.is_some() && self.import_chain.is_some() {
anyhow::bail!("Can't set consume_snapshot and import_chain at the same time!")
}

if let Some(snapshot_path) = &self.import_snapshot {
cfg.client.snapshot_path = Some(snapshot_path.into());
cfg.client.snapshot = true;
}
if let Some(snapshot_path) = &self.consume_snapshot {
cfg.client.snapshot_path = Some(snapshot_path.into());
cfg.client.snapshot = true;
cfg.client.consume_snapshot = true;
}
if let Some(snapshot_path) = &self.import_chain {
cfg.client.snapshot_path = Some(snapshot_path.into());
cfg.client.snapshot = false;
}
cfg.client.snapshot_height = self.height;
cfg.client.snapshot_head = self.head.map(|head| head as i64);
if let Some(skip_load) = self.skip_load {
Expand Down Expand Up @@ -412,26 +399,11 @@ mod tests {
let options = CliOpts::default();
assert!(options.to_config().is_ok());

// Creating a config with both --import_snapshot and --import_chain should fail
let options = CliOpts {
import_snapshot: Some("snapshot.car".into()),
import_chain: Some("snapshot.car".into()),
..Default::default()
};
assert!(options.to_config().is_err());

// Creating a config with only --import_snapshot should succeed
let options = CliOpts {
import_snapshot: Some("snapshot.car".into()),
..Default::default()
};
assert!(options.to_config().is_ok());

// Creating a config with only --import_chain should succeed
let options = CliOpts {
import_chain: Some("snapshot.car".into()),
..Default::default()
};
assert!(options.to_config().is_ok());
}
}
4 changes: 1 addition & 3 deletions src/daemon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ pub(super) async fn start(
}
}

if let (true, Some(validate_from)) = (config.client.snapshot, config.client.snapshot_height) {
if let Some(validate_from) = config.client.snapshot_height {
// We've been provided a snapshot and asked to validate it
ensure_params_downloaded().await?;
// Use the specified HEAD, otherwise take the current HEAD.
Expand Down Expand Up @@ -535,7 +535,6 @@ async fn set_snapshot_path_if_needed(
(true, false, true) => {
let url = crate::cli_shared::snapshot::stable_url(vendor, chain)?;
config.client.snapshot_path = Some(url.to_string().into());
config.client.snapshot = true;
}
(true, false, false) => {
// we need a snapshot, don't have one, and don't have permission to download one, so ask the user
Expand All @@ -562,7 +561,6 @@ async fn set_snapshot_path_if_needed(
bail!("Forest requires a snapshot to sync with the network, but automatic fetching is disabled.")
}
config.client.snapshot_path = Some(url.to_string().into());
config.client.snapshot = true;
}
};

Expand Down

0 comments on commit 5919593

Please sign in to comment.