Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(staged-sync): correctly calculate total entries in bodies checkpoint #6992

Merged
merged 2 commits into from Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 7 additions & 8 deletions crates/stages/src/stages/bodies.rs
Expand Up @@ -346,8 +346,7 @@ fn stage_checkpoint<DB: Database>(
// Count only static files entries. If we count the database entries too, we may have
// duplicates. We're sure that the static files have all entries that database has,
// because we run the `StaticFileProducer` before starting the pipeline.
total: (provider.static_file_provider().count_entries::<tables::Headers>()? as u64)
.saturating_sub(1),
total: provider.static_file_provider().count_entries::<tables::Headers>()? as u64,
})
}

Expand Down Expand Up @@ -397,7 +396,7 @@ mod tests {
total // seeded headers
}))
}, done: false }) if block_number < 200 &&
processed == 1 + batch_size && total == previous_stage
processed == batch_size + 1 && total == previous_stage + 1
);
assert!(runner.validate_execution(input, output.ok()).is_ok(), "execution validation");
}
Expand Down Expand Up @@ -436,7 +435,7 @@ mod tests {
}))
},
done: true
}) if processed == total && total == previous_stage
}) if processed + 1 == total && total == previous_stage + 1
);
assert!(runner.validate_execution(input, output.ok()).is_ok(), "execution validation");
}
Expand Down Expand Up @@ -472,7 +471,7 @@ mod tests {
total
}))
}, done: false }) if block_number >= 10 &&
processed == 1 + batch_size && total == previous_stage
processed - 1 == batch_size && total == previous_stage + 1
);
let first_run_checkpoint = first_run.unwrap().checkpoint;

Expand All @@ -493,7 +492,7 @@ mod tests {
total
}))
}, done: true }) if block_number > first_run_checkpoint.block_number &&
processed == total && total == previous_stage
processed + 1 == total && total == previous_stage + 1
);
assert_matches!(
runner.validate_execution(input, output.ok()),
Expand Down Expand Up @@ -534,7 +533,7 @@ mod tests {
total
}))
}, done: true }) if block_number == previous_stage &&
processed == total && total == previous_stage
processed + 1 == total && total == previous_stage + 1
);
let checkpoint = output.unwrap().checkpoint;
runner
Expand All @@ -560,7 +559,7 @@ mod tests {
processed: 1,
total
}))
}}) if total == previous_stage
}}) if total == previous_stage + 1
);

assert_matches!(runner.validate_unwind(input), Ok(_), "unwind validation");
Expand Down