platform icon indicating copy to clipboard operation
platform copied to clipboard

Doc: How to install Dash Drive

Open coolaj86 opened this issue 1 year ago • 3 comments

Overview

Corrections for https://docs.dash.org/en/stable/docs/user/masternodes/setup-testnet.html#drive to install drive from the current codebase.

Notable changes:

  • Go is completely unnecessary
  • Node is completely unnecessary
  • Python is completely unnecessary
  • WASM components are not used directly by drive

Where is the repo to pull request changes to the out-of-date docs?

Table of Contents

  • System Requirements
  • Pre-reqs (Node, Go, Rust, Serviceman)
  • Build Dash Drive from Source
  • Configure
  • Install as System Service
  • Build Dash Drive WASM

System Requirements

  • 8gb RAM (compiling requires about 5gb)
  • 20gb Storage (16gb may suffice, depending on OS size)
    (several GB will be used as build cache during compile)
  • As many CPUs as you have to spare
  • glibc-based system (not Alpine / musl)

Pre-reqs

Install:

  • C tools
  • Protobuf tools
  • Rust
  • Serviceman
sudo apt update
sudo apt install -y \
    build-essential \
    clang \
    cmake
sudo apt install -y \
    protobuf-compiler
curl https://webi.sh/rust | sh
curl https://webi.sh/serviceman | sh
source ~/.config/envman/PATH.env

Build from Source

IMPORTANT
Check https://github.com/dashpay/platform to see whether it's actually master or something else, like v1.0-dev, that's the current working "main" branch.

# EXAMPLE w/ 'v1.0-dev'
git clone --depth 1 --single-branch --branch 'v1.0-dev' \
    https://github.com/dashpay/platform.git \
    ./dash-drive/
# EXAMPLE w/ 'master'
git clone --depth 1 --single-branch --branch 'master' \
    https://github.com/dashpay/platform.git \
    ./dash-drive/
pushd ./dash-drive/

Build Dash Drive

# this WILL NOT work
#yarn workspace @dashevo/rs-drive build

# do this instead
pushd ./packages/rs-drive-abci/

cargo build
ls -lAhF ../target/debug/drive-abci

cargo build --release
ls -lAhF ../target/release/drive-abci

popd

(building unnecessary WASM components moved to its own section)

# SKIP this part
# (the work for this was done above with rs-drive-abci)
#yarn workspaces focus --production @dashevo/drive

Configure Dash Drive

# this WILL NOT work
# (the file doesn't exist)
#cp packages/js-drive/.env.example packages/js-drive/.env

# do this instead
mkdir -p ~/.config/dash-drive/
mkdir -p ~/srv/dash-drive/
#cp -rp ./packages/rs-drive-abci/.env.example ~/.config/dash-drive/env
#cp -rp ./packages/rs-drive-abci/.env.mainnet ~/.config/dash-drive/env
cp -rp ./packages/rs-drive-abci/.env.testnet ~/.config/dash-drive/env
chmod 0750 ~/.config/dash-drive/
chmod 0640 ~/.config/dash-drive/env
my_env_path="$HOME/.config/dash-drive/env"

