use challangeCount as sampleRate in IsTicketWinner
This commit is contained in:
parent
d5b94884c8
commit
1cdf6a6f8d
@ -519,7 +519,10 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add
|
|||||||
|
|
||||||
var winners []sectorbuilder.EPostCandidate
|
var winners []sectorbuilder.EPostCandidate
|
||||||
for _, c := range candidates {
|
for _, c := range candidates {
|
||||||
if types.IsTicketWinner(c.PartialTicket[:], ssize, pow.TotalPower, 1) {
|
sectors := types.BigDiv(pow.MinerPower, types.NewInt(ssize))
|
||||||
|
challangeCount := sectorbuilder.ElectionPostChallengeCount(sectors.Uint64())
|
||||||
|
|
||||||
|
if types.IsTicketWinner(c.PartialTicket[:], ssize, pow.TotalPower, int64(challangeCount)) {
|
||||||
winners = append(winners, c)
|
winners = append(winners, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,7 +545,7 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
winnerCheck := async.Err(func() error {
|
winnerCheck := async.Err(func() error {
|
||||||
_, tpow, err := stmgr.GetPower(ctx, syncer.sm, baseTs, h.Miner)
|
mpow, tpow, err := stmgr.GetPower(ctx, syncer.sm, baseTs, h.Miner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("failed getting power: %w", err)
|
return xerrors.Errorf("failed getting power: %w", err)
|
||||||
}
|
}
|
||||||
@ -556,7 +556,10 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, t := range h.EPostProof.Candidates {
|
for _, t := range h.EPostProof.Candidates {
|
||||||
if !types.IsTicketWinner(t.Partial, ssize, tpow, 1) {
|
sectors := types.BigDiv(mpow, types.NewInt(ssize))
|
||||||
|
challangeCount := sectorbuilder.ElectionPostChallengeCount(sectors.Uint64())
|
||||||
|
|
||||||
|
if !types.IsTicketWinner(t.Partial, ssize, tpow, int64(challangeCount)) {
|
||||||
return xerrors.Errorf("miner created a block but was not a winner")
|
return xerrors.Errorf("miner created a block but was not a winner")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ func (sb *SectorBuilder) GenerateEPostCandidates(sectorInfo SortedPublicSectorIn
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
challengeCount := electionPostChallengeCount(uint64(len(sectorInfo.Values())))
|
challengeCount := ElectionPostChallengeCount(uint64(len(sectorInfo.Values())))
|
||||||
|
|
||||||
proverID := addressToProverID(sb.Miner)
|
proverID := addressToProverID(sb.Miner)
|
||||||
return sectorbuilder.GenerateCandidates(sb.ssize, proverID, challengeSeed, challengeCount, privsectors)
|
return sectorbuilder.GenerateCandidates(sb.ssize, proverID, challengeSeed, challengeCount, privsectors)
|
||||||
@ -425,7 +425,7 @@ func NewSortedPublicSectorInfo(sectors []sectorbuilder.PublicSectorInfo) SortedP
|
|||||||
}
|
}
|
||||||
|
|
||||||
func VerifyElectionPost(ctx context.Context, sectorSize uint64, sectorInfo SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []EPostCandidate, proverID address.Address) (bool, error) {
|
func VerifyElectionPost(ctx context.Context, sectorSize uint64, sectorInfo SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []EPostCandidate, proverID address.Address) (bool, error) {
|
||||||
challengeCount := electionPostChallengeCount(uint64(len(sectorInfo.Values())))
|
challengeCount := ElectionPostChallengeCount(uint64(len(sectorInfo.Values())))
|
||||||
return verifyPost(ctx, sectorSize, sectorInfo, challengeCount, challengeSeed, proof, candidates, proverID)
|
return verifyPost(ctx, sectorSize, sectorInfo, challengeCount, challengeSeed, proof, candidates, proverID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,13 +467,13 @@ func GenerateDataCommitment(ssize uint64, pieces []PublicPieceInfo) ([CommLen]by
|
|||||||
return sectorbuilder.GenerateDataCommitment(ssize, pieces)
|
return sectorbuilder.GenerateDataCommitment(ssize, pieces)
|
||||||
}
|
}
|
||||||
|
|
||||||
func electionPostChallengeCount(sectors uint64) uint64 {
|
func ElectionPostChallengeCount(sectors uint64) uint64 {
|
||||||
// ceil(sectors / build.SectorChallengeRatioDiv)
|
// ceil(sectors / build.SectorChallengeRatioDiv)
|
||||||
return (sectors + build.SectorChallengeRatioDiv - 1) / build.SectorChallengeRatioDiv
|
return (sectors + build.SectorChallengeRatioDiv - 1) / build.SectorChallengeRatioDiv
|
||||||
}
|
}
|
||||||
|
|
||||||
func fallbackPostChallengeCount(sectors uint64) uint64 {
|
func fallbackPostChallengeCount(sectors uint64) uint64 {
|
||||||
challengeCount := electionPostChallengeCount(sectors)
|
challengeCount := ElectionPostChallengeCount(sectors)
|
||||||
if challengeCount > build.MaxFallbackPostChallengeCount {
|
if challengeCount > build.MaxFallbackPostChallengeCount {
|
||||||
return build.MaxFallbackPostChallengeCount
|
return build.MaxFallbackPostChallengeCount
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user