mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(stages): add commit threshold to merkle stage v2 (#1656)
Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
@ -44,10 +44,7 @@ pub(crate) async fn dump_merkle_stage<DB: Database>(
|
||||
unwind_and_copy::<DB>(db_tool, (from, to), tip_block_number, &output_db).await?;
|
||||
|
||||
if should_run {
|
||||
println!(
|
||||
"\n# Merkle stage does not support dry run, so it will actually be committing changes."
|
||||
);
|
||||
run(output_db, to, from).await?;
|
||||
dry_run(output_db, to, from).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -113,7 +110,7 @@ async fn unwind_and_copy<DB: Database>(
|
||||
}
|
||||
|
||||
/// Try to re-execute the stage straightaway
|
||||
async fn run(
|
||||
async fn dry_run(
|
||||
output_db: reth_db::mdbx::Env<reth_db::mdbx::WriteMap>,
|
||||
to: u64,
|
||||
from: u64,
|
||||
@ -121,18 +118,24 @@ async fn run(
|
||||
info!(target: "reth::cli", "Executing stage.");
|
||||
|
||||
let mut tx = Transaction::new(&output_db)?;
|
||||
|
||||
MerkleStage::Execution {
|
||||
clean_threshold: u64::MAX, // Forces updating the root instead of calculating from scratch
|
||||
let mut exec_output = false;
|
||||
while !exec_output {
|
||||
exec_output = MerkleStage::Execution {
|
||||
clean_threshold: u64::MAX, /* Forces updating the root instead of calculating from
|
||||
* scratch */
|
||||
}
|
||||
.execute(
|
||||
&mut tx,
|
||||
reth_stages::ExecInput {
|
||||
previous_stage: Some((StageId("Another"), to)),
|
||||
stage_progress: Some(from),
|
||||
},
|
||||
)
|
||||
.await?
|
||||
.done;
|
||||
}
|
||||
.execute(
|
||||
&mut tx,
|
||||
reth_stages::ExecInput {
|
||||
previous_stage: Some((StageId("Another"), to)),
|
||||
stage_progress: Some(from),
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
tx.drop()?;
|
||||
|
||||
info!(target: "reth::cli", "Success.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user