Skip to content

Firo Services

a-bezrukov edited this page Nov 28, 2021 · 6 revisions

Insight block explorer based on bitcore-node-zcoin

Click to expand

Brief description

This is an AngularJS WebUI project, which uses firod as the backend and the main database for Firo address and tx info. It uses MongoDB as the Rich List storage and relblocks as the Lelantus/Sigma information storage

Entry point

bitcore-node-zcoin

Installation

The Quick Start guide provides access to a simple installation script which can be used as a base for more advanced scripting For the testnet faucet one should start with the testnet_utils branch of bitcore-node-zcoin rather than master.

Configuration

The Insight configuration file is bitcore-node-zcoin.json which is generated and placed inside the installation dir. Here is an example:

{
  "network": "livenet",
  "port": 3001,
  "services": [
    "bitcoind",
    "insight-api-zcoin",
    "insight-ui-zcoin",
    "web"
  ],
  "servicesConfig": {
    "bitcoind": {
      "spawn": {
        "datadir": "/home/insight/.firo/",
        "exec": "/usr/local/bin/firod"
      }
    },
    "insight-api-zcoin": {
      "db": {
        "url": "mongodb://localhost:27017/insight"
      },
      "postgres_db": {
        "host": "localhost",
        "database": "relblocks",
        "user": "relblocks_ro",
        "password": "PASSWORD"
      }
    }    
  }
}

Usually it is serviceConfig.bitcoind.spawn that needs to be changed. It is usually the Linux service that runs the node. The service file can be found at /lib/systemd/system/bitcore-node-zcoin.service

Usual issues

  1. Indices corruption
    Symptoms: When the Address or Tx index gets corrupted the Insight may show something like negative address balance or invalid txs or tx number.
    Root cause: In case of Insight crash or if restart is requested Insight waits for firod process to gracefully finish. If it is not finished in time, the Insight kills the process leaving the indices in the corrupted state.
    Ways to fix: Firod reindex only. Nginx may be set to use the other Insight instance and the current one should be reindexed
  2. Unknown mining pool/block producer
    Symptoms: When a new miner starts mining blocks, the miner's url is not listed in the main or block views.
    Root cause: The corresponding pool is absent from the pools.json file
    Ways to fix: Look the Insight logs with sudo journalctl -u bitcore-node-zcoin for messages like Cannot find pool:, extract the pool data from the coinbase script and add it to the pools.js
  3. Supported URLs

https://insight.firo.org/api/zerocoin/gettotalzeromint

https://insight.firo.org/api/zerocoin/gettotalzerospend

https://insight.firo.org/api/zerocoin/getrealsupply

https://insight.firo.org/api/ext/getmoneysupply

electrumx-firo

Click to expand

Brief description

This is a very robust Python server for Electum-Firo client.

Entry point

electrumx-firo

Installation

Requires Python>=3.7 to run setup.py and go through the installation steps.

Configuration

Requires the environment variables to be set like in this example:

#!/bin/bash
export COIN=Firo
export NET=Testnet
export DAEMON_URL=http://FIROUSER:FIROPASSWORD@localhost:18888/
export DB_DIRECTORY=/home/electrumx/.electrumx_testnet/
export DB_ENGINE=leveldb
export USERNAME=electrumx
export ELECTRUMX=/home/electrumx/source/electrumx/electrumx_server
export SERVICES=tcp://0.0.0.0:51001,ssl://0.0.0.0:51002
export ANON_LOGS=electrumx
export BANNER_FILE=/home/electrumx/banner.txt
export DONATION_ADDRESS=aFrAVZFr8pva5mG8XKaUH8EXcFVVNxLiuB
export CACHE_MB=2048
export MAX_SESSIONS=1024
export SSL_CERTFILE=/home/electrumx/server.crt
export SSL_KEYFILE=/home/electrumx/server.key
export MAX_SEND=2000000

python3.8 electrumx_server

Usual issues

  1. A rare crash with message struct.error: 'H' format requires 0 <= number <= 65535
    Symptoms: electrumx server crashes with the error and cannot start
    Root cause: Overflow of a 16-bits variable
    Ways to fix: rm -rf electrumx's hist, meta, utxo dirs and resync from scratch
  2. Inability to merge our code into the parent
    Root cause: Our code allows for doublespend in a number of blocks.

Electrum-Firo

Click to expand

Brief description

A Python SPV wallet, a client for electrumx-firo. The code quality is quite poor but it is improving

