Skip to content

Commit

Permalink
TIER1 debug: fix usage of AccountKey vs PeerId (near#8220)
Browse files Browse the repository at this point in the history
This PR corrects usage of AccountKey and PeerId in the TIER1 debug page.

Sample pending TIER1 connections:
<img width="1090" alt="Screen Shot 2022-12-13 at 5 44 08 PM" src="https://user-images.githubusercontent.com/3241341/207462241-f4c45ca4-0ce2-43bf-800a-d74bef1511cd.png">

Sample after connections are established:
<img width="1117" alt="Screen Shot 2022-12-13 at 5 44 32 PM" src="https://user-images.githubusercontent.com/3241341/207462253-da4266d5-687f-4809-8b31-f83d2bb98712.png">
  • Loading branch information
saketh-are authored and nikurt committed Dec 19, 2022
1 parent 1cf16f6 commit 47fdfe3
Showing 1 changed file with 38 additions and 39 deletions.
77 changes: 38 additions & 39 deletions chain/jsonrpc/res/tier1_network_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,42 @@
let network_info = data.detailed_debug_status.network_info;

// tier1_connections contains TIER1 nodes we are currently connected to
network_info.tier1_connections.forEach(function (peer, index) {
let peer_id = peer.peer_id;
rendered.add(peer_id);

let validator = "";
data.detailed_debug_status.network_info.known_producers.forEach(element => {
if (element.peer_id == peer_id) {
validator = element.account_id;
}
});

network_info.tier1_connections.forEach(function (peer) {
let account_key = "";
let proxies = new Array();

network_info.tier1_accounts_data.forEach(account => {
if (account.peer_id == peer_id) {
if (account.peer_id == peer.peer_id) {
account_key = account.account_key;
account.proxies.forEach(proxy => {
proxies.push(proxy.peer_id.substr(8, 5) + "...@" + proxy.addr);
});
}
});

rendered.add(account_key);

let account_id = "";
network_info.known_producers.forEach(producer => {
if (producer.peer_id == peer.peer_id) {
account_id = producer.account_id;
}
});

let last_ping = convertTime(peer.last_time_received_message_millis)
let last_ping_class = ""
if (data.node_public_key == peer_id) {
if (data.node_public_key == account_key) {
last_ping = "n/a"
} else if (peer.last_time_received_message_millis > 60 * 1000) {
last_ping_class = "peer_far_behind";
}

let row = $('.js-tbody-peers').append($('<tr>')
.append($('<td>').append(add_debug_port_link(peer.addr)))
.append($('<td>').append(validator))
.append($('<td>').append(peer.peer_id.substr(8, 5) + "..."))
.append($('<td>').append(account_key.substr(8, 5) + "..."))
.append($('<td>').append(account_id))
.append($('<td>').append("[" + proxies.join(",") + "]"))
.append($('<td>').append(peer.peer_id.substr(8, 5) + "..."))
.append($('<td>').append(last_ping).addClass(last_ping_class))
.append($('<td>').append(JSON.stringify(peer.tracked_shards)))
.append($('<td>').append(JSON.stringify(peer.archival)))
Expand All @@ -60,17 +63,17 @@

// tier1_accounts_data contains data about TIER1 nodes we would like to connect to
network_info.tier1_accounts_data.forEach(account => {
let peer_id = account.peer_id;
let account_key = account.account_key;

if (rendered.has(peer_id)) {
if (rendered.has(account_key)) {
return;
}
rendered.add(peer_id);
rendered.add(account_key);

let validator = "";
data.detailed_debug_status.network_info.known_producers.forEach(element => {
if (element.peer_id == peer_id) {
validator = element.account_id;
let account_id = "";
network_info.known_producers.forEach(producer => {
if (producer.peer_id == account.peer_id) {
account_id = producer.account_id;
}
});

Expand All @@ -81,9 +84,10 @@

let row = $('.js-tbody-peers').append($('<tr>')
.append($('<td>'))
.append($('<td>').append(validator))
.append($('<td>').append(peer_id.substr(8, 5) + "..."))
.append($('<td>').append(account_key.substr(8, 5) + "..."))
.append($('<td>').append(account_id))
.append($('<td>').append("[" + proxies.join(",") + "]"))
.append($('<td>').append(account.peer_id.substr(8, 5) + "..."))
.append($('<td>'))
.append($('<td>'))
.append($('<td>'))
Expand All @@ -93,24 +97,18 @@
)
});

// tier1_accounts_keys contains accounts whose data we would like to connect
network_info.tier1_accounts_keys.forEach(peer_id => {
if (rendered.has(peer_id)) {
// tier1_accounts_keys contains accounts whose data we would like to collect
network_info.tier1_accounts_keys.forEach(account_key => {
if (rendered.has(account_key)) {
return;
}
rendered.add(peer_id);

let validator = "";
data.detailed_debug_status.network_info.known_producers.forEach(element => {
if (element.peer_id == peer_id) {
validator = element.account_id;
}
});
rendered.add(account_key);

let row = $('.js-tbody-peers').append($('<tr>')
.append($('<td>'))
.append($('<td>').append(validator))
.append($('<td>').append(peer_id.substr(8, 5) + "..."))
.append($('<td>').append(account_key.substr(8, 5) + "..."))
.append($('<td>'))
.append($('<td>'))
.append($('<td>'))
.append($('<td>'))
.append($('<td>'))
Expand Down Expand Up @@ -143,9 +141,10 @@ <h1>
<thead>
<tr>
<th>Address</th>
<th>Validator</th>
<th>PeerId</th>
<th>AccountKey</th>
<th>AccountId</th>
<th>Proxies</th>
<th>PeerId</th>
<th>Last ping</th>
<th>Tracked Shards</th>
<th>Archival</th>
Expand Down

0 comments on commit 47fdfe3

Please sign in to comment.