Skip to content

Commit

Permalink
fix: prevent MinerSectorEvent panic on empty SectorStateEventso (#1053)
Browse files Browse the repository at this point in the history
- fixes #1052
  • Loading branch information
frrist authored Sep 1, 2022
1 parent ab09cca commit eb9bc47
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tasks/actorstate/miner/sector_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ func (SectorEventsExtractor) Extract(ctx context.Context, a actorstate.ActorInfo
}

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

sectorChanges = miner.MakeSectorChanges()
for _, sector := range sectors {
sectorChanges.Added = append(sectorChanges.Added, *sector)
}

preCommitChanges = miner.MakePreCommitChanges()
if err = extState.CurrentState().ForEachPrecommittedSector(func(info minertypes.SectorPreCommitOnChainInfo) error {
preCommitChanges.Added = append(preCommitChanges.Added, info)
return nil
Expand Down

0 comments on commit eb9bc47

Please sign in to comment.