diff --git a/chain/gen/mining.go b/chain/gen/mining.go index 4889c632f..5fc56e8b2 100644 --- a/chain/gen/mining.go +++ b/chain/gen/mining.go @@ -27,7 +27,17 @@ func MinerCreateBlock(ctx context.Context, sm *stmgr.StateManager, w api.WalletA return nil, xerrors.Errorf("failed to load tipset state: %w", err) } - worker, err := stmgr.GetMinerWorkerRaw(ctx, sm, st, bt.Miner) + lbts, err := stmgr.GetLookbackTipSetForRound(ctx, sm, pts, bt.Epoch) + if err != nil { + return nil, xerrors.Errorf("getting lookback miner actor state: %w", err) + } + + lbst, _, err := sm.TipSetState(ctx, lbts) + if err != nil { + return nil, err + } + + worker, err := stmgr.GetMinerWorkerRaw(ctx, sm, lbst, bt.Miner) if err != nil { return nil, xerrors.Errorf("failed to get miner worker: %w", err) } diff --git a/miner/miner.go b/miner/miner.go index 7451d617a..7de7f5b73 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -386,7 +386,7 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg, rbase = bvals[len(bvals)-1] } - ticket, err := m.computeTicket(ctx, &rbase, base) + ticket, err := m.computeTicket(ctx, &rbase, base, mbi) if err != nil { return nil, xerrors.Errorf("scratching ticket failed: %w", err) } @@ -456,16 +456,7 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg, return b, nil } -func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, base *MiningBase) (*types.Ticket, error) { - mi, err := m.api.StateMinerInfo(ctx, m.address, types.EmptyTSK) - if err != nil { - return nil, err - } - worker, err := m.api.StateAccountKey(ctx, mi.Worker, types.EmptyTSK) - if err != nil { - return nil, err - } - +func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, base *MiningBase, 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) @@ -481,7 +472,7 @@ func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, bas return nil, err } - vrfOut, err := gen.ComputeVRF(ctx, m.api.WalletSign, worker, input) + vrfOut, err := gen.ComputeVRF(ctx, m.api.WalletSign, mbi.WorkerKey, input) if err != nil { return nil, err }