ZcashFoundation / zebra

Zcash - Financial Privacy in Rust 🦓
https://zfnd.org/zebra/
Apache License 2.0
413 stars 106 forks source link

feat(zebra-db): Split low level database code inside `zebra-state` #7926

Open oxarbitrage opened 1 year ago

oxarbitrage commented 1 year ago

Motivation

We want to re-using RocksDB for our scanner work, because we already have well-tested low level interfaces to it.

Suggested Changes

We want to move low-level database code into:

And move anything specific to zebra-state outside those modules:

Related Work

This was mentioned in https://github.com/ZcashFoundation/zebra/issues/7904#issuecomment-1802586921 and earlier comments on that ticket.

teor2345 commented 1 year ago

@arya2 this ticket is related to some ideas you had about making format upgrades generic.

The simplest change we could do is to pass a format upgrade function and a format check function to the upgrade task in the split out crate.

But how much more work would it be to refactor each upgrade into an upgrade trait, and then pass a list of upgrade trait objects to the upgrade task?

I guess we could do that later, it's not required to do the split.

arya2 commented 1 year ago

But how much more work would it be to refactor each upgrade into an upgrade trait, and then pass a list of upgrade trait objects to the upgrade task?

I don't think it would be too significant, but it would involve a lot of code movement that could be difficult to review alongside this change.

I guess we could do that later, it's not required to do the split.

It would be good to do it before the next format upgrade, I opened https://github.com/ZcashFoundation/zebra/issues/7932

teor2345 commented 1 year ago

But how much more work would it be to refactor each upgrade into an upgrade trait, and then pass a list of upgrade trait objects to the upgrade task?

I don't think it would be too significant, but it would involve a lot of code movement that could be difficult to review alongside this change.

I was expecting this change to happen in 2-3 PRs:

mpguerra commented 1 year ago

But how much more work would it be to refactor each upgrade into an upgrade trait, and then pass a list of upgrade trait objects to the upgrade task?

I don't think it would be too significant, but it would involve a lot of code movement that could be difficult to review alongside this change.

I was expecting this change to happen in 2-3 PRs:

* optional: change upgrades into a trait

This is #7932

* move zebra-state specific code out of the files that are going to be moved to zebra-db

This can be this issue (#7926)

* create the zebra-db crate

I've split this out into another checklist item in #7728

mpguerra commented 1 month ago

Is this still relevant even if we don't do any more work on the scanner?