Closed Pitasi closed 2 years ago
The database already contains all the informations we need so I suggest we do this in the api-server before returning results.
Main blocker I see is that in database we store the validator address in the form sifvaloper1lnhxf6war6qlldemkqzp0t3g57hpe9a6nh3tyv
while in the delegations tables we have the validator_address column in the form fcee64e9dd1e81ffb73bb00417ae28a7ae1c97ba
.
If we want to do things properly I suggest we add a new column to validators
to additionally store the bech32 decoded address. After we do this, we can calculate the staking balance in a single db query joining the tables.
Tracelistener writes the
shares
amount into the db. api-server returns that amount as-is.The problem is that
shares
and the actual staked amount are two separates concepts as exaplained here: https://allinbits.slack.com/archives/CQBCG2DT7/p1650967174081609?thread_ts=1650965509.245189&cid=CQBCG2DT7.To summarize what we need to return instead of
shares
is:shares / total_validator_shares * total_validator_balance
DoD:
validator_address
column is added to thevalidators
table, and tracelistener writes the bech32 decoded operator address in that column/stakingbalances
, api-server do the proper calculation explained above