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

feat(primitives, storage): save prune checkpoints in database #3628

Merged
merged 6 commits into from
Jul 11, 2023

Conversation

shekhirin
Copy link
Collaborator

@shekhirin shekhirin commented Jul 6, 2023

Resolves #3432

Not a breaking change: we've added new table. Also, we're free to change it without breaking changes until we start writing into it.

@codecov
Copy link

codecov bot commented Jul 6, 2023

Codecov Report

Merging #3628 (c973280) into main (a39ee4a) will decrease coverage by 17.74%.
The diff coverage is 12.50%.

Impacted file tree graph

Impacted Files Coverage Δ
crates/primitives/src/lib.rs 100.00% <ø> (ø)
crates/storage/db/src/abstraction/table.rs 18.60% <ø> (ø)
crates/storage/db/src/tables/mod.rs 29.26% <ø> (-24.40%) ⬇️
crates/storage/db/src/tables/models/mod.rs 66.66% <0.00%> (-11.77%) ⬇️
crates/primitives/src/prune/part.rs 16.66% <16.66%> (ø)
crates/primitives/src/prune/mode.rs 25.00% <100.00%> (-70.84%) ⬇️

... and 205 files with indirect coverage changes

Flag Coverage Δ
integration-tests 15.86% <0.00%> (+0.02%) ⬆️
unit-tests 43.90% <12.50%> (-20.28%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 16.03% <ø> (-10.28%) ⬇️
blockchain tree 70.63% <ø> (-10.95%) ⬇️
pipeline 68.03% <ø> (-19.08%) ⬇️
storage (db) 60.87% <0.00%> (-12.70%) ⬇️
trie 67.15% <ø> (-27.51%) ⬇️
txpool 33.93% <ø> (-15.06%) ⬇️
networking 54.91% <ø> (-22.90%) ⬇️
rpc 44.93% <ø> (-13.33%) ⬇️
consensus 40.50% <ø> (-22.91%) ⬇️
revm 21.66% <ø> (-13.20%) ⬇️
payload builder 6.83% <ø> (ø)
primitives 65.18% <28.57%> (-23.06%) ⬇️

@shekhirin shekhirin marked this pull request as ready for review July 6, 2023 14:18
@shekhirin shekhirin force-pushed the alexey/prune-checkpoint-database branch from 890f491 to 5793f13 Compare July 6, 2023 14:51
@shekhirin shekhirin requested review from mattsse and rkrasiuk and removed request for rakita and gakonst July 6, 2023 15:40
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only defines another table and types and doesn't write to/create it.

perhaps we also want proptest for this?

lgtm otherwise, pending @joshieDo

@@ -17,7 +17,7 @@ pub enum PruneMode {
#[cfg(test)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah we only need this for tests?

otherwise can use #[default]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, only for that part:

#[test]
pub fn #test() {
#fuzz(#ident::default())
}

@mattsse mattsse added the A-db Related to the database label Jul 6, 2023
@shekhirin
Copy link
Collaborator Author

@mattsse main_codec generates prop tests for both

PrunePart
#[allow(non_snake_case)]
#[cfg(test)]
mod PrunePartTests {
    use super::Compact;
    extern crate test;
    #[cfg(test)]
    #[rustc_test_marker = "prune::part::PrunePartTests::proptest"]
    pub const proptest: test::TestDescAndFn = test::TestDescAndFn {
        desc: test::TestDesc {
            name: test::StaticTestName("prune::part::PrunePartTests::proptest"),
            ignore: false,
            ignore_message: ::core::option::Option::None,
            source_file: "crates/primitives/src/prune/part.rs",
            start_line: 4usize,
            start_col: 1usize,
            end_line: 4usize,
            end_col: 14usize,
            compile_fail: false,
            no_run: false,
            should_panic: test::ShouldPanic::No,
            test_type: test::TestType::UnitTest,
        },
        testfn: test::StaticTestFn(|| test::assert_test_result(proptest())),
    };
    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("crates/primitives/src/prune/part.rs");
                let mut runner = ::proptest::test_runner::TestRunner::new(config);
                let names = "field";
                match runner.run(
                    &::proptest::strategy::Strategy::prop_map(
                        ::proptest::arbitrary::any::<super::PrunePart>(),
                        |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::PrunePart::from_compact(&buf, len);
                                if !(field == decoded) {
                                    ::core::panicking::panic(
                                        "assertion failed: field == decoded",
                                    )
                                };
                            }
                        };
                        Ok(())
                    },
                ) {
                    Ok(_) => (),
                    Err(e) => {
                        ::std::rt::panic_fmt(format_args!("{0}\n{1}", e, runner));
                    }
                }
            };
        };
    }
}
PruneCheckpoint
#[allow(non_snake_case)]
#[cfg(test)]
mod PruneCheckpointTests {
    use super::Compact;
    extern crate test;
    #[cfg(test)]
    #[rustc_test_marker = "prune::checkpoint::PruneCheckpointTests::proptest"]
    pub const proptest: test::TestDescAndFn = test::TestDescAndFn {
        desc: test::TestDesc {
            name: test::StaticTestName("prune::checkpoint::PruneCheckpointTests::proptest"),
            ignore: false,
            ignore_message: ::core::option::Option::None,
            source_file: "crates/primitives/src/prune/checkpoint.rs",
            start_line: 5usize,
            start_col: 1usize,
            end_line: 5usize,
            end_col: 14usize,
            compile_fail: false,
            no_run: false,
            should_panic: test::ShouldPanic::No,
            test_type: test::TestType::UnitTest,
        },
        testfn: test::StaticTestFn(|| test::assert_test_result(proptest())),
    };
    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("crates/primitives/src/prune/checkpoint.rs");
                let mut runner = ::proptest::test_runner::TestRunner::new(config);
                let names = "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);
                                if !(field == decoded) {
                                    ::core::panicking::panic(
                                        "assertion failed: field == decoded",
                                    )
                                };
                            }
                        };
                        Ok(())
                    },
                ) {
                    Ok(_) => (),
                    Err(e) => {
                        ::std::rt::panic_fmt(format_args!("{0}\n{1}", e, runner));
                    }
                }
            };
        };
    }
}

@shekhirin shekhirin added this pull request to the merge queue Jul 11, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Jul 11, 2023
@shekhirin shekhirin added this pull request to the merge queue Jul 11, 2023
Merged via the queue into main with commit 9412963 Jul 11, 2023
@shekhirin shekhirin deleted the alexey/prune-checkpoint-database branch July 11, 2023 15:50
merklefruit pushed a commit to merklefruit/op-reth-old that referenced this pull request Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save pruning checkpoints in a separate database table
3 participants