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

fix: null pointer access after sp not found #222

Merged
merged 1 commit into from
Apr 27, 2023
Merged
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
12 changes: 6 additions & 6 deletions x/storage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (k Keeper) UpdateBucketInfo(ctx sdk.Context, operator sdk.AccAddress, bucke
func (k Keeper) DiscontinueBucket(ctx sdk.Context, operator sdk.AccAddress, bucketName, reason string) error {
sp, found := k.spKeeper.GetStorageProviderByGcAddr(ctx, operator)
if !found {
return types.ErrNoSuchStorageProvider
return types.ErrNoSuchStorageProvider.Wrapf("SP operator address: %s", operator.String())
}
if sp.Status != sptypes.STATUS_IN_SERVICE {
return sptypes.ErrStorageProviderNotInService
Expand Down Expand Up @@ -581,7 +581,7 @@ func (k Keeper) SealObject(

sp, found := k.spKeeper.GetStorageProviderBySealAddr(ctx, spSealAcc)
if !found {
return errors.Wrapf(types.ErrNoSuchStorageProvider, "sealAddr: %s, status: %s", spSealAcc.String(), sp.Status.String())
return errors.Wrapf(types.ErrNoSuchStorageProvider, "SP seal address: %s", spSealAcc.String())
}

if !sdk.MustAccAddressFromHex(sp.OperatorAddress).Equals(sdk.MustAccAddressFromHex(bucketInfo.PrimarySpAddress)) {
Expand Down Expand Up @@ -913,13 +913,13 @@ func (k Keeper) RejectSealObject(ctx sdk.Context, operator sdk.AccAddress, bucke

sp, found := k.spKeeper.GetStorageProviderBySealAddr(ctx, operator)
if found {
return errors.Wrapf(types.ErrNoSuchStorageProvider, "sealAddr: %s, status: %s", operator.String(), sp.Status.String())
return errors.Wrapf(types.ErrNoSuchStorageProvider, "SP seal address: %s", operator.String())
}
if sp.Status != sptypes.STATUS_IN_SERVICE {
return sptypes.ErrStorageProviderNotInService
}
if !sdk.MustAccAddressFromHex(sp.OperatorAddress).Equals(sdk.MustAccAddressFromHex(bucketInfo.PrimarySpAddress)) {
return errors.Wrapf(types.ErrAccessDenied, "Only allowed primary sp to do cancel create object")
return errors.Wrapf(types.ErrAccessDenied, "Only allowed primary SP to do cancel create object")
}

err := k.UnlockStoreFee(ctx, bucketInfo, objectInfo)
Expand Down Expand Up @@ -948,7 +948,7 @@ func (k Keeper) RejectSealObject(ctx sdk.Context, operator sdk.AccAddress, bucke
func (k Keeper) DiscontinueObject(ctx sdk.Context, operator sdk.AccAddress, bucketName string, objectIds []sdkmath.Uint, reason string) error {
sp, found := k.spKeeper.GetStorageProviderByGcAddr(ctx, operator)
if !found {
return types.ErrNoSuchStorageProvider
return types.ErrNoSuchStorageProvider.Wrapf("SP operator address: %s", operator.String())
}
if sp.Status != sptypes.STATUS_IN_SERVICE {
return sptypes.ErrStorageProviderNotInService
Expand Down Expand Up @@ -1239,7 +1239,7 @@ func (k Keeper) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, grou
func (k Keeper) VerifySPAndSignature(ctx sdk.Context, spAcc sdk.AccAddress, sigData []byte, signature []byte) error {
sp, found := k.spKeeper.GetStorageProvider(ctx, spAcc)
if !found {
return errors.Wrapf(types.ErrNoSuchStorageProvider, "spAddr: %s, status: %s", sp.OperatorAddress, sp.Status.String())
return errors.Wrapf(types.ErrNoSuchStorageProvider, "SP operator address: %s", spAcc.String())
}
if sp.Status != sptypes.STATUS_IN_SERVICE {
return sptypes.ErrStorageProviderNotInService
Expand Down