Entry point

Electrum-Firo

Building the release binaries

Linux: run contrib/dash/build.sh and it will prepare the Windows and Linux binaries
Macos: iteratively run contrib/dash/build.sh on HighSierra to install all the dependencies. It may not build with the python-bls==0.1.9. Here is a patch to solve it:

diff --git a/contrib/dash/actions/install-osx.sh b/contrib/dash/actions/install-osx.sh
index 72a83882..eea83b4c 100755
--- a/contrib/dash/actions/install-osx.sh
+++ b/contrib/dash/actions/install-osx.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-set -ev
+set -exv
 
 if [[ -n $GITHUB_ACTION ]]; then
     PYTHON_VERSION=3.7.9
diff --git a/contrib/dash/actions/script-osx.sh b/contrib/dash/actions/script-osx.sh
index 7bec32d1..9cd2e44e 100755
--- a/contrib/dash/actions/script-osx.sh
+++ b/contrib/dash/actions/script-osx.sh
@@ -1,11 +1,12 @@
 #!/bin/bash
-set -ev
+set -exv
 
 export MACOSX_DEPLOYMENT_TARGET=10.13
 
 export PY37BINDIR=/Library/Frameworks/Python.framework/Versions/3.7/bin/
 export PATH=$PATH:$PY37BINDIR
 echo osx build version is $DASH_ELECTRUM_VERSION
+export DASH_ELECTRUM_VERSION=$DASH_ELECTRUM_VERSION
 
 
 if [[ -n $GITHUB_REF ]]; then
@@ -37,7 +38,7 @@ cp contrib/osx/osx_actions.spec osx.spec
 cp contrib/dash/pyi_runtimehook.py .
 cp contrib/dash/pyi_tctl_runtimehook.py .
 
-pyinstaller --clean \
+sudo -E pyinstaller --clean \
     -y \
     --name electrum-firo-$DASH_ELECTRUM_VERSION.bin \
     osx.spec
diff --git a/contrib/dash/build.sh b/contrib/dash/build.sh
index e63595f5..29cd5e1d 100755
--- a/contrib/dash/build.sh
+++ b/contrib/dash/build.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+set -ex
+
 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
 REPO_DIR="$(realpath $SCRIPT_DIR/../../)"
 ACTIONS_DIR="$SCRIPT_DIR/actions"
diff --git a/contrib/deterministic-build/requirements.txt b/contrib/deterministic-build/requirements.txt
index 7115e924..2ffa8260 100644
--- a/contrib/deterministic-build/requirements.txt
+++ b/contrib/deterministic-build/requirements.txt
@@ -198,7 +198,7 @@ zipp==3.4.1 \
 colorama==0.4.4 \
     --hash=sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b \
     --hash=sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2
-python-bls==0.1.9 \
+python-bls==0.1.8 \
     --hash=sha256:9c89eb9d8a5d667ef9f3422a5ba64cacb52bff47cc3acdb21780152b1cc2c8c8 \
     --hash=sha256:10d2d1148f594366858aebcc07c987dbbcf5b89a0b0b23bd59e6af0d4134601e \
     --hash=sha256:beecbe0c6f42a5e065c7a563c655e17cbc44624ecbd5302a5e733098748a6cf1 \

Use cases

  • Syncing from scratch
  • Receiving/Sending coins with or without a hardware wallet
  • Registering and managing a masternode w/wo a hardware wallet

Usual issues

Relblocks

Click to expand

Brief description

Relblocks is a blockchain in an SQL database for ease of stats calculation and attacks detection. Relblocks is a part of our Watchdog service which monitors the blockchain in order to detect doublespends, spending too much of the privacy transactions, etc. It uses Postgres as the DB

Entry point

Relblocks

Relblocks wiki

Installation

Builing relblocks: installing cmake and the build tools, cloning the repo, mkdir build, executing cmake in the build dir.
Deploying the DB schema: executing scripts/database/init_db.sh as root

Configuration

{
  "connection_string": "dbname=relblocks user=relblocks password=PASSWORD host=localhost",
  "path": "/usr/local/bin/",
  "net": ""
}

path - the firod path
net - the parameters to pass to firod. Maybe "-testnet", "-disablesafemode" or any valid parameters

Usual issues

  • As it reads the blocks from firo-cli in text mode, its performance is slower than it could be
  • Database schema update may take time per #1

Watchdog

Click to expand

Brief description

