Skip to content
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ jobs:
steps:
- run_test:
workspace_member: snarkvm-parameters
flags: --run-ignored ignored-only -- --test-threads=2
flags: --run-ignored ignored-only -- --test-threads=2
use_cache: false
cache_key_suffix: -v-{{ epoch }}
no_output_timeout: 20m
Expand Down
19 changes: 19 additions & 0 deletions console/network/src/consensus_heights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub enum ConsensusVersion {
/// and dynamic dispatch, and identifier literal types.
V14 = 14,
/// V15: Introduces the record-existence check and `commit.*.raw` instruction variants.
/// Increase the anchor time to 35.
V15 = 15,
}

Expand Down Expand Up @@ -347,6 +348,11 @@ mod tests {
assert!(*version > previous_version);
previous_version = *version;
}
let mut previous_version = N::ANCHOR_TIMES.first().unwrap().0;
for (version, _) in N::ANCHOR_TIMES.iter().skip(1) {
assert!(*version > previous_version);
previous_version = *version;
}
}

/// Ensure that consensus *heights* are unique and incrementing.
Expand Down Expand Up @@ -400,6 +406,10 @@ mod tests {
// Double-check that consensus_config_value returns the correct value.
assert_eq!(consensus_config_value!(N, MAX_WRITES, height).unwrap(), *value);
}
for (version, value) in N::ANCHOR_TIMES.iter() {
let height = N::CONSENSUS_VERSION_HEIGHTS().iter().find(|(c_version, _)| c_version == version).unwrap().1;
assert_eq!(consensus_config_value!(N, ANCHOR_TIMES, height).unwrap(), *value);
}
}

/// Ensure that consensus_config_value returns a valid value for all consensus versions.
Expand All @@ -411,6 +421,7 @@ mod tests {
assert!(consensus_config_value!(N, MAX_PROGRAM_SIZE, *height).is_some());
assert!(consensus_config_value!(N, MAX_TRANSACTION_SIZE, *height).is_some());
assert!(consensus_config_value!(N, MAX_WRITES, *height).is_some());
assert!(consensus_config_value!(N, ANCHOR_TIMES, *height).is_some());
}
}

Expand Down Expand Up @@ -460,6 +471,7 @@ mod tests {
let _ = [N1::MAX_PROGRAM_SIZE, N2::MAX_PROGRAM_SIZE, N3::MAX_PROGRAM_SIZE];
let _ = [N1::MAX_TRANSACTION_SIZE, N2::MAX_TRANSACTION_SIZE, N3::MAX_TRANSACTION_SIZE];
let _ = [N1::MAX_WRITES, N2::MAX_WRITES, N3::MAX_WRITES];
let _ = [N1::ANCHOR_TIMES, N2::ANCHOR_TIMES, N3::ANCHOR_TIMES];
}

/// Ensure that `LATEST_MAX_*` functions return valid values without panicking.
Expand Down Expand Up @@ -534,4 +546,11 @@ mod tests {
let result = ConsensusVersion::from_bytes_le(&invalid_bytes);
assert!(result.is_err());
}

#[test]
fn test_reward_anchor_time() {
assert_eq!(MainnetV0::REWARD_ANCHOR_TIME, MainnetV0::ANCHOR_TIMES.first().unwrap().1);
assert_eq!(TestnetV0::REWARD_ANCHOR_TIME, TestnetV0::ANCHOR_TIMES.first().unwrap().1);
assert_eq!(CanaryV0::REWARD_ANCHOR_TIME, CanaryV0::ANCHOR_TIMES.first().unwrap().1);
}
}
14 changes: 11 additions & 3 deletions console/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,17 @@ pub trait Network:
const ARC_0005_COMPUTE_DISCOUNT: u64 = 25;

/// The anchor height, defined as the expected number of blocks to reach the coinbase target.
const ANCHOR_HEIGHT: u32 = Self::ANCHOR_TIME as u32 / Self::BLOCK_TIME as u32;
/// The anchor time in seconds.
const ANCHOR_TIME: u16 = 25;
/// Note: The anchor height used exclusively by `coinbase_reward_v1`.
const ANCHOR_HEIGHT: u32 = Self::REWARD_ANCHOR_TIME as u32 / Self::BLOCK_TIME as u32;
/// The anchor time used specifically for calculating the coinbase reward.
/// We ensure that the reward anchor time matches the original ConsensusVersion::V1 anchor time
/// to maintain the original coinbase reward schedule.
const REWARD_ANCHOR_TIME: u16 = 25;
/// A list of (consensus_version, anchor_time_in_seconds) pairs (sparse).
/// Each entry takes effect at the specified version and remains active until the next entry.
/// The anchor time, defined as the expected time in seconds to reach the coinbase target.
const ANCHOR_TIMES: [(ConsensusVersion, u16); 2] =
[(ConsensusVersion::V1, Self::REWARD_ANCHOR_TIME), (ConsensusVersion::V15, 35)];
/// The expected time per block in seconds.
const BLOCK_TIME: u16 = 10;
/// The number of blocks per epoch.
Expand Down
Loading