-
Notifications
You must be signed in to change notification settings - Fork 102
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
add(state): Track spending transaction ids by spent outpoints and revealed nullifiers #8895
base: main
Are you sure you want to change the base?
Conversation
zebra-state/src/service/finalized_state/disk_format/upgrade/track_tx_locs_by_spends.rs
Outdated
Show resolved
Hide resolved
Added a |
…a read method and an update to `prepare_spending_transparent_tx_ids_batch()` for maintaining it when committing blocks to the finalized state. Adds TODOs for remaining production changes needed for issue #8837.
…Id` ReadResponse
…cations in db format upgrade
… its type to a `Spend` enum
…aDb instead of DiskDb, checks cancel_receiver before every db operation
…ng transaction ids
…logs for progress updates
fd2bcca
to
f6faf42
Compare
…in db format version file
- adds the build metadata to the db version file before adding indexes. - deletes indexes when running without the `indexer` feature
@mpguerra It looks like it's actually not using much storage space, I was looking at the db metrics printed at startup which were about double the expected storage requirements prior to the change, but the total size of the state cache directory is about the same as it was before, so I think the db metrics are overestimating the total db size. I checked the number of keys by column family, and by height 2M on Mainnet, it's ~10M transparent outputs and ~150M nullifiers in total, not all of which are spent. It's 10B per spent transparent output and 5 bytes per nullifier, so it should be, at most, ~1GB of additional storage requirements by block 2M. I'll update this comment with the number of nullifiers and transparent outputs at the network chain tip once my node finishes syncing, but it's looking like hiding this behind a feature may have been unnecessary.
Update: At the current network chain tip, it's about 6.2GB of extra data (5.5gb + 140M * 5B), also it's 14B per spent transparent output, not 10B (I had forgot about the output index). 6.2GB doesn't seem excessive, but we could use the feature later if/when caching blocks in their compact format. Relevant Column Family Sizessprout_nullifiers (Disk: 146.7 MB, Memory: 9.4 MB, num_keys: Some(1663236))
sapling_nullifiers (Disk: 230 MB, Memory: 4.2 MB, num_keys: Some(3068534))
orchard_nullifiers (Disk: 6.3 GB, Memory: 55.1 MB, num_keys: Some(134798732))
tx_loc_by_spent_out_loc (Disk: 5.5 GB, Memory: 6.3 MB, num_keys: Some(316786532)) |
| `tx_loc_by_spent_out_loc` | `OutputLocation` | `TransactionLocation` | Create | | ||
| *Sprout* | | | | | ||
| `sprout_nullifiers` | `sprout::Nullifier` | `()` | Create | | ||
| `sprout_nullifiers` | `sprout::Nullifier` | `TransactionLocation` | Create | | ||
| `sprout_anchors` | `sprout::tree::Root` | `sprout::NoteCommitmentTree` | Create | | ||
| `sprout_note_commitment_tree` | `()` | `sprout::NoteCommitmentTree` | Update | | ||
| *Sapling* | | | | | ||
| `sapling_nullifiers` | `sapling::Nullifier` | `()` | Create | | ||
| `sapling_nullifiers` | `sapling::Nullifier` | `TransactionLocation` | Create | | ||
| `sapling_anchors` | `sapling::tree::Root` | `()` | Create | | ||
| `sapling_note_commitment_tree` | `block::Height` | `sapling::NoteCommitmentTree` | Create | | ||
| `sapling_note_commitment_subtree` | `block::Height` | `NoteCommitmentSubtreeData` | Create | | ||
| *Orchard* | | | | | ||
| `orchard_nullifiers` | `orchard::Nullifier` | `()` | Create | | ||
| `orchard_nullifiers` | `orchard::Nullifier` | `TransactionLocation` | Create | |
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 will need an update if we keep the indexer
feature.
…c when trying to open the db with that column family.
@@ -6168,6 +6168,7 @@ dependencies = [ | |||
"bincode", | |||
"chrono", | |||
"color-eyre", | |||
"crossbeam-channel", |
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.
The format upgrade runs much faster for me now, about 8 minutes for 2M blocks, which has been helpful for manual testing. I think the channel types in Rust's standard library didn't work because they weren't Send
or Sync
, and the ones in tokio lack blocking receive methods.
The I thought it was because a column family could be dropped earlier, but it happened again after switching to removing a comprehensive range instead of dropping the column family, so now I'm thinking it's because it's trying to open a secondary db before opening the primary db, where opening the primary db will create any missing column families but opening the secondary panics when one is missing because it lacks write access. I'll confirm that manually, if that is the case, I think |
Motivation
We want to lookup transaction ids by their transparent inputs and revealed nullifiers.
Closes #8837,
Closes #8838.
Closes #8922.
Solution
tx_loc_by_spent_out_loc
column family()
TransactionLocation
of spending transactions by spentOutputLocation
s and nullifiers when writing blocks to the finalized statespent_utxos
field on non-finalizedChain
sReadRequest
andReadResponse
variants for querying spending tx ids by outpoint with theReadStateService
spending_transaction_hash()
read function used to handle the newReadRequest
It may be possible to update the
tx_loc_by_transparent_addr_loc
column instead, but adding a new one seemed easier.Related Changes:
cancel_receiver
to acrossbeam-channel::mpmc
and parallelizes the db format upgrade by blockTests
PR Author's Checklist
PR Reviewer's Checklist