sed -i 's/^CORE_JSON_RPC_PASSWORD.*/CORE_JSON_RPC_PASSWORD=password/' "${my_env_path}"
sed -i 's/^CORE_JSON_RPC_PORT.*/CORE_JSON_RPC_PORT=19998/' "${my_env_path}"
sed -i 's/^CORE_JSON_RPC_USERNAME.*/CORE_JSON_RPC_USERNAME=dashrpc/' "${my_env_path}"
sed -i 's/^INITIAL_CORE_CHAINLOCKED_HEIGHT.*/INITIAL_CORE_CHAINLOCKED_HEIGHT=854281/' "${my_env_path}"
sed -i 's/^VALIDATOR_SET_LLMQ_TYPE.*/VALIDATOR_SET_LLMQ_TYPE=6/' "${my_env_path}"
sed -i 's/^DASHPAY_MASTER_PUBLIC_KEY=.*/DASHPAY_MASTER_PUBLIC_KEY=02d4dcce3f0a8d2936ce26df4d255fd2835b629b73eea39d4b2778096b91e77946/' "${my_env_path}"
sed -i 's/^DASHPAY_SECOND_PUBLIC_KEY=.*/DASHPAY_SECOND_PUBLIC_KEY=03699c8b4ebf1696c92e9ec605a02a38f6f9cec47d13fb584fdad779e936e20ccb/' "${my_env_path}"
sed -i 's/^DPNS_MASTER_PUBLIC_KEY=.*/DPNS_MASTER_PUBLIC_KEY=02c8b4747b528cac5fddf7a6cc63702ee04ed7d1332904e08510343ea00dce546a/' "${my_env_path}"
sed -i 's/^DPNS_SECOND_PUBLIC_KEY=.*/DPNS_SECOND_PUBLIC_KEY=0201ee28f84f5485390567e939c2b586010b63a69ec92cab535dc96a8c71913602/' "${my_env_path}"
sed -i 's/^FEATURE_FLAGS_MASTER_PUBLIC_KEY=.*/FEATURE_FLAGS_MASTER_PUBLIC_KEY=029cf2232549de08c114c19763309cb067688e21e310ac07458b59c2c026be7234/' "${my_env_path}"
sed -i 's/^FEATURE_FLAGS_SECOND_PUBLIC_KEY=.*/FEATURE_FLAGS_SECOND_PUBLIC_KEY=02a2abb50c03ae9f778f08a93849ba334a82e625153720dd5ef14e564b78b414e5/' "${my_env_path}"
sed -i 's/^MASTERNODE_REWARD_SHARES_MASTER_PUBLIC_KEY=.*/MASTERNODE_REWARD_SHARES_MASTER_PUBLIC_KEY=0319d795c0795bc8678bd0e58cfc7a4ad75c8e1797537728e7e8de8b9acc2bae2b/' "${my_env_path}"
sed -i 's/^MASTERNODE_REWARD_SHARES_SECOND_PUBLIC_KEY=.*/MASTERNODE_REWARD_SHARES_SECOND_PUBLIC_KEY=033756572938aaad752158b858ad38511c6edff4c79cf8462f70baa25fc6e8a616/' "${my_env_path}"
sed -i 's/^WITHDRAWALS_MASTER_PUBLIC_KEY=.*/WITHDRAWALS_MASTER_PUBLIC_KEY=032f79d1d9d6e652599d3315d30306b1277fbf588e32e383aef0a59749547d47b7/' "${my_env_path}"
sed -i 's/^WITHDRAWALS_SECOND_PUBLIC_KEY=.*/WITHDRAWALS_SECOND_PUBLIC_KEY=03eebbe3dc3721603a0b5a13441f214550ffa7d035b7dea9f1911de0f63ddac58d/' "${my_env_path}"

Test Run

./target/debug/drive-abci -c ~/.config/dash-drive/env start

Install as a System Service

# this WILL NOT work
#pm2 start yarn --name "drive" -- workspace @dashevo/drive abci

# do this instead
my_user="$(id -u -n)"
sudo env PATH="${PATH}" \
    serviceman add --name dash-drive --system --username="${my_user}" -- \
    ./target/release/drive-abci -c ~/.config/dash-drive/env start

Check the logs

sudo journalctl -xefu dash-drive

Build WASM Components

Not required to run Dash Drive, but possibly useful as an SDK component for some other software that can consume WASM libraries.

sudo apt install -y \
    pkg-config \
    libssl-dev \
    llvm
 # Check the wasm-bindgen VERSION (ex: 0.2.85)
 grep -B 1 -A 8 'name = "wasm-bindgen"' Cargo.lock

 # Install *that* version of the CLI
 my_wbg_cli_ver="$(
     grep -B 1 -A 8 'name = "wasm-bindgen"' Cargo.lock |
         grep 'version' |
         cut -d'"' -f2
 )"
 echo "$my_wbg_cli_ver"
 # ex: 0.2.86
 cargo install wasm-bindgen-cli@"$my_wbg_cli_ver"
 wasm-bindgen -V
