Links

Run API Node

Last updated 16 Oct 2023
3API node parameters
The hardware requirements for the API node depend on the traffic pointed to the individual node. It has to be able to stay synchronized and serve the requests at the same time. Therefore, you should scale it according to your expected load.

Minimum requirements for API node with all history (Q2 2023):

  • Cloud: m6i.2xlarge General Purpose Instance with 4 vCPUs (3.5 GHz), 32GB of memory, up to 10 Gbps network bandwidth, and at least 13 TB of gp2 SSD. Bare metal with equivalent or higher specs are even better.
  • We recommend at least 1 Gbps (10+Gbps is better) network bandwidth for a public API node.
  • Ubuntu Server 22.04 LTS (64-bit) or similar Linux/Unix based system.

Storage

13 TB is needed if you'd like to run with a full size (non-pruned) datadir. Available snapshots for download: link.

What are we going to do?

Setting up the node

Network settings

Open up port 22 for SSH, as well as port 5050 for both TCP and UDP traffic for node P2P network. Also if you plan to expose the API, then select a port which will serve the RPC API request. A custom port can be used with --port <port> flag for P2P and --http.port <port> flag for API when you run your node, more on that later in this article. Keep all other ports closed as the node doesn't need any other.

Set up non-root user

If there is already a non-root user with sudo rights available, you can skip this step.
# SSH into your machine
(local)$ ssh root@{IP_ADDRESS}
# Update the system
$ sudo apt-get update && sudo apt-get upgrade -y
# Create a non-root user
$ USER={USERNAME}
$ sudo mkdir -p /home/$USER/.ssh
$ sudo touch /home/$USER/.ssh/authorized_keys
$ sudo useradd -d /home/$USER $USER
$ sudo usermod -aG sudo $USER
$ sudo chown -R $USER:$USER /home/$USER/
$ sudo chmod 700 /home/$USER/.ssh
$ sudo chmod 644 /home/$USER/.ssh/authorized_keys
Make sure to paste your public SSH key into the authorized_keys file of the newly created user in order to be able to log in via SSH.
# Enable sudo without password for the user
$ sudo vi /etc/sudoers
Add the following line to the end of the file:
{USERNAME} ALL=NOPASSWD: ALL
Now close the root SSH connection to the machine and log in as your newly created user:
# Close the root SSH connection
$ exit
# Log in as new user
(local)$ ssh {USERNAME}@{IP_ADDRESS}

Install required tools

You are still logged in as the new user via SSH. Now we are going to install Go and Opera.
First, install the required build tools:
# Install build-essential
$ sudo apt-get install -y build-essential
Install Go
# Install latest Go compiler
$ wget https://go.dev/dl/go1.19.1.linux-amd64.tar.gz
$ sudo tar -xvf go1.19.1.linux-amd64.tar.gz
$ sudo mv go /usr/local
Export the required Go paths
# Export go paths
$ vi ~/.bash_aliases
# Append the following lines
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Validate your Go installation
# $ go version

Build and run your API node

For building go-opera from the source, please always checkout the latest supported version. The list of actual releases and release candidates can be found here in description.
# Install Opera
$ git clone https://github.com/Fantom-foundation/go-opera.git
$ cd go-opera/
$ git checkout release/1.1.3-rc.5
$ make
Validate your Opera installation:
$./build/opera version
Version: 1.1.3-rc.5
db.preset
When using version 1.1.3 (introduced since version 1.1.2) you need to add db.preset argument for starting opera command. You can see options for this parameters with opera help command. For standard conditions, please use this option:
  • db.preset=ldb-1
You can use different db presets, either --db.preset ldb-1 OR --db.preset pbl-1 OR --db.preset legacy-db . Note that, ldb-1 will sync slightly faster, but may respond slower on multiple parallel API queries; whereas pbl-1 will sync a bit longer, but have more stable API response time.

Run API node

For running an API node, you need to download a genesis file and synchronize from this genesis state to present. If you just want to provide only the latest data from your API node, you can select the pruned genesis files, without a history data. In case that you want to provide all historical data, then you have to select genesis file with "Starting EVM history" filled with Full in the table.
The other option is to use a snapshot. More information about snapshots you can find here.
For the first run with a genesis file, you have to provide a path to this file with the --genesis parameter. It is not needed once the genesis is processed and also it is not needed when running with the snapshot. With the parameter --datadir, you specify where your blockchain data will be stored. In case of using snapshot, you need to point a datadir to the snapshot location.
# Start opera node
$ nohup ./build/opera \
--genesis=mainnet-109331-full-mpt.g \
--datadir={DATA LOCATION} \
--http --http.port=8080 \
--http.addr="127.0.0.1" --http.corsdomain="*" \
--http.api=eth,web3,net,txpool,ftm \
--db.preset ldb-1 &
You can check other parameters with opera help command. Note that https and ws must not be enabled on a server that stores wallet account. For trouble shooting your node, please check this.

Run transaction tracing API node

Running a transaction tracing node is very similar as a standard API node. Transaction traces are created when blocks are processed during blockchain synchronization, so it is a good practice to start a node from scratch and let it synchronize with --tracenode flag.
You have to run your transaction tracing node using tx-tracing go-opera 1.1.3-rc.5 (full sync mode). For newer versions please check the actual txtracing branch in the Fantom foundation github repository. Note that --http and --ws must not be enabled on a server that stores wallet account.
# Install Opera
$ git clone https://github.com/Fantom-foundation/go-opera.git
$ cd go-opera/
$ git checkout release/txtracing/1.1.3-rc.5
$ make
Validate your Opera installation:
$./build/opera version
Version: 1.1.3-txtracing-rc.5
Download a genesis file from this list of genesis files with full history (Starting EVM history column with Full). It is recommended to use this genesis file mainnet-5577-full-mpt.g.
# Start opera node
$ nohup ./opera \
--tracenode \
--genesis=mainnet-5577-full-mpt.g \
--datadir={DATA LOCATION} \
--http --http.port=8080 \
--http.addr="127.0.0.1" --http.corsdomain="*" \
--http.api=eth,web3,net,txpool,ftm,trace \
--db.preset=ldb-1 &
The most important parameter for the transaction tracing node is the --tracenode. It enables the tracing capabilities. The trace parameter of the --http.api exposes the trace API on the http interface.
You can check other parameters with opera help command. The default synchronization mode is full. You shouldn't use any other mode as tracing needs all the data generated during the regular syncing procedure.
More details on tracing, please check this guide. For trouble shooting your node, please check this.
© 2024 Fantom Foundation