Skip to content

Commit

Permalink
Merge remote-tracking branch 'namada/fraccaman/base-directory' (#1138)…
Browse files Browse the repository at this point in the history
… into maint-0.15

* namada/fraccaman/base-directory:
  added changelog
  fix: review comments
  fix: doc strings
  fix: use data_dir
  ledger: default folder in home directory
  • Loading branch information
juped committed May 11, 2023
2 parents d5e854d + ac0eb29 commit 5d187f0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
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 @@ -153,6 +153,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 @@ -1660,8 +1660,7 @@ pub mod args {
use super::context::*;
use super::utils::*;
use super::{ArgGroup, ArgMatches};
use crate::config;
use crate::config::{Action, ActionAtHeight, TendermintMode};
use crate::config::{self, Action, ActionAtHeight, TendermintMode};
use crate::facade::tendermint::Timeout;
use crate::facade::tendermint_config::net::Address as TendermintAddress;

Expand All @@ -1676,7 +1675,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: Arg<BlockHeight> = arg("block-height");
Expand Down Expand Up @@ -1818,7 +1817,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::storage::BlockHeight;
use namada::types::time::Rfc3339String;
Expand Down Expand Up @@ -376,6 +377,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

0 comments on commit 5d187f0

Please sign in to comment.