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 fee.{payer,granter} and tip fields to StdSignDoc #10348

Merged
merged 34 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6ec5722
Add IsTipper
amaury1093 Oct 7, 2021
6eb5a10
Use addr in signer data
amaury1093 Oct 7, 2021
72a56cb
Always populate addr in signer data
amaury1093 Oct 7, 2021
c0bd505
fi error messages
amaury1093 Oct 7, 2021
551f5f4
make proto gen
amaury1093 Oct 12, 2021
49987e7
Merge branch 'master' into am/0fee0gas
amaury1093 Oct 12, 2021
76b8dff
fix build
amaury1093 Oct 12, 2021
e285150
Add fields to sign docs and sign mode handler
amaury1093 Oct 12, 2021
3f04021
Remove getSequence
amaury1093 Oct 12, 2021
031b987
Merge branch 'am/0fee0gas' of ssh://github.com/cosmos/cosmos-sdk into…
amaury1093 Oct 12, 2021
a33a5cd
Update x/auth/migrations/legacytx/stdtx.go
amaury1093 Oct 12, 2021
a5d11b3
Update x/auth/migrations/legacytx/stdsign.go
amaury1093 Oct 12, 2021
894a7ce
Use addressCodec
amaury1093 Oct 12, 2021
6c66bfb
NewTxConfig with addrCdc
amaury1093 Oct 12, 2021
debee8d
REmove simapp.NewBech32
amaury1093 Oct 12, 2021
e3a7c35
Move bech32 stuff to x/auth/address
amaury1093 Oct 13, 2021
dfd1d82
Add changelog
amaury1093 Oct 13, 2021
7092ee8
Move address.Codec to x/auth
amaury1093 Oct 13, 2021
bac6349
Fix test
amaury1093 Oct 13, 2021
b5a18ea
Merge branch 'am/0fee0gas' of ssh://github.com/cosmos/cosmos-sdk into…
amaury1093 Oct 13, 2021
80b0637
Merge branch 'am/amino-tipper' of ssh://github.com/cosmos/cosmos-sdk …
amaury1093 Oct 13, 2021
ab495df
Add tests for tipper and feepayer
amaury1093 Oct 13, 2021
892bff4
Rename tests
amaury1093 Oct 13, 2021
2dd883c
Add more tests
amaury1093 Oct 13, 2021
07ef3e2
Empty tip test
amaury1093 Oct 13, 2021
34a4a89
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am/a…
amaury1093 Oct 18, 2021
d5feed5
Revert unwanted files
amaury1093 Oct 18, 2021
0071f3c
Less line diff
amaury1093 Oct 18, 2021
df19e58
fix test
amaury1093 Oct 18, 2021
6c069d5
fix another test
amaury1093 Oct 18, 2021
7216370
Fix test
amaury1093 Oct 18, 2021
0fa4bc0
Update x/auth/migrations/legacytx/stdtx_test.go
amaury1093 Oct 19, 2021
7602d4d
Address reviews
amaury1093 Oct 22, 2021
6b9abab
Merge branch 'master' into am/amino-tipper
amaury1093 Oct 22, 2021
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
Prev Previous commit
Next Next commit
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am/a…
…mino-tipper
  • Loading branch information
