-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add endpoints for block and attestation rewards #260
Conversation
Define reward api endpoints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Thanks @naviechan & @kevinbogner!
In addition to the minor edits I've proposed the main thing missing is an API for the sync committee rewards. I didn't describe one in my original messages, but it should be similar to the others, maybe something like:
/eth/v1/beacon/blocks/{block_id}/sync_committee_rewards?id=...
{
"data": [
{
"validator_index": "0",
"reward": "-1000",
},
{
"validator_index": "1",
"reward": "1000",
},
]
}
The function that defines these rewards is here: https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#sync-aggregate-processing
I'd be open to speccing that endpoint in a separate PR if you like! Maybe one of you could take that on while the other updates the existing endpoints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting super close to being ready to merge. I think this is probably the final round of review from me before we can pass it to the other maintainers for merging!
per validator rewards
wording changes from sproul Co-authored-by: Michael Sproul <micsproul@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it!
as a nit, can we updated the endpoints to : |
Thanks @rolfyone |
In the Nimbus codebase, we have a set of routines which can produce not only the obtained rewards, but also the maximum reward that was possible if your attestations were perfect. This allows the creation of UIs and reports which focus on the deviation from perfect behavior. In other words, if a validator produces a wrong head vote for example (while hitting source and target correctly), this can be seen as an opportunity cost (a negative score) instead of as a positive increase of the balance. |
@zah Great idea! I think all the clients will end up with that data on-hand while computing the attestation rewards, it's just a matter of how to present it. We could take advantage of the fact that the rewards are fixed per effective balance with something like: {
"ideal_rewards": [
{
"effective_balance": "1000000000",
"head": "2500",
"target": "5000",
"source": "5000"
},
{
"effective_balance": "2000000000",
"head": "2500",
"target": "5000",
"source": "5000"
}
],
"rewards": [
{
"validator_index": "0",
"effective_balance": "32000000000",
"head": "0",
"target": "5000",
"source": "5000",
}
],
} Or maybe a {
"rewards": [
{
"validator_index": "0",
"head": "0",
"ideal_head": "2500",
"target": "5000",
"source": "5000",
},
{
"validator_index": "1",
"head": "0",
"ideal_head": "2500",
"target": "-5000",
"ideal_target": "5000",
"source": "-5000",
"ideal_source": "5000",
}
],
} This has the advantage of being smaller over the wire when the majority of requested validators are behaving optimally, however it introduces more duplication when there is a lot of sub-optimal voting. I think I have a slight preference for the first Another option would be an entirely separate API for the ideal reward information. However I don't think this would really be simpler, and it would likely be less efficient. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue: sigp/lighthouse#3661
Currently, there is no way to get block rewards paid on the consensus side. Therefore, we propose two endpoints.
/eth/v1/beacon/rewards/blocks/{block_id}
Get block rewards
/eth/v1/beacon/rewards/attestations/{epoch}
Get attestation rewards