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

feat: one-click installer - cli edition #3534

Merged
merged 6 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ base_layer/wallet_ffi/build.config
base_layer/wallet_ffi/.cargo/config

keys.json

# Ignore docker files
applications/launchpad/docker_rig/*.Dockerfile
applications/launchpad/docker_rig/docker-compose.yml
10 changes: 10 additions & 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"infrastructure/shutdown",
"infrastructure/storage",
"infrastructure/test_utils",
"applications/deps_only",
# "applications/installer",
"applications/tari_base_node",
"applications/tari_console_wallet",
Expand Down
9 changes: 9 additions & 0 deletions applications/deps_only/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "deps_only"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
log = "0.4.14"
8 changes: 8 additions & 0 deletions applications/deps_only/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! This is a dummy application that does nothing useful. BUT building it will download and compile all the crates if
//! you run `cargo build --bin deps_only` from the project root. This is very handy for creating a common image in
//! docker that provides a common shared set of compiled libraries, which can be cached and used to build a variety
//! of other app-specific images

fn main() {
log::info!("Hi Tari. This app does nothing except build all the dependencies");
}
217 changes: 217 additions & 0 deletions applications/launchpad/docker_rig/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
# Tari Launchpad - CLI edition

a.k.a. _Tari one-click miner_.

Currently this only works on MacOS and Linux.
Contributions for `quick_start.bat` are welcomed.

## Prerequisites

1. [Docker](https://docs.docker.com/get-docker/)
2. Set up some environment variables:
- `DATA_FOLDER` (required). The path to store the Tari configuration files and logs. You can create multiple
network setups, each in their own sandbox.
- `TARI_NETWORK` (optional). Default=weatherwax. Specify the Tari network to connect to.
- `START_TOR` (optional). Default=1. Whether we should start a Tor instance
- `START_BASE_NODE` (optional). Default=1. Whether we should start a base node instance
- `START_WALLET` (optional). Default=1. Whether we should start a wallet instance (GRPC only)
- `START_MINER` (optional). Default=1. Whether we should fire up a SHA_3 solo miner.
- `USE_OWN_MODEROD` (optional). Default=0. Whether we should start and sync our own Monero node.
- `START_MONERO_MM` (optional). Default=1. Whether we should start merge-mining on Monero.

- `TARI_WALLET_PASSWORD` (optional). Highly recommended. Default: tari. The password for your Tari wallet.
- `TARI_WALLET__WEATHERWAX__TOR_CONTROL_AUTH` (optional). Default: tari. The password for the Tor control auth.
- `TARI_MONERO_WALLET_ADDRESS` (optional). Though you'll donate funds to some random address if you don't set it.

## Quick Start

`./quick-start.sh`

And you should be golden.

## Interacting with the wallet and base node.

Any Tari client that supports gRPC can be connected to the node setup. With the default configuration, the base node
will be at `http://127.0.0.1:18142` and the wallet will be at `http://127.0.0.1:18143`.

[Kreya](https://kreya.app/) is a fairly user-friendly gRPC client that can give you a rudimentary UI to the docker rig
out of the box:

#### Getting block information

![get_blocks](img/node_blocks.jpg)

#### Wallet - whoami

![whoami](img/wallet_id.jpg)

#### Wallet - send transactions

![send](img/wallet_send.jpg)

## Viewing logs and configuration files

Logs and configuration files are stored in `{DATA_FOLDER}/{app}/log/*.log`.

So assuming your data folder is `/tmp/tari1/, the generated file structure looks like:

```text
/tmp/tari1$ ll -R
drwxr-xr-x user user 128 B Wed Nov 3 15:56:53 2021  base_node/
drwxr-xr-x user user 96 B Wed Nov 3 15:56:53 2021  config/
drwxr-xr-x user user 128 B Mon Nov 1 12:55:50 2021  mm_proxy/
drwxr-xr-x user user 128 B Mon Nov 1 12:55:58 2021  sha3_miner/
drwxr-xr-x user user 64 B Wed Nov 3 15:56:53 2021  tor/
drwxr-xr-x user user 192 B Mon Nov 1 12:56:17 2021  wallet/
drwxr-xr-x user user 96 B Mon Nov 1 12:20:31 2021  xmrig/

./base_node:
drwxr-xr-x user user 128 B Fri Oct 29 17:44:56 2021  config/
drwxr-xr-x user user 320 B Wed Nov 3 15:40:55 2021  log/

./base_node/config:
.rw-r--r-- user user 312 B Mon Nov 1 20:09:38 2021  base_node_id.json
.rw-r--r-- user user 211 B Mon Nov 1 20:09:38 2021  base_node_tor.json

./base_node/log:
.rw-r--r-- user user 3.3 MB Wed Nov 3 15:54:20 2021  core.log
.rw-r--r-- user user 1 MB Wed Nov 3 15:53:10 2021  network.log
.rw-r--r-- user user 0 B Mon Nov 1 13:01:33 2021  other.log

./config:
.rw-r--r-- user user 4.1 KB Mon Nov 1 20:12:10 2021  log4rs.yml

./mm_proxy:
drwxr-xr-x user user 128 B Mon Nov 1 12:53:33 2021  config/
drwxr-xr-x user user 352 B Wed Nov 3 14:10:04 2021  log/

./mm_proxy/config:
.rw-r--r-- user user 8.7 KB Mon Nov 1 12:53:33 2021  config.toml
.rw-r--r-- user user 1.1 KB Mon Nov 1 12:53:33 2021  log4rs.yml

./mm_proxy/log:
.rw-r--r-- user user 8.4 MB Wed Nov 3 15:53:53 2021  core.log
.rw-r--r-- user user 0 B Mon Nov 1 13:01:38 2021  network.log
.rw-r--r-- user user 0 B Mon Nov 1 13:01:38 2021  other.log

./sha3_miner:
drwxr-xr-x user user 192 B Mon Nov 1 13:01:36 2021  log/

./sha3_miner/log:
.rw-r--r-- user user 677.7 KB Wed Nov 3 15:49:31 2021  core.log
.rw-r--r-- user user 0 B Mon Nov 1 13:01:36 2021  network.log
.rw-r--r-- user user 0 B Mon Nov 1 13:01:36 2021  other.log

./wallet:
drwxr-xr-x user user 192 B Mon Nov 1 12:56:17 2021  ./
drwxr-xr-x user user 288 B Wed Nov 3 15:56:53 2021  ../
drwxr-xr-x user user 256 B Wed Nov 3 15:23:19 2021  log/
drwxr-xr-x user user 128 B Wed Nov 3 15:54:10 2021  weatherwax/

./wallet/log:
.rw-r--r-- user user 564.2 KB Wed Nov 3 15:54:20 2021  core.log
.rw-r--r-- user user 280.3 KB Wed Nov 3 15:54:08 2021  network.log
.rw-r--r-- user user 0 B Mon Nov 1 13:01:24 2021  other.log

./xmrig:
drwxr-xr-x user user 96 B Mon Nov 1 12:20:31 2021  ./
drwxr-xr-x user user 288 B Wed Nov 3 15:56:53 2021  ../
.rw-r--r-- user user 212.9 KB Wed Nov 3 15:53:53 2021  xmrig.log
```

You can edit the network configuration (requires a container restart) and log configuration (takes effect within 30s)
by editing the files in the top-level `config` folder.



## Current shortcomings and TODOs

* It's a CLI only. Next step is to build a nice UI wrapper around this.

* TODO - Windows support.

* The blockchain data is stores in docker volumes, and not on the host machine directly. This is due to crippling performance
limitations one suffers when mounting host file system from Windows or MacOS into docker containers.
This isn't a big drawback, since you seldom want or need to access the raw blockchain database files anyway. Are they're
[still accessible](#accessing-blockchain-data). But **ensure that you reserve enough space to store the Tari, and optionally,
Monero blockchains inside the Docker VM**.

* TODO - Multi-network sandboxing. Sandboxing currently doesn't work across different networks (e.g. weatherwax and mainnet). This should be fixed soon.

* Local MoneroD support. The merge-miner proxy doesn't actually use the local MoneroD container if it is running. This
is left as a TODO for the UI version.

* Tor control password. For now, you set this manually. In the UI edition, this will be ephemeral and configured automatically.

* GRPC addresses. The code only supports IPv4 addresses as gRPC configuration parameters. This makes the docker networking
fragile since the IP addresses must be guessed. TODO - accept DNS names in gRPC configs to make this more robust.




### Accessing blockchain data

The blockchain data is stored in a docker volume for performance reasons. If you need to back up or access the LMDB
a blockchain data, you can use something like this to extract it to the host filesystem:

`docker run --rm -v $(pwd):/backup -v blockchain:/blockchain ubuntu tar czvf /backup/backup.tar.gz /blockchain`


## Layout

+-----------------------+
| |
+---->| Console Wallet +------------------+
| | | |
| +----------+------------+ |
| | |
| | gRPC |
| | |
| | |
| +----------v------------+ +------v-----+
| | | Socks5 | |
| | Base Node +---------->| Tor |----> Network
| | | | |
| +----------^------------+ +------------+
| |
| |
| |
| +----------+------------+
| | |
+-----+ SHA3-Miner |
| | |
| +-----------------------+
|
|
|
| +-----------------------+
| | |
+-----+ XMRRig etc |
| |
+-----------------------+

#### Notes

Building docker images:

```
cd buildtools/docker_rig
docker build -t quay.io/tarilabs/tor:latest -f base_node.Dockerfile .
docker build -t quay.io/tarilabs/tari_base_node:latest -f base_node.Dockerfile ../../
```

Base node/Wallet config for using the Tor docker container:

```toml
tcp_listener_address = "/ip4/0.0.0.0/tcp/18189"
transport = "tor"
tor_control_address = "/dns4/tor/tcp/9051"
tor_control_auth = "password=asdf" # replace with your configured password
tor_onion_port = 18141
tor_forward_address = "/ip4/0.0.0.0/tcp/18189"
tor_socks_address_override="/dns4/tor/tcp/9050"
```

When attaching to a running container:

To detach the tty without exiting the shell/program, use the escape sequence ^P^Q (Ctrl+P followed by Ctrl+Q).
61 changes: 61 additions & 0 deletions applications/launchpad/docker_rig/base_node.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
FROM quay.io/tarilabs/rust_tari-build-with-deps:nightly-2021-09-18 as builder

WORKDIR /tari

# Adding only necessary things up front and copying the entrypoint script last
# to take advantage of layer caching in docker
ADD Cargo.lock .
ADD Cargo.toml .
ADD applications applications
ADD base_layer base_layer
ADD common common
ADD comms comms
ADD infrastructure infrastructure
ADD meta meta
ADD rust-toolchain.toml .

ARG ARCH=native
ARG FEATURES=avx2
ENV RUSTFLAGS="-C target_cpu=$ARCH"
ENV ROARING_ARCH=$ARCH
ENV CARGO_HTTP_MULTIPLEXING=false

# Caches downloads across docker builds
RUN cargo build --bin deps_only --release

RUN cargo build --bin tari_base_node --release --features $FEATURES --locked

# Create a base minimal image for the executables
FROM quay.io/bitnami/minideb:bullseye as base
# Disable Prompt During Packages Installation
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt -y install \
apt-transport-https \
bash \
ca-certificates \
curl \
gpg \
iputils-ping \
less \
libreadline8 \
libreadline-dev \
libsqlite3-0 \
openssl \
telnet

RUN groupadd -g 1000 tari && useradd -s /bin/bash -u 1000 -g 1000 tari

RUN mkdir -p "/var/tari/base_node/weatherwax" \
&& mkdir -p "/var/tari/base_node/igor" \
&& mkdir -p "/var/tari/base_node/mainnet" \
&& chown -R tari.tari "/var/tari/base_node"

USER tari

ENV APP_NAME=base_node APP_EXEC=tari_base_node

COPY --from=builder /tari/target/release/$APP_EXEC /usr/bin/
COPY applications/launchpad/docker_rig/start_tari_app.sh /usr/bin/start_tari_app.sh

ENTRYPOINT [ "start_tari_app.sh", "-c", "/var/tari/config/config.toml", "-b", "/var/tari/base_node" ]
# CMD [ "--non-interactive-mode" ]
Loading