diff --git a/chain/gen/gen.go b/chain/gen/gen.go index f0e884073..6d891f260 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -362,7 +362,7 @@ func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m add rbase = entries[len(entries)-1] } - eproof, err := IsRoundWinner(ctx, pts, round, m, rbase, mbi, mc) + eproof, err := IsRoundWinner(ctx, round, m, rbase, mbi, mc) if err != nil { return nil, nil, nil, xerrors.Errorf("checking round winner failed: %w", err) } @@ -639,7 +639,7 @@ func (wpp *wppProvider) ComputeProof(context.Context, []proof7.ExtendedSectorInf return ValidWpostForTesting, nil } -func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch, +func IsRoundWinner(ctx context.Context, round abi.ChainEpoch, miner address.Address, brand types.BeaconEntry, mbi *api.MiningBaseInfo, a MiningCheckAPI) (*types.ElectionProof, error) { buf := new(bytes.Buffer) diff --git a/cmd/lotus-shed/election.go b/cmd/lotus-shed/election.go index 7ac74de48..23c533c31 100644 --- a/cmd/lotus-shed/election.go +++ b/cmd/lotus-shed/election.go @@ -219,7 +219,7 @@ func backTestWinner(ctx context.Context, miner address.Address, round abi.ChainE brand = bvals[len(bvals)-1] } - winner, err := gen.IsRoundWinner(ctx, ts, round, miner, brand, mbi, api) + winner, err := gen.IsRoundWinner(ctx, round, miner, brand, mbi, api) if err != nil { return nil, xerrors.Errorf("failed to check if we win next round: %w", err) } diff --git a/miner/miner.go b/miner/miner.go index 9281854d7..b6285eda6 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -507,13 +507,13 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (minedBlock *type rbase = bvals[len(bvals)-1] } - ticket, err := m.computeTicket(ctx, &rbase, base, mbi) + ticket, err := m.computeTicket(ctx, &rbase, round, base.TipSet.MinTicket(), mbi) if err != nil { err = xerrors.Errorf("scratching ticket failed: %w", err) return nil, err } - winner, err = gen.IsRoundWinner(ctx, base.TipSet, round, m.address, rbase, mbi, m.api) + winner, err = gen.IsRoundWinner(ctx, round, m.address, rbase, mbi, m.api) if err != nil { err = xerrors.Errorf("failed to check if we win next round: %w", err) return nil, err @@ -589,15 +589,14 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (minedBlock *type return minedBlock, nil } -func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, base *MiningBase, mbi *api.MiningBaseInfo) (*types.Ticket, error) { +func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, round abi.ChainEpoch, chainRand *types.Ticket, mbi *api.MiningBaseInfo) (*types.Ticket, error) { buf := new(bytes.Buffer) if err := m.address.MarshalCBOR(buf); err != nil { return nil, xerrors.Errorf("failed to marshal address to cbor: %w", err) } - round := base.TipSet.Height() + base.NullRounds + 1 if round > build.UpgradeSmokeHeight { - buf.Write(base.TipSet.MinTicket().VRFProof) + buf.Write(chainRand.VRFProof) } input, err := lrand.DrawRandomness(brand.Data, crypto.DomainSeparationTag_TicketProduction, round-build.TicketRandomnessLookback, buf.Bytes())