wip fixing IsTicketWinner

This commit is contained in:
Łukasz Magiera 2019-12-02 23:46:49 +01:00
parent 923748e551
commit ab36a5aa04
3 changed files with 5 additions and 11 deletions

View File

@ -519,10 +519,7 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add
var winners []sectorbuilder.EPostCandidate
for _, c := range candidates {
sectors := types.BigDiv(pow.MinerPower, types.NewInt(ssize))
challangeCount := sectorbuilder.ElectionPostChallengeCount(sectors.Uint64())
if types.IsTicketWinner(c.PartialTicket[:], ssize, pow.TotalPower, int64(challangeCount)) {
if types.IsTicketWinner(c.PartialTicket[:], ssize, pow.TotalPower) {
winners = append(winners, c)
}
}

View File

@ -545,7 +545,7 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
}
winnerCheck := async.Err(func() error {
mpow, tpow, err := stmgr.GetPower(ctx, syncer.sm, baseTs, h.Miner)
_, tpow, err := stmgr.GetPower(ctx, syncer.sm, baseTs, h.Miner)
if err != nil {
return xerrors.Errorf("failed getting power: %w", err)
}
@ -556,10 +556,7 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
}
for _, t := range h.EPostProof.Candidates {
sectors := types.BigDiv(mpow, types.NewInt(ssize))
challangeCount := sectorbuilder.ElectionPostChallengeCount(sectors.Uint64())
if !types.IsTicketWinner(t.Partial, ssize, tpow, int64(challangeCount)) {
if !types.IsTicketWinner(t.Partial, ssize, tpow) {
return xerrors.Errorf("miner created a block but was not a winner")
}
}

View File

@ -172,7 +172,7 @@ func CidArrsEqual(a, b []cid.Cid) bool {
var blocksPerEpoch = NewInt(build.BlocksPerEpoch)
func IsTicketWinner(partialTicket []byte, ssizeI uint64, totpow BigInt, sampleRate int64) bool {
func IsTicketWinner(partialTicket []byte, ssizeI uint64, totpow BigInt) bool {
ssize := NewInt(ssizeI)
/*
@ -189,7 +189,7 @@ func IsTicketWinner(partialTicket []byte, ssizeI uint64, totpow BigInt, sampleRa
lhs := BigFromBytes(h[:]).Int
lhs = lhs.Mul(lhs, totpow.Int)
lhs = lhs.Mul(lhs, big.NewInt(sampleRate))
lhs = lhs.Mul(lhs, big.NewInt(build.SectorChallengeRatioDiv))
// rhs = sectorSize * 2^256
// rhs = sectorSize << 256