Orakl Network Request-Response
Last updated
Last updated
The Orakl Network Request-Response is one of the main Orakl Network solutions. It provides an access to off-chain data from on-chain smart contracts. Requests are emitted through on-chain event, captured by the Orakl Network Request-Response Listener, processed by the Orakl Network Request-Response Worker and eventually responded back to on-chain through the Orakl Network Request-Response Reporter.
The code is located under , and separated to three independent microservices: listener, worker and reporter.
The Orakl Network Request-Response requires an access to state for listeners and reporters.
The Orakl Network API holds information about all listeners. The command below adds a single Request-Response listener to the Orakl Network state to listen on requestResponseCoordinatorAddress
for DataRequested
event. The chain
parameter specifies a chain on which we expect to operate with the Orakl Network Request-Response Listener.
example
The Orakl Network API holds information about all reporters. The command below adds a single Request-Response reporter to the Orakl Network state to report to oracleAddress
. The chain parameter specifies a chain on which we expect to operate. Reporter is defined by an address
and a privateKey
parameters.
example
NODE_ENV=production
CHAIN
PROVIDER_URL
ORAKL_NETWORK_API_URL
LOG_LEVEL
REDIS_HOST
REDIS_PORT
HEALTH_CHECK_PORT
SLACK_WEBHOOK_URL
CHAIN
environment variable specifies on which chain the Orakl Network Request-Response will be running, and which resources will be collected from the Orakl Network API.
PROVIDER_URL
defines an URL string representing a JSON-RPC endpoint that listener and reporter communicate through.
ORAKL_NETWORK_API_URL
corresponds to url where the Orakl Network API is running. The Orakl Network API interface is used to access Orakl Network state such as listener configuration.
Setting a level of logs emitted by a running instance is set through LOG_LEVEL
environment variable, and can be one of the following: error
, warning
, info
, debug
and trace
, ordered from the most restrictive to the least. By selecting any of the available options you subscribe to the specified level and all levels with lower restrictiveness.
The Orakl Network Request-Response does not offer a rich REST API, but defines a health check endpoint (/
) served under a port denoted as HEALTH_CHECK_PORT
.
Before launching the Request-Response solution, the Orakl Network API has to be accessible from the Orakl Network Request-Response to load listener settings.
After the Orakl Network API is healthy, launch the Request-Response service, which consists of listener, worker, and reporter microservices, with the command below. Microservices communicate with each other through the BullMQ - job queue.
Run in dev mode through the following command:
It's also possible to run the microservices separately in any arbitrary order:
Note that the current docker implementation is designed to run a single service, either rr
or vrf
, at a time. Therefore, it's highly recommended to add --force-recreate
when running docker-compose up
command. That will restart all containers thus removing all the modified data in those containers.
Here is what happens after the above command is run:
api
, postgres
, redis
, and json-rpc
services will start as separate docker containers
postgres
will get populated with necessary data:
chains
services
listener (after contracts are deployed)
reporter (after contracts are deployed)
migration files in contracts/v0.1/migration/
get updated with provided keys and other values
if the chain is localhost
:
contracts/v0.1/hardhat.config.cjs
file gets updated with PROVIDER_URL
relevant coordinator and prepayment contracts get deployed
The architecture is very similar to the Orakl Network VRF. The only difference is that the Orakl Network Request-Response Worker fetches and processes data based on the on-chain request.
Before we launch the Orakl Network Request-Response, we must specify . The environment variables are automatically loaded from a .env
file.
The Orakl Network Request-Response is implemented in Node.js which uses NODE_ENV
environment variable to signal the execution environment (e.g. production
, development
). generally ensures that logging is kept to a minimum, and more caching levels take place to optimize performance.
REDIS_HOST
and REDIS_PORT
represent host and port of to which all Orakl Network Request-Response microservices connect. The default values are localhost
and 6379
, respectively.
Errors and warnings emitted by the Orakl Network Request-Response can be . The webhook URL can be set with the SLACK_WEBOOK_URL
environment variable.
From repository's root, run the following command to build all images:
Set wallet credentials, ADDRESS
and PRIVATE_KEY
values, in the file. Keep in mind that the default chain is localhost
. If changes are required, update CHAIN
(other options being baobab
and cypress
) and PROVIDER_URL
values. Note that if the chain is not localhost
, Coordinator
and Prepayment
contracts won't be deployed. Instead, Bisonai's already deployed will be used. After setting the appropriate .env
values, run the following command to start the Request-Response service: