Add lighthouse db command (#3129)

## Proposed Changes

Add a `lighthouse db` command with three initial subcommands:

- `lighthouse db version`: print the database schema version.
- `lighthouse db migrate --to N`: manually upgrade (or downgrade!) the database to a different version.
- `lighthouse db inspect --column C`: log the key and size in bytes of every value in a given `DBColumn`.

This PR lays the groundwork for other changes, namely:

- Mark's fast-deposit sync (https://github.com/sigp/lighthouse/pull/2915), for which I think we should implement a database downgrade (from v9 to v8).
- My `tree-states` work, which already implements a downgrade (v10 to v8).
- Standalone purge commands like `lighthouse db purge-dht` per https://github.com/sigp/lighthouse/issues/2824.

## Additional Info

I updated the `strum` crate to 0.24.0, which necessitated some changes in the network code to remove calls to deprecated methods.

Thanks to @winksaville for the motivation, and implementation work that I used as a source of inspiration (https://github.com/sigp/lighthouse/pull/2685).
This commit is contained in:
Michael Sproul
2022-04-01 00:58:59 +00:00
parent ea783360d3
commit 41e7a07c51
25 changed files with 449 additions and 89 deletions

View File

@@ -275,6 +275,7 @@ fn main() {
.subcommand(boot_node::cli_app())
.subcommand(validator_client::cli_app())
.subcommand(account_manager::cli_app())
.subcommand(database_manager::cli_app())
.get_matches();
// Configure the allocator early in the process, before it has the chance to use the default values for
@@ -485,7 +486,16 @@ fn run<E: EthSpec>(
// Exit as soon as account manager returns control.
return Ok(());
};
}
if let Some(sub_matches) = matches.subcommand_matches(database_manager::CMD) {
info!(log, "Running database manager for {} network", network_name);
// Pass the entire `environment` to the database manager so it can run blocking operations.
database_manager::run(sub_matches, environment)?;
// Exit as soon as database manager returns control.
return Ok(());
}
info!(log, "Lighthouse started"; "version" => VERSION);
info!(