-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(stages, storage): pruning configuration #3341
Conversation
Codecov Report
... and 18 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more.
|
8690453
to
503f211
Compare
503f211
to
1cbf0b0
Compare
6cef5e5
to
ad302cd
Compare
PrunableStage
and Pipeline::prune
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like a good start! what kind of scope are you planning for this PR? is it in its final form?
crates/storage/db/src/tables/mod.rs
Outdated
table!( | ||
/// Stores the highest pruned block number. | ||
( PruneStage ) StageId | BlockNumber | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dream of collapsing SyncStage
, SyncStageProgress
& PruneStage
into a single table
This is its final form, plan to implement pruning for stages and trigger pruning in separate PRs |
Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
what's the plan for pruning outside the pipeline during live sync? |
hooking it into the |
will the threshold be present in the pipeline as well? since we don't know how far the target is from the tip |
I think it shouldn't be in the pipeline, but rather in the engine. I expect the distance between target block number for pruning and the tip to always be low:
|
4fb4ac1
to
6411995
Compare
6411995
to
97a6782
Compare
use reth_codecs::Compact; | ||
|
||
#[test] | ||
fn prune_checkpoint_roundtrip() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary since deriving main_codec
automatically adds derive_arbitrary
which generates these kind of roundtrip tests for a default of 256 cases. It's mentioned on derive_arbitratry
, but not on the main_codec
docs, should probably add.
...
running 1 test
test prune::mode::PruneModeTests::proptest ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 283 filtered out; finished in 0.01s
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, I see:
#[cfg(test)]
mod PruneCheckpointTests {
use super::Compact;
#[test]
fn proptest() {
let mut config = proptest::prelude::ProptestConfig::with_cases(256i32 as u32);
{
let mut config = config.__sugar_to_owned();
::proptest::sugar::force_no_fork(&mut config);
{
config.source_file = Some(file!( ));
let mut runner = ::proptest::test_runner::TestRunner::new(config);
let names = stringify!( field );
match runner.run(
&::proptest::strategy::Strategy::prop_map(
::proptest::arbitrary::any::<super::PruneCheckpoint>(),
|values| ::proptest::sugar::NamedArguments(names, values)),
|::proptest::sugar::NamedArguments(
_, field)|
{
let _: () = {
{
let mut buf = (::alloc::vec::Vec::new());
let len = field.clone().to_compact(&mut buf);
let (decoded, _) = super::PruneCheckpoint::from_compact(&buf, len);
assert!(field == decoded);
}
};
Ok(())
})
{
Ok(_) => (),
Err(e) => panic!("{}\n{}", e, runner),
}
}
}
}
}
removed
Just giving some context for the change of field order on 506643e This should have been caught during compilation time (resulting in an error), but a couple weeks ago, this got changed and I missed this PR. Will follow up with reverting that change, alongside some better docs for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serde nits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Resolves #3430
PruneMode
There are two modes for pruning, when it's enabled:
Full
– prune all blocks, used for full node.Distance
– prune blocks before thehead-N
block number. In other words, keep last N blocks.Before
– prune blocks before the specified block number. The specified block number is not pruned.PruneTarget
For convenience,
PruneMode
can be converted into thePruneTarget
which represents either:All
variant – prune all blocks, i.e. not save any data. Used for the full node.Block(BlockNumber)
variant – prune blocks up to the specified block number, inclusive.PruneConfig
As per the description in the linked issue: #3430 (comment).