Skip to content

Commit

Permalink
neard: remove unsafe_reset_all and unsafe_reset_data commands (#7026
Browse files Browse the repository at this point in the history
)

The two undocumented `unsafe_reset_all` and `unsafe_reset_data`
commands have been deprecated since 1.25.  Get rid of them.  This also
gets rid of `get_store_path` function which is the last place where
path to the RocksDB is assumed to be `<neard-home>/data`.

Issue: #6857
  • Loading branch information
mina86 authored Jun 14, 2022
1 parent 7542246 commit e75d1e8
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 36 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
RocksDB configurable via `config.json` file (at `store.path` path)
rather than being hard-coded to `data` directory in neard home
directory [#6938](https://github.com/near/nearcore/pull/6938)
* Removed undocumented `unsafe_reset_all` and `unsafe_reset_data`
commands. They were deprecated since 1.25

## 1.26.0 [2022-05-18]

Expand Down
6 changes: 0 additions & 6 deletions core/store/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ impl Default for StoreConfig {
}
}

// TODO(#6857): Get rid of this function. Clients of this method should use
// StoreOpener::get_path instead..
pub fn get_store_path(base_path: &std::path::Path) -> std::path::PathBuf {
base_path.join(STORE_PATH)
}

/// Builder for opening a RocksDB database.
///
/// Typical usage:
Expand Down
2 changes: 1 addition & 1 deletion core/store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub mod migrations;
pub mod test_utils;
mod trie;

pub use crate::config::{get_store_path, StoreConfig, StoreOpener};
pub use crate::config::{StoreConfig, StoreOpener};

#[derive(Clone)]
pub struct Store {
Expand Down
29 changes: 0 additions & 29 deletions neard/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use near_primitives::types::{Gas, NumSeats, NumShards};
use near_state_viewer::StateViewerSubCommand;
use near_store::db::RocksDB;
use std::cell::Cell;
use std::fs;
use std::net::SocketAddr;
use std::path::{Path, PathBuf};
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -77,16 +76,6 @@ impl NeardCmd {
}
NeardSubCommand::Run(cmd) => cmd.run(&home_dir, genesis_validation, runtime),

// TODO(mina86): Remove the command in Q3 2022.
NeardSubCommand::UnsafeResetData => {
let store_path = near_store::get_store_path(&home_dir);
unsafe_reset("unsafe_reset_data", &store_path, "data", "<near-home-dir>/data");
}
// TODO(mina86): Remove the command in Q3 2022.
NeardSubCommand::UnsafeResetAll => {
unsafe_reset("unsafe_reset_all", &home_dir, "data and config", "<near-home-dir>");
}

NeardSubCommand::StateViewer(cmd) => {
cmd.subcmd.run(&home_dir, genesis_validation, cmd.readwrite);
}
Expand Down Expand Up @@ -135,15 +124,6 @@ pub(super) struct StateViewerCommand {
subcmd: StateViewerSubCommand,
}

fn unsafe_reset(command: &str, path: &std::path::Path, what: &str, default: &str) {
let dir =
path.to_str().map(|path| shell_escape::unix::escape(path.into())).unwrap_or(default.into());
warn!(target: "neard", "The ‘{}’ command is deprecated and will be removed in Q3 2022", command);
warn!(target: "neard", "Use ‘rm -r -- {}’ instead (which is effectively what this command does)", dir);
info!(target: "neard", "Removing all {} from {}", what, path.display());
fs::remove_dir_all(path).expect("Removing data failed");
}

#[derive(Parser, Debug)]
struct NeardOpts {
/// Sets verbose logging for the given target, or for all targets if no
Expand Down Expand Up @@ -188,15 +168,6 @@ pub(super) enum NeardSubCommand {
// Deprecated since 1.24. Delete it in a couple of releases in 2022.
#[clap(hide = true)]
Testnet(LocalnetCmd),
/// (unsafe) Remove the entire NEAR home directory (which includes the
/// configuration, genesis files, private keys and data). This effectively
/// removes all information about the network.
#[clap(alias = "unsafe_reset_all", hide = true)]
UnsafeResetAll,
/// (unsafe) Remove all the data, effectively resetting node to the genesis state (keeps genesis and
/// config).
#[clap(alias = "unsafe_reset_data", hide = true)]
UnsafeResetData,
/// View DB state.
#[clap(name = "view-state", alias = "view_state")]
StateViewer(StateViewerCommand),
Expand Down

0 comments on commit e75d1e8

Please sign in to comment.