mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
refactor(stages): input target reached & output done checks (#3119)
This commit is contained in:
@ -120,30 +120,22 @@ impl Command {
|
||||
|
||||
let mut account_hashing_done = false;
|
||||
while !account_hashing_done {
|
||||
let output = account_hashing_stage
|
||||
.execute(
|
||||
&mut provider_rw,
|
||||
ExecInput {
|
||||
target: Some(block),
|
||||
checkpoint: progress.map(StageCheckpoint::new),
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
account_hashing_done = output.done;
|
||||
let input = ExecInput {
|
||||
target: Some(block),
|
||||
checkpoint: progress.map(StageCheckpoint::new),
|
||||
};
|
||||
let output = account_hashing_stage.execute(&mut provider_rw, input).await?;
|
||||
account_hashing_done = output.is_done(input);
|
||||
}
|
||||
|
||||
let mut storage_hashing_done = false;
|
||||
while !storage_hashing_done {
|
||||
let output = storage_hashing_stage
|
||||
.execute(
|
||||
&mut provider_rw,
|
||||
ExecInput {
|
||||
target: Some(block),
|
||||
checkpoint: progress.map(StageCheckpoint::new),
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
storage_hashing_done = output.done;
|
||||
let input = ExecInput {
|
||||
target: Some(block),
|
||||
checkpoint: progress.map(StageCheckpoint::new),
|
||||
};
|
||||
let output = storage_hashing_stage.execute(&mut provider_rw, input).await?;
|
||||
storage_hashing_done = output.is_done(input);
|
||||
}
|
||||
|
||||
let incremental_result = merkle_stage
|
||||
@ -173,7 +165,7 @@ impl Command {
|
||||
loop {
|
||||
let clean_result = merkle_stage.execute(&mut provider_rw, clean_input).await;
|
||||
assert!(clean_result.is_ok(), "Clean state root calculation failed");
|
||||
if clean_result.unwrap().done {
|
||||
if clean_result.unwrap().is_done(clean_input) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,8 @@ impl NodeState {
|
||||
pipeline_position,
|
||||
pipeline_total,
|
||||
stage_id,
|
||||
result: ExecOutput { checkpoint, done },
|
||||
result: ExecOutput { checkpoint },
|
||||
done,
|
||||
} => {
|
||||
self.current_checkpoint = checkpoint;
|
||||
|
||||
|
||||
@ -77,16 +77,11 @@ async fn dry_run<DB: Database>(
|
||||
|
||||
let mut exec_output = false;
|
||||
while !exec_output {
|
||||
exec_output = exec_stage
|
||||
.execute(
|
||||
&mut provider,
|
||||
reth_stages::ExecInput {
|
||||
target: Some(to),
|
||||
checkpoint: Some(StageCheckpoint::new(from)),
|
||||
},
|
||||
)
|
||||
.await?
|
||||
.done;
|
||||
let exec_input = reth_stages::ExecInput {
|
||||
target: Some(to),
|
||||
checkpoint: Some(StageCheckpoint::new(from)),
|
||||
};
|
||||
exec_output = exec_stage.execute(&mut provider, exec_input).await?.is_done(exec_input);
|
||||
}
|
||||
|
||||
info!(target: "reth::cli", "Success.");
|
||||
|
||||
@ -76,16 +76,11 @@ async fn dry_run<DB: Database>(
|
||||
|
||||
let mut exec_output = false;
|
||||
while !exec_output {
|
||||
exec_output = exec_stage
|
||||
.execute(
|
||||
&mut provider,
|
||||
reth_stages::ExecInput {
|
||||
target: Some(to),
|
||||
checkpoint: Some(StageCheckpoint::new(from)),
|
||||
},
|
||||
)
|
||||
.await?
|
||||
.done;
|
||||
let exec_input = reth_stages::ExecInput {
|
||||
target: Some(to),
|
||||
checkpoint: Some(StageCheckpoint::new(from)),
|
||||
};
|
||||
exec_output = exec_stage.execute(&mut provider, exec_input).await?.is_done(exec_input);
|
||||
}
|
||||
|
||||
info!(target: "reth::cli", "Success.");
|
||||
|
||||
@ -119,20 +119,17 @@ async fn dry_run<DB: Database>(
|
||||
let mut provider = shareable_db.provider_rw()?;
|
||||
let mut exec_output = false;
|
||||
while !exec_output {
|
||||
let exec_input = reth_stages::ExecInput {
|
||||
target: Some(to),
|
||||
checkpoint: Some(StageCheckpoint::new(from)),
|
||||
};
|
||||
exec_output = MerkleStage::Execution {
|
||||
clean_threshold: u64::MAX, /* Forces updating the root instead of calculating
|
||||
* from
|
||||
* scratch */
|
||||
// Forces updating the root instead of calculating from scratch
|
||||
clean_threshold: u64::MAX,
|
||||
}
|
||||
.execute(
|
||||
&mut provider,
|
||||
reth_stages::ExecInput {
|
||||
target: Some(to),
|
||||
checkpoint: Some(StageCheckpoint::new(from)),
|
||||
},
|
||||
)
|
||||
.execute(&mut provider, exec_input)
|
||||
.await?
|
||||
.done;
|
||||
.is_done(exec_input);
|
||||
}
|
||||
|
||||
info!(target: "reth::cli", "Success.");
|
||||
|
||||
@ -20,7 +20,7 @@ use reth_stages::{
|
||||
IndexAccountHistoryStage, IndexStorageHistoryStage, MerkleStage, SenderRecoveryStage,
|
||||
StorageHashingStage, TransactionLookupStage,
|
||||
},
|
||||
ExecInput, ExecOutput, PipelineError, Stage, UnwindInput,
|
||||
ExecInput, PipelineError, Stage, UnwindInput,
|
||||
};
|
||||
use std::{any::Any, net::SocketAddr, path::PathBuf, sync::Arc};
|
||||
use tracing::*;
|
||||
@ -238,10 +238,13 @@ impl Command {
|
||||
checkpoint: Some(checkpoint.with_block_number(self.from)),
|
||||
};
|
||||
|
||||
while let ExecOutput { checkpoint: stage_progress, done: false } =
|
||||
exec_stage.execute(&mut provider_rw, input).await?
|
||||
{
|
||||
input.checkpoint = Some(stage_progress);
|
||||
loop {
|
||||
let result = exec_stage.execute(&mut provider_rw, input).await?;
|
||||
if result.is_done(input) {
|
||||
break
|
||||
}
|
||||
|
||||
input.checkpoint = Some(result.checkpoint);
|
||||
|
||||
if self.commit {
|
||||
provider_rw.commit()?;
|
||||
|
||||
Reference in New Issue
Block a user