Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

### Changed

- [#6471](https://github.com/ChainSafe/forest/pull/6471) Moved `forest-tool state` subcommand to `forest-dev`.

### Removed

### Fixed
Expand Down
14 changes: 10 additions & 4 deletions docs/docs/users/reference/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ generate_markdown_section "forest-tool" "benchmark graph-traversal"
generate_markdown_section "forest-tool" "benchmark forest-encoding"
generate_markdown_section "forest-tool" "benchmark export"

generate_markdown_section "forest-tool" "state"
generate_markdown_section "forest-tool" "state compute"
generate_markdown_section "forest-tool" "state replay-compute"

generate_markdown_section "forest-tool" "state-migration"
generate_markdown_section "forest-tool" "state-migration actor-bundle"

Expand Down Expand Up @@ -158,3 +154,13 @@ generate_markdown_section "forest-tool" "shed openrpc"

generate_markdown_section "forest-tool" "index"
generate_markdown_section "forest-tool" "index backfill"

generate_markdown_section "forest-dev" ""

generate_markdown_section "forest-dev" "fetch-rpc-tests"

generate_markdown_section "forest-dev" "state"
generate_markdown_section "forest-dev" "state compute"
generate_markdown_section "forest-dev" "state replay-compute"
generate_markdown_section "forest-dev" "state validate"
generate_markdown_section "forest-dev" "state replay-validate"
33 changes: 11 additions & 22 deletions src/chain_sync/chain_follower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,6 @@ impl SyncTask {
bad_block_cache: Option<Arc<BadBlockCache>>,
) -> Option<SyncEvent> {
tracing::trace!("SyncTask::execute {self}");
let cs = state_manager.chain_store();
match self {
SyncTask::ValidateTipset {
tipset,
Expand All @@ -840,29 +839,19 @@ impl SyncTask {
SyncTask::ValidateTipset {
tipset,
is_proposed_head,
} => {
let genesis = cs.genesis_tipset();
match validate_tipset(
&state_manager,
cs,
tipset.clone(),
&genesis,
bad_block_cache,
)
.await
{
Ok(()) => Some(SyncEvent::ValidatedTipset {
tipset,
is_proposed_head,
}),
Err(e) => {
warn!("Error validating tipset: {}", e);
Some(SyncEvent::BadTipset(tipset))
}
} => match validate_tipset(&state_manager, tipset.clone(), bad_block_cache).await {
Ok(()) => Some(SyncEvent::ValidatedTipset {
tipset,
is_proposed_head,
}),
Err(e) => {
warn!("Error validating tipset: {e}");
Some(SyncEvent::BadTipset(tipset))
}
}
},
SyncTask::FetchTipset(key, epoch) => {
match get_full_tipset_batch(&network, cs, None, &key).await {
match get_full_tipset_batch(&network, state_manager.chain_store(), None, &key).await
{
Ok(parents) => Some(SyncEvent::NewFullTipsets(parents)),
Err(e) => {
tracing::warn!(%key, %epoch, "failed to fetch tipset: {e}");
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 @@ -8,7 +8,7 @@ pub mod consensus;
pub mod metrics;
pub mod network_context;
mod sync_status;
mod tipset_syncer;
pub(crate) mod tipset_syncer;
mod validation;

pub use self::{
Expand Down
11 changes: 7 additions & 4 deletions src/chain_sync/tipset_syncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ impl TipsetSyncerError {
/// validation.
pub async fn validate_tipset<DB: Blockstore + Send + Sync + 'static>(
state_manager: &Arc<StateManager<DB>>,
chainstore: &ChainStore<DB>,
full_tipset: FullTipset,
genesis: &Tipset,
bad_block_cache: Option<Arc<BadBlockCache>>,
) -> Result<(), TipsetSyncerError> {
if full_tipset.key().eq(genesis.key()) {
if full_tipset
.key()
.eq(state_manager.chain_store().genesis_tipset().key())
{
trace!("Skipping genesis tipset validation");
return Ok(());
}
Expand All @@ -123,7 +124,9 @@ pub async fn validate_tipset<DB: Blockstore + Send + Sync + 'static>(
while let Some(result) = validations.join_next().await {
match result? {
Ok(block) => {
chainstore.add_to_tipset_tracker(block.header());
state_manager
.chain_store()
.add_to_tipset_tracker(block.header());
}
Err((cid, why)) => {
warn!("Validating block [CID = {cid}] in EPOCH = {epoch} failed: {why}");
Expand Down
5 changes: 5 additions & 0 deletions src/dev/subcommands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2019-2026 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

mod state_cmd;

use crate::cli_shared::cli::HELP_MESSAGE;
use crate::rpc::Client;
use crate::utils::net::{DownloadFileOption, download_file_with_cache};
Expand Down Expand Up @@ -30,12 +32,15 @@ pub struct Cli {
pub enum Subcommand {
/// Fetch RPC test snapshots to the local cache
FetchRpcTests,
#[command(subcommand)]
State(state_cmd::StateCommand),
}

impl Subcommand {
pub async fn run(self, _client: Client) -> anyhow::Result<()> {
match self {
Self::FetchRpcTests => fetch_rpc_tests().await,
Self::State(cmd) => cmd.run().await,
}
}
}
Expand Down
Loading
Loading