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

Update PoH speed check to derive rate from Bank #2447

Merged
merged 4 commits into from
Aug 6, 2024

Conversation

steviez
Copy link

@steviez steviez commented Aug 5, 2024

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:

[2024-08-05T18:09:44.850926545Z INFO  solana_core::validator] PoH speed check: computed hashes per second 13917067, target hashes per second 10000000

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.

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.
@steviez steviez requested a review from bw-solana August 5, 2024 21:03
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);
Copy link
Author

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:

pub ns_per_slot: u128,

Comment on lines -2944 to +2959
target_tick_duration: Duration::from_millis(solana_sdk::clock::MS_PER_TICK),
target_tick_duration: target_tick_duration(),
Copy link
Author

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

core/src/validator.rs Outdated Show resolved Hide resolved
bw-solana
bw-solana previously approved these changes Aug 5, 2024
Copy link

@bw-solana bw-solana left a 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

Copy link
Author

@steviez steviez left a 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)

Copy link

@bw-solana bw-solana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@steviez steviez merged commit 72d8341 into anza-xyz:master Aug 6, 2024
40 checks passed
@steviez steviez deleted the val_poh_speed branch August 6, 2024 17:57
ray-kast pushed a commit to abklabs/agave that referenced this pull request Nov 27, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants