Skip to content
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

ledger: default folder in home directory #1138

Merged
merged 5 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/1138-base-directory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Changed the default base directory. On linux, the default path will be `$XDG_DATA_HOME/com.heliax.namada`, on OSX it will be `$HOME/.local/share/com.heliax.namada`.
([#1138](https://github.com/anoma/namada/pull/1138))
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ masp_proofs = { git = "https://github.com/anoma/masp", rev = "bee40fc465f6afbd10
bimap = {version = "0.6.2", features = ["serde"]}
rust_decimal = "1.26.1"
rust_decimal_macros = "1.26.1"
directories = "4.0.1"

[dev-dependencies]
namada = {path = "../shared", default-features = false, features = ["testing", "wasm-runtime"]}
Expand Down
9 changes: 5 additions & 4 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,8 +1582,7 @@ pub mod args {
use super::utils::*;
use super::{ArgGroup, ArgMatches};
use crate::client::types::{ParsedTxArgs, ParsedTxTransferArgs};
use crate::config;
use crate::config::TendermintMode;
use crate::config::{self, TendermintMode};
use crate::facade::tendermint::Timeout;
use crate::facade::tendermint_config::net::Address as TendermintAddress;

Expand All @@ -1598,7 +1597,7 @@ pub mod args {
"base-dir",
DefaultFn(|| match env::var("NAMADA_BASE_DIR") {
Ok(dir) => dir.into(),
Err(_) => config::DEFAULT_BASE_DIR.into(),
Err(_) => config::get_default_namada_folder(),
}),
);
// const BLOCK_HEIGHT_OPT: ArgOpt<BlockHeight> = arg_opt("height");
Expand Down Expand Up @@ -1731,7 +1730,9 @@ pub mod args {
configuration and state is stored. This value can also \
be set via `NAMADA_BASE_DIR` environment variable, but \
the argument takes precedence, if specified. Defaults to \
`.namada`.",
`$XDG_DATA_HOME/com.heliax.namada` or \
`$HOME/.local/share/com.heliax.namada` depending on the \
operating system (former is linux, latter is osx).",
))
.arg(WASM_DIR.def().about(
"Directory with built WASM validity predicates, \
Expand Down
9 changes: 9 additions & 0 deletions apps/src/lib/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::path::{Path, PathBuf};
use std::str::FromStr;

use directories::ProjectDirs;
use namada::types::chain::ChainId;
use namada::types::time::Rfc3339String;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -348,6 +349,14 @@ impl Config {
}
}

pub fn get_default_namada_folder() -> PathBuf {
if let Some(project_dir) = ProjectDirs::from("com", "heliax", "namada") {
project_dir.data_dir().to_path_buf()
} else {
DEFAULT_BASE_DIR.into()
}
}

pub const VALUE_AFTER_TABLE_ERROR_MSG: &str = r#"
Error while serializing to toml. It means that some nested structure is followed
by simple fields.
Expand Down
4 changes: 2 additions & 2 deletions documentation/docs/src/user-guide/ledger.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namada ledger

The node will attempt to connect to the persistent validator nodes and other peers in the network, and synchronize to the latest block.

By default, the ledger will store its configuration and state in the `.namada` directory relative to the current working directory. You can use the `--base-dir` CLI global argument or `NAMADA_BASE_DIR` environment variable to change it.
By default, the ledger will store its configuration and state in the `.namada` directory in either `$XDG_DATA_HOME/<project_path>` or `$HOME/.local/share/<project_path>`, where `<project_path>` is `com.heliax.namada`. You can use the `--base-dir` CLI global argument or `NAMADA_BASE_DIR` environment variable to change it.

The ledger also needs access to the built WASM files that are used in the genesis block. These files are included in release and shouldn't be modified, otherwise your node will fail with a consensus error on the genesis block. By default, these are expected to be in the `wasm` directory, relative to the current working directory. This can also be set with the `--wasm-dir` CLI global argument, `NAMADA_WASM_DIR` environment variable or the configuration file.
The ledger also needs access to the built WASM files that are used in the genesis block. These files are included in release and shouldn't be modified, otherwise your node will fail with a consensus error on the genesis block. By default, these are expected to be in the `wasm` directory inside the chain directory that's in the base directory. This can also be set with the `--wasm-dir` CLI global argument, `NAMADA_WASM_DIR` environment variable or the configuration file.

The ledger configuration is stored in `.namada/{chain_id}/config.toml` (with
default `--base-dir`). It is created when you join the network. You can modify
Expand Down