Allora off-chain nodes publish inferences, forecasts, and losses informed by a configurable ground truth to the Allora chain.
- Clone the repository
- Make sure to remove any .env file so it doesn't clash with the automated environment variables
- Copy config.example.json and populate with your variables. You can either populate with your existing wallet or leave it empty for it to be autocreated
cp config.example.json config.json
- Run command below to load your config.json file to environment
chmod +x init.config
./init.config
from the root diectory. This will:
- Load your config.json file into the environment. Depending on whether you provided your wallet details or not it will also do the following:
- Automatically create allora keys for you. You will have to request for some tokens from faucet to be able to register your worker and stake your reputer. You can find your address in ./data/env_file
- Automatically export the needed variables from the account created to be used by the offchain node and bundles it with the your provided config.json and then pass them to the node as environemnt variable
- Run
docker compose up --build
. This will:- Run the both the offchain node and the source services, communicating through endpoints attached to the internal dns
Please note that the environment variable will be created as bumdle of your config.json and allora account secrets, please make sure to remove every sectrets before commiting to remote git repository
- Clone the repository
- Install Go 1.22.5
- Install the dependencies:
go mod download
- Copy environment variables:
cp .env.example .env
- Fill in the environment variables in
.env
with your own values - If you're a worker...
- Configure your inference and/or forecast models in
adapters/
and/or another source linked to by adapters inadapters/
directory.
- Configure your inference and/or forecast models in
- If you're a reputer...
- Configure your repute and/or loss models in
adapters/
and/or another source linked to by adapters inadapters/
directory.
- Configure your repute and/or loss models in
- Map each topic to the appropriate adapter in
config.json
. - Run the following commands:
chmod +x start.local
./start.local
Some metrics has been provided for in the node. You can access them with port :2112/metrics
. Here are the following list of existing metrics:
allora_worker_inference_request_count
: The total number of times worker requests inference from sourceallora_worker_forecast_request_count
: The total number of times worker requests forecast from sourceallora_reputer_truth_request_count
: The total number of times reputer requests truth from sourceallora_worker_data_build_count
: The total number of times worker built data successfullyallora_reputer_data_build_count
: The total number of times reputer built data successfullyallora_worker_chain_submission_count
: The total number of worker commits to the chainallora_reputer_chain_submission_count
: The total number of reputer commits to the chain
Please note that we will keep updating the list as more metrics are being added
There are several ways to configure the node. In order of preference, you can do any of these:
- Set the
ALLORA_OFFCHAIN_NODE_CONFIG_JSON
env var with a configuration as a JSON string. - Set the
ALLORA_OFFCHAIN_NODE_CONFIG_FILE_PATH
env var pointing to a file, which contains configuration as JSON. An example if provided inconfig.example.json
.
Each option completely overwrites the other options.
This is the entrypoint for the application that simply builds and runs the Go program.
It spins off a distinct processes per role worker, reputer per topic configered in config.json
.
- Spawn a go routine per topic
- Get topic data from chain via RPC. Hold this in memory
- Check if wallet registered in topic as worker
- If wallet not registered in topic as worker then attempt to register
- Fail if failed to register
- Every config.loop_seconds seconds...
- Get and set latest_open_worker_nonce_from_chain from the chain
- If latest_open_worker_nonce_from_chain does not exist or nil then continue to next loop
- i.e. wait another config.loop_seconds
- Retry request_retries times with uniform backoff:
- Invoke configured
inferenceEntrypoint
,forecastEntrypoint
for topic and get results- Else, break this inner retry loop
- Attempt to commit inference and forecast bundle to the chain
- Log success/failures as usual
- Invoke configured
- Spawn a go routine per topic
- Get topic data from chain via RPC. Hold this in memory
- Check if wallet registered in topic as reputer
- If wallet not registered in topic as reputer then attempt to register
- Fail if failed to register
- Get current stake from reputer on topic (not including delegate stake)
- Fail if failed to get
- If config.min_stake_to_repute > current_stake then attempt to add difference in stake (config.min_stake_to_repute - current_stake) to hit the configured minimum, using config.wallet
- Fail if failed to add stake
- If success or if condition met, then continue with rest of loop
- Every config.loop_seconds seconds...
- Get and set latest_open_reputer_nonce_from_chain from the chain
- If latest_open_reputer_nonce_from_chain does not exist or nil then continue to next loop
- i.e. wait another config.loop_seconds
- Retry request_retries times with uniform backoff:
- Invoke configured
truthEntrypoint, lossEntrypoint
for topic and get results- Else, break this inner retry loop
- Attempt to commit loss bundle to the chain
- Log success/failures as usual
- Invoke configured
- For now, we put adapters to generate or relay reputer/worker data in packages.
- Should use modules instead of packages
- Then in JSON one can specify which modules to use for which topics and automatically load them with a script that calls
go get ...
- Make lambda function adapters => super cheap to continuously run for all those with AWS accounts
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.