rotki
rotki copied to clipboard
Create user initiated historical balance sanity check (EVM only)
Abstract
At the moment of writing users can finally see their balance calculated through historical events only on the asset graph. With #2480 we can also show it somewhere in the UI. Perhaps asset page? And with #2227 we will be able to ask a historical balance as a source of truth for an address and a token and a chain.
These all can then be combined into a sanity check to find out and suggest fixes for discrepancies. Essentially going through events in a range, calculating historical balance from events and dissecting a comparison with the actual historical balance to find discrepancies.
Related issues
This is related to and depends on:
- https://github.com/rotki/rotki/issues/2227
- https://github.com/rotki/rotki/issues/2480
Task
- Take as input an address, a chain id, an asset and a time period to check for consistency
- Calculate historical balance from events up to that period for the selected data. Compare with actual historical balance of the asset in that period for the selected data. If it does not match then stop and tell the user there was discrepancy already before the period.
- If they do match then start comparing. Does the last period point match? Then we are all good.
- If not then bisect. Go to the middle of the period and compare. Is it fine? Then to the middle of the right period. Is it not fine? Then to the middle of the left period. And so on and so forth.