Skip to content

Commit

Permalink
Merge pull request #9326 from filecoin-project/asr/deal-info-logs
Browse files Browse the repository at this point in the history
feat: add descriptive errors to markets event handler
  • Loading branch information
arajasek authored Sep 16, 2022
2 parents 7663ec2 + 4382bbc commit 10087ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion chain/events/events_called.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ func (me *messageEvents) Called(ctx context.Context, check CheckFunc, msgHnd Msg

id, err := me.hcAPI.onHeadChanged(ctx, check, hnd, rev, confidence, timeout)
if err != nil {
return err
return xerrors.Errorf("on head changed error: %w", err)
}

me.lk.Lock()
Expand Down
8 changes: 4 additions & 4 deletions markets/storageadapter/ondealsectorcommitted.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (mgr *SectorCommittedManager) OnDealSectorPreCommitted(ctx context.Context,
// Note: the error returned from here will end up being returned
// from OnDealSectorPreCommitted so no need to call the callback
// with the error
return false, false, err
return false, false, xerrors.Errorf("failed to check deal activity: %w", err)
}

if isActive {
Expand All @@ -89,7 +89,7 @@ func (mgr *SectorCommittedManager) OnDealSectorPreCommitted(ctx context.Context,

diff, err := mgr.dpc.diffPreCommits(ctx, provider, dealInfo.PublishMsgTipSet, ts.Key())
if err != nil {
return false, false, err
return false, false, xerrors.Errorf("failed to diff precommits: %w", err)
}

for _, info := range diff.Added {
Expand Down Expand Up @@ -139,7 +139,7 @@ func (mgr *SectorCommittedManager) OnDealSectorPreCommitted(ctx context.Context,
// current deal ID from the publish message CID
res, err := mgr.dealInfo.GetCurrentDealInfo(ctx, ts.Key(), &proposal, publishCid)
if err != nil {
return false, err
return false, xerrors.Errorf("failed to get dealinfo: %w", err)
}

// If this is a replica update method that succeeded the deal is active
Expand All @@ -159,7 +159,7 @@ func (mgr *SectorCommittedManager) OnDealSectorPreCommitted(ctx context.Context,
// Extract the message parameters
sn, err := dealSectorInPreCommitMsg(msg, res)
if err != nil {
return false, err
return false, xerrors.Errorf("failed to extract message params: %w", err)
}

if sn != nil {
Expand Down
6 changes: 3 additions & 3 deletions markets/storageadapter/ondealsectorcommitted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestOnDealSectorPreCommitted(t *testing.T) {
"error getting current deal info in check func": {
currentDealInfoErr: errors.New("something went wrong"),
expectedCBCallCount: 0,
expectedError: xerrors.Errorf("failed to set up called handler: failed to look up deal on chain: something went wrong"),
expectedError: xerrors.Errorf("failed to set up called handler: failed to check deal activity: failed to look up deal on chain: something went wrong"),
},
"sector already active": {
currentDealInfo: pipeline.CurrentDealInfo{
Expand All @@ -162,7 +162,7 @@ func TestOnDealSectorPreCommitted(t *testing.T) {
PublishMsgTipSet: types.EmptyTSK,
},
expectedCBCallCount: 0,
expectedError: xerrors.Errorf("failed to set up called handler: deal %d was slashed at epoch %d", dealID, slashedDeal.State.SlashEpoch),
expectedError: xerrors.Errorf("failed to set up called handler: failed to check deal activity: deal %d was slashed at epoch %d", dealID, slashedDeal.State.SlashEpoch),
},
"error getting current deal info in called func": {
currentDealInfo: pipeline.CurrentDealInfo{
Expand All @@ -180,7 +180,7 @@ func TestOnDealSectorPreCommitted(t *testing.T) {
},
},
expectedCBCallCount: 1,
expectedCBError: errors.New("handling applied event: something went wrong"),
expectedCBError: errors.New("handling applied event: failed to get dealinfo: something went wrong"),
},
"proposed deal epoch timeout": {
currentDealInfo: pipeline.CurrentDealInfo{
Expand Down

0 comments on commit 10087ff

Please sign in to comment.