Skip to content

Commit

Permalink
fix(client): Panic due to possible nil params response (#277)
Browse files Browse the repository at this point in the history
Root cause of
babylonlabs-io/finality-provider#121. If
response is nil due to error, will cause panic
  • Loading branch information
gitferry authored Nov 19, 2024
1 parent 11c7332 commit 48978b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

- [#270](https://github.com/babylonlabs-io/babylon/pull/270) Validate there is only
one finality provider key in the staking request
- [#270](https://github.com/babylonlabs-io/babylon/pull/277) Panic due to possible
nil params response

## v0.16.1

Expand Down
7 changes: 4 additions & 3 deletions client/query/finality.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package query
import (
"context"

finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types"
"github.com/cosmos/cosmos-sdk/client"
sdkquerytypes "github.com/cosmos/cosmos-sdk/types/query"

finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types"
)

// QueryFinality queries the Finality module of the Babylon node according to the given function
Expand Down Expand Up @@ -65,7 +66,7 @@ func (c *QueryClient) ActivatedHeight() (*finalitytypes.QueryActivatedHeightResp
}

// FinalityParams queries the finality module parameters
func (c *QueryClient) FinalityParams() (*finalitytypes.Params, error) {
func (c *QueryClient) FinalityParams() (*finalitytypes.QueryParamsResponse, error) {
var resp *finalitytypes.QueryParamsResponse
err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error {
var err error
Expand All @@ -74,7 +75,7 @@ func (c *QueryClient) FinalityParams() (*finalitytypes.Params, error) {
return err
})

return &resp.Params, err
return resp, err
}

// VotesAtHeight queries the Finality module to get signature set at a given babylon block height
Expand Down

0 comments on commit 48978b0

Please sign in to comment.