Skip to content

Commit 83bbf80

Browse files
mmsqemergify[bot]
authored andcommitted
refactor(x/auth): allow empty public keys for GetSignBytesAdapter (#19651)
(cherry picked from commit 06a3989) # Conflicts: # CHANGELOG.md
1 parent 09a49fe commit 83bbf80

File tree

3 files changed

+92
-8
lines changed

3 files changed

+92
-8
lines changed

CHANGELOG.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,53 @@ Ref: https://keepachangelog.com/en/1.0.0/
3838

3939
## [Unreleased]
4040

41+
<<<<<<< HEAD
4142
## [v0.50.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.5) - 2024-XX-XX
43+
=======
44+
Every module contains its own CHANGELOG.md. Please refer to the module you are interested in.
45+
46+
### Features
47+
48+
* (runtime) [#19571](https://github.com/cosmos/cosmos-sdk/pull/19571) Implement `core/router.Service` it in runtime. This service is present in all modules (when using depinject).
49+
* (types) [#19164](https://github.com/cosmos/cosmos-sdk/pull/19164) Add a ValueCodec for the math.Uint type that can be used in collections maps.
50+
* (types) [#19281](https://github.com/cosmos/cosmos-sdk/pull/19281) Added a new method, `IsGT`, for `types.Coin`. This method is used to check if a `types.Coin` is greater than another `types.Coin`.
51+
* (client) [#18557](https://github.com/cosmos/cosmos-sdk/pull/18557) Add `--qrcode` flag to `keys show` command to support displaying keys address QR code.
52+
* (client) [#18101](https://github.com/cosmos/cosmos-sdk/pull/18101) Add a `keyring-default-keyname` in `client.toml` for specifying a default key name, and skip the need to use the `--from` flag when signing transactions.
53+
* (tests) [#17868](https://github.com/cosmos/cosmos-sdk/pull/17868) Added helper method `SubmitTestTx` in testutil to broadcast test txns to test e2e tests.
54+
* (client) [#17513](https://github.com/cosmos/cosmos-sdk/pull/17513) Allow overwriting `client.toml`. Use `client.CreateClientConfig` in place of `client.ReadFromClientConfig` and provide a custom template and a custom config.
55+
* (runtime) [#18475](https://github.com/cosmos/cosmos-sdk/pull/18475) Adds an implementation for core.branch.Service.
56+
* (baseapp) [#18499](https://github.com/cosmos/cosmos-sdk/pull/18499) Add `MsgRouter` response type from message name function.
57+
* (types) [#18768](https://github.com/cosmos/cosmos-sdk/pull/18768) Add MustValAddressFromBech32 function.
58+
* (gRPC) [#19049](https://github.com/cosmos/cosmos-sdk/pull/19049) Add debug log prints for each gRPC request.
59+
* (x/consensus) [#19483](https://github.com/cosmos/cosmos-sdk/pull/19483) Add consensus messages registration to consensus module.
60+
61+
### Improvements
62+
63+
* (server) [#19455](https://github.com/cosmos/cosmos-sdk/pull/19455) Allow calling back into the application struct in PostSetup.
64+
* (types) [#19512](https://github.com/cosmos/cosmos-sdk/pull/19512) The notion of basic manager does not exist anymore.
65+
* The module manager now can do everything that the basic manager was doing.
66+
* `AppModuleBasic` has been deprecated for extension interfaces. Modules can now implement `HasRegisterInterfaces`, `HasGRPCGateway` and `HasAminoCodec` when relevant.
67+
* SDK modules now directly implement those extension interfaces on `AppModule` instead of `AppModuleBasic`.
68+
* (client/keys) [#18950](https://github.com/cosmos/cosmos-sdk/pull/18950) Improve `<appd> keys add`, `<appd> keys import` and `<appd> keys rename` by checking name validation.
69+
* (client/keys) [#18745](https://github.com/cosmos/cosmos-sdk/pull/18745) Improve `<appd> keys export` and `<appd> keys mnemonic` by adding --yes option to skip interactive confirmation.
70+
* (client/keys) [#18743](https://github.com/cosmos/cosmos-sdk/pull/18743) Improve `<appd> keys add -i` by hiding inputting of bip39 passphrase.
71+
* (client/keys) [#18703](https://github.com/cosmos/cosmos-sdk/pull/18703) Improve `<appd> keys add` and `<appd> keys show` by checking whether there are duplicate keys in the multisig case.
72+
* Usage of `Must...` kind of functions are avoided in keeper methods.
73+
* (client/keys) [#18687](https://github.com/cosmos/cosmos-sdk/pull/18687) Improve `<appd> keys mnemonic` by displaying mnemonic discreetly on an alternate screen and adding `--indiscreet` option to disable it.
74+
* (client/keys) [#18684](https://github.com/cosmos/cosmos-sdk/pull/18684) Improve `<appd> keys export` by displaying unarmored hex private key discreetly on an alternate screen and adding `--indiscreet` option to disable it.
75+
* (client/keys) [#18663](https://github.com/cosmos/cosmos-sdk/pull/18663) Improve `<appd> keys add` by displaying mnemonic discreetly on an alternate screen and adding `--indiscreet` option to disable it.
76+
* (types) [#18440](https://github.com/cosmos/cosmos-sdk/pull/18440) Add `AmountOfNoValidation` to `sdk.DecCoins`.
77+
* (client) [#17503](https://github.com/cosmos/cosmos-sdk/pull/17503) Add `client.Context{}.WithAddressCodec`, `WithValidatorAddressCodec`, `WithConsensusAddressCodec` to provide address codecs to the client context. See the [UPGRADING.md](./UPGRADING.md) for more details.
78+
* (crypto/keyring) [#17503](https://github.com/cosmos/cosmos-sdk/pull/17503) Simplify keyring interfaces to use `[]byte` instead of `sdk.Address` for addresses.
79+
* (all) [#16537](https://github.com/cosmos/cosmos-sdk/pull/16537) Properly propagated `fmt.Errorf` errors and using `errors.New` where appropriate.
80+
* (rpc) [#17470](https://github.com/cosmos/cosmos-sdk/pull/17470) Avoid open 0.0.0.0 to public by default and add `listen-ip-address` argument for `testnet init-files` cmd.
81+
* (types) [#17670](https://github.com/cosmos/cosmos-sdk/pull/17670) Use `ctx.CometInfo` in place of `ctx.VoteInfos`
82+
* [#17733](https://github.com/cosmos/cosmos-sdk/pull/17733) Ensure `buf export` exports all proto dependencies
83+
* (crypto/keys) [#18026](https://github.com/cosmos/cosmos-sdk/pull/18026) Made public key generation constant time on `secp256k1`
84+
* (crypto | x/auth) [#14372](https://github.com/cosmos/cosmos-sdk/pull/18194) Key checks on signatures antehandle.
85+
* (types) [#18963](https://github.com/cosmos/cosmos-sdk/pull/18963) Swap out amino json encoding of `ABCIMessageLogs` for std lib json encoding
86+
* (x/auth) [#19651](https://github.com/cosmos/cosmos-sdk/pull/19651) Allow empty public keys in `GetSignBytesAdapter`.
87+
>>>>>>> 06a398931 (refactor(x/auth): allow empty public keys for GetSignBytesAdapter (#19651))
4288
4389
### Bug Fixes
4490

x/auth/signing/adapter.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,24 @@ func GetSignBytesAdapter(
4141
return nil, err
4242
}
4343

44-
anyPk, err := codectypes.NewAnyWithValue(signerData.PubKey)
45-
if err != nil {
46-
return nil, err
47-
}
44+
var pubKey *anypb.Any
45+
if signerData.PubKey != nil {
46+
anyPk, err := codectypes.NewAnyWithValue(signerData.PubKey)
47+
if err != nil {
48+
return nil, err
49+
}
4850

51+
pubKey = &anypb.Any{
52+
TypeUrl: anyPk.TypeUrl,
53+
Value: anyPk.Value,
54+
}
55+
}
4956
txSignerData := txsigning.SignerData{
5057
ChainID: signerData.ChainID,
5158
AccountNumber: signerData.AccountNumber,
5259
Sequence: signerData.Sequence,
5360
Address: signerData.Address,
54-
PubKey: &anypb.Any{
55-
TypeUrl: anyPk.TypeUrl,
56-
Value: anyPk.Value,
57-
},
61+
PubKey: pubKey,
5862
}
5963
// Generate the bytes to be signed.
6064
return handlerMap.GetSignBytes(ctx, txSignMode, txSignerData, txData)

x/auth/signing/adapter_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package signing_test
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/stretchr/testify/require"
8+
9+
authsign "cosmossdk.io/x/auth/signing"
10+
11+
"github.com/cosmos/cosmos-sdk/testutil/testdata"
12+
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
13+
"github.com/cosmos/cosmos-sdk/types/tx/signing"
14+
)
15+
16+
func TestGetSignBytesAdapterNoPublicKey(t *testing.T) {
17+
encodingConfig := moduletestutil.MakeTestEncodingConfig()
18+
txConfig := encodingConfig.TxConfig
19+
_, _, addr := testdata.KeyTestPubAddr()
20+
signerData := authsign.SignerData{
21+
Address: addr.String(),
22+
ChainID: "test-chain",
23+
AccountNumber: 11,
24+
Sequence: 15,
25+
}
26+
w := txConfig.NewTxBuilder()
27+
_, err := authsign.GetSignBytesAdapter(
28+
context.Background(),
29+
txConfig.SignModeHandler(),
30+
signing.SignMode_SIGN_MODE_DIRECT,
31+
signerData,
32+
w.GetTx())
33+
require.NoError(t, err)
34+
}

0 commit comments

Comments
 (0)