-
Notifications
You must be signed in to change notification settings - Fork 22
feat: add dump-db command to neptune-cli #637
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
base: master
Are you sure you want to change the base?
Conversation
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]
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. |
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
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 |
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.
/// 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. |
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.
For the wallet DB, this is correct. I think the other DBs don't leak anything money-related when dumped.
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. |
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. |
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:
commit message follows.
This command enables dumping key/val pairs of all values in a given leveldb database as hex.