Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add descriptive errors to markets event handler #9326

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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