Skip to content

Commit

Permalink
feat(client): add consensus address for debug cmd (#20328)
Browse files Browse the repository at this point in the history
Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com>
(cherry picked from commit 11de280)

# Conflicts:
#	CHANGELOG.md
#	client/debug/main.go
  • Loading branch information
mmsqe authored and mergify[bot] committed May 13, 2024
1 parent 5b6045c commit 9fb691a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

<<<<<<< HEAD
=======
Every module contains its own CHANGELOG.md. Please refer to the module you are interested in.

### Features

* (tests) [#20013](https://github.com/cosmos/cosmos-sdk/pull/20013) Introduce system tests to run multi node local testnet in CI
* (runtime) [#19953](https://github.com/cosmos/cosmos-sdk/pull/19953) Implement `core/transaction.Service` in runtime.
* (client) [#19905](https://github.com/cosmos/cosmos-sdk/pull/19905) Add grpc client config to `client.toml`.
* (runtime) [#19571](https://github.com/cosmos/cosmos-sdk/pull/19571) Implement `core/router.Service` in runtime. This service is present in all modules (when using depinject).
* (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.
* (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`.
* (client) [#18557](https://github.com/cosmos/cosmos-sdk/pull/18557) Add `--qrcode` flag to `keys show` command to support displaying keys address QR code.
* (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.
* (tests) [#17868](https://github.com/cosmos/cosmos-sdk/pull/17868) Added helper method `SubmitTestTx` in testutil to broadcast test txns to test e2e tests.
* (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.
* (runtime) [#18475](https://github.com/cosmos/cosmos-sdk/pull/18475) Adds an implementation for core.branch.Service.
* (baseapp) [#18499](https://github.com/cosmos/cosmos-sdk/pull/18499) Add `MsgRouter` response type from message name function.
* (types) [#18768](https://github.com/cosmos/cosmos-sdk/pull/18768) Add MustValAddressFromBech32 function.
* (gRPC) [#19049](https://github.com/cosmos/cosmos-sdk/pull/19049) Add debug log prints for each gRPC request.
* (x/consensus) [#19483](https://github.com/cosmos/cosmos-sdk/pull/19483) Add consensus messages registration to consensus module.
* (types) [#19759](https://github.com/cosmos/cosmos-sdk/pull/19759) Align SignerExtractionAdapter in PriorityNonceMempool Remove.
* (client) [#19870](https://github.com/cosmos/cosmos-sdk/pull/19870) Add new query command `wait-tx`. Alias `event-query-tx-for` to `wait-tx` for backward compatibility.
* (crypto/keyring) [#20212](https://github.com/cosmos/cosmos-sdk/pull/20212) Expose the db keyring used in the keystore.
* (genutil) [#19971](https://github.com/cosmos/cosmos-sdk/pull/19971) Allow manually setting the consensus key type in genesis
* (debug) [#20328](https://github.com/cosmos/cosmos-sdk/pull/20328) Add consensus address for debug cmd.

>>>>>>> 11de28062 (feat(client): add consensus address for debug cmd (#20328))
### Improvements

* (runtime) [#20264](https://github.com/cosmos/cosmos-sdk/pull/20264) Expose grpc query router via depinject.
Expand Down
43 changes: 43 additions & 0 deletions client/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ $ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
var addr []byte

// try hex, then bech32
<<<<<<< HEAD

Check failure on line 259 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected statement, found '<<'

Check failure on line 259 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected }

Check failure on line 259 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected statement, found '<<'

Check failure on line 259 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected }
var err error

Check failure on line 260 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected var in composite literal; possibly missing comma or }

Check failure on line 260 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected var in composite literal; possibly missing comma or }
addr, err = hex.DecodeString(addrString)
if err != nil {
Expand All @@ -268,13 +269,55 @@ $ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
if err3 != nil {
return fmt.Errorf("expected hex or bech32. Got errors: hex: %v, bech32 acc: %v, bech32 val: %v", err, err2, err3)
}
=======

Check failure on line 272 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected statement, found '=='

Check failure on line 272 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected }

Check failure on line 272 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected statement, found '=='

Check failure on line 272 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected }
var (
addr []byte
err error
)

Check warning

Code scanning / CodeQL

Unreachable statement Warning

This statement is unreachable.
decodeFns := []func(text string) ([]byte, error){
hex.DecodeString,
clientCtx.AddressCodec.StringToBytes,
clientCtx.ValidatorAddressCodec.StringToBytes,
clientCtx.ConsensusAddressCodec.StringToBytes,
}
errs := make([]any, 0, len(decodeFns))
for _, fn := range decodeFns {
if addr, err = fn(addrString); err == nil {
break
>>>>>>> 11de28062 (feat(client): add consensus address for debug cmd (#20328))

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected statement, found '>>'

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected '{', found cmd

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected operand, found 'ILLEGAL'

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

illegal character U+0023 '#'

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected >>, expected }

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid character U+0023 '#'

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected statement, found '>>'

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected '{', found cmd

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected operand, found 'ILLEGAL'

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

illegal character U+0023 '#'

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected >>, expected }

Check failure on line 287 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid character U+0023 '#'
}

Check failure on line 288 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected }, expected expression

Check failure on line 288 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected }, expected expression
errs = append(errs, err)

Check failure on line 289 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ), expected { after for clause

Check failure on line 289 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ), expected { after for clause
}
if len(errs) == len(decodeFns) {

Check failure on line 291 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected ')', found 'if'

Check failure on line 291 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected ';', found len

Check warning

Code scanning / CodeQL

Expression has no effect Warning

This expression has no effect.

Check failure on line 291 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected ')', found 'if'

Check failure on line 291 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected ';', found len
errTags := []string{
"hex", "bech32 acc", "bech32 val", "bech32 con",
}
format := ""
for i := range errs {
if format != "" {
format += ", "
}
format += errTags[i] + ": %w"
}

Check warning

Code scanning / CodeQL

Unreachable statement Warning

This statement is unreachable.
return fmt.Errorf("expected hex or bech32. Got errors: "+format, errs...)
}

Check warning

Code scanning / CodeQL

Unreachable statement Warning

This statement is unreachable.

<<<<<<< HEAD

Check failure on line 305 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected statement, found '<<'

Check failure on line 305 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected }

Check failure on line 305 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected statement, found '<<'

Check failure on line 305 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected }
cmd.Println("Address:", addr)
cmd.Printf("Address (hex): %X\n", addr)
cmd.Printf("Bech32 Acc: %s\n", sdk.AccAddress(addr))
cmd.Printf("Bech32 Val: %s\n", sdk.ValAddress(addr))
=======

Check failure on line 310 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected }

Check failure on line 310 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected }
acc, _ := clientCtx.AddressCodec.BytesToString(addr)
val, _ := clientCtx.ValidatorAddressCodec.BytesToString(addr)
con, _ := clientCtx.ConsensusAddressCodec.BytesToString(addr)

cmd.Println("Address:", addr)
cmd.Printf("Address (hex): %X\n", addr)
cmd.Printf("Bech32 Acc: %s\n", acc)
cmd.Printf("Bech32 Val: %s\n", val)
cmd.Printf("Bech32 Con: %s\n", con)
>>>>>>> 11de28062 (feat(client): add consensus address for debug cmd (#20328))

Check failure on line 320 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected '{', found cmd

Check failure on line 320 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected >>, expected }

Check failure on line 320 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / dependency-review

expected '{', found cmd

Check failure on line 320 in client/debug/main.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected >>, expected }
return nil

Check warning

Code scanning / CodeQL

Expression has no effect Warning

This expression has no effect.
},
}
Expand Down

0 comments on commit 9fb691a

Please sign in to comment.