rustup target add wasm32-unknown-unknown
pushd ./packages/wasm_dpp/

cargo build --target wasm32-unknown-unknown
ls -lAhF ../target/wasm32-unknown-unknown/debug/wasm_dpp.wasm

cargo build --release --target wasm32-unknown-unknown
ls -lAhF ../target/wasm32-unknown-unknown/release/wasm_dpp.wasm

popd

coolaj86 avatar Feb 10 '24 00:02 coolaj86

Just finished running through the instructions and can confirm that they are accurate, with one caveat:

It may or may not be necessary to install libssl-dev for the WASM lib. I initially thought the error I was getting was about it being missing, but it turned out to be pkg-config. I suspect that it is also required.

coolaj86 avatar Feb 10 '24 01:02 coolaj86

https://github.com/dashpay/docs/blob/20.0.0/docs/user/masternodes/setup-testnet.rst

pshenmic avatar Feb 11 '24 17:02 pshenmic

Note: As per usual, the protoc shipped with apt may be a decade (or 22 major versions, whatever) behind the official release: https://github.com/protocolbuffers/protobuf/releases

~/.local/opt/protoc/bin/protoc --version
libprotoc 25.3
/usr/bin/protoc --version
libprotoc 3.12.4

How to install protoc v25

mkdir -p ~/Downloads/
pushd ~/Downloads/
curl -L -O https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-linux-x86_64.zip
popd

mkdir -p ~/.local/opt/protoc-v25.3/
pushd ~/.local/opt/protoc-v25.3/
unzip ~/Downloads/protoc-25.3-linux-x86_64.zip
popd

pushd ~/.local/opt/
ln -sf ./protoc-v25.3/ ./protoc
popd

pathman add ~/.local/opt/protoc/bin/
export PATH="$HOME/.local/opt/protoc/bin/:$PATH"

How to install llvm v17

mkdir -p ~/Downloads/
pushd ~/Downloads/
curl -L -O https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz
popd

mkdir -p ~/.local/opt/llvm-v17.0.6/
pushd ~/.local/opt/
tar xvf ~/Downloads/clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz
ln -s ./clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04/ ./clang+llvm
popd

pathman add ~/.local/opt/clang+llvm/bin/
export PATH="$HOME/.local/opt/clang+llvm/bin/:$PATH"

How to install Envoy

curl -L -O https://github.com/envoyproxy/envoy/releases/download/v1.23.10/envoy-1.23.10-linux-x86_64
chmod a+x ./envoy-1.23.10-linux-x86_64
mkdir -p ~/.local/bin/
mv ./envoy-1.23.10-linux-x86_64 ~/.local/bin/envoy

Configure

# NOTE
# Probably better to adapt from
# ./packages/dashmate/templates/platform/dapi/envoy/envoy.yaml.dot

curl -L -O https://gist.githubusercontent.com/strophy/2716c203d88e77419152f6392623b844/raw/ce7aa360b544621c22587a09e0cf7190fd4a202e/envoy.yaml
mkdir -p ~/.config/envoy/
chmod 0700 ~/.config/envoy/
mv ./envoy.yaml ~/.config/envoy/config.yaml
chmod 0600 ~/.config/envoy/config.yaml

Run

envoy --config-path ~/.config/envoy/config.yaml

If Envoy is behind a TLS-terminating proxy on a different port:

static_resources:
  listeners:
    - name: grpc_and_json_rpc
      address:
        socket_address:
          address: 10.11.5.111
          #port_value: 10000
          port_value: 3080
      filter_chains:
        - filters: *filters

coolaj86 avatar Feb 23 '24 05:02 coolaj86

I don't think we have such a section there anymore. DCG doesn't support any other installation than dashmate, atm. Shall we close the issue?

shumkov avatar Sep 23 '24 16:09 shumkov

Please reopen if you think otherwise

shumkov avatar Sep 26 '24 18:09 shumkov