Check for nil returns from StateSectorGetInfo
This commit is contained in:
parent
33a176eae4
commit
f95e6602a0
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
1
chain/actors/builtin/miner/v0.go
generated
1
chain/actors/builtin/miner/v0.go
generated
@ -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 {
|
||||
|
1
chain/actors/builtin/miner/v10.go
generated
1
chain/actors/builtin/miner/v10.go
generated
@ -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 {
|
||||
|
1
chain/actors/builtin/miner/v2.go
generated
1
chain/actors/builtin/miner/v2.go
generated
@ -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 {
|
||||
|
1
chain/actors/builtin/miner/v3.go
generated
1
chain/actors/builtin/miner/v3.go
generated
@ -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 {
|
||||
|
1
chain/actors/builtin/miner/v4.go
generated
1
chain/actors/builtin/miner/v4.go
generated
@ -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 {
|
||||
|
1
chain/actors/builtin/miner/v5.go
generated
1
chain/actors/builtin/miner/v5.go
generated
@ -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 {
|
||||
|
1
chain/actors/builtin/miner/v6.go
generated
1
chain/actors/builtin/miner/v6.go
generated
@ -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 {
|
||||
|
1
chain/actors/builtin/miner/v7.go
generated
1
chain/actors/builtin/miner/v7.go
generated
@ -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 {
|
||||
|
1
chain/actors/builtin/miner/v8.go
generated
1
chain/actors/builtin/miner/v8.go
generated
@ -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 {
|
||||
|
1
chain/actors/builtin/miner/v9.go
generated
1
chain/actors/builtin/miner/v9.go
generated
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user