cardano-community / koios-artifacts

Artifacts for https://koios.rest and https://api.koios.rest websites
Creative Commons Attribution 4.0 International
20 stars 25 forks source link

Add dangling account stake to grest.account_active_stake_cache #94

Closed Dean998 closed 2 years ago

Dean998 commented 2 years ago

**Is your feature request related to a problem? I'm always frustrated when I can't find the delegators that are still staked in a retired pool.

Describe the solution you'd like

I would like there to be a way to find the delegators that are still staked in retired pools

Describe alternatives you've considered Finding a way or adding another parameter that checks account status and dangling accounts

Additional context Priyank helped me build this feature request.

rdlrt commented 2 years ago

Essentially the ask is to have accounts that are still registered, but the corresponding pools having been deregistered to show up in account_active_stake_cache and stake_distribution_cache (which is also used by pool_delegators endpoint)

This could be a bit tricky as it would impact stake calculations and timings.

The other alternative is to only update pool_delegators endpoint to artificially add a join for accounts delegating to retired pool being queried (if pool is actually retired) - this could be seamless and potentially get included within koios-1.0.7 itself

dostrelith678 commented 2 years ago

With regards to account_active_stake_cache, AFAIK adding those dangling accounts in there would be a mistake as the stake of those accounts is not considered active in the protocol.

I prefer this solution ⬇️

The other alternative is to only update pool_delegators endpoint to artificially add a join for accounts delegating to retired pool being queried (if pool is actually retired) - this could be seamless and potentially get included within koios-1.0.7 itself

dostrelith678 commented 2 years ago

After investigating, I see that stake_distribution_cache does capture accounts staked to retired pools. I consider this correct as it's a representation of LIVE stake, not ACTIVE stake.

For example:

select * from grest.pool_delegators('pool103gv6hc8ux9tvu7597f4806fayzeyvrn2pp338ndztgl6jg29mf');
                        stake_address                        | amount  | active_epoch_no
-------------------------------------------------------------+---------+-----------------
 stake1u8r6uk0yse9qs3s2fgacmhunlmfj2kweq8dtxc9c85mt2csmjugcu | 1489783 |             210
 stake1ux20zaj7l4m0zz3gqa5pg6rg3n37paptva50m0rtfqrhkas7d0p26 | 1000000 |             233
 stake1u9k745lpt39aamj05r6th6zr2xk3x2wtfvlh4m2qverek3gyl23et | 0       |             210
(3 rows)

This also matches data that can be seen on explorers for this pool.

So I am a bit confused now as to what would be the action for this issue/request... As from what I can see, accounts delegated to retired pools ARE available through the /pool_delegators endpoint.

rdlrt commented 2 years ago

From tg group: https://testnet.koios.rest/api/v0/pool_delegators?_pool_bech32=pool10vchpw7e525qdtygdhxuak4ujwrfa0ygjxhqqm03rz0z7586fq4

-> returns []

but for instance account_info for stake_test1urf6y7ktcqwzxd2tc3x54437jl6vcqvazgrdka3v2njdjzgyn6axc shows delegated to this retired pool

dostrelith678 commented 2 years ago

Ok, as far as I can tell right now, the above address belongs to the new-accounts job because even though it's active, it's not part of epoch_stake since it's delegated to a retired pool. The new-accounts job had a fix recently that when applied correctly captures this stake address in SDC - so the problem seems to be just the bug there fixed under: https://github.com/cardano-community/guild-operators/pull/1541.

I am getting 72 rows for select * from grest.pool_delegators('pool10vchpw7e525qdtygdhxuak4ujwrfa0ygjxhqqm03rz0z7586fq4'); including the mentioned address:

select * from grest.pool_delegators('pool10vchpw7e525qdtygdhxuak4ujwrfa0ygjxhqqm03rz0z7586fq4') where stake_address='stake_test1urf6y7ktcqwzxd2tc3x54437jl6vcqvazgrdka3v2njdjzgyn6axc';
                          stake_address                           |   amount    | active_epoch_no |                    latest_delegation_tx_hash
------------------------------------------------------------------+-------------+-----------------+------------------------------------------------------------------
 stake_test1urf6y7ktcqwzxd2tc3x54437jl6vcqvazgrdka3v2njdjzgyn6axc | 11282566947 |             224 | b0f4bb4963d13d66aaa0e23505fa3fbdbdd4f36a42170e09c9c7f438dad73b06
(1 row)
rdlrt commented 2 years ago

Right so we should be good to close this as fixed as part of koios-1.0.8 then?

dostrelith678 commented 2 years ago

Yep, I think so.