Skip to content

Commit

Permalink
client: add {node,validator}_public_key field to /status response; de…
Browse files Browse the repository at this point in the history
…precated node_key (#7828)

Currently, response to the /status request returns a `node_key`
field. However, the field does not include node key but rather
validator key.  Deprecated it in favour of two new fields:
`node_public_key` and `validator_public_key`.

Fixes: #7672
  • Loading branch information
mina86 authored and nikurt committed Nov 9, 2022
1 parent a39445b commit 3bdd2b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
deprecated. If they are set in `config.json` the node will fail if migration
needs to be performed. Use `store.migration_snapshot` instead to configure
the behaviour [#7486](https://github.com/near/nearcore/pull/7486)
* `/status` response has now two more fields: `node_public_key` and
`validator_public_key`. The `node_key` field is now deprecated and should not
be used since it confusingly holds validator key.
* Added `near_peer_message_sent_by_type_bytes` and
`near_peer_message_sent_by_type_total` Prometheus metrics measuring
size and number of messages sent to peers.
Expand Down
14 changes: 10 additions & 4 deletions chain/client/src/client_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,12 @@ impl Handler<Status> for ClientActor {
let protocol_version =
self.client.runtime_adapter.get_epoch_protocol_version(&head.epoch_id)?;

let validator_and_key =
self.client.validator_signer.as_ref().map(|vs| (vs.validator_id(), vs.public_key()));
let node_public_key = self.node_id.public_key().clone();
let (validator_account_id, validator_public_key) = match &self.client.validator_signer {
Some(vs) => (Some(vs.validator_id().clone()), Some(vs.public_key().clone())),
None => (None, None),
};
let node_key = validator_public_key.clone();

let mut earliest_block_hash = None;
let mut earliest_block_height = None;
Expand Down Expand Up @@ -778,8 +782,10 @@ impl Handler<Status> for ClientActor {
epoch_id: Some(head.epoch_id),
epoch_start_height,
},
validator_account_id: validator_and_key.as_ref().map(|v| v.0.clone()),
node_key: validator_and_key.as_ref().map(|v| v.1.clone()),
validator_account_id,
validator_public_key,
node_public_key,
node_key,
uptime_sec,
detailed_debug_status,
})
Expand Down
4 changes: 4 additions & 0 deletions core/primitives/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,11 @@ pub struct StatusResponse {
pub sync_info: StatusSyncInfo,
/// Validator id of the node
pub validator_account_id: Option<AccountId>,
/// Public key of the validator.
pub validator_public_key: Option<PublicKey>,
/// Public key of the node.
pub node_public_key: PublicKey,
/// Deprecated; same as `validator_public_key` which you should use instead.
pub node_key: Option<PublicKey>,
/// Uptime of the node.
pub uptime_sec: i64,
Expand Down

0 comments on commit 3bdd2b9

Please sign in to comment.