From 3407848e8c4daf58bcdebae31e6855c46efe7491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 23 Nov 2023 21:19:16 +0100 Subject: [PATCH 1/2] fix: miner info: Show correct sector state counts --- CHANGELOG.md | 1 + storage/pipeline/stats.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 664fa3778..05caea4f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/storage/pipeline/stats.go b/storage/pipeline/stats.go index 696cd56a5..a558421ae 100644 --- a/storage/pipeline/stats.go +++ b/storage/pipeline/stats.go @@ -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])) } From 00535fe3eece9592f541142f92b5b578559b220d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 27 Nov 2023 18:30:46 +0100 Subject: [PATCH 2/2] itests: TestSectorsSummary --- itests/sector_pledge_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/itests/sector_pledge_test.go b/itests/sector_pledge_test.go index 1e045c79d..b4e5c1133 100644 --- a/itests/sector_pledge_test.go +++ b/itests/sector_pledge_test.go @@ -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) + } +}