Skip to content

Commit

Permalink
feat(pd): add default homedir for start
Browse files Browse the repository at this point in the history
Closes #3335.
  • Loading branch information
conorsch authored and hdevalence committed Nov 17, 2023
1 parent cd109ff commit 08c80b2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
16 changes: 11 additions & 5 deletions crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ enum RootCommand {
/// Starts the Penumbra daemon.
Start {
/// The path used to store all `pd`-related data and configuration.
/// If unset, defaults to ~/.penumbra/testnet_data/node0/pd.
#[clap(long, env = "PENUMBRA_PD_HOME", display_order = 100)]
home: PathBuf,
home: Option<PathBuf>,
/// Bind the ABCI server to this socket.
///
/// The ABCI server is used by Tendermint to drive the application state.
Expand Down Expand Up @@ -291,10 +292,15 @@ async fn main() -> anyhow::Result<()> {
)
}

let mut rocks_path = home.clone();
rocks_path.push("rocksdb");
// Unpack home directory. Accept an explicit path, but default
// to a sane value if unspecified.
let pd_home = match home {
Some(h) => h,
None => get_testnet_dir(None).join("node0").join("pd"),
};
let rocksdb_home = pd_home.join("rocksdb");

let storage = Storage::init(rocks_path)
let storage = Storage::init(rocksdb_home)
.await
.context("Unable to initialize RocksDB storage")?;

Expand Down Expand Up @@ -436,7 +442,7 @@ async fn main() -> anyhow::Result<()> {
use tokio_stream::wrappers::TcpListenerStream;
use tokio_util::compat::{FuturesAsyncReadCompatExt, TokioAsyncReadCompatExt};

let mut acme_cache = home.clone();
let mut acme_cache = pd_home.clone();
acme_cache.push("rustls_acme_cache");

let grpc_bind = grpc_bind.unwrap_or(
Expand Down
3 changes: 1 addition & 2 deletions deployments/systemd/cometbft.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Description=CometBFT for Penumbra

[Service]
ExecStart=/usr/local/bin/cometbft start --home $HOME/.penumbra/testnet_data/node0/cometbft
Restart=on-failure
RestartSec=5
Restart=no
User=$USER

[Install]
Expand Down
7 changes: 4 additions & 3 deletions deployments/systemd/penumbra.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ Description=Penumbra pd
Wants=cometbft.service

[Service]
ExecStart=/usr/local/bin/pd start --home $HOME/.penumbra/testnet_data/node0/pd
Restart=on-failure
RestartSec=5
ExecStart=/usr/local/bin/pd start
# Consider overriding the home directory, e.g.
# ExecStart=/usr/local/bin/pd start --home /var/www/.penumbra/testnet_data/node0/pd
Restart=no
User=$USER
# Raise filehandle limit for tower-abci.
LimitNOFILE=65536
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/src/dev/devnet-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export RUST_LOG="info,pd=debug,penumbra=debug,jmt=debug"
To run `pd`, run

```shell
cargo run --release --bin pd -- start --home ~/.penumbra/testnet_data/node0/pd
cargo run --release --bin pd -- start
```

This will start but won't do anything yet, because CometBFT isn't running.
Expand Down
7 changes: 3 additions & 4 deletions docs/guide/src/pd/join-testnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ the section above on resetting node state.

### Running `pd` and `cometbft`

Next, run `pd` with the `--home` parameter pointed at the correct part of the
testnet data directory.
Next, run `pd`:

```shell
cargo run --bin pd --release -- start --home ~/.penumbra/testnet_data/node0/pd
cargo run --bin pd --release -- start
```

Then (perhaps in another terminal), run CometBFT, also specifying `--home`:
Then (perhaps in another terminal), run CometBFT, specifying `--home`:

```shell
cometbft start --home ~/.penumbra/testnet_data/node0/cometbft
Expand Down

0 comments on commit 08c80b2

Please sign in to comment.