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

chain: added near_node_protocol_upgrade_voting_start metric #7877

Merged
merged 2 commits into from
Oct 19, 2022
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
Instead of it aggregate `near_peer_message_received_by_type_total` metric.
For example, to get total rate of received messages use
`sum(rate(near_peer_message_received_by_type_total{...}[5m]))`.
* Added `near_node_protocol_upgrade_voting_start` Prometheus metric whose value
is timestamp when voting for the next protocol version starts.
* Few changes to `view_state` JSON RPC query:
- The requset has now an optional `include_proof` argument. When set to
`true`, response’s `proof` will be populated.
Expand Down
13 changes: 13 additions & 0 deletions chain/client/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ pub(crate) static NODE_PROTOCOL_VERSION: Lazy<IntGauge> = Lazy::new(|| {
.unwrap()
});

pub(crate) static NODE_PROTOCOL_UPGRADE_VOTING_START: Lazy<IntGauge> = Lazy::new(|| {
try_create_int_gauge(
"near_node_protocol_upgrade_voting_start",
"Time in seconds since Unix epoch determining when node will start voting for the protocol upgrade; zero if there is no schedule for the voting")
.unwrap()
});

pub static PRODUCE_CHUNK_TIME: Lazy<near_o11y::metrics::HistogramVec> = Lazy::new(|| {
try_create_histogram_vec(
"near_produce_chunk_time",
Expand Down Expand Up @@ -311,6 +318,12 @@ pub static PRODUCE_AND_DISTRIBUTE_CHUNK_TIME: Lazy<near_o11y::metrics::Histogram
/// `neard_version` argument.
pub(crate) fn export_version(neard_version: &near_primitives::version::Version) {
NODE_PROTOCOL_VERSION.set(near_primitives::version::PROTOCOL_VERSION.into());
NODE_PROTOCOL_UPGRADE_VOTING_START.set(
once_cell::sync::Lazy::force(&near_primitives::version::PROTOCOL_UPGRADE_SCHEDULE)
.as_ref()
.map(|schedule| schedule.timestamp())
.unwrap_or(0),
);
NODE_DB_VERSION.set(near_store::metadata::DB_VERSION.into());
NODE_BUILD_INFO.reset();
NODE_BUILD_INFO
Expand Down
6 changes: 5 additions & 1 deletion core/primitives/src/upgrade_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use near_primitives_core::types::ProtocolVersion;
use std::str::FromStr;

/// Defines the point in time after which validators are expected to vote on the new protocol version.
pub(crate) struct ProtocolUpgradeVotingSchedule {
pub struct ProtocolUpgradeVotingSchedule {
timestamp: chrono::DateTime<Utc>,
}

Expand All @@ -24,6 +24,10 @@ impl ProtocolUpgradeVotingSchedule {
pub fn is_in_future(&self) -> bool {
chrono::Utc::now() < self.timestamp
}

pub fn timestamp(&self) -> i64 {
self.timestamp.timestamp()
}
}

pub(crate) fn get_protocol_version_internal(
Expand Down
18 changes: 9 additions & 9 deletions core/primitives/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ pub const PROTOCOL_VERSION: ProtocolVersion = if cfg!(feature = "nightly_protoco

/// The points in time after which the voting for the latest protocol version
/// should start.
#[allow(dead_code)]
const PROTOCOL_UPGRADE_SCHEDULE: Lazy<Option<ProtocolUpgradeVotingSchedule>> = Lazy::new(|| {
if cfg!(feature = "shardnet") {
Some(ProtocolUpgradeVotingSchedule::from_str("2022-09-05 15:00:00").unwrap())
} else {
// Update to latest protocol version on release.
None
}
});
pub static PROTOCOL_UPGRADE_SCHEDULE: Lazy<Option<ProtocolUpgradeVotingSchedule>> =
Lazy::new(|| {
if cfg!(feature = "shardnet") {
Some(ProtocolUpgradeVotingSchedule::from_str("2022-09-05 15:00:00").unwrap())
} else {
// Update to latest protocol version on release.
None
}
});

/// Gives new clients an option to upgrade without announcing that they support
/// the new version. This gives non-validator nodes time to upgrade. See
Expand Down