Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion src/chain_sync/chain_muxer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use serde::{Deserialize, Serialize};

const DEFAULT_RECENT_STATE_ROOTS: i64 = 2000;
pub const DEFAULT_RECENT_STATE_ROOTS: i64 = 2000;

/// Structure that defines syncing configuration options
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion src/chain_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

mod bad_block_cache;
mod chain_follower;
mod chain_muxer;
pub mod chain_muxer;
pub mod consensus;
pub mod metrics;
pub mod network_context;
Expand Down
21 changes: 13 additions & 8 deletions src/cli/subcommands/snapshot_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0, MIT

use crate::chain::FilecoinSnapshotVersion;
use crate::chain_sync::SyncConfig;
use crate::chain_sync::chain_muxer::DEFAULT_RECENT_STATE_ROOTS;
use crate::cli_shared::snapshot::{self, TrustedVendor};
use crate::db::car::forest::new_forest_car_temp_path_in;
use crate::networks::calibnet;
Expand Down Expand Up @@ -34,10 +34,10 @@ pub enum SnapshotCommands {
/// Tipset to start the export from, default is the chain head
#[arg(short, long)]
tipset: Option<i64>,
/// How many state-roots to include. Lower limit is 900 for `calibnet` and `mainnet`.
#[arg(short, long)]
depth: Option<crate::chain::ChainEpochDelta>,
/// Export snapshot in the experimental v2 format(FRC-0108).
/// How many state trees to include. 0 for chain spine with no state trees.
#[arg(short, long, default_value_t = DEFAULT_RECENT_STATE_ROOTS)]
depth: crate::chain::ChainEpochDelta,
/// Snapshot format to export.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
#[arg(long, value_enum, default_value_t = FilecoinSnapshotVersion::V1)]
format: FilecoinSnapshotVersion,
},
Expand Down Expand Up @@ -83,8 +83,13 @@ impl SnapshotCommands {
raw_network_name.as_str()
};

let tipset =
ChainGetTipSetByHeight::call(&client, (epoch, Default::default())).await?;
// This could take long when the requested epoch is far behind the chain head
let tipset = client
.call(
ChainGetTipSetByHeight::request((epoch, Default::default()))?
.with_timeout(Duration::from_secs(60 * 15)),
)
.await?;

let output_path = match output_path.is_dir() {
true => output_path.join(snapshot::filename(
Expand All @@ -106,7 +111,7 @@ impl SnapshotCommands {
let params = ForestChainExportParams {
version: format,
epoch,
recent_roots: depth.unwrap_or(SyncConfig::default().recent_state_roots),
recent_roots: depth,
output_path: temp_path.to_path_buf(),
tipset_keys: ApiTipsetKey(Some(chain_head.key().clone())),
skip_checksum,
Expand Down
8 changes: 0 additions & 8 deletions src/rpc/methods/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,6 @@ impl RpcMethod<1> for ForestChainExport {
return Err(anyhow::anyhow!("Another chain export job is still in progress").into());
}

let chain_finality = ctx.chain_config().policy.chain_finality;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still worth putting a warning. Zero-depth snapshots are a niche use case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a warning on the client(forest-cli) side.

if recent_roots < chain_finality {
return Err(anyhow::anyhow!(format!(
"recent-stateroots must be greater than {chain_finality}"
))
.into());
}

let head = ctx.chain_store().load_required_tipset_or_heaviest(&tsk)?;
let start_ts =
ctx.chain_index()
Expand Down
Loading