Oracle

Overview

This guide is only for validator nodes

The Slinky Oracle consists of two main elements:

  1. An on-chain component that retrieves price data from the sidecar with each block, forwards these prices to the blockchain through vote extensions, and compiles prices from all validators involved.

  2. A sidecar process dedicated to polling price information from various providers and delivering this data to the on-chain component.

For additional information on the oracle, refer to the Slinky repository at https://github.com/skip-mev/slinky/.

Pre-compiled binaries will be made available in the future. Currently, users are advised to compile the necessary software from the source code.

Tutorial

Step 1: Clone the Repository

Clone the slinky repository.

git clone https://github.com/skip-mev/slinky.git
cd slinky

# checkout proper version
git checkout v0.4.3

Step 2: Running The Sidecar

Config Setup

To operate the oracle sidecar, it is essential to have valid configuration files for both the oracle component and the market component. The oracle executable recognizes flags that specify each configuration file. Below are recommended default settings suitable for the existing Initia Devnet environment.

Oracle Component

The oracle component determines how often to poll price providers, multi-plexing behavior of websockets, and more. This has been tested by Skip and is safe to use. The recommended oracle component can be found in config/core/oracle.json within the Slinky repo.

Market Component

The market component determines what markets the side-car should be fetching prices for. The desired markets will be stored on-chain and pulled by the sidecar. To properly configure the sidecar, you must point the sidecar to the GRPC port on a node (typically port 9090). This can be done by adding the --market-map-endpoint flag when starting the sidecar or modifying the oracle.json component as shown below.

// config/core/oracle.json found in the repo.

```json
{
  ...,
    {
      "name": "marketmap_api",
      "api": {
        "enabled": true,
        "timeout": 20000000000,
        "interval": 10000000000,
        "reconnectTimeout": 2000000000,
        "maxQueries": 1,
        "atomic": true,
        "url": "0.0.0.0:9090", // URL that must point to a node GRPC endpoint
        "endpoints": null,
        "batchSize": 0,
        "name": "marketmap_api"
      },
      "type": "market_map_provider"
    }
  ],
  "metrics": {
    "prometheusServerAddress": "0.0.0.0:8002",
    "enabled": true
  },
  "host": "0.0.0.0",
  "port": "8080"
}
```

Starting The Sidecar

Initiating the oracle sidecar process is accomplished by executing the binary.

# Build the Slinky binary in the repo.
make build

# Run with the core oracle config from the repo.
./build/slinky --oracle-config-path ./config/core/oracle.json --market-map-endpoint 0.0.0.0:9090

The GRPC server operates with the default settings of 0.0.0.0:8080, and if activated, the Prometheus metrics endpoint uses 0.0.0.0:8002 as its default host and port.

Step 3: Validating Prices

Upon launching the oracle, you should observe successful price retrieval from the provider sources. Additionally, you have the option to execute the test client script available in the Slinky repository by using the command make run-oracle-client.

Step 4: Enable Oracle Vote Extension

In order to utilize the Slinky oracle data in the Initia node, the Oracle setting should be enabled in the config/app.toml file.

###############################################################################
###                                  Oracle                                 ###
###############################################################################
[oracle]
# Enabled indicates whether the oracle is enabled.
enabled = "true"

# Oracle Address is the URL of the out of process oracle sidecar. This is used to
# connect to the oracle sidecar when the application boots up. Note that the address
# can be modified at any point, but will only take effect after the application is
# restarted. This can be the address of an oracle container running on the same
# machine or a remote machine.
oracle_address = "127.0.0.1:8080"

# Client Timeout is the time that the client is willing to wait for responses from 
# the oracle before timing out.
client_timeout = "500ms"

# MetricsEnabled determines whether oracle metrics are enabled. Specifically
# this enables instrumentation of the oracle client and the interaction between
# the oracle and the app.
metrics_enabled = "false"

Last updated

Logo

© 2024 Initia Foundation, All rights reserved.