babylonchain / babylon-finality-gadget

3 stars 3 forks source link

fix: 1) divide by zero bug; 2) should not return error when not have enough power #36

Closed bap2pecs closed 4 months ago

bap2pecs commented 4 months ago

Summary

I found that checkBlockFinalized() always returns true no matter what hash I pass in, thus found this bug

unfortunately this was never caught b/c float(0)/float(0) won't throw

fix is to add if totalPower == 0 check

the second bug found is when there is not enough power we should not return an error, it's a valid result

also I fixed a few other things

Test Plan

make lint
make test
make run