Skip to content

Commit

Permalink
Backport: IBC query header/node-state fixes (#9385)
Browse files Browse the repository at this point in the history
* fix ibc query header/node-state cmds

* changelog

Co-authored-by: Amaury M <1293565+amaurym@users.noreply.github.com>
  • Loading branch information
colin-axner and amaury1093 authored Jun 17, 2021
1 parent bc3521c commit 7aa514d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* [\#9385](https://github.com/cosmos/cosmos-sdk/pull/9385) Fix IBC `query ibc client header` cli command. Support historical queries for query header/node-state commands.
* [\#9401](https://github.com/cosmos/cosmos-sdk/pull/9401) Fixes incorrect export of IBC identifier sequences. Previously, the next identifier sequence for clients/connections/channels was not set during genesis export. This resulted in the next identifiers being generated on the new chain to reuse old identifiers (the sequences began again from 0).
* [\#9408](https://github.com/cosmos/cosmos-sdk/pull/9408) Update simapp to use correct default broadcast mode.

Expand Down
16 changes: 13 additions & 3 deletions x/ibc/core/02-client/client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,19 @@ func QueryTendermintHeader(clientCtx client.Context) (ibctmtypes.Header, int64,
return ibctmtypes.Header{}, 0, err
}

height := info.Response.LastBlockHeight
var height int64
if clientCtx.Height != 0 {
height = clientCtx.Height
} else {
height = info.Response.LastBlockHeight
}

commit, err := node.Commit(context.Background(), &height)
if err != nil {
return ibctmtypes.Header{}, 0, err
}

page := 0
page := 1
count := 10_000

validators, err := node.Validators(context.Background(), &height, &page, &count)
Expand Down Expand Up @@ -173,7 +178,12 @@ func QueryNodeConsensusState(clientCtx client.Context) (*ibctmtypes.ConsensusSta
return &ibctmtypes.ConsensusState{}, 0, err
}

height := info.Response.LastBlockHeight
var height int64
if clientCtx.Height != 0 {
height = clientCtx.Height
} else {
height = info.Response.LastBlockHeight
}

commit, err := node.Commit(context.Background(), &height)
if err != nil {
Expand Down

0 comments on commit 7aa514d

Please sign in to comment.