View block rewards
Use the rewards API to view the validator rewards.
You cannot query attestation rewards for the latest epoch.
Enable the rewards API with the --rest-api-enabled
command line option.
A Swagger interface is also available. Use the --rest-api-docs-enabled
command line option to enable the web interface.
Limitations
The following limitations apply:
-
The rewards API currently supports the
altair
fork upgrade and later. -
The rewards API relies on state and block data to retrieve the reward information, meaning you'll receive limited data if the beacon node being queried is not an archive node.
-
You can only query blocks from finalized to head if you are in
prune
storage mode.
Impact of data storage modes
You can change the data-storage-mode
without re-initializing your database.
You can change the frequency that states are stored by specifying data-storage-archive-frequency
, but it will only affect the state storage from the time that the change has been made. It will also directly impact the amount of disk space required by Teku.
Consider using a beacon node with archive
mode storage if you frequently call the rewards API on finalized data. However, this may produce slow results due to having to replay blocks due to the infrequent storage of states on disk (every 2048 slots by default).
You can consider tuning your data storage to access data quicker, by storing more states (at the cost of disk space), for example, setting the archive frequency to 256
or even 64
, and replaying less blocks.
Examples
Query all the rewards from the block currently at head.
- Example
- Result
curl http://localhost:5051/eth/v1/beacon/rewards/blocks/head |jq
{
"execution_optimistic": false,
"finalized": false,
"data": {
"proposer_index": "555552",
"total": "1217168",
"attestations": "0",
"sync_aggregate": "1217168",
"proposer_slashings": "0",
"attester_slashings": "0"
}
}
Query all the sync committee rewards from the block at head for validator index 1.
- Example
- Result
curl -X POST \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
http://localhost:5051/eth/v1/beacon/rewards/sync_committee/head \
-d '["1"]' |jq
{
"execution_optimistic": false,
"finalized": false,
"data": [
{
"validator_index": "1",
"reward": "16778"
}
]
}
Query attestation rewards from epoch 204644, just for validator index 0.
- Example
- Result
curl -X POST \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
http://localhost:5051/eth/v1/beacon/rewards/attestations/204648 \
-d '["0"]' |jq
{
"execution_optimistic": false,
"finalized": true,
"data": {
"ideal_rewards": [...],
"total_rewards": [
{
"validator_index": "0",
"head": "3125",
"target": "6005",
"source": "3236"
}
]
}
}