Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .changelog/1222.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support searching validators by node-id/entity-id
16 changes: 10 additions & 6 deletions api/spec/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,13 @@ paths:
description: |
A filter on the validator name. Every returned validator will have
a name that is a superstring of the input param.
- in: query
name: id
schema:
type: string
description: |
A filter on the entity or node ID (base64-encoded ed25519 public key).
Returns the validator whose entity_id matches the provided value, or whose node's node_id matches the provided value.
responses:
'200':
description: |
Expand Down Expand Up @@ -2490,8 +2497,7 @@ components:
required: [total_voting_power, total_delegators, total_staked_balance]
properties:
total_voting_power:
type: integer
format: int64
allOf: [$ref: '#/components/schemas/TextBigInt']
description: The total voting power across all validators.
total_delegators:
type: integer
Expand Down Expand Up @@ -2564,12 +2570,10 @@ components:
allOf: [$ref: '#/components/schemas/Escrow']
description: The escrow account data for this validator.
voting_power:
type: integer
format: int64
allOf: [$ref: '#/components/schemas/TextBigInt']
description: The voting power of this validator.
voting_power_cumulative:
type: integer
format: int64
allOf: [$ref: '#/components/schemas/TextBigInt']
description: The cumulative voting power of this validator and all other validators ranked higher than itself.
active:
type: boolean
Expand Down
1 change: 1 addition & 0 deletions storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,7 @@ func (c *StorageClient) Validators(ctx context.Context, p apiTypes.GetConsensusV
queries.ValidatorsData,
address,
p.Name,
p.Id,
p.Limit,
p.Offset,
)
Expand Down
13 changes: 7 additions & 6 deletions storage/client/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ const (
ValidatorsAggStats = `
SELECT
COALESCE (
(SELECT SUM(voting_power)
(SELECT SUM(voting_power)::NUMERIC
FROM chain.nodes)
, 0) AS total_voting_power,
COALESCE (
Expand Down Expand Up @@ -504,9 +504,9 @@ const (
delegators_count.count
, 0) AS num_delegators,
COALESCE (
validator_nodes.voting_power
validator_nodes.voting_power::NUMERIC
, 0) AS voting_power,
SUM(validator_nodes.voting_power)
SUM(validator_nodes.voting_power::NUMERIC)
OVER (ORDER BY validator_rank.rank) AS voting_power_cumulative,
COALESCE(chain.commissions.schedule, '{}'::JSONB) AS commissions_schedule,
chain.blocks.time AS start_date,
Expand Down Expand Up @@ -537,10 +537,11 @@ const (
AND chain.nodes.roles LIKE '%validator%'
AND chain.nodes.voting_power = validator_nodes.voting_power
WHERE ($1::text IS NULL OR chain.entities.address = $1::text) AND
($2::text IS NULL OR chain.entities.meta->>'name' LIKE '%' || $2::text || '%')
($2::text IS NULL OR chain.entities.meta->>'name' LIKE '%' || $2::text || '%') AND
($3::text IS NULL OR chain.entities.id = $3::text OR chain.nodes.id = $3::text)
ORDER BY rank
LIMIT $3::bigint
OFFSET $4::bigint`
LIMIT $4::bigint
OFFSET $5::bigint`

ValidatorHistory = `
WITH entity AS (
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e_regression/damask/expected/validator.body
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"stats": {
"total_delegators": 35414,
"total_staked_balance": "5708092745980859133",
"total_voting_power": 307554773957760060
"total_voting_power": "307554773957760057"
},
"total_count": 1,
"validators": [
Expand Down Expand Up @@ -460,8 +460,8 @@
"window_length": 14400,
"window_uptime": 884
},
"voting_power": 34834350461211,
"voting_power_cumulative": 34834350461211
"voting_power": "34834350461211",
"voting_power_cumulative": "34834350461211"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"is_total_count_clipped": false,
"stats": {
"total_delegators": 35414,
"total_staked_balance": "5708092745980859133",
"total_voting_power": "307554773957760057"
},
"total_count": 1,
"validators": [
{
"active": true,
"current_commission_bound": {
"epoch_end": 0,
"epoch_start": 2310,
"lower": 0,
"upper": 25000
},
"current_rate": 20000,
"entity_address": "oasis1qr3w66akc8ud9a4zsgyjw2muvcfjgfszn5ycgc0a",
"entity_id": "HPeLbzc88IoYEP0TC4nqSxfxdPCPjduLeJqFvmxFye8=",
"escrow": {
"active_balance": "557356819483297",
"active_shares": "506789203787843",
"debonding_balance": "0",
"debonding_shares": "0",
"num_delegators": 13,
"self_delegation_balance": "9263128275881",
"self_delegation_shares": "8422707392134"
},
"in_validator_set": true,
"media": {
"email": "Michael.fairbairn@rmit.edu.au",
"keybase": "mikefairbairn",
"logoUrl": "http:://e2e-tests-mock-static-logo-url",
"name": "RMIT Blockchain Innovation Hub",
"twitter": "BlockchainRMIT",
"url": "https://rmitblockchain.io"
},
"node_id": "wqd9Yy3n7TWKfYRn2bI9Hd6/623CfC7NCUoRbQ5UkR8=",
"rank": 92,
"start_date": "2022-04-11T09:30:00Z",
"uptime": {
"segment_length": 1200,
"segment_uptimes": [
884,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"window_length": 14400,
"window_uptime": 884
},
"voting_power": "34834350461211",
"voting_power_cumulative": "34834350461211"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HTTP/1.1 200 OK
Content-Type: application/json
Vary: Origin
Date: UNINTERESTING
Content-Length: UNINTERESTING

65 changes: 65 additions & 0 deletions tests/e2e_regression/damask/expected/validator_by_node_id.body
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"is_total_count_clipped": false,
"stats": {
"total_delegators": 35414,
"total_staked_balance": "5708092745980859133",
"total_voting_power": "307554773957760057"
},
"total_count": 1,
"validators": [
{
"active": true,
"current_commission_bound": {
"epoch_end": 0,
"epoch_start": 2310,
"lower": 0,
"upper": 25000
},
"current_rate": 20000,
"entity_address": "oasis1qr3w66akc8ud9a4zsgyjw2muvcfjgfszn5ycgc0a",
"entity_id": "HPeLbzc88IoYEP0TC4nqSxfxdPCPjduLeJqFvmxFye8=",
"escrow": {
"active_balance": "557356819483297",
"active_shares": "506789203787843",
"debonding_balance": "0",
"debonding_shares": "0",
"num_delegators": 13,
"self_delegation_balance": "9263128275881",
"self_delegation_shares": "8422707392134"
},
"in_validator_set": true,
"media": {
"email": "Michael.fairbairn@rmit.edu.au",
"keybase": "mikefairbairn",
"logoUrl": "http:://e2e-tests-mock-static-logo-url",
"name": "RMIT Blockchain Innovation Hub",
"twitter": "BlockchainRMIT",
"url": "https://rmitblockchain.io"
},
"node_id": "wqd9Yy3n7TWKfYRn2bI9Hd6/623CfC7NCUoRbQ5UkR8=",
"rank": 92,
"start_date": "2022-04-11T09:30:00Z",
"uptime": {
"segment_length": 1200,
"segment_uptimes": [
884,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"window_length": 14400,
"window_uptime": 884
},
"voting_power": "34834350461211",
"voting_power_cumulative": "34834350461211"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HTTP/1.1 200 OK
Content-Type: application/json
Vary: Origin
Date: UNINTERESTING
Content-Length: UNINTERESTING

Loading
Loading