This is a service that constantly monitors the blockchain state and report to a Matrix channel on events like too fast growth of the circulation. It uses Jenkins to manage the jobs and relblocks to provide the stats data

Entry point

wd.zcoin.io/jenkins

Installation

Regular Jenkins installation and PgAdmin5 installation

Configuration

Regular

Usual issues

Firo Masternode Tool

Click to expand

Brief description

Firo masternode tool is a python project which allows for creation and management of Firo masternodes as well as it provides very simple wallet functionality. As it is impossible to sign a ProRegTx-like transaction with a hardware keystore, it uses an outstanding dedicated RPC service to sign such txs. The service description and the installation guidelines are in contrib/nginx dir.

Entry point

https://github.com/firoorg/firo-masternode-tool

Build Process

The build is neatly dome by the Github actions.

Configuration

See the contrib/nginx dir

Usual issues

I may run out of funds for the ProRegTx sending.

Gitian Build Script

Click to expand

Brief description

#!/usr/bin/env bash

set -e
set -x

branch="master"
targets="${targets:-lwm}"

readonly GITIAN_BUILDER="gitian_builder"
readonly NCPU="${ncpu:-$(nproc)}"
readonly WD=$(pwd -P)


if [ ! -d "${GITIAN_BUILDER}" ] ;
then
    git clone https://github.com/firoorg/gitian-builder.git ${GITIAN_BUILDER}
fi

mkdir -p ${GITIAN_BUILDER}/inputs

pushd ${GITIAN_BUILDER}/inputs

if [ ! -d "firo" ] ;
then
    git clone -b $branch [email protected]:firoorg/firo.git firo
fi

curl -LO https://bitcoincore.org/cfields/osslsigncode-Backports-to-1.7.1.patch
curl -LO http://downloads.sourceforge.net/project/osslsigncode/osslsigncode/osslsigncode-1.7.1.tar.gz
echo "Getting Dependencies"
cd ..
make -C inputs/firo/depends download SOURCES_PATH=$(pwd)/cache/common
rm -rf firo-binaries
mkdir firo-binaries
bin/make-base-vm --distro ubuntu --suite bionic --arch amd64 --docker
popd

if [ ! -d "${GITIAN_BUILDER}_WIN" ] ;
then
    cp -r ${GITIAN_BUILDER} ${GITIAN_BUILDER}_WIN
fi

if [ ! -d "${GITIAN_BUILDER}_OSX" ] ;
then
    cp -r ${GITIAN_BUILDER} ${GITIAN_BUILDER}_OSX
fi

export USE_DOCKER=1

if [[ $targets == *"l"* ]]; 
then
    (
    pushd ${GITIAN_BUILDER}
    bin/gbuild -j ${NCPU} --commit firo=$branch inputs/firo/contrib/gitian-descriptors/gitian-linux.yml
    mv build/out/firo-*.tar.gz build/out/src/firo-*.tar.gz firo-binaries 
    popd
    ) &
    linux_pid=$!
else 
    echo "Not building Linux"
    linux_pid=$!
fi

if [[ $targets == *"w"* ]];
then
    (
    pushd ${GITIAN_BUILDER}_WIN
    export gitian_target="gitian-target-win"
    bin/gbuild -j ${NCPU} --commit firo=$branch inputs/firo/contrib/gitian-descriptors/gitian-win.yml
    mv build/out/firo-*.zip build/out/firo-*.exe firo-binaries &
    popd
    ) &
    win_pid=$!
else
    echo "Not building Windows"
    win_pid=$!
fi

if [[ $targets == *"m"* ]];
then
    (
    pushd ${GITIAN_BUILDER}_OSX
    export gitian_target="gitian-target-osx"
    curl -L -o inputs/MacOSX10.14.sdk.tar.gz https://bitcoincore.org/depends-sources/sdks/MacOSX10.14.sdk.tar.gz
    bin/gbuild -j ${NCPU} --commit firo=$branch inputs/firo/contrib/gitian-descriptors/gitian-osx.yml
    mv build/out/firo-*.tar.gz build/out/firo-*.dmg firo-binaries &
    popd
    ) &
    osx_pid=$!
else
    echo "Not building macos"
    osx_pid=$!
fi

wait $linux_pid
wait $win_pid
wait $osx_pid

Configuration

branch="master" specifies the branch to be built. targets can be specified to change the OS set it is built for.

Usual issues

Local code changes will be checked out with what was originally in the branch.

Clone this wiki locally