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

Add admin key to get /network/nodes endpoint #9776

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions hedera-mirror-rest/__tests__/service/networkNodeService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ describe('NetworkNodeService.getNetworkNodesWithFiltersQuery tests', () => {
stake_rewarded,
staking_period
from node_stake
where consensus_timestamp = (select max(consensus_timestamp) from node_stake))
where consensus_timestamp = (select max(consensus_timestamp) from node_stake)),
n as (select admin_key, node_id
from node)
select abe.description,
abe.memo,
abe.node_id,
Expand All @@ -53,6 +55,7 @@ describe('NetworkNodeService.getNetworkNodesWithFiltersQuery tests', () => {
adb.file_id,
adb.start_consensus_timestamp,
adb.end_consensus_timestamp,
n.admin_key,
ns.max_stake,
ns.min_stake,
ns.reward_rate,
Expand All @@ -73,6 +76,7 @@ describe('NetworkNodeService.getNetworkNodesWithFiltersQuery tests', () => {
from address_book_entry abe
join adb on adb.start_consensus_timestamp = abe.consensus_timestamp
left join ns on abe.node_id = ns.node_id
left join n on abe.node_id = n.node_id
order by abe.node_id asc
limit $2`;
assertSqlQueryEqual(query, expected);
Expand All @@ -95,7 +99,9 @@ describe('NetworkNodeService.getNetworkNodesWithFiltersQuery tests', () => {
stake_rewarded,
staking_period
from node_stake
where consensus_timestamp = (select max(consensus_timestamp) from node_stake))
where consensus_timestamp = (select max(consensus_timestamp) from node_stake)),
n as (select admin_key, node_id
from node)
select abe.description,
abe.memo,
abe.node_id,
Expand All @@ -105,6 +111,7 @@ describe('NetworkNodeService.getNetworkNodesWithFiltersQuery tests', () => {
adb.file_id,
adb.start_consensus_timestamp,
adb.end_consensus_timestamp,
n.admin_key,
ns.max_stake,
ns.min_stake,
ns.reward_rate,
Expand All @@ -125,6 +132,7 @@ describe('NetworkNodeService.getNetworkNodesWithFiltersQuery tests', () => {
from address_book_entry abe
join adb on adb.start_consensus_timestamp = abe.consensus_timestamp
left join ns on abe.node_id = ns.node_id
left join n on abe.node_id = n.node_id
where abe.node_id = $2
order by abe.node_id asc
limit $3`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
"responseJson": {
"nodes": [
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"responseJson": {
"nodes": [
{
"admin_key": null,
"description": "description",
"file_id": "0.0.101",
"max_stake": 2000,
Expand Down Expand Up @@ -190,6 +191,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.101",
"max_stake": 2000,
Expand Down
25 changes: 25 additions & 0 deletions hedera-mirror-rest/__tests__/specs/network/nodes/max-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@
"responseJson": {
"nodes": [
{
"admin_key": null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All specs have the admin_key as null. We should populate valid admin keys for at least one file like this one. It should include different variations like ED25519, ECDSA, 3200 immutable key, and one complex key.

"description": "description",
"file_id": "0.0.102",
"max_stake": 5000,
Expand Down Expand Up @@ -397,6 +398,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -424,6 +426,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -451,6 +454,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -478,6 +482,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -505,6 +510,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -532,6 +538,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -559,6 +566,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -586,6 +594,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -613,6 +622,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -640,6 +650,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -667,6 +678,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -694,6 +706,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -721,6 +734,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -748,6 +762,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -775,6 +790,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -802,6 +818,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -829,6 +846,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -856,6 +874,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -883,6 +902,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -910,6 +930,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -937,6 +958,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -964,6 +986,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -991,6 +1014,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down Expand Up @@ -1018,6 +1042,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"responseJson": {
"nodes": [
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": 5000,
Expand Down Expand Up @@ -158,6 +159,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
"responseJson": {
"nodes": [
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": 2000,
Expand Down Expand Up @@ -193,6 +194,7 @@
}
},
{
"admin_key": null,
"description": "description",
"file_id": "0.0.102",
"max_stake": 2000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ describe('NetworkNodeViewModel', () => {
stakeRewarded: 4,
stakingPeriod: '1654991999999999999',
},
node: {
adminKey: null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test should populate a valid key

nodeId: 0,
},
};
const defaultExpected = {
admin_key: null,
description: 'desc 1',
file_id: '0.0.102',
max_stake: 1000,
Expand Down Expand Up @@ -113,9 +118,13 @@ describe('NetworkNodeViewModel', () => {
stakeRewarded: null,
stakingPeriod: null,
},
node: {
adminKey: null,
},
})
).toEqual({
...defaultExpected,
admin_key: null,
description: null,
max_stake: null,
memo: null,
Expand Down
9 changes: 8 additions & 1 deletion hedera-mirror-rest/api/v1/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2766,7 +2766,7 @@ components:
example: ProtobufEncoded
key:
type: string
example: "421050820e1485acdd59726088e0e4a2130ebbbb70009f640ad95c78dd5a7b38"
example: "15706b229b3ba33d4a5a41ff54ce1cfe0a3d308672a33ff382f81583e02bd743"
Links:
type: object
properties:
Expand All @@ -2777,6 +2777,7 @@ components:
NetworkNode:
type: object
required:
- admin_key
- description
- file_id
- max_stake
Expand All @@ -2794,6 +2795,8 @@ components:
- staking_period
- timestamp
properties:
admin_key:
$ref: "#/components/schemas/Key"
description:
description: a memo associated with the address book
nullable: true
Expand Down Expand Up @@ -2862,6 +2865,9 @@ components:
timestamp:
$ref: "#/components/schemas/TimestampRange"
example:
admin_key:
_type: "ED25519"
key: "15706b229b3ba33d4a5a41ff54ce1cfe0a3d308672a33ff382f81583e02bd743"
description: "address book 1"
file_id: "0.0.102"
max_stake: 50000
Expand Down Expand Up @@ -3615,6 +3621,7 @@ components:
- FILEDELETE
- FILEUPDATE
- FREEZE
- NODE
- NODECREATE
- NODEDELETE
- NODESTAKEUPDATE
Expand Down
2 changes: 2 additions & 0 deletions hedera-mirror-rest/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Entity from './entity';
import EthereumTransaction from './ethereumTransaction';
import ExchangeRate from './exchangeRate';
import FileData from './fileData';
import Node from './node';
import NetworkNode from './networkNode';
import NetworkStake from './networkStake';
import Nft from './nft';
Expand Down Expand Up @@ -82,6 +83,7 @@ export {
EthereumTransaction,
ExchangeRate,
FileData,
Node,
NetworkNode,
NetworkStake,
Nft,
Expand Down
Loading