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: changed the data type for FeePayer and FeeGranter #16272

Merged
merged 25 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d6a5778
changed the data type for FeePayer and FeeGranter
vishal-kanna May 24, 2023
db85847
Merge branch 'main' into typechange
vishal-kanna May 24, 2023
5722e74
uncommented the log
vishal-kanna May 24, 2023
ab71c8d
Merge branch 'typechange' of https://github.com/vishal-kanna/cosmos-s…
vishal-kanna May 24, 2023
9c5a899
Merge branch 'main' of https://github.com/vishal-kanna/cosmos-sdk int…
vishal-kanna May 30, 2023
1f239a5
fix: solved the error in test files
vishal-kanna May 30, 2023
4ca085f
Merge branch 'main' into typechange
atheeshp Jun 5, 2023
4cdb162
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into type…
vishal-kanna Jul 7, 2023
2af76ce
change added in changelog
vishal-kanna Jul 7, 2023
072c86f
mentioned the change in changelog under the API breaking changes
vishal-kanna Jul 7, 2023
616030b
Revert "mentioned the change in changelog under the API breaking chan…
vishal-kanna Jul 7, 2023
40cccf1
mentioned the change in changelog under the API breaking changes
vishal-kanna Jul 7, 2023
eb5bcc2
changed name of the variable and used the Equalfold method
vishal-kanna Jul 7, 2023
717a478
used the strings.EqualFold method
vishal-kanna Jul 7, 2023
3ed1d9d
mades changes as per request
vishal-kanna Jul 7, 2023
56d10d2
removed the extra line in the changelog
vishal-kanna Jul 7, 2023
6d609fa
Update CHANGELOG.md
likhita-809 Jul 7, 2023
40c8d4f
made changes as per the review
vishal-kanna Jul 7, 2023
465261c
Merge branch 'typechange' of https://github.com/vishal-kanna/cosmos-s…
vishal-kanna Jul 7, 2023
9fd6586
Merge branch 'main' into typechange
vishal-kanna Jul 11, 2023
ee10450
removed the extra variable
vishal-kanna Jul 11, 2023
5eaca40
Merge branch 'typechange' of https://github.com/vishal-kanna/cosmos-s…
vishal-kanna Jul 11, 2023
7037cae
reverted the variable
vishal-kanna Jul 11, 2023
d0093c8
removed the variable
vishal-kanna Jul 11, 2023
5142197
made suggested change in the changelog
vishal-kanna Jul 11, 2023
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
4 changes: 2 additions & 2 deletions types/tx_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ type (
Tx
GetGas() uint64
GetFee() Coins
FeePayer() AccAddress
FeeGranter() AccAddress
FeePayer() []byte
FeeGranter() []byte
}

// TxWithMemo must have GetMemo() method to use ValidateMemoDecorator
Expand Down
5 changes: 3 additions & 2 deletions x/auth/ante/fee.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ante

import (
"bytes"
"fmt"

errorsmod "cosmossdk.io/errors"
Expand Down Expand Up @@ -88,7 +89,7 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee
if feeGranter != nil {
if dfd.feegrantKeeper == nil {
return sdkerrors.ErrInvalidRequest.Wrap("fee grants are not enabled")
} else if !feeGranter.Equals(feePayer) {
} else if !bytes.Equal(feeGranter, feePayer) {
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
err := dfd.feegrantKeeper.UseGrantedFees(ctx, feeGranter, feePayer, fee, sdkTx.GetMsgs())
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return errorsmod.Wrapf(err, "%s does not allow to pay fees for %s", feeGranter, feePayer)
Expand All @@ -115,7 +116,7 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee
sdk.NewEvent(
sdk.EventTypeTx,
sdk.NewAttribute(sdk.AttributeKeyFee, fee.String()),
sdk.NewAttribute(sdk.AttributeKeyFeePayer, deductFeesFrom.String()),
sdk.NewAttribute(sdk.AttributeKeyFeePayer, string(deductFeesFrom[:])),
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
),
}
ctx.EventManager().EmitEvents(events)
Expand Down
4 changes: 2 additions & 2 deletions x/auth/tx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (w *wrapper) GetFee() sdk.Coins {
return w.tx.AuthInfo.Fee.Amount
}

func (w *wrapper) FeePayer() sdk.AccAddress {
func (w *wrapper) FeePayer() []byte {
feePayer := w.tx.AuthInfo.Fee.Payer
if feePayer != "" {
return sdk.MustAccAddressFromBech32(feePayer)
Expand All @@ -147,7 +147,7 @@ func (w *wrapper) FeePayer() sdk.AccAddress {
return w.GetSigners()[0]
}

func (w *wrapper) FeeGranter() sdk.AccAddress {
func (w *wrapper) FeeGranter() []byte {
feePayer := w.tx.AuthInfo.Fee.Granter
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
if feePayer != "" {
return sdk.MustAccAddressFromBech32(feePayer)
Expand Down
8 changes: 5 additions & 3 deletions x/auth/tx/direct_aux.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ func (signModeDirectAuxHandler) GetSignBytes(
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "got empty address in %s handler", signingtypes.SignMode_SIGN_MODE_DIRECT_AUX)
}

feePayer := protoTx.FeePayer().String()
feePayer := protoTx.FeePayer()

feepayer := sdk.AccAddress(feePayer)
vishal-kanna marked this conversation as resolved.
Show resolved Hide resolved

// Fee payer cannot use SIGN_MODE_DIRECT_AUX, because SIGN_MODE_DIRECT_AUX
// does not sign over fees, which would create malleability issues.
if feePayer == data.Address {
return nil, sdkerrors.ErrUnauthorized.Wrapf("fee payer %s cannot sign with %s", feePayer, signingtypes.SignMode_SIGN_MODE_DIRECT_AUX)
if feepayer.String() == data.Address {
vishal-kanna marked this conversation as resolved.
Show resolved Hide resolved
return nil, sdkerrors.ErrUnauthorized.Wrapf("fee payer %s cannot sign with %s", feepayer, signingtypes.SignMode_SIGN_MODE_DIRECT_AUX)
}

signDocDirectAux := types.SignDocDirectAux{
Expand Down
3 changes: 2 additions & 1 deletion x/auth/tx/direct_aux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ func TestDirectAuxHandler(t *testing.T) {

modeHandler := signModeDirectAuxHandler{}

t.Log("verify fee payer cannot use SIGN_MODE_DIRECT_AUX")
// t.Log("verify fee payer cannot use SIGN_MODE_DIRECT_AUX")
vishal-kanna marked this conversation as resolved.
Show resolved Hide resolved
_, err = modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, feePayerSigningData, txBuilder.GetTx())

require.EqualError(t, err, fmt.Sprintf("fee payer %s cannot sign with %s: unauthorized", feePayerAddr.String(), signingtypes.SignMode_SIGN_MODE_DIRECT_AUX))

t.Log("verify GetSignBytes with generating sign bytes by marshaling signDocDirectAux")
Expand Down