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: add ErrInvalidApproval errorcode for sp's approval invalid #175

Merged
merged 2 commits into from
Apr 17, 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
9 changes: 3 additions & 6 deletions x/storage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,14 +946,11 @@ func (k Keeper) VerifySPAndSignature(ctx sdk.Context, spAcc sdk.AccAddress, sigD
return sptypes.ErrStorageProviderNotInService
}

approvalAccAddress, err := sdk.AccAddressFromHexUnsafe(sp.ApprovalAddress)
if err != nil {
return err
}
approvalAccAddress := sdk.MustAccAddressFromHex(sp.ApprovalAddress)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to check the "err" value returned any more?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the AccAddressFromHexUnsafe function is replaced with MustAccAddressFromHex.

It is agreed on the chain that the address stored on the chain must be correct, and the MustAccAddressFromHex interface is judged. If there is an error in parsing the address, it will panic.

err = types.VerifySignature(approvalAccAddress, sdk.Keccak256(sigData), signature)
err := types.VerifySignature(approvalAccAddress, sdk.Keccak256(sigData), signature)
if err != nil {
return err
return errors.Wrapf(types.ErrInvalidApproval, "verify signature error: %s", err)
}
return nil
}
Expand Down