unwind tracing (#750)

This commit is contained in:
Roman Krasiuk
2023-01-06 16:39:54 +02:00
committed by GitHub
parent 059c33dd03
commit 929cde46c4
5 changed files with 6 additions and 0 deletions

View File

@@ -183,6 +183,7 @@ impl<DB: Database, D: BodyDownloader, C: Consensus> Stage<DB> for BodyStage<D, C
tx: &mut Transaction<'_, DB>,
input: UnwindInput,
) -> Result<UnwindOutput, StageError> {
info!(target: "sync::stages::bodies", to_block = input.unwind_to, "Unwinding");
// Cursors to unwind bodies, ommers, transactions and tx hash to number
let mut body_cursor = tx.cursor_mut::<tables::BlockBodies>()?;
let mut ommers_cursor = tx.cursor_mut::<tables::BlockOmmers>()?;

View File

@@ -291,6 +291,8 @@ impl<DB: Database> Stage<DB> for ExecutionStage {
tx: &mut Transaction<'_, DB>,
input: UnwindInput,
) -> Result<UnwindOutput, StageError> {
info!(target: "sync::stages::execution", to_block = input.unwind_to, "Unwinding");
// Acquire changeset cursors
let mut account_changeset = tx.cursor_dup_mut::<tables::AccountChangeSet>()?;
let mut storage_changeset = tx.cursor_dup_mut::<tables::StorageChangeSet>()?;

View File

@@ -144,6 +144,7 @@ impl<DB: Database, D: HeaderDownloader, C: Consensus, H: HeadersClient, S: Statu
input: UnwindInput,
) -> Result<UnwindOutput, StageError> {
// TODO: handle bad block
info!(target: "sync::stages::headers", to_block = input.unwind_to, "Unwinding");
tx.unwind_table_by_walker::<tables::CanonicalHeaders, tables::HeaderNumbers>(
input.unwind_to + 1,
)?;

View File

@@ -116,6 +116,7 @@ impl<DB: Database> Stage<DB> for SenderRecoveryStage {
tx: &mut Transaction<'_, DB>,
input: UnwindInput,
) -> Result<UnwindOutput, StageError> {
info!(target: "sync::stages::sender_recovery", to_block = input.unwind_to, "Unwinding");
// Lookup latest tx id that we should unwind to
let latest_tx_id = tx.get_block_body_by_num(input.unwind_to)?.last_tx_index();
tx.unwind_table_by_num::<tables::TxSenders>(latest_tx_id)?;

View File

@@ -77,6 +77,7 @@ impl<DB: Database> Stage<DB> for TotalDifficultyStage {
tx: &mut Transaction<'_, DB>,
input: UnwindInput,
) -> Result<UnwindOutput, StageError> {
info!(target: "sync::stages::total_difficulty", to_block = input.unwind_to, "Unwinding");
tx.unwind_table_by_num_hash::<tables::HeaderTD>(input.unwind_to)?;
Ok(UnwindOutput { stage_progress: input.unwind_to })
}