Skip to content

Conversation

dan-da
Copy link
Collaborator

@dan-da dan-da commented Jul 31, 2025

context:

I added this command to neptune-cli in case it is helpful for debugging issues with user's databases.

Both keys and values are stored as bytes inside level-db and are output (dumped) as hex encoded byte strings, with a space between each byte so it is easy to see visually identify each byte.

It requires an understanding of the expected data types to interpret the dumped data.

Example usage and output:

target/debug/neptune-cli dump-db testnet wallet`
Key (hex): 01 00 00 00 00 00 00 00 00
Value (hex): 28 00 00 00 00 00 00 00 d9 86 e9 b2 29 83 1f 77 9c ee 1a 55 6f 2a 63 d2 46 31 55 9e b9 b3 bb 8c 3d ac a8 d6 5d 1f 66 ac ca 1d 10 02 66 98 ad a8

Key (hex): 01 00 00 00 00 00 00 00 03
Value (hex): 28 00 00 00 00 00 00 00 d9 86 e9 b2 29 83 1f 77 9c ee 1a 55 6f 2a 63 d2 46 31 55 9e b9 b3 bb 8c 3d ac a8 d6 5d 1f 66 ac ca 1d 10 02 66 98 ad a8

Key (hex): 01 00 00 00 00 00 00 00 05
Value (hex): 08 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00

Key (hex): 01 00 00 00 00 00 00 00 06
Value (hex): 08 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00

Key (hex): 01 00 00 00 00 00 00 00 08
Value (hex): 02 00 00 00 00 00 00 00 01 00

commit message follows.


This command enables dumping key/val pairs of all values in a given leveldb database as hex.

Usage: neptune-cli dump-db <NETWORK> <DB_STORE>

Arguments:
  <NETWORK>
  <DB_STORE>  [possible values: archival-block-mmr, banned-ips, block-index, mutator-set, wallet]

This command enables dumping key/val pairs of all values in a given
leveldb database as hex.

Usage: neptune-cli dump-db <NETWORK> <DB_STORE>

Arguments:
  <NETWORK>
  <DB_STORE>  [possible values: archival-block-mmr, banned-ips, block-index, mutator-set, wallet]
@dan-da dan-da requested a review from aszepieniec July 31, 2025 01:17
@Sword-Smith
Copy link
Member

Very nice. I think we should add a warning not to share the output with others, unless there's a good reason. Not sure about the wording. To be fair, the wallet output can be used to deanonymize transactions, not to steal funds.

Copy link
Contributor

@aszepieniec aszepieniec left a comment

Choose a reason for hiding this comment

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

LGTM

I had a stab at @Sword-Smith's suggested disclaimer. Note that the docstring is used for the command help info.

@@ -159,6 +184,12 @@ enum Command {
/// retrieve info about peers
PeerInfo,

/// dump all key/val pairs in the indicated database
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// dump all key/val pairs in the indicated database
/// Dump all key/val pairs in the indicated database.
///
/// Note that the resulting data dump contains private information that would
/// enable the reader to deanonymize transactions. Only share this information
/// if the privacy risk is acceptable. This dump does not contain information
/// that would enable the reader to spend UTXOs.

Copy link
Member

Choose a reason for hiding this comment

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

For the wallet DB, this is correct. I think the other DBs don't leak anything money-related when dumped.

@aszepieniec
Copy link
Contributor

If I understand correctly, this CLI command makes the python script of 1c33831 unnecessary. If so, let's drop that script.

@dan-da
Copy link
Collaborator Author

dan-da commented Jul 31, 2025

If I understand correctly, this CLI command makes the python script of 1c33831 unnecessary. If so, let's drop that script.

Each has its own advantages; I would probably keep both, but if picking just one I would pick the python script.

The python script is more flexible in that it accepts a path to any DB directory. So it will work with backups, etc. Also it can be used even if the user does not have a functioning neptune installation.

The neptune-cli command is perhaps more user-friendly in that it accepts a network argument and db-type and automatically figures out the DB location from there. Also it may easier for users to get running especially on windows. But it is somewhat circuitous to use with arbitrary DB locations.

@aszepieniec
Copy link
Contributor

Right. So there's plenty of things that you might want to do with the python script that you just can't do with the CLI command. Let's keep both then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants