-
Notifications
You must be signed in to change notification settings - Fork 232
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
Update PoH speed check to derive rate from Bank #2447
Conversation
The PoH speed check currently determines the target hash rate by reading values from genesis. However, the hashes per tick rate has been increased via feature gates. Thus, the speed check is using a slower hash rate for comparison than what is actually active. So, update the PoH speed check to derive PoH hash rate from a Bank instead.
core/src/validator.rs
Outdated
let hashes_per_slot = hashes_per_tick * ticks_per_slot; | ||
let hash_samples = maybe_hash_samples.unwrap_or(hashes_per_slot); | ||
|
||
let hash_time = compute_hash_time(hash_samples); | ||
let my_hashes_per_second = (hash_samples as f64 / hash_time.as_secs_f64()) as u64; | ||
let target_slot_duration = Duration::from_nanos(genesis_config.ns_per_slot() as u64); | ||
|
||
let target_slot_duration = Duration::from_nanos(bank.ns_per_slot as u64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure ns_per_slot
should be public in Bank
, but seemingly a refactor for after this:
Line 730 in 4e5af1e
pub ns_per_slot: u128, |
target_tick_duration: Duration::from_millis(solana_sdk::clock::MS_PER_TICK), | ||
target_tick_duration: target_tick_duration(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this change isn't critical for the PR. But, the constant MS_PER_TICK
is 6ms; 6 ms/tick * 64 ticks/slot = 384 ms/slot. It annoyed me that this didn't come out to the 400ms, and I noticed when observing the info
log from speed check. Can revert it back if desired
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left one suggestion that would reduce indent level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ended up doing the let-else change you mentioned as I also thought this change might be worthy of a CHANGELOG entry (since it could now be an error at startup for nodes that can't hash fast enough)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The PoH speed check currently determines the target hash rate by reading values from genesis. However, the hashes per tick rate has been increased via feature gates. Thus, the speed check is using a slower hash rate for comparison than what is actually active. So, update the PoH speed check to derive PoH hash rate from a Bank instead
Problem
The PoH speed check currently determines the target hash rate by reading values from genesis. However, the hashes per tick rate has been increased via feature gates. Thus, the speed check is using a slower hash rate for comparison than what is actually active.
Summary of Changes
So, update the PoH speed check to derive PoH hash rate from a Bank instead.
Running this on MNB, I see the following log emitted:
10 million is the correct value; the log output shared in my previous PR (#2400) will show that we were previously showing 2 million as the target.