# EOSIO Node

We are going to use what's known as a `SHIP` node.  This node will expose the state history web socket to monitor on chain activity and it will not produce blocks.

{% hint style="info" %}
For nodeos's documentation head over to b1's dev docs [here](https://developers.eos.io/manuals/eos/v2.1/nodeos/index)
{% endhint %}

{% hint style="info" %}
If you prefer Kubernetes, checkout our dapp dsp k8s repo: <https://github.com/liquidapps-io/dapp-dsp-k8s>
{% endhint %}

Minimum requirements for nodeos:

* 7GB of RAM - [Github Link](https://github.com/EOSIO/eos/blob/master/scripts/eosio_build_ubuntu.sh#L10)
* 5GB of DISK - [Github Link](https://github.com/EOSIO/eos/blob/8f29da1845c1f1a3479bc32dce0238e9873a8bf4/scripts/.build_vars#L78)

Though you will want more than this to run a testnet nodeos instance, and significantly more to handle the EOS mainnet or other mainnets.

Chain resource analysis for Mainnet/Kylin: <https://docs.dfuse.io/eosio/admin-guide/system-requirements/>

This may also provide some context for resource requirements: <https://github.com/EOSChronicleProject/chronicle-tutorial/blob/master/01_nodeos_server_setup.md>

### Prerequisites

* jq
* wget
* curl

### Get EOSIO binary

```bash
# nodeos versions 1.8+ and 2.0+ are supported
VERSION=3.1.2
```

#### Ubuntu 22.04

```bash
FILENAME=leap-$VERSION-ubuntu22.04-x86_64.deb
INSTALL_TOOL=apt
```

#### Ubuntu 20.04

```bash
FILENAME=leap-$VERSION-ubuntu20.04-x86_64.deb
INSTALL_TOOL=apt
```

#### Ubuntu 18.04

```bash
FILENAME=leap-$VERSION-ubuntu18.04-x86_64.deb
INSTALL_TOOL=apt
```

{% hint style="info" %}
Nodeos is now only available for Ubuntu, if you want to run docker you can build the Dockerfile [here](https://github.com/NatPDeveloper/antelope-io-docker) or use [`natpdev/cdt-leap`](https://hub.docker.com/r/natpdev/leap-cdt)
{% endhint %}

### Install

```bash
wget https://github.com/AntelopeIO/leap/releases/download/v$VERSION/$FILENAME
sudo $INSTALL_TOOL install ./$FILENAME
```

### Prepare Directories

```bash
#cleanup
rm -rf $HOME/.local/share/eosio/nodeos || true

#create dirs
mkdir $HOME/.local/share/eosio/nodeos/data/blocks -p
mkdir $HOME/.local/share/eosio/nodeos/data/snapshots -p
mkdir $HOME/.local/share/eosio/nodeos/config -p
```

#### Snapshots

If you would like an up to date snapshot, please visit: [snapshots.eosnation.io](https://snapshots.eosnation.io/) and find the latest snapshot for the chain you are using. You will want to unpack the file and store it here with the following file name: `$HOME/.local/share/eosio/nodeos/data/snapshots/boot.bin`.

To unzip

```bash
wget https://pub.store.eosnation.io/kylin-snapshots/snapshot-2022-08-01-18-kylin-v6-0242018756.bin.zst
# sudo apt install zstd
unzstd snapshot-2022-08-01-18-kylin-v6-0242018756.bin.zst
mv snapshot-2022-08-01-18-kylin-v6-0242018756.bin $HOME/.local/share/eosio/nodeos/data/snapshots/boot.bin
```

#### Kylin

```bash
URL="http://storage.googleapis.com/eos-kylin-snapshot/snapshot-2019-06-10-09(utc)-0312d3b9843e2efa6831806962d6c219d37200e0b897a0d9243bcab40b2b546b.bin"
P2P_FILE=https://validate.eosnation.io/kylin/reports/config.txt
GENESIS=https://raw.githubusercontent.com/cryptokylin/CryptoKylin-Testnet/master/genesis.json
CHAIN_STATE_SIZE=256000
wget $URL -O $HOME/.local/share/eosio/nodeos/data/snapshots/boot.bin
```

#### Jungle

You can find more Jungle peers here: <https://monitor.jungletestnet.io/#p2p>

```bash
export MONTH=01
export DAY=09
wget https://eosn.sfo2.digitaloceanspaces.com/snapshots/snapshot-2020-$MONTH-$DAY-15-jungle.bin.bz2
bzip2 -d ./snapshot-2020-01-09-15-jungle.bin.bz2
mv snapshot-2020-01-09-15-jungle.bin $HOME/.local/share/eosio/nodeos/data/snapshots/boot.bin
P2P_FILE=https://validate.eosnation.io/jungle/reports/config.txt
GENESIS=https://raw.githubusercontent.com/EOS-Jungle-Testnet/Node-Manual-Installation/master/genesis.json
CHAIN_STATE_SIZE=256000
```

#### Mainnet

```bash
URL="https://s3.eu-central-1.wasabisys.com/eosnodetools/snapshots/snap_2019-12-15-13-00.tar.gz"
P2P_FILE=https://eosnodes.privex.io/?config=1
GENESIS=https://raw.githubusercontent.com/CryptoLions/EOS-MainNet/master/genesis.json
CHAIN_STATE_SIZE=16384
cd $HOME/.local/share/eosio/nodeos/data
wget $URL -O - | tar xvz
SNAPFILE=`ls snapshots/*.bin | head -n 1 | xargs -n 1 basename`
mv snapshots/$SNAPFILE snapshots/boot.bin
```

### Configuration

**Please note that it is crucial that all of the following configuration flags are set. If any are missing, it will likely cause issues with running th**e **DSP software.**

{% hint style="info" %}
If you would like to run Firehose be sure to comment in the flag below
{% endhint %}

Firehose is a service provided through the deep mind option that enables the DSP to listen for very specific information from the blockchain. This service also requires running a few more services detailed in the [Firehose Setup](/liquidapps-documentation/dapp-service-providers/dsps/setup-dsp/eosio-node/firehose-setup.md) section.

The state history plugin provides the entire current state of the blockchain through a web socket connection which is not ideal as the DSP does not care about the overwhelming majority of the information it is being fed.

<pre class="language-bash"><code class="lang-bash">cd $HOME/.local/share/eosio/nodeos/config

# download genesis
wget $GENESIS
# config
cat &#x3C;&#x3C;EOF >> $HOME/.local/share/eosio/nodeos/config/config.ini
agent-name = "DSP"
<strong># for firehose comment in the below plugin
</strong><strong># deep-mind = true
</strong>http-server-address = 0.0.0.0:8888
p2p-listen-endpoint = 0.0.0.0:9876
blocks-dir = "blocks"
abi-serializer-max-time-ms = 3000
max-transaction-time = 150000
wasm-runtime = eos-vm
eos-vm-oc-enable = true
contracts-console = true
p2p-max-nodes-per-host = 1
allowed-connection = any
max-clients = 100
sync-fetch-span = 500
connection-cleanup-period = 30
http-validate-host = false
access-control-allow-origin = *
access-control-allow-headers = *
access-control-allow-credentials = false
verbose-http-errors = true
http-threads=4
net-threads=4
chain-threads=4
eos-vm-oc-compile-threads=2
trace-history-debug-mode = true
trace-history = true
http-max-response-time-ms = 500
transaction-retry-max-storage-size-gb = 4
transaction-finality-status-max-storage-size-gb = 4
disable-subjective-billing = true
block-log-retain-blocks = 1000
state-history-log-retain-blocks = 1000
transaction-retry-max-expiration-sec = 300
p2p-dedup-cache-expire-time-sec = 3
transaction-retry-interval-sec=6
plugin = eosio::producer_plugin
plugin = eosio::chain_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::net_plugin
plugin = eosio::state_history_plugin
state-history-endpoint = 0.0.0.0:8887
chain-state-db-size-mb = $CHAIN_STATE_SIZE
EOF

curl $P2P_FILE > p2p-config.ini
<strong>cat p2p-config.ini | grep "p2p-peer-address" >> $HOME/.local/share/eosio/nodeos/config/config.ini
</strong></code></pre>

{% hint style="info" %}
If your node isn't syncing, comment out the other peers and just put **p2p-peer-address = kylin.seed.eosnation.io:9876** assuming a kylin install
{% endhint %}

*Please note the following about some `config.ini` settings:*

* `read-mode = head` (default is: `read-more = speculative` and does not need to be specified in the `config.ini`) must not be used to prevent duplicate `xwarmup` actions | [read more about read modes here](https://developers.eos.io/eosio-nodeos/docs/read-modes)
* if supporting the Hyperion API <https://github.com/eosrio/Hyperion-History-API>, must add the `chain-state-history = true`, note this will significantly increase storage requirements
* it is recommended to whitelist all staked contracts for subjective CPU billing so that assertion errors from services do not consumer CPU time, add for each contract

  ```
  disable-subjective-account-billing=jouleappcont
  ```
* or add `disable-subjective-billing = true` to disable all subjective billing
* regarding `http-threads`, `net-threads`, `chain-threads` and `eos-vm-oc-compile-threads` read Kevin's thoughts here <https://t.me/c/1139062279/312621>

### Run

First run (from snapshot)

```bash
nodeos --disable-replay-opts --snapshot $HOME/.local/share/eosio/nodeos/data/snapshots/boot.bin --delete-state-history --delete-all-blocks
```

You will know that the node is fully synced once you see blocks being produced every half second at the head block. You can match the block number you are seeing in the nodeos logs to what [bloks.io](https://bloks.io/) is indicating as the head block on the chain you are syncing (mainnet, Kylin etc). Once you have confirmed that it is synced press `CTRL+C` once, wait for the node to shutdown and proceed to the next step.

### systemd

```bash
export NODEOS_EXEC=`which nodeos`
export NODEOS_USER=$USER
sudo -E su - -p
cat <<EOF > /lib/systemd/system/nodeos.service
[Unit]
Description=nodeos
After=network.target
[Service]
User=$NODEOS_USER
ExecStart=$NODEOS_EXEC --disable-replay-opts
[Install]
WantedBy=multi-user.target
EOF

systemctl start nodeos
systemctl enable nodeos
exit
sleep 3
systemctl status nodeos
```

### Firehose

If you would like to run Firehose, continue to [this](/liquidapps-documentation/dapp-service-providers/dsps/setup-dsp/eosio-node/firehose-setup.md) section.

### Optimizations

* [atticlab - cpu performance presentation](https://github.com/atticlab/eos-bp-performance/blob/master/cpu_perf_presentation.pdf)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.liquidapps.io/liquidapps-documentation/dapp-service-providers/dsps/setup-dsp/eosio-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
