diff --git a/chain/actors/builtin/miner/actor.go.template b/chain/actors/builtin/miner/actor.go.template index 74923a453..069b74d31 100644 --- a/chain/actors/builtin/miner/actor.go.template +++ b/chain/actors/builtin/miner/actor.go.template @@ -79,6 +79,7 @@ type State interface { LockedFunds() (LockedFunds, error) FeeDebt() (abi.TokenAmount, error) + // Returns nil, nil if sector is not found GetSector(abi.SectorNumber) (*SectorOnChainInfo, error) FindSector(abi.SectorNumber) (*SectorLocation, error) GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error) diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index 8d1dc89e9..4f93ff6a9 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -127,6 +127,7 @@ type State interface { LockedFunds() (LockedFunds, error) FeeDebt() (abi.TokenAmount, error) + // Returns nil, nil if sector is not found GetSector(abi.SectorNumber) (*SectorOnChainInfo, error) FindSector(abi.SectorNumber) (*SectorLocation, error) GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error) diff --git a/chain/actors/builtin/miner/state.go.template b/chain/actors/builtin/miner/state.go.template index e6994daa3..5ba5f5463 100644 --- a/chain/actors/builtin/miner/state.go.template +++ b/chain/actors/builtin/miner/state.go.template @@ -100,6 +100,7 @@ func (s *state{{.v}}) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state{{.v}}) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index d053df0ac..10903b46b 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -90,6 +90,7 @@ func (s *state0) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state0) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/actors/builtin/miner/v10.go b/chain/actors/builtin/miner/v10.go index 3cd3974b5..d72f7124a 100644 --- a/chain/actors/builtin/miner/v10.go +++ b/chain/actors/builtin/miner/v10.go @@ -90,6 +90,7 @@ func (s *state10) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state10) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/actors/builtin/miner/v2.go b/chain/actors/builtin/miner/v2.go index 33c00ae62..c9870a124 100644 --- a/chain/actors/builtin/miner/v2.go +++ b/chain/actors/builtin/miner/v2.go @@ -89,6 +89,7 @@ func (s *state2) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state2) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/actors/builtin/miner/v3.go b/chain/actors/builtin/miner/v3.go index c59a053bd..c71c8315a 100644 --- a/chain/actors/builtin/miner/v3.go +++ b/chain/actors/builtin/miner/v3.go @@ -90,6 +90,7 @@ func (s *state3) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state3) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/actors/builtin/miner/v4.go b/chain/actors/builtin/miner/v4.go index 0eecd89f3..2e3c6ee79 100644 --- a/chain/actors/builtin/miner/v4.go +++ b/chain/actors/builtin/miner/v4.go @@ -90,6 +90,7 @@ func (s *state4) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state4) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/actors/builtin/miner/v5.go b/chain/actors/builtin/miner/v5.go index f667a7149..28ab438e4 100644 --- a/chain/actors/builtin/miner/v5.go +++ b/chain/actors/builtin/miner/v5.go @@ -90,6 +90,7 @@ func (s *state5) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state5) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/actors/builtin/miner/v6.go b/chain/actors/builtin/miner/v6.go index 37e4aba0b..9e819e55f 100644 --- a/chain/actors/builtin/miner/v6.go +++ b/chain/actors/builtin/miner/v6.go @@ -90,6 +90,7 @@ func (s *state6) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state6) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/actors/builtin/miner/v7.go b/chain/actors/builtin/miner/v7.go index 4d330a4e7..f98233c37 100644 --- a/chain/actors/builtin/miner/v7.go +++ b/chain/actors/builtin/miner/v7.go @@ -90,6 +90,7 @@ func (s *state7) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state7) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/actors/builtin/miner/v8.go b/chain/actors/builtin/miner/v8.go index 1822a3c25..ee3c475ea 100644 --- a/chain/actors/builtin/miner/v8.go +++ b/chain/actors/builtin/miner/v8.go @@ -90,6 +90,7 @@ func (s *state8) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state8) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/actors/builtin/miner/v9.go b/chain/actors/builtin/miner/v9.go index 39328c559..12e888706 100644 --- a/chain/actors/builtin/miner/v9.go +++ b/chain/actors/builtin/miner/v9.go @@ -90,6 +90,7 @@ func (s *state9) PreCommitDeposits() (abi.TokenAmount, error) { return s.State.PreCommitDeposits, nil } +// Returns nil, nil if sector is not found func (s *state9) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { info, ok, err := s.State.GetSector(s.store, num) if !ok || err != nil { diff --git a/chain/stmgr/actors.go b/chain/stmgr/actors.go index f4fa2d98d..0c2524b7b 100644 --- a/chain/stmgr/actors.go +++ b/chain/stmgr/actors.go @@ -103,6 +103,7 @@ func PreCommitInfo(ctx context.Context, sm *StateManager, maddr address.Address, return mas.GetPrecommittedSector(sid) } +// Returns nil, nil if sector is not found func MinerSectorInfo(ctx context.Context, sm *StateManager, maddr address.Address, sid abi.SectorNumber, ts *types.TipSet) (*miner.SectorOnChainInfo, error) { act, err := sm.LoadActor(ctx, maddr, ts) if err != nil { diff --git a/itests/ccupgrade_test.go b/itests/ccupgrade_test.go index 909b5691e..819340ea1 100644 --- a/itests/ccupgrade_test.go +++ b/itests/ccupgrade_test.go @@ -71,6 +71,7 @@ func runTestCCUpgrade(t *testing.T) *kit.TestFullNode { { si, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK) require.NoError(t, err) + require.NotNil(t, si) require.Less(t, 50000, int(si.Expiration)) } client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) diff --git a/itests/sector_make_cc_avail_test.go b/itests/sector_make_cc_avail_test.go index c6ed4b36d..524b3c70f 100644 --- a/itests/sector_make_cc_avail_test.go +++ b/itests/sector_make_cc_avail_test.go @@ -44,6 +44,7 @@ func TestMakeAvailable(t *testing.T) { { si, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK) require.NoError(t, err) + require.NotNil(t, si) require.Less(t, 50000, int(si.Expiration)) } client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) diff --git a/itests/sector_prefer_no_upgrade_test.go b/itests/sector_prefer_no_upgrade_test.go index 0294899d9..96f07f9e4 100644 --- a/itests/sector_prefer_no_upgrade_test.go +++ b/itests/sector_prefer_no_upgrade_test.go @@ -46,6 +46,7 @@ func TestPreferNoUpgrade(t *testing.T) { { si, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK) require.NoError(t, err) + require.NotNil(t, si) require.Less(t, 50000, int(si.Expiration)) } client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) diff --git a/itests/sector_revert_available_test.go b/itests/sector_revert_available_test.go index 99d410e95..41a46024f 100644 --- a/itests/sector_revert_available_test.go +++ b/itests/sector_revert_available_test.go @@ -42,6 +42,7 @@ func TestAbortUpgradeAvailable(t *testing.T) { { si, err := client.StateSectorGetInfo(ctx, maddr, CCUpgrade, types.EmptyTSK) require.NoError(t, err) + require.NotNil(t, si) require.Less(t, 50000, int(si.Expiration)) } client.WaitForSectorActive(ctx, t, CCUpgrade, maddr) diff --git a/miner/warmup.go b/miner/warmup.go index 3b73afbc9..46236784a 100644 --- a/miner/warmup.go +++ b/miner/warmup.go @@ -59,6 +59,9 @@ out: if err != nil { return xerrors.Errorf("getting sector info: %w", err) } + if si == nil { + return xerrors.Errorf("sector not found %d", sector) + } ts, err := m.api.ChainHead(ctx) if err != nil { diff --git a/node/impl/full/state.go b/node/impl/full/state.go index c91fcb298..91ffd3b9e 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -1046,6 +1046,7 @@ func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.A return pci, err } +// Returns nil, nil if sector is not found func (m *StateModule) StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error) { ts, err := m.Chain.GetTipSetFromKey(ctx, tsk) if err != nil { diff --git a/storage/pipeline/states_replica_update.go b/storage/pipeline/states_replica_update.go index b42820f48..e1b9cfc30 100644 --- a/storage/pipeline/states_replica_update.go +++ b/storage/pipeline/states_replica_update.go @@ -143,6 +143,10 @@ func (m *Sealing) handleSubmitReplicaUpdate(ctx statemachine.Context, sector Sec log.Errorf("handleSubmitReplicaUpdate: api error, not proceeding: %+v", err) return nil } + if onChainInfo == nil { + return xerrors.Errorf("sector not found %d", sector.SectorNumber) + } + sp, err := m.currentSealProof(ctx.Context()) if err != nil { log.Errorf("sealer failed to return current seal proof not proceeding: %+v", err) diff --git a/storage/pipeline/upgrade_queue.go b/storage/pipeline/upgrade_queue.go index 309e59573..9d9e1ca46 100644 --- a/storage/pipeline/upgrade_queue.go +++ b/storage/pipeline/upgrade_queue.go @@ -33,6 +33,9 @@ func (m *Sealing) MarkForUpgrade(ctx context.Context, id abi.SectorNumber) error if err != nil { return xerrors.Errorf("failed to read sector on chain info: %w", err) } + if onChainInfo == nil { + return xerrors.Errorf("sector not found %d", id) + } active, err := m.sectorActive(ctx, ts.Key(), id) if err != nil {