amaury1093 committed Oct 18, 2021
commit 34a4a89444613c4b787ffeeaf72d7eb19d880a77
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Move Msg routers from BaseApp to middlewares.
* Move Baseapp panic recovery into a middleware.
* Rename simulation helper methods `baseapp.{Check,Deliver}` to `baseapp.Sim{Check,Deliver}`.
* [\#10322](https://github.com/cosmos/cosmos-sdk/pull/10322) The `tx.NewTxConfig` function takes a new parameter of type `address.Codec` used to encode and decode addresses. As such, a new field `AddressCdc` has been added to `simapp.EncodingConfig`.
* (x/gov) [\#10373](https://github.com/cosmos/cosmos-sdk/pull/10373) Removed gov `keeper.{MustMarshal, MustUnmarshal}`.
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved

### Client Breaking Changes

Expand Down
14 changes: 14 additions & 0 deletions client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,24 @@ func Sign(txf Factory, name string, txBuilder client.TxBuilder, overwriteSig boo
return err
}

pubkeys, err := txBuilder.GetTx().GetPubKeys()
if err != nil {
return err
}

signerIndex := 0
for i, p := range pubkeys {
if p.Equals(pubKey) {
signerIndex = i
break
}
}

signerData := authsigning.SignerData{
ChainID: txf.chainID,
AccountNumber: txf.accountNumber,
Sequence: txf.sequence,
SignerIndex: signerIndex,
Address: sdk.AccAddress(pubKey.Address()).String(),
}

Expand Down
3 changes: 2 additions & 1 deletion x/auth/client/cli/tx_multisign.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) {
return fmt.Errorf("set the chain id with either the --chain-id flag or config file")
}

for _, sig := range sigs {
for j, sig := range sigs {
signingData := signing.SignerData{
Address: sdk.AccAddress(sig.PubKey.Address()).String(),
ChainID: txFactory.ChainID(),
AccountNumber: txFactory.AccountNumber(),
Sequence: txFactory.Sequence(),
SignerIndex: j,
}

err = signing.VerifySignature(sig.PubKey, signingData, sig.Data, txCfg.SignModeHandler(), txBuilder.GetTx())
Expand Down
3 changes: 3 additions & 0 deletions x/auth/signing/sign_mode_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ type SignerData struct {
// since in SIGN_MODE_DIRECT the account sequence is already in the signer
// info.
Sequence uint64

// SignerIndex index of signer in the signer_infos array.
SignerIndex int
}
28 changes: 4 additions & 24 deletions x/auth/tx/direct_aux.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package tx

import (
"bytes"
"fmt"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
types "github.com/cosmos/cosmos-sdk/types/tx"
Expand Down Expand Up @@ -44,27 +42,9 @@ func (h signModeDirectAuxHandler) GetSignBytes(
return nil, fmt.Errorf("can only handle a protobuf Tx, got %T", tx)
}

if data.Address == "" {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "got empty address in %s handler", signingtypes.SignMode_SIGN_MODE_DIRECT_AUX)
}

addrBz, err := h.addressCdc.StringToBytes(data.Address)
if err != nil {
return nil, err
}

var pubKey *codectypes.Any
pubKeys, err := protoTx.GetPubKeys()
if err != nil {
return nil, err
}
for i, pk := range pubKeys {
if bytes.Equal(addrBz, pk.Address()) {
pubKey = protoTx.tx.AuthInfo.SignerInfos[i].PublicKey
}
}
if pubKey == nil {
return nil, sdkerrors.ErrInvalidRequest.Wrapf("got empty pubKey in %s handler", signingtypes.SignMode_SIGN_MODE_DIRECT_AUX)
signerInfo := protoTx.tx.AuthInfo.SignerInfos[data.SignerIndex]
if signerInfo == nil || signerInfo.PublicKey == nil {
return nil, sdkerrors.ErrInvalidRequest.Wrapf("got empty pubkey for signer #%d in %s handler", data.SignerIndex, signingtypes.SignMode_SIGN_MODE_DIRECT_AUX)
}

signDocDirectAux := types.SignDocDirectAux{
Expand All @@ -73,7 +53,7 @@ func (h signModeDirectAuxHandler) GetSignBytes(
AccountNumber: data.AccountNumber,
Sequence: data.Sequence,
Tip: protoTx.tx.AuthInfo.Tip,
PublicKey: pubKey,
PublicKey: signerInfo.PublicKey,
}

return signDocDirectAux.Marshal()
Expand Down
5 changes: 2 additions & 3 deletions x/auth/tx/mode_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/address"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
)

Expand All @@ -17,7 +16,7 @@ var DefaultSignModes = []signingtypes.SignMode{

// makeSignModeHandler returns the default protobuf SignModeHandler supporting
// SIGN_MODE_DIRECT, SIGN_MODE_DIRECT_AUX and SIGN_MODE_LEGACY_AMINO_JSON.
func makeSignModeHandler(modes []signingtypes.SignMode, addressCdc address.Codec) signing.SignModeHandler {
func makeSignModeHandler(modes []signingtypes.SignMode) signing.SignModeHandler {
if len(modes) < 1 {
panic(fmt.Errorf("no sign modes enabled"))
}
Expand All @@ -31,7 +30,7 @@ func makeSignModeHandler(modes []signingtypes.SignMode, addressCdc address.Codec
case signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON:
handlers[i] = signModeLegacyAminoJSONHandler{}
case signingtypes.SignMode_SIGN_MODE_DIRECT_AUX:
handlers[i] = signModeDirectAuxHandler{addressCdc}
handlers[i] = signModeDirectAuxHandler{}
default:
panic(fmt.Errorf("unsupported sign mode %+v", mode))
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.