Skip to content

Update PoH speed check to derive rate from Bank#2447

Merged
steviez merged 4 commits intoanza-xyz:masterfrom
steviez:val_poh_speed
Aug 6, 2024
Merged

Update PoH speed check to derive rate from Bank#2447
steviez merged 4 commits intoanza-xyz:masterfrom
steviez:val_poh_speed

Conversation

@steviez
Copy link
Copy Markdown

@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
Comment thread core/src/validator.rs Outdated
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
Copy Markdown
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 thread core/src/validator.rs
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
Copy Markdown
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

Comment thread core/src/validator.rs Outdated
bw-solana
bw-solana previously approved these changes Aug 5, 2024
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown

@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
@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