From adcda68d6266e7332d562cf7186020357e8a977d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 3 Dec 2019 00:18:27 +0100 Subject: [PATCH] fix winner math --- chain/types/blockheader.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chain/types/blockheader.go b/chain/types/blockheader.go index f00e8a0c3..aec7d8514 100644 --- a/chain/types/blockheader.go +++ b/chain/types/blockheader.go @@ -191,15 +191,15 @@ func IsTicketWinner(partialTicket []byte, ssizeI uint64, totpow BigInt) bool { lhs := BigFromBytes(h[:]).Int lhs = lhs.Mul(lhs, totpow.Int) - lhs = lhs.Mul(lhs, big.NewInt(build.SectorChallengeRatioDiv)) // rhs = sectorSize * 2^256 // rhs = sectorSize << 256 rhs := new(big.Int).Lsh(ssize.Int, sha256bits) + rhs = rhs.Mul(rhs, big.NewInt(build.SectorChallengeRatioDiv)) rhs = rhs.Mul(rhs, blocksPerEpoch.Int) // h(vrfout) * totalPower < e * sectorSize * 2^256? - return lhs.Cmp(rhs) == -1 + return lhs.Cmp(rhs) < 0 } func (t *Ticket) Equals(ot *Ticket) bool {