diff --git a/CHANGELOG.md b/CHANGELOG.md index a9dcd7bf9fc..fc8361cbf77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,10 @@ - Change the F3 HeadLookback parameter to 4 ([filecoin-project/lotus#12648](https://github.com/filecoin-project/lotus/pull/12648)). - Upgrade go-f3 to 0.7.1 to resolve Tipset not found errors when trying to establish instance start time ([filecoin-project/lotus#12651](https://github.com/filecoin-project/lotus/pull/12651)). +## Changes + +- The Lotus Miner will now always mine on the latest chain head returned by lotus, even if that head has less "weight" than the previously seen head. This is necessary because F3 may end up finalizing a tipset with a lower weight, although this situation should be rare on the Filecoin mainnet. ([filecoin-project/lotus#12659](https://github.com/filecoin-project/lotus/pull/12659)) + ## Deps # UNRELEASED Node v1.30.0 diff --git a/miner/miner.go b/miner/miner.go index b7e39a953c4..785cc3a2c9a 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -400,11 +400,8 @@ type MiningBase struct { } // GetBestMiningCandidate implements the fork choice rule from a miner's -// perspective. -// -// It obtains the current chain head (HEAD), and compares it to the last tipset -// we selected as our mining base (LAST). If HEAD's weight is larger than -// LAST's weight, it selects HEAD to build on. Else, it selects LAST. +// perspective, returning the best head to mine on. This includes the number of null rounds we think +// we should insert and the time at which we received said head. func (m *Miner) GetBestMiningCandidate(ctx context.Context) (*MiningBase, error) { m.lk.Lock() defer m.lk.Unlock() @@ -414,27 +411,10 @@ func (m *Miner) GetBestMiningCandidate(ctx context.Context) (*MiningBase, error) return nil, err } - if m.lastWork != nil { - if m.lastWork.TipSet.Equals(bts) { - return m.lastWork, nil - } - - btsw, err := m.api.ChainTipSetWeight(ctx, bts.Key()) - if err != nil { - return nil, err - } - ltsw, err := m.api.ChainTipSetWeight(ctx, m.lastWork.TipSet.Key()) - if err != nil { - m.lastWork = nil - return nil, err - } - - if types.BigCmp(btsw, ltsw) <= 0 { - return m.lastWork, nil - } + if m.lastWork == nil || !m.lastWork.TipSet.Equals(bts) { + m.lastWork = &MiningBase{TipSet: bts, ComputeTime: time.Now()} } - m.lastWork = &MiningBase{TipSet: bts, ComputeTime: time.Now()} return m.lastWork, nil }