Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Latest commit

 

History

History
168 lines (111 loc) · 4.09 KB

setup.md

File metadata and controls

168 lines (111 loc) · 4.09 KB

Mercury Setup Instructions

This guide will show you how to setup Mercury. All the steps here use Ubuntu 20.04 LTS.

Mercury can be built from source, or a precompiled binary can be used. Then the database tables must be setup, and Mercury will need to be configured. Finally, you will need to start Mercury.

Building From Source

Step 1: Install Build Dependencies

Install basic dependencies.

apt install build-essential postgresql git wget curl libssl-dev pkg-config clang

Install Rust using rustup

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Step 2: Clone the Repository

Clone the repository and checkout the tag of the version you intend to use. Using the dev or main branches may not be stable, so a tag is always recommended.

git clone https://github.com/nervosnetwork/mercury.git
cd mercury
git checkout v0.4.4

Step 3: Build Mercury

cargo build --release

The resulting binary will be target/release/mercury.

Installing a Precompiled Release

Step 1: Install Dependencies

Install basic dependencies.

apt install postgresql git wget curl

Step 2: Clone the Repository

We will not be building from source, but there are still some valuable files. Cloning the repository is the easiest way to get everything we need. Make sure to checkout the tag that matches the version of the release you downloaded.

git clone https://github.com/nervosnetwork/mercury.git
cd mercury
git checkout v0.4.4

Step 3: Download and Extract a Precompiled Binary

wget https://github.com/nervosnetwork/mercury/releases/download/v0.4.4/mercury-x86_64-unknown-linux-gnu.tar.gz
tar xzf mercury-x86_64-unknown-linux-gnu.tar.gz

Setup the Database Tables

Step 1: Launch Psql as an Administrative User

Switch to the postgres user and launch psql as an administrative user.

sudo su -l postgres
psql

Step 2: Create the User and Database

After launching psql use the following SQL commands to create a user and database.

CREATE USER mercury WITH ENCRYPTED PASSWORD 'mercury';
CREATE DATABASE mercury;
GRANT ALL PRIVILEGES ON DATABASE mercury TO mercury;

You can then quit psql using \q and then use exit to return to the previous user.

Step 3: Use Psql to Create the Tables

Use psql to

psql -h localhost -U mercury -f devtools/create_table/create_table.sql

Configure Mercury

Configuration files are available for the mainnet and testnet.

# mainnet
nano mercury/devtools/config/mainnet_config.toml
# testnet
nano mercury/devtools/config/testnet_config.toml

Many configuration options are available, but the options below must be changed.

Step 1: Update the Database Connection Information

Modify the database settings to match those you configured. Make sure that the port matches your configure PostgreSQL port (default: 5432).

db_type = "postgres"
db_host = "127.0.0.1"
db_port = 5432
db_name = "mercury"
db_user = "mercury"
password = "mercury"

Step 2: Update the CKB Node RPC URI

If you are running a CKB node on the same machine it will not need to be updated. Update as needed.

ckb_uri = "http://127.0.0.1:8114"

Step 3: Update the Listen URI

By default, Mercury will listen for local connections only.

listen_uri = "127.0.0.1:8116"

If you need Mercury to listen for connections from other machines, change it to the following.

listen_uri = "0.0.0.0:8116"

Running Mercury

Running a binary you compiled from source.

target/release/mercury --config devtools/config/testnet_config.toml run

Running a precompiled binary.

./mercury --config devtools/config/testnet_config.toml run

Viewing the Mercury logs.

tail -f free-space/testnet/log/mercury.log