anoma / namada

Rust implementation of Namada, a Proof-of-Stake L1 for interchain asset-agnostic privacy
https://namada.net
GNU General Public License v3.0
2.4k stars 952 forks source link

querying total stake and voting powers for past epochs #3810

Open egasimus opened 1 month ago

egasimus commented 1 month ago

In order to independently compute proposal results, we need to fetch voting power for each vote of each past governance proposal. To achieve this, it appears that we need the following data for each past epoch:

As far as I understood from epoched.rs, the Epoched struct only keeps data for a fixed number of past epochs. Could you explain why this is the case and whether there is a workaround for fetching historical data from the node?

Fraccaman commented 1 month ago

Hi @egasimus! Right now, this is a limitation of namada. We "prune" some of the PoS data each epoch, meaning that the data you are looking for its not easily accessible and requires a more complex mechanism to query it. Unfortunately, this is not a priority for us right now and we won't look into it in the short future. As a workaround, you start a fullnode from scratch and while the fullnode is synching, you can connect an indexer.

Ill' leave the issue open and update it as soon as we start working on this.

egasimus commented 1 month ago

Thanks! Fair enough. For the workaround, doesn't that mean a race between the fullnode sync and the indexer? Doesn't sound very reliable. it would be massively helpful if the node at least returned an error that the queried data has been pruned, rather than just returning empty values.

opsecx commented 1 day ago

Hi @egasimus! Right now, this is a limitation of namada. We "prune" some of the PoS data each epoch, meaning that the data you are looking for its not easily accessible and requires a more complex mechanism to query it. Unfortunately, this is not a priority for us right now and we won't look into it in the short future.

As a workaround, you start a fullnode from scratch and while the fullnode is synching, you can connect an indexer.

Ill' leave the issue open and update it as soon as we start working on this.

I'm curious, would running a node with indexer = kv disrupt this pruning? or unrelated?

opsecx commented 1 day ago

@Fraccaman having this data available seems like a big net gain for the "indexing community" - any chance it could be given some priority? (not top ofc but also included at some point)

brentstone commented 1 day ago

@opsecx I'm not super familiar with the technical details of indexers, but I think I can offer some insight here:

The pruning occurs in the protocol, so no indexer setting would be able to disrupt or change it. However, an indexer or similar service could cache these pieces of data elsewhere while it reads them as they still exist in Namada and then persist them after they've been pruned from the namada DB.