Deploy a Coin Prediction Reputer
This is an example of a setup for running an Allora Network reputer node for providing ground truth and reputation, where the Allora Network node defers the requests to another container which is responsible for providing the ground truth, which is run in a separate container. It also provides a means of updating the internal database of the ground truth provider.
Components
- Reputer: The node that responds to reputer requests from the Allora Network.
- Truth: A container that performs reputation tasks, maintains the state of the model, and responds to reputation requests via a simple Flask application. It fetches data from CoinGecko.
- Updater: A cron-like container designed to periodically trigger the Truth node's data updates.
A full working example for a reputer node for ETH price prediction topics is provided in the docker-compose.yml
file (opens in a new tab) of our example repo. Simply run:
Explainer Video
Please see the video below to get a full deep-dive on how to deploy a reputer:
Setup a Reputer Node with docker-compose
Download the Repository
git clone https://github.com/allora-network/coin-prediction-reputer.git
cd coin-prediction-reputer
Configure Your Environment
- Copy
config.example.json
and name the copyconfig.json
. - Open
config.json
and update the necessary fields inside thewallet
sub-object andworker
config with your specific values:
wallet
Sub-object
nodeRpc
: The RPC URL for the corresponding network the node will be deployed onaddressKeyName
: The name you gave your wallet key when setting up your walletaddressRestoreMnemonic
: The mnemonic that was outputted when setting up a new key
reputer
Config
topicId
: The specific topic ID you created the reputer for.SourceOfTruthEndpoint
: The endpoint exposed by your source of truth server to provide the truth data to the network.Token
: The token for the specific topic you are verifying truth data for. This token should be included in the source of truth endpoint for retrieval.- The
Token
variable is specific to the endpoint you expose in yourmain.py
file. It is not related to any blockchain parameter and is only locally specific.
- The
minStake
: The minimum stake required to participate as a reputer. This stake will be deducted from the reputer's wallet balance.loopSeconds
: The amount of seconds to wait between attempts to get the next reputer nonce
When placing your minimum stake, the system will verify the amount of funds you have already staked in the topic. If your staked amount is insufficient, it will automatically pull the necessary funds from your wallet to meet the required minimum.
The reputer
config is an array of sub-objects, each representing a different topic ID. This structure allows you to manage multiple topic IDs, each within its own sub-object.
To deploy a reputer that provides inferences for multiple topics, you can duplicate the existing sub-object and add it to the reputer
array. Update the topicId
, SourceOfTruthEndpoint
, minStake
and Token
fields with the appropriate values for each new topic:
"worker": [
{
"topicId": 1,
"reputerEntrypointName": "api-worker-reputer",
"loopSeconds": 30,
"minStake": 100000,
"parameters": {
"SourceOfTruthEndpoint": "http://source:8888/truth/{Token}/{BlockHeight}",
"Token": "ethereum"
}
},
// reputer providing ground truth for topic ID 2
{
"topicId": 2,
"reputerEntrypointName": "api-worker-reputer",
"loopSeconds": 30,
"minStake": 100000,
"parameters": {
"SourceOfTruthEndpoint": "http://source:8888/truth/{Token}/{BlockHeight}",
"Token": "ethereum"
}
}
],
Running the Node
Now that the node is configured, let's deploy and register it to the network. To run the node, follow these steps:
Export Variables
Execute the following command from the root directory:
chmod +x init.config
./init.config
This command will automatically export the necessary variables from the account created. These variables are used by the offchain node and are bundled with your provided config.json
, then passed to the node as environment variables.
If you need to make changes to your config.json
file after you ran the init.config
command, rerun:
chmod +x init.config
./init.config
before proceeding.
Request from Faucet
Copy your Allora address and request some tokens from the Allora Testnet Faucet (opens in a new tab) to register your reputer in the next step successfully.
Deploy the Node
docker compose up --build
Both the offchain node and the source services will be started. They will communicate through endpoints attached to the internal DNS.
A successful response from your Reputer should display:
{"level":"debug","msg":"Send Reputer Data to chain","txHash":"<tx-hash>","time":"<timestamp>","message":"Success"}
Congratulations! You've successfully deployed and registered your node on Allora.
Keep it updated
You can keep the state updated by hitting the url:
http://localhost:8000/update/<token-name>/<token-from>/<token-to>
where:
token-name
: the name of the token on internal database, e.g. ETHUSDtoken-from
: the name of the token on Coingecko naming, e.g. ethereumtoken-to
: the name of the token on Coingecko naming, e.g. usd
It is expected that this endpoint is hit periodically, as this is crucial for maintaining the accuracy of the provided ground truth.
Testing the Truth Service
Here we'll setup a reputer with only the "truth service", which fetches the ground truth.
To only test the truth service, you can simply follow these steps:
- Run
docker compose up --build truth
and wait for the initial data load. - Requests can now be sent, e.g. ETH price ground truths can be fetched with:
or you can trigger an update to the current ETH price:
$ curl http://localhost:8000/gt/ETHUSD/1719565747 {"value":"3431.440268842158"}
$ curl http://localhost:8000/update/ETHUSD/ethereum/usd