Serialize zindex stats to disk in zindex.dat #48

Closed
opened 3 years ago by duke · 7 comments
duke commented 3 years ago
Owner

Currently on a reboot, various zindex stats can only be calculated in memory and so shielded pool stats only reflect the blocks since the node was rebooted, not since block 1.

Changing the format of other blockchain data on disk makes old version incompatible and would make a painful upgrade process. Instead, we can store this new zindex data in a new file zindex.dat.

If zindex.dat is present, we will load the data that is used to calculate the anonset size (shielded pool size) from that file. If the chain height in zindex.dat is the same as the current best height of the node when it restarts, we can be reasonably sure we are adding new stats exactly where we left off.

Currently on a reboot, various zindex stats can only be calculated in memory and so shielded pool stats only reflect the blocks since the node was rebooted, not since block 1. Changing the format of other blockchain data on disk makes old version incompatible and would make a painful upgrade process. Instead, we can store this new zindex data in a new file `zindex.dat`. If `zindex.dat` is present, we will load the data that is used to calculate the anonset size (shielded pool size) from that file. If the chain height in `zindex.dat` is the same as the current best height of the node when it restarts, we can be reasonably sure we are adding new stats exactly where we left off.
Poster
Owner

This is currently in testing on zindexdb branch

This is currently in testing on `zindexdb` branch
Poster
Owner

@onryo @hyp3r @jahway603 please put any build/testing issues here

@onryo @hyp3r @jahway603 please put any build/testing issues here
Poster
Owner

I did testing on two different machines with very good results. All anonset stats matched on both machines, before and after a restart. So the main goal is accomplished. We have a few small bugs that would be nice to be fixed. Nobody currently relies on this stuff, but we want our stats to be correct!

  • window_payments is incorrect
  • All variables starting with window_* are incorrect
    • This is likely from a bug where we do not initialize the variables related to window values when reading zindex.dat from disk. The values shown are all-time values, not just the default "window", which is 30 days.
  • organic.payments went from 0 to what now looks like an all-time value of 2.9M. This may have already been broken and is less important than the above 2 items

Notes

  • nullifiers is currently incorrect already, and only shows a count of the the nullfiier cache, not all-time. Does not need to be fixed in this branch
I did testing on two different machines with very good results. All anonset stats matched on both machines, before and after a restart. So the main goal is accomplished. We have a few small bugs that would be nice to be fixed. Nobody currently relies on this stuff, but we want our stats to be correct! * [ ] `window_payments` is incorrect * [ ] All variables starting with `window_*` are incorrect * This is likely from a bug where we do not initialize the variables related to `window` values when reading zindex.dat from disk. The values shown are all-time values, not just the default "window", which is 30 days. * [ ] `organic.payments` went from 0 to what now looks like an all-time value of 2.9M. This may have already been broken and is less important than the above 2 items Notes * `nullifiers` is currently incorrect already, and only shows a count of the the nullfiier cache, not all-time. Does not need to be fixed in this branch
Poster
Owner

Attached is anonset data in CSV format, up to block 567875. This can be used to generate a graph of our anonset over-time. Might be interesting to @onryo

Format:

height,zins,zouts,anonset at that height

Attached is anonset data in CSV format, up to block 567875. This can be used to generate a graph of our anonset over-time. Might be interesting to @onryo Format: height,zins,zouts,anonset at that height
Poster
Owner

I am seeing pindexPast->nChainPayments as 0, which causes window_payments to be an all-time value, when getchaintxstats is called. Same behavior when a custom window of 10 blocks is used, it's not related to the size of the window

I am seeing `pindexPast->nChainPayments` as 0, which causes `window_payments` to be an all-time value, when `getchaintxstats` is called. Same behavior when a custom window of 10 blocks is used, it's not related to the size of the window
Poster
Owner

1st Ever Graph of anonset size over time for a privacy coin

1st Ever Graph of anonset size over time for a privacy coin
Poster
Owner

This is done and merged

This is done and merged
duke closed this issue 3 years ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.