Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
samricotta committed Oct 15, 2024
1 parent e6232c9 commit b3aab03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## Unreleased

### Security
### API Breaking

* [#194](https://github.com/babylonlabs-io/babylon/pull/194) Adjusted handling of `FinalityProviderSigningInfo` in finality keeper queries to improve API security
* Modified `QuerySigningInfosResponse` to remove direct exposure of sensitive fields
Expand Down
5 changes: 5 additions & 0 deletions proto/babylon/finality/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,14 @@ message QuerySigningInfoRequest {
// SigningInfoResponse defines the API response containing a finality provider's signing info
// for monitoring their liveness activity.
message SigningInfoResponse {
// fp_btc_pk is the BTC PK of the finality provider that casts this vote
string fp_btc_pk_hex = 1;
// start_height is the block height at which finality provider become active
int64 start_height = 2;
// missed_blocks_counter defines a counter to avoid unnecessary array reads.
// Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`.
int64 missed_blocks_counter = 3;
// Timestamp until which the validator is jailed due to liveness downtime.
google.protobuf.Timestamp jailed_until = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

Expand Down
10 changes: 5 additions & 5 deletions x/finality/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (k Keeper) SigningInfo(ctx context.Context, req *types.QuerySigningInfoRequ
return nil, status.Errorf(codes.NotFound, "SigningInfo not found for the finality provider %s", req.FpBtcPkHex)
}

return &types.QuerySigningInfoResponse{SigningInfo: k.convertToSigningInfoResponse(signingInfo)}, nil
return &types.QuerySigningInfoResponse{SigningInfo: convertToSigningInfoResponse(signingInfo)}, nil
}

// SigningInfos returns signing-infos of all finality providers.
Expand All @@ -271,10 +271,10 @@ func (k Keeper) SigningInfos(ctx context.Context, req *types.QuerySigningInfosRe
if err != nil {
return nil, err
}
return &types.QuerySigningInfosResponse{SigningInfos: k.convertToSigningInfosResponse(signInfos), Pagination: pageRes}, nil
return &types.QuerySigningInfosResponse{SigningInfos: convertToSigningInfosResponse(signInfos), Pagination: pageRes}, nil
}

func (k Keeper) convertToSigningInfoResponse(info types.FinalityProviderSigningInfo) types.SigningInfoResponse {
func convertToSigningInfoResponse(info types.FinalityProviderSigningInfo) types.SigningInfoResponse {
return types.SigningInfoResponse{
FpBtcPkHex: info.FpBtcPk.MarshalHex(),
StartHeight: info.StartHeight,
Expand All @@ -283,10 +283,10 @@ func (k Keeper) convertToSigningInfoResponse(info types.FinalityProviderSigningI
}
}

func (k Keeper) convertToSigningInfosResponse(signInfos []types.FinalityProviderSigningInfo) []types.SigningInfoResponse {
func convertToSigningInfosResponse(signInfos []types.FinalityProviderSigningInfo) []types.SigningInfoResponse {
response := make([]types.SigningInfoResponse, len(signInfos))
for i, info := range signInfos {
response[i] = k.convertToSigningInfoResponse(info)
response[i] = convertToSigningInfoResponse(info)
}
return response
}

0 comments on commit b3aab03

Please sign in to comment.