Skip to content

Commit 456791b

Browse files
committed
Support validators by node-id/entity-od
1 parent 95bd722 commit 456791b

25 files changed

+617
-391
lines changed

api/spec/v1.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,13 @@ paths:
561561
description: |
562562
A filter on the validator name. Every returned validator will have
563563
a name that is a superstring of the input param.
564+
- in: query
565+
name: id
566+
schema:
567+
type: string
568+
description: |
569+
A filter on the entity or node ID (base64-encoded ed25519 public key).
570+
Returns the validator with the matching entity ID or a node matching the given node ID if it exists.
564571
responses:
565572
'200':
566573
description: |

storage/client/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,7 @@ func (c *StorageClient) Validators(ctx context.Context, p apiTypes.GetConsensusV
13661366
queries.ValidatorsData,
13671367
address,
13681368
p.Name,
1369+
p.Id,
13691370
p.Limit,
13701371
p.Offset,
13711372
)

storage/client/queries/queries.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,11 @@ const (
537537
AND chain.nodes.roles LIKE '%validator%'
538538
AND chain.nodes.voting_power = validator_nodes.voting_power
539539
WHERE ($1::text IS NULL OR chain.entities.address = $1::text) AND
540-
($2::text IS NULL OR chain.entities.meta->>'name' LIKE '%' || $2::text || '%')
540+
($2::text IS NULL OR chain.entities.meta->>'name' LIKE '%' || $2::text || '%') AND
541+
($3::text IS NULL OR chain.entities.id = $3::text OR chain.nodes.id = $3::text)
541542
ORDER BY rank
542-
LIMIT $3::bigint
543-
OFFSET $4::bigint`
543+
LIMIT $4::bigint
544+
OFFSET $5::bigint`
544545

545546
ValidatorHistory = `
546547
WITH entity AS (

tests/e2e_regression/damask/expected/validator.body

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"stats": {
44
"total_delegators": 35414,
55
"total_staked_balance": "5708092745980859133",
6-
"total_voting_power": 307554773957760060
6+
"total_voting_power": 307554773957760057
77
},
88
"total_count": 1,
99
"validators": [
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"is_total_count_clipped": false,
3+
"stats": {
4+
"total_delegators": 35414,
5+
"total_staked_balance": "5708092745980859133",
6+
"total_voting_power": 307554773957760057
7+
},
8+
"total_count": 1,
9+
"validators": [
10+
{
11+
"active": true,
12+
"current_commission_bound": {
13+
"epoch_end": 0,
14+
"epoch_start": 2310,
15+
"lower": 0,
16+
"upper": 25000
17+
},
18+
"current_rate": 20000,
19+
"entity_address": "oasis1qr3w66akc8ud9a4zsgyjw2muvcfjgfszn5ycgc0a",
20+
"entity_id": "HPeLbzc88IoYEP0TC4nqSxfxdPCPjduLeJqFvmxFye8=",
21+
"escrow": {
22+
"active_balance": "557356819483297",
23+
"active_shares": "506789203787843",
24+
"debonding_balance": "0",
25+
"debonding_shares": "0",
26+
"num_delegators": 13,
27+
"self_delegation_balance": "9263128275881",
28+
"self_delegation_shares": "8422707392134"
29+
},
30+
"in_validator_set": true,
31+
"media": {
32+
"email": "Michael.fairbairn@rmit.edu.au",
33+
"keybase": "mikefairbairn",
34+
"logoUrl": "http:://e2e-tests-mock-static-logo-url",
35+
"name": "RMIT Blockchain Innovation Hub",
36+
"twitter": "BlockchainRMIT",
37+
"url": "https://rmitblockchain.io"
38+
},
39+
"node_id": "wqd9Yy3n7TWKfYRn2bI9Hd6/623CfC7NCUoRbQ5UkR8=",
40+
"rank": 92,
41+
"start_date": "2022-04-11T09:30:00Z",
42+
"uptime": {
43+
"segment_length": 1200,
44+
"segment_uptimes": [
45+
884,
46+
0,
47+
0,
48+
0,
49+
0,
50+
0,
51+
0,
52+
0,
53+
0,
54+
0,
55+
0,
56+
0
57+
],
58+
"window_length": 14400,
59+
"window_uptime": 884
60+
},
61+
"voting_power": 34834350461211,
62+
"voting_power_cumulative": 34834350461211
63+
}
64+
]
65+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: application/json
3+
Vary: Origin
4+
Date: UNINTERESTING
5+
Content-Length: UNINTERESTING
6+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"is_total_count_clipped": false,
3+
"stats": {
4+
"total_delegators": 35414,
5+
"total_staked_balance": "5708092745980859133",
6+
"total_voting_power": 307554773957760057
7+
},
8+
"total_count": 1,
9+
"validators": [
10+
{
11+
"active": true,
12+
"current_commission_bound": {
13+
"epoch_end": 0,
14+
"epoch_start": 2310,
15+
"lower": 0,
16+
"upper": 25000
17+
},
18+
"current_rate": 20000,
19+
"entity_address": "oasis1qr3w66akc8ud9a4zsgyjw2muvcfjgfszn5ycgc0a",
20+
"entity_id": "HPeLbzc88IoYEP0TC4nqSxfxdPCPjduLeJqFvmxFye8=",
21+
"escrow": {
22+
"active_balance": "557356819483297",
23+
"active_shares": "506789203787843",
24+
"debonding_balance": "0",
25+
"debonding_shares": "0",
26+
"num_delegators": 13,
27+
"self_delegation_balance": "9263128275881",
28+
"self_delegation_shares": "8422707392134"
29+
},
30+
"in_validator_set": true,
31+
"media": {
32+
"email": "Michael.fairbairn@rmit.edu.au",
33+
"keybase": "mikefairbairn",
34+
"logoUrl": "http:://e2e-tests-mock-static-logo-url",
35+
"name": "RMIT Blockchain Innovation Hub",
36+
"twitter": "BlockchainRMIT",
37+
"url": "https://rmitblockchain.io"
38+
},
39+
"node_id": "wqd9Yy3n7TWKfYRn2bI9Hd6/623CfC7NCUoRbQ5UkR8=",
40+
"rank": 92,
41+
"start_date": "2022-04-11T09:30:00Z",
42+
"uptime": {
43+
"segment_length": 1200,
44+
"segment_uptimes": [
45+
884,
46+
0,
47+
0,
48+
0,
49+
0,
50+
0,
51+
0,
52+
0,
53+
0,
54+
0,
55+
0,
56+
0
57+
],
58+
"window_length": 14400,
59+
"window_uptime": 884
60+
},
61+
"voting_power": 34834350461211,
62+
"voting_power_cumulative": 34834350461211
63+
}
64+
]
65+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: application/json
3+
Vary: Origin
4+
Date: UNINTERESTING
5+
Content-Length: UNINTERESTING
6+

0 commit comments

Comments
 (0)