Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add consensus address to validator query response #20434

Merged
merged 35 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2463cec
Add consensus address to validator query response
lucaslopezf May 21, 2024
625865e
proto files
lucaslopezf May 21, 2024
c09ed0a
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf May 21, 2024
1d7cb9a
Changelog and linter
lucaslopezf May 21, 2024
424b463
Add address codec to validator
lucaslopezf May 23, 2024
de54dad
linting issues
lucaslopezf May 24, 2024
2a6c01f
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf May 24, 2024
3f9ecd0
minor change
lucaslopezf May 24, 2024
b17271c
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf May 24, 2024
edcce4d
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf May 27, 2024
428a4b5
Add validators migration
lucaslopezf May 30, 2024
00fd6d0
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf May 30, 2024
7cf677d
minor fix
lucaslopezf May 30, 2024
8c727b7
Add consensus address to query and delete it from Validator
lucaslopezf Jun 12, 2024
6a8d0ff
fix go mod
lucaslopezf Jun 12, 2024
cd433e7
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf Jun 12, 2024
da97cd2
tests
lucaslopezf Jun 12, 2024
0cdaa92
linting issues
lucaslopezf Jun 12, 2024
3fcbe1e
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf Jun 12, 2024
f279a5d
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf Jun 12, 2024
157dbd6
Update x/staking/keeper/grpc_query.go
lucaslopezf Jun 13, 2024
9338222
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf Jun 13, 2024
af8202f
minor changes
lucaslopezf Jun 13, 2024
9c0621b
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf Jun 13, 2024
c162fbe
add annotations fields
lucaslopezf Jun 13, 2024
677d04d
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf Jun 13, 2024
82dd520
Update x/staking/proto/cosmos/staking/v1beta1/query.proto
lucaslopezf Jun 17, 2024
9bb7568
Update x/staking/proto/cosmos/staking/v1beta1/query.proto
lucaslopezf Jun 17, 2024
f97f074
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf Jun 17, 2024
3e18086
minor change
lucaslopezf Jun 17, 2024
8c8502a
make validators query backward compatible
lucaslopezf Jun 19, 2024
79b3c98
minor change
lucaslopezf Jun 19, 2024
009d532
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf Jun 19, 2024
de98c7e
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf Jun 20, 2024
f50bcaa
Merge branch 'main' into lucas/add-cons-address-to-validator
lucaslopezf Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
633 changes: 355 additions & 278 deletions api/cosmos/staking/v1beta1/staking.pulsar.go

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions x/staking/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"
"errors"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"strings"

"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -48,6 +49,7 @@ func (k Querier) Validators(ctx context.Context, req *types.QueryValidatorsReque
return nil, nil
}

setConsensusAddress(val)
return val, nil
}, func() *types.Validator {
return &types.Validator{}
Expand Down Expand Up @@ -84,6 +86,7 @@ func (k Querier) Validator(ctx context.Context, req *types.QueryValidatorRequest
return nil, status.Errorf(codes.NotFound, "validator %s not found", req.ValidatorAddr)
}

setConsensusAddress(&validator)
return &types.QueryValidatorResponse{Validator: validator}, nil
}

Expand Down Expand Up @@ -649,3 +652,17 @@ func redelegationsToRedelegationResponses(ctx context.Context, k *Keeper, redels

return resp, nil
}

// setConsensusAddress sets the ConsensusAddress field for the given validator
func setConsensusAddress(validator *types.Validator) {
lucaslopezf marked this conversation as resolved.
Show resolved Hide resolved
if validator == nil {
lucaslopezf marked this conversation as resolved.
Show resolved Hide resolved
return
}

cpk, ok := validator.ConsensusPubkey.GetCachedValue().(cryptotypes.PubKey)
// Best-effort way
if ok {
consAddr := sdk.ConsAddress(cpk.Address())
validator.ConsensusAddress = consAddr.String()
}
}
3 changes: 3 additions & 0 deletions x/staking/proto/cosmos/staking/v1beta1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ message Validator {

// list of unbonding ids, each uniquely identifying an unbonding of this validator
repeated uint64 unbonding_ids = 13;

// consensus_address defines the address of the validator's consensus
string consensus_address = 14 [(cosmos_proto.scalar) = "cosmos.AddressString"];
lucaslopezf marked this conversation as resolved.
Show resolved Hide resolved
}

// BondStatus is the status of a validator.
Expand Down
Loading
Loading