From 2fd0cb4affc98ef3218f1628e34ee374a8ba5ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 9 Dec 2022 09:54:28 +0100 Subject: [PATCH 1/3] fix: sealing: Avoid nil dereference in debug log --- storage/pipeline/input.go | 4 ---- storage/pipeline/sealing.go | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/storage/pipeline/input.go b/storage/pipeline/input.go index 3499c855c..e49e39d86 100644 --- a/storage/pipeline/input.go +++ b/storage/pipeline/input.go @@ -494,10 +494,6 @@ func (m *Sealing) updateInput(ctx context.Context, sp abi.RegisteredSealProof) e continue } if !ok { - exp, _, _ := getExpirationCached(sector.number) - - // todo move this log into checkDealAssignable, make more detailed about the reason - log.Debugf("CC update sector %d cannot fit deal, expiration %d before deal end epoch %d", id, exp, piece.deal.DealProposal.EndEpoch) continue } diff --git a/storage/pipeline/sealing.go b/storage/pipeline/sealing.go index 6caa9ddc6..0fadb6131 100644 --- a/storage/pipeline/sealing.go +++ b/storage/pipeline/sealing.go @@ -142,8 +142,21 @@ type openSector struct { } func (o *openSector) checkDealAssignable(piece *pendingPiece, expF expFn) (bool, error) { + log := log.With( + "sector", o.number, + + "deal", piece.deal.DealID, + "dealEnd", piece.deal.DealProposal.EndEpoch, + "dealStart", piece.deal.DealProposal.StartEpoch, + "dealClaimEnd", piece.claimTerms.claimTermEnd, + + "lastAssignedDealEnd", o.lastDealEnd, + "update", o.ccUpdate, + ) + // if there are deals assigned, check that no assigned deal expires after termMax if o.lastDealEnd > piece.claimTerms.claimTermEnd { + log.Debugw("deal not assignable to sector", "reason", "term end beyond last assigned deal end") return false, nil } @@ -153,15 +166,26 @@ func (o *openSector) checkDealAssignable(piece *pendingPiece, expF expFn) (bool, } sectorExpiration, _, err := expF(o.number) if err != nil { + log.Debugw("deal not assignable to sector", "reason", "error getting sector expiranion", "error", err) return false, err } + log = log.With( + "sectorExpiration", sectorExpiration, + ) + // check that in case of upgrade sector, it's expiration isn't above deals claim TermMax if sectorExpiration > piece.claimTerms.claimTermEnd { + log.Debugw("deal not assignable to sector", "reason", "term end beyond sector expiration") return false, nil } - return sectorExpiration >= piece.deal.DealProposal.EndEpoch, nil + if sectorExpiration < piece.deal.DealProposal.EndEpoch { + log.Debugw("deal not assignable to sector", "reason", "sector expiration less than deal expiration") + return false, nil + } + + return true, nil } type pieceAcceptResp struct { From f0bf3408bc5c694a637cb78c0b987e5afa7e887f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 9 Dec 2022 09:56:11 +0100 Subject: [PATCH 2/3] sealing: Add a guard check to getExpirationCached when sector not found --- storage/pipeline/input.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/pipeline/input.go b/storage/pipeline/input.go index e49e39d86..25c752e5f 100644 --- a/storage/pipeline/input.go +++ b/storage/pipeline/input.go @@ -449,6 +449,9 @@ func (m *Sealing) updateInput(ctx context.Context, sp abi.RegisteredSealProof) e if err != nil { return 0, big.Zero(), err } + if onChainInfo == nil { + return 0, big.Zero(), xerrors.Errorf("sector info for sector %d not found", sn) + } memo[sn] = struct { e abi.ChainEpoch p abi.TokenAmount From 4854bef927cd988718ae663a33b7fecf2ff2dd15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 9 Dec 2022 10:03:20 +0100 Subject: [PATCH 3/3] mod tidy, fix lint --- node/modules/tracer/tracer.go | 2 +- node/modules/tracer/tracer_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/modules/tracer/tracer.go b/node/modules/tracer/tracer.go index e31b4ea52..0d0a156d9 100644 --- a/node/modules/tracer/tracer.go +++ b/node/modules/tracer/tracer.go @@ -4,9 +4,9 @@ import ( "time" logging "github.com/ipfs/go-log/v2" - "github.com/libp2p/go-libp2p-core/peer" pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub_pb "github.com/libp2p/go-libp2p-pubsub/pb" + "github.com/libp2p/go-libp2p/core/peer" ) var log = logging.Logger("lotus-tracer") diff --git a/node/modules/tracer/tracer_test.go b/node/modules/tracer/tracer_test.go index d5faf8a62..7ade67861 100644 --- a/node/modules/tracer/tracer_test.go +++ b/node/modules/tracer/tracer_test.go @@ -4,9 +4,9 @@ import ( "testing" "time" - "github.com/libp2p/go-libp2p-core/peer" pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub_pb "github.com/libp2p/go-libp2p-pubsub/pb" + "github.com/libp2p/go-libp2p/core/peer" "github.com/stretchr/testify/require" )