You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is for tracking the error handling in the indexation module:
For Balances:
At the moment all "amounts" for coins, messages and contracts is stored as u64. When implementing the "balances cache" I noticed that when we calculate the total balances, we use the accumulator which is u64 and we call saturating_add() on it. This may lead to the balances being calculated incorrectly.
In the original PR the accumulator has been changed to u128, which vastly reduces the problem with accumulation (one would require humongous amount of u64s to overflow u128). However, there is still a problem with balance deduction, as we might find ourselves in the situation where, for example, our balance is 100, but we try to reduce it by 200.
This is a fatal error and indicates a serious bug in the logic. Currently, we just log it and continue.
To be considered:
Properly handle the underflow error
maybe change the return type of "balances()" from StorageResult to something else, since overflow is not a storage error
update integration tests - some of them are written with the assumption that balances calculation is infallible
Consider changing all "amounts" to be u128, so that even a single coin can have a balance greater than u64
For Coins To Spend:
When "coins to spend" index is considered, the possible errors to be handled are:
trying to index the same coin twice
trying to remove the coin that is not in the index
The text was updated successfully, but these errors were encountered:
Originally posted by @rafal-ch in #2383 (comment)
This issue is for tracking the error handling in the indexation module:
For Balances:
At the moment all "amounts" for coins, messages and contracts is stored as
u64
. When implementing the "balances cache" I noticed that when we calculate the total balances, we use the accumulator which isu64
and we callsaturating_add()
on it. This may lead to the balances being calculated incorrectly.In the original PR the accumulator has been changed to
u128
, which vastly reduces the problem with accumulation (one would require humongous amount ofu64
s to overflowu128
). However, there is still a problem with balance deduction, as we might find ourselves in the situation where, for example, our balance is100
, but we try to reduce it by200
.This is a fatal error and indicates a serious bug in the logic. Currently, we just log it and continue.
To be considered:
StorageResult
to something else, since overflow is not a storage errorConsider changing all "amounts" to beu128
, so that even a single coin can have a balance greater thanu64
For Coins To Spend:
When "coins to spend" index is considered, the possible errors to be handled are:
The text was updated successfully, but these errors were encountered: