-
Notifications
You must be signed in to change notification settings - Fork 130
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 address rewards metadata #1818
base: dev
Are you sure you want to change the base?
Conversation
cfea75c
to
f4de181
Compare
Nothing in consensus or in the chain should be affected by this right? Like this should sync independently and then we have a machine that will output the right locked amounts? So we could test this by simply attaching it to the portal backend server and using these new RPC endpoints? |
Yeah that's the intent, if that all looks gucci, I will get this onto canary and Ryan can test using these numbers, which makes it not really urgent at all for merging and so forth. |
This adds some new fields to the rewards DB.
Batched Accrued Rewards
These numbers expose some more metadata on what exactly is the composition of the
amount
value (which is rewards + unlocked stake) into separate fields. You can calculate how many tokens are actively locked in the network(lifetime locked - (lifetime unlocked + lifetime liquidated))
or see how many rewards an address has earnt (lifetime_rewards
) or how much has been liquidated from the address (lifetime_liquidated
).I've updated the
get_accrued_rewards
to return a struct now which has all this metadata plus more. It's basically all documented in the APIThe way this is achieved is by simply storing the result of the ETH transactions that we confirm and witness and feed it down into the rewards DB where it enumerates them together. These new fields don't kick in until the ETH hardfork so they're all gated and should return 0 if queried before then. This way collecting this metadata only needs to happen on the ETH code path instead of also requiring to work on the OXEN path.
Since it's gated, this will only trigger a rescan on stagenet which has 50k blocks. Since the new fields are written on the ETH hardfork there'll be no rescan needed for mainnet. It'll just gracefully start enumerating the fields when the hardfork elapses.
This does overlap with the Oxen 10 backwards compat fix that was recently patched. I had to patch ontop again to preserve the old behaviour. For Oxen 11, I just made it support parsing the new
wallet_info
struct that we return in the RPC call.The
get_accrued_rewards
now returns something like this