Rayls Docs

Rayls Privacy Ledger

Pre-requisites

  • A Linux machine or WSL with Docker installed
  • A MongoDB Cluster
  • Access to registry.parfin.io

1.1 Configuring the environment

1.1 Environment variables

The first thing that we need to do is to configure the required environment variables, which are:

  • MONGODB_CONN → This is the connection string to MongoDB
  • MONGODB_DATABASE → This is the name of the database

To configure an environment variable in Linux, you will need to run the command export. Example:

export MONGODB_DATABASE="MyMongoDatabase"

1.2 Folder structure

For the purpose of this guide, let's create a folder to store the data files, that will be a volume to the container.

mkdir -p ~/rayls/data

1.3 Login at registry.parfin.io

The container of the Privacy Ledger will be downloaded from Parfin´s registry. So before running the container, you must have access to the registry and have authenticated yourself in the repository. To do this run docker login registry.parfin.io and input your Parfin Nexus repository username and password.

2. Initialise the Privacy Ledger

Only perform this step if you have not initialised the Privacy Ledger. This step will load files in the data structure and the database in the MongoDB.

Once we have defined the init script inside the container, we need to configure the docker command to run the script as the entry point.

sudo docker run -it -v ~/rayls/data:/app/data --env MONGODB_CONN=$MONGODB_CONN --env MONGODB_DATABASE=$MONGODB_DATABASE --entrypoint /app/scripts/init.sh registry.parfin.io/rayls-privacy-ledger:v1.7.1

To validate if the init run has been successful, verify the below:

  • You haven't received any error in the output of the command below
  • Can access the MongoDB and check if the database was created
  • If the nodekey was created inside ~/rayls/data/parchain directory

3. Run the Privacy Ledger

After the successful initialisation, its time to start the Privacy Ledger, to do so just run the command below:

sudo docker run -v ~/rayls/data:/app/data --env MONGODB_CONN=$MONGODB_CONN --env MONGODB_DATABASE=$MONGODB_DATABASE -p 8545:8545 -p 8660:8660 registry.parfin.io/rayls-privacy-ledger:v1.7.1

Congratulations, you're now on Blockchain Rayls! 👏👏


Extras

Container flags explanation

-v Map the local drive ~/rayls/data to /app/data in the container.
--env Map to container an environment variable.
-p Accept the connection in a specific port and redirect to the port that the container is listening.

Run container in background

To run the container in background, just add the -d flag. Example:

sudo docker run -v ~/rayls/data:/app/data -d --env MONGODB_CONN=$MONGODB_CONN --env MONGODB_DATABASE=$MONGODB_DATABASE -p 8545:8545 -p 8660:8660 registry.parfin.io/rayls-privacy-ledger:1.7.1

Test the container

To test the container is accepting connections at the RPC-JSON port and returning information from the last block, perform the following.

Run from another terminal in the same instance, or adjust the address in the end of the command, the command below:

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", true],"id":1}' localhost:8545

The Rayls Privacy Ledger structure in the container

The next step is to create a folder structure in the container to organise the files and make possible to customise the configuration files and scripts over a volume mapping, and to have the data almost transparent for the customers.

This is the folder structure inside the container.

├─/app │ ├─ data │ ├─ scripts │ └ var
  • /app → where we store the binaries
  • /app/data → where we save the data, such as the node key.
  • /app/scripts → where are hosted scripts as the init.sh and start-rayls-privacy-ledger.sh
  • /app/var → where we save the configuration files, such as the genesis.json and config.toml

How to customise the script and config files

We have some default files in the scripts and var directories that can be customised. In this step we share the files and the default information at them:

/app/var/config.toml

[Eth]
RPCGasCap = 9000000000000

[Eth.Ethash]
DisallowBlockCreation = true
CacheDir = "ethash"
CachesInMem = 2
CachesOnDisk = 3
CachesLockMmap = false
DatasetDir = "/app/data/.ethash"
DatasetsInMem = 1
DatasetsOnDisk = 2
DatasetsLockMmap = false
PowMode = 0
NotifyFull = false

/app/var/genesis.json

{
    "config": {
      "chainId": 12345,
      "homesteadBlock": 0,
      "eip150Block": 0,
      "eip155Block": 0,
      "eip158Block": 0,
      "byzantiumBlock": 0,
      "constantinopleBlock": 0,
      "petersburgBlock": 0,
      "istanbulBlock": 0,
      "berlinBlock": 0,
      "ethash": {}
    },
    "difficulty": "1",
    "gasLimit": "9000000000000",
    "alloc": {
        "0x5f2E7061aDd05c8B4C2b48054E5A591eFFa270Aa": {
            "balance": "300000000000000000000000"
        }
    }
}

/app/scripts/init.sh

#!/bin/bash
/app/rayls-privacy-ledger init --datadir /app/data --db.engine mongodb --db.engine.host $MONGODB_CONN --db.engine.name=$MONGODB_DATABASE /app/var/genesis.json

/app/scripts/start-rayls-privacy-ledger.sh

#!/bin/bash
/app/rayls-privacy-ledger \
--http \
--http.vhosts='*' \
--http.addr="0.0.0.0" \
--http.api="net,web3,eth,debug,txpool" \
--http.port 8545 \
--http.corsdomain '*' \
--ws \
--ws.port 8660 \
--ws.addr="0.0.0.0" \
--ws.api eth,net,web3 \
--ws.origins '*' \
--datadir /app/data/ \
--networkid 12345 \
--mine \
--miner.threads=1 \
--miner.etherbase=0x1bE478ee83095aF7F21bd84743fB39B68Dd600A6 \
--rpc.gascap 0 \
--gcmode "archive" \
--syncmode=full \
--miner.gasprice 0 \
--port 30309 \
--config /app/var/config.toml \
--db.engine mongodb \
--db.engine.host $MONGODB_CONN \
--db.engine.name=$MONGODB_DATABASE

To customise a file or folder, create the files in the Linux machine and map with the -v parameter of the container.

The /app/scripts/start-rayls-privacy-ledger.sh is the default Entry point of the container.