diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index 7a89ab8d5..b507fd387 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -193,6 +193,16 @@ func GetMinerSectorSize(ctx context.Context, sm *StateManager, ts *types.TipSet, return minfo.SectorSize, nil } +func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (uint64, error) { + var mas actors.StorageMinerActorState + _, err := sm.LoadActorState(ctx, maddr, &mas, ts) + if err != nil { + return 0, xerrors.Errorf("failed to load miner actor state: %w", err) + } + + return mas.SlashedAt, nil +} + func GetStorageDeal(ctx context.Context, sm *StateManager, dealId uint64, ts *types.TipSet) (*actors.OnChainDeal, error) { var state actors.StorageMarketState if _, err := sm.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil { diff --git a/lib/sectorbuilder/sectorbuilder_test.go b/lib/sectorbuilder/sectorbuilder_test.go index a0547dc07..044c690bf 100644 --- a/lib/sectorbuilder/sectorbuilder_test.go +++ b/lib/sectorbuilder/sectorbuilder_test.go @@ -34,7 +34,7 @@ func (s *seal) precommit(t *testing.T, sb *sectorbuilder.SectorBuilder, sid uint dlen := sectorbuilder.UserBytesForSectorSize(sectorSize) var err error - r := io.LimitReader(rand.New(rand.NewSource(42 + int64(sid))), int64(dlen)) + r := io.LimitReader(rand.New(rand.NewSource(42+int64(sid))), int64(dlen)) s.ppi, err = sb.AddPiece(dlen, sid, r, []uint64{}) if err != nil { t.Fatalf("%+v", err) diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 93bc973c1..8097730f4 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -52,6 +52,14 @@ func (a *StateAPI) StateMinerPower(ctx context.Context, maddr address.Address, t return api.MinerPower{}, err } + slashed, err := stmgr.GetMinerSlashed(ctx, a.StateManager, ts, maddr) + if err != nil { + return api.MinerPower{}, err + } + if slashed != 0 { + mpow = types.NewInt(0) + } + return api.MinerPower{ MinerPower: mpow, TotalPower: tpow,