Revert "refactor(stages): input target reached & output done checks" (#3114)

This commit is contained in:
Georgios Konstantopoulos
2023-06-12 10:19:46 -07:00
committed by GitHub
parent 9a8c680e0f
commit 7ec4b0a5cf
26 changed files with 379 additions and 313 deletions

View File

@ -119,22 +119,30 @@ impl Command {
let mut account_hashing_done = false;
while !account_hashing_done {
let input = ExecInput {
target: Some(block),
checkpoint: progress.map(StageCheckpoint::new),
};
let output = account_hashing_stage.execute(&mut tx, input).await?;
account_hashing_done = output.is_done(input);
let output = account_hashing_stage
.execute(
&mut tx,
ExecInput {
target: Some(block),
checkpoint: progress.map(StageCheckpoint::new),
},
)
.await?;
account_hashing_done = output.done;
}
let mut storage_hashing_done = false;
while !storage_hashing_done {
let input = ExecInput {
target: Some(block),
checkpoint: progress.map(StageCheckpoint::new),
};
let output = storage_hashing_stage.execute(&mut tx, input).await?;
storage_hashing_done = output.is_done(input);
let output = storage_hashing_stage
.execute(
&mut tx,
ExecInput {
target: Some(block),
checkpoint: progress.map(StageCheckpoint::new),
},
)
.await?;
storage_hashing_done = output.done;
}
let incremental_result = merkle_stage
@ -162,7 +170,7 @@ impl Command {
loop {
let clean_result = merkle_stage.execute(&mut tx, clean_input).await;
assert!(clean_result.is_ok(), "Clean state root calculation failed");
if clean_result.unwrap().is_done(clean_input) {
if clean_result.unwrap().done {
break
}
}

View File

@ -72,8 +72,7 @@ impl NodeState {
pipeline_position,
pipeline_total,
stage_id,
result: ExecOutput { checkpoint },
done,
result: ExecOutput { checkpoint, done },
} => {
self.current_checkpoint = checkpoint;

View File

@ -76,11 +76,16 @@ async fn dry_run(
let mut exec_output = false;
while !exec_output {
let exec_input = reth_stages::ExecInput {
target: Some(to),
checkpoint: Some(StageCheckpoint::new(from)),
};
exec_output = exec_stage.execute(&mut tx, exec_input).await?.is_done(exec_input);
exec_output = exec_stage
.execute(
&mut tx,
reth_stages::ExecInput {
target: Some(to),
checkpoint: Some(StageCheckpoint::new(from)),
},
)
.await?
.done;
}
tx.drop()?;

View File

@ -73,11 +73,16 @@ async fn dry_run(
let mut exec_output = false;
while !exec_output {
let exec_input = reth_stages::ExecInput {
target: Some(to),
checkpoint: Some(StageCheckpoint::new(from)),
};
exec_output = exec_stage.execute(&mut tx, exec_input).await?.is_done(exec_input);
exec_output = exec_stage
.execute(
&mut tx,
reth_stages::ExecInput {
target: Some(to),
checkpoint: Some(StageCheckpoint::new(from)),
},
)
.await?
.done;
}
tx.drop()?;

View File

@ -116,17 +116,19 @@ async fn dry_run(
let mut tx = Transaction::new(&output_db)?;
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 {
// Forces updating the root instead of calculating from scratch
clean_threshold: u64::MAX,
clean_threshold: u64::MAX, /* Forces updating the root instead of calculating from
* scratch */
}
.execute(&mut tx, exec_input)
.execute(
&mut tx,
reth_stages::ExecInput {
target: Some(to),
checkpoint: Some(StageCheckpoint::new(from)),
},
)
.await?
.is_done(exec_input);
.done;
}
tx.drop()?;

View File

@ -20,7 +20,7 @@ use reth_stages::{
IndexAccountHistoryStage, IndexStorageHistoryStage, MerkleStage, SenderRecoveryStage,
StorageHashingStage, TransactionLookupStage,
},
ExecInput, Stage, UnwindInput,
ExecInput, ExecOutput, Stage, UnwindInput,
};
use std::{any::Any, net::SocketAddr, ops::Deref, path::PathBuf, sync::Arc};
use tracing::*;
@ -236,13 +236,10 @@ impl Command {
checkpoint: Some(checkpoint.with_block_number(self.from)),
};
loop {
let result = exec_stage.execute(&mut tx, input).await?;
if result.is_done(input) {
break
}
input.checkpoint = Some(result.checkpoint);
while let ExecOutput { checkpoint: stage_progress, done: false } =
exec_stage.execute(&mut tx, input).await?
{
input.checkpoint = Some(stage_progress);
if self.commit {
tx.commit()?;