Skip to content

Fantom-foundation/Fantom-Datafeed-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fantom Datafeed Backend Service

The repository contains implementation of high performance blockchain backend service for datafeed contracts off-chain world interaction.

The Datafeed Backend service is responsible for monitoring smart contracts activity on block chain, especially for emitted events on contracts, and respond with relevant data from off-chain world needed to perform on-chain actions. Special modules can also feed on-chain contracts with external data, based on specified criteria, timer, or API response.

Building the source

Building Datafeed Backend requires GIT package and Go (version 1.14 or later is recommended). You can install it using your favourite package manager. The latest version of Go can be installed directly from GoLang Website.

Once you have the Go environment ready, clone the Watchdog repository from GitHub and build the binary package:

git clone https://github.com/Fantom-foundation/Fantom-Datafeed-Backend.git
go build ./cmd/datafeed

The build output is build/watchdog executable.

You don't need to clone the project into $GOPATH due to Go Modules tooling, use any suitable location. We recommend moving the built Datafeed Backend binary to your bin path and using Systemd unit to manage the Backend as a service for production use.

Running the Datafeed Backend server

You need access to an RPC interface of an Opera Lachesis node to run the Datafeed Backend server. Please follow Lachesis instructions to build and run the node. You can obtain access to a remotely running instance of Lachesis, too.

We recommend using local IPC channel for communication between a Lachesis node and the Datafeed Backend server for performance and security reasons. Please consider security implications of opening Lachesis RPC to outside world access.

System.d Service unit file

To run the Datafeed Backend as a system service on Linux, create a service unit file on appropriate location. The actual place for putting the service file may vary by Linux distribution. For example, you can use /etc/systemd/system/datafeed.service file path on Ubuntu systems.

We assume you want to use /var/opera/datafeed as the working directory for the Watchdog and that you copied the Watchdog binary to /usr/bin/datafeed. In that case, the recommended .service file content is:

[Unit]
Description=Fantom Datafeed Backend service
After=network.target auditd.service

[Service]
Type=simple
User=opera
Group=opera
WorkingDirectory=/var/opera/datafeed
ExecStart=/usr/bin/datafeed \
            --rpc /var/opera/lachesis/data/lachesis.ipc \
            --cfg /var/opera/datafeed/modules.json \
            --log NOTICE
OOMScoreAdjust=-900
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
Alias=datafeed.service

Adjust the service unit file to match your path and configuration details for Opera RPC interface, work path and Datafeed Backend binary file location.

Don't forget to update the System.d status to be able to use the new service file to start and stop the Watchdog: systemctl daemon-reload. Manage the service start/stop using usual System.d commands, i.e. systemctl start datafeed.service.

About

High performance block chain watchdog for oracle contracts off-chain world interaction.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages