From 3566e96b553f188785ac21a12cea94757b53ae59 Mon Sep 17 00:00:00 2001 From: Aayush Date: Fri, 11 Aug 2023 09:52:26 -0400 Subject: [PATCH] refactor: pass more specialized params to computeTicket --- miner/miner.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/miner/miner.go b/miner/miner.go index 241c5e00f..b6285eda6 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -507,7 +507,7 @@ 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 @@ -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())