Skip to content

Commit eb9bc47

Browse files
authored
fix: prevent MinerSectorEvent panic on empty SectorStateEventso (#1053)
- fixes #1052
1 parent ab09cca commit eb9bc47

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tasks/actorstate/miner/sector_events.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ func (SectorEventsExtractor) Extract(ctx context.Context, a actorstate.ActorInfo
3434
}
3535

3636
var (
37-
sectorChanges *miner.SectorChanges
38-
preCommitChanges *miner.PreCommitChanges
39-
sectorStateChanges *SectorStateEvents
37+
sectorChanges = miner.MakeSectorChanges()
38+
preCommitChanges = miner.MakePreCommitChanges()
39+
sectorStateChanges = &SectorStateEvents{
40+
Removed: bitfield.New(),
41+
Recovering: bitfield.New(),
42+
Faulted: bitfield.New(),
43+
Recovered: bitfield.New(),
44+
}
4045
)
4146
if extState.ParentState() == nil {
4247
// If the miner doesn't have previous state list all of its current sectors and precommits
@@ -45,12 +50,10 @@ func (SectorEventsExtractor) Extract(ctx context.Context, a actorstate.ActorInfo
4550
return nil, fmt.Errorf("loading miner sectors: %w", err)
4651
}
4752

48-
sectorChanges = miner.MakeSectorChanges()
4953
for _, sector := range sectors {
5054
sectorChanges.Added = append(sectorChanges.Added, *sector)
5155
}
5256

53-
preCommitChanges = miner.MakePreCommitChanges()
5457
if err = extState.CurrentState().ForEachPrecommittedSector(func(info minertypes.SectorPreCommitOnChainInfo) error {
5558
preCommitChanges.Added = append(preCommitChanges.Added, info)
5659
return nil

0 commit comments

Comments
 (0)