Open Nizametdinov opened 5 years ago
@Gnappuraz and I reviewed it, and this issue occurs because we want to finalize epoch not when 2/3 of votes are reached but when ">2/3" of votes are reached. The way how it's implemented, there is an equal comparison ">=2/3" but! current total votes don't include the current reward factor; however, the threshold (2/3) includes it which "more or less" turns this ">=" sign into ">" one.
Here we can see https://github.com/dtr-org/unit-e/blob/master/src/esperanza/finalizationstate.cpp#L529-L532 that reward was attributed to m_cur_dyn_deposits
and m_prev_dyn_deposits
but not to curDynastyVotes
or prevDynastyVotes
This implementation we borrowed from Casper, and I think we should change it to have a strict >2/3
comparison and attribute current reward to both, total votes and the threshold. Then we won't have this "weird behavior" when the current reward factor is >0, and now we see that 2/3 of votes don't finalize when they used to finalize. Another issue with the current implementation is that if the reward factor is too large (because there are no finalization for decades*), you'll never able to finalize, even if everyone votes
Describe the bug Consider the following setup:
After a few finalized epochs finalization fails. For some reason, the votes of the first finalizer become unable to finalize an epoch.
To Reproduce The following test
fails with the error:
Expected behavior Finalizer with 2/3 of total deposit should be able to finalize any epoch if it's the only finalizer which votes.