near_primitives/version.rs
1use crate::types::Balance;
2use near_primitives_core::chains::{MAINNET, TESTNET};
3
4/// Data structure for semver version and github tag or commit.
5#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Default)]
6#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
7pub struct Version {
8 pub version: String,
9 pub build: String,
10 pub commit: String,
11 #[serde(default)]
12 pub rustc_version: String,
13}
14
15use crate::upgrade_schedule::ProtocolUpgradeVotingSchedule;
16
17/// near_primitives_core re-exports
18pub use near_primitives_core::types::ProtocolVersion;
19pub use near_primitives_core::version::MIN_SUPPORTED_PROTOCOL_VERSION;
20pub use near_primitives_core::version::PROD_GENESIS_PROTOCOL_VERSION;
21pub use near_primitives_core::version::PROTOCOL_VERSION;
22pub use near_primitives_core::version::ProtocolFeature;
23
24/// Minimum gas price proposed in NEP 92 and the associated protocol version
25pub const MIN_GAS_PRICE_NEP_92: Balance = Balance::from_yoctonear(1_000_000_000);
26
27/// Minimum gas price proposed in NEP 92 (fixed) and the associated protocol version
28pub const MIN_GAS_PRICE_NEP_92_FIX: Balance = Balance::from_yoctonear(100_000_000);
29
30/// The protocol version for the block header v3. This is also when we started using
31/// versioned block producer hash format.
32pub const BLOCK_HEADER_V3_PROTOCOL_VERSION: ProtocolVersion = 49;
33
34/// Returns the protocol upgrade schedule for chain_id or an empty schedule if
35/// chain_id is not recognized.
36pub fn get_protocol_upgrade_schedule(chain_id: &str) -> ProtocolUpgradeVotingSchedule {
37 // Update according to the schedule when making a release. Keep in mind that
38 // the protocol upgrade will happen 1-2 epochs (15h-30h) after the set date.
39 // Ideally that should be during working hours.
40 //
41 // Multiple protocol version upgrades can be scheduled. Please make sure
42 // that they are ordered by datetime and version, the last one is the
43 // PROTOCOL_VERSION and that there is enough time between subsequent
44 // upgrades.
45 //
46 // At most one protocol version upgrade vote can happen per epoch. If, by any
47 // chance, two or more votes get scheduled on the same epoch, the latest upgrades
48 // will be postponed.
49
50 // e.g.
51 // let v1_protocol_version = 50;
52 // let v2_protocol_version = 51;
53 // let v1_datetime = ProtocolUpgradeVotingSchedule::parse_datetime("2000-01-01 15:00:00").unwrap();
54 // let v2_datetime = ProtocolUpgradeVotingSchedule::parse_datetime("2000-01-10 15:00:00").unwrap();
55 //
56 // let schedule = vec![(v1_datetime, v1_protocol_version), (v2_datetime, v2_protocol_version)];
57 let schedule = match chain_id {
58 MAINNET => {
59 let v1_protocol_version = 82;
60 // Tuesday Dec 9th 03:00 UTC
61 let v1_datetime =
62 ProtocolUpgradeVotingSchedule::parse_datetime("2025-12-09 03:00:00").unwrap();
63 let schedule = vec![(v1_datetime, v1_protocol_version)];
64 schedule
65 }
66 TESTNET => {
67 let v1_protocol_version = 82;
68 // Tuesday Nov 25th 00:00 UTC
69 let v1_datetime =
70 ProtocolUpgradeVotingSchedule::parse_datetime("2025-11-25 00:00:00").unwrap();
71 let schedule = vec![(v1_datetime, v1_protocol_version)];
72 schedule
73 }
74 _ => {
75 let schedule = vec![];
76 schedule
77 }
78 };
79 ProtocolUpgradeVotingSchedule::new_from_env_or_schedule(
80 MIN_SUPPORTED_PROTOCOL_VERSION,
81 PROTOCOL_VERSION,
82 schedule,
83 )
84 .unwrap()
85}