Nexa Prerequisites
Setting Up Cassandra
Prerequisites

The latest version of Java 8, either the Oracle Java Standard Edition 8 or OpenJDK 8. For using cqlsh, the latest version of Python 2.7.

Installation 

Follow below instructions to install via your Linux distribution's package manager

Debian based distros (Ubuntu/etc.) 

sudo apt-get install cassandra

Arch Linux & derivatives 

Install the cassandra package from the User Repository, using your favourite AUR helper.

Configuration

Edit section data_file_directories to reflect below, where 'repo' is ideally mounted on an exclusive drive/SSD. This reduces IO contention b/w Neo4j and Cassandra databases. Also ensure the folders have the writer permissions enabled.

data_file_directories: /<repo>/lib/cassandra/data
commitlog_directory: /repo/lib/cassandra/commitlog
listen_address: localhost

Also tweak the below settings appropriately per the instructions provided in the config file. The below sample values are good for a 12 core machine

concurrent_reads: 32 
concurrent_writes: 96 
concurrent_counter_writes: 32

To facilitate the highly concurrent application, its advisible to make the following system configurations, it primarily is meant to help Cassandra operate at its best.

/etc/limits.conf
* - memlock unlimited
* - nofile 100000
* - nproc 32768
* - as unlimited

/etc/sysctl.conf
vm.max_map_count = 1048575

Login to CQL shell (cqlsh) and execute the following:
CREATE KEYSPACE xoken WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'}  AND durable_writes = true;

CREATE TABLE xoken.misc_store (
    key text PRIMARY KEY,
    value frozen<tuple<boolean, int, bigint, text>>
) 

CREATE TABLE xoken.transactions (
    tx_id text PRIMARY KEY,
    block_info frozen<tuple<frozen<tuple<text, int>>, int>>,
    tx_serialized blob
) 

CREATE TABLE xoken.blocks_by_hash (
    block_hash text PRIMARY KEY,
    block_header text,
    block_height int
) 

CREATE TABLE xoken.ep_address_outputs (
    epoch boolean,
    address text,
    output frozen<tuple<text, int>>,
    is_output_spent boolean,
    is_type_receive boolean,
    other_address text,
    prev_outpoint frozen<tuple<text, int>>,
    value bigint,
    PRIMARY KEY (epoch, address, output)
) 

CREATE TABLE xoken.address_outputs (
    address text,
    output frozen<tuple<text, int>>,
    block_info frozen<tuple<frozen<tuple<text, int>>, int>>,
    is_block_confirmed boolean,
    is_output_spent boolean,
    is_type_receive boolean,
    other_address text,
    prev_outpoint frozen<tuple<text, int>>,
    value bigint,
    PRIMARY KEY (address, output)
) 

CREATE TABLE xoken.txidmap (
    txid text PRIMARY KEY,
    blockhash text,
    txindex int
) 

CREATE TABLE xoken.blocks_by_height (
    block_height int PRIMARY KEY,
    block_hash text,
    block_header text
) 

CREATE TABLE xoken.ep_transactions (
    epoch boolean,
    tx_id text,
    tx_serialized blob,
    PRIMARY KEY (epoch, tx_id)
) 

Setting Up Neo4j
Installation

Recommend following official prerequisite & install instructions as below - https://neo4j.com/docs/operations-manual/current/installation/linux/

Note:
  • Only Neo4j version "3.5.x" is officially supported. The packaged Neo4j driver does NOT support versions 4.x.x.
  • If Neo4j demands Java 10/11 proceed installing the same, it can typically co-exist with Java8 (Cassandra dependency) without causing an issue.

Install the neo4j community edition package from the User Repository, using your favourite AUR helper. Subsequently you can configure running it via systemd per instructions here

Configuration

Add the following at the bottom of the file /etc/neo4j/neo4j.conf dbms.connector.bolt.thread_pool_min_size=20
dbms.connector.bolt.thread_pool_max_size=1024
dbms.connector.bolt.thread_pool_keep_alive=5m

Login to the Neo4j web console and execute the following:

CREATE CONSTRAINT ON (n:mnode) ASSERT n.v IS UNIQUE;

You can verify if the constraints have been applied correctly by querying

$ :schema

And you should see the following output,

Indexes
ON :mnode(v) ONLINE  (for uniqueness constraint)

Constraints
   ON ( mnode:mnode ) ASSERT mnode.v IS UNIQUE

Other packages

Using the appropriate package manager for your Linux distribution install the below packages. For example on Arch variants run,

sudo pacman -S libsecp256k1
sudo pacman -S leveldb


→ Nexa Installation