Merge pull request #11456 from filecoin-project/fix/mineinfo-counts

fix: miner info: Show correct sector state counts
This commit is contained in:
Andrew Jackson (Ajax) 2023-11-27 13:01:51 -06:00 committed by GitHub
commit 3283cb70a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View File

@ -4,6 +4,7 @@
- chore: Auto remove local chain data when importing chain file or snapshot ([filecoin-project/lotus#11277](https://github.com/filecoin-project/lotus/pull/11277))
- feat: metric: export Mpool message count ([filecoin-project/lotus#11361](https://github.com/filecoin-project/lotus/pull/11361))
- feat: sealing: load SectorsSummary from sealing SectorStats instead of calling API each time ([filecoin-project/lotus#11353](https://github.com/filecoin-project/lotus/pull/11353))
- fix: miner info: Show correct sector state counts ([filecoin-project/lotus#11456](https://github.com/filecoin-project/lotus/pull/11456))
## Improvements
- fix: Add time slicing to splitstore purging step during compaction to reduce lock congestion [filecoin-project/lotus#11269](https://github.com/filecoin-project/lotus/pull/11269)

View File

@ -223,3 +223,29 @@ func TestPledgeSynth(t *testing.T) {
runTest(t, 3)
})
}
func TestSectorsSummary(t *testing.T) {
kit.QuietMiningLogs()
blockTime := 50 * time.Millisecond
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
nPreseal := 2
_, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.PresealSectors(nPreseal))
ens.InterconnectAll().BeginMining(blockTime)
miner.PledgeSectors(ctx, 1, 0, nil)
ms, err := miner.SectorsSummary(ctx)
require.NoError(t, err)
require.Len(t, ms, 1) // all proving
for st, n := range ms {
require.Equal(t, api.SectorState(sealing.Proving), st)
require.Equal(t, 1+nPreseal, n)
}
}

View File

@ -44,6 +44,10 @@ func (ss *SectorStats) updateSector(ctx context.Context, cfg sealiface.Config, i
ss.totals[toStatState(oldst, cfg.FinalizeEarly)]--
ss.byState[oldst]--
if ss.byState[oldst] <= 0 {
delete(ss.byState, oldst)
}
mctx, _ := tag.New(ctx, tag.Upsert(metrics.SectorState, string(oldst)))
stats.Record(mctx, metrics.SectorStates.M(ss.byState[oldst]))
}