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

turbine: Adjust reference tick calculation #4644

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

steviez
Copy link

@steviez steviez commented Jan 27, 2025

Problem

The current reference tick calculation results in the reference tick being recorded as 0 when a Bank has reached max tick height

Summary of Changes

Adjust the calculation to saturate at bank.ticks_per_slot() - 1, which coincides with the max value of 63 that fit in the 6 bits allocated for reference_tick in the shred header.

I sampled a random block (313491481) from MNB and plotted reference tick vs. shred index to show the issue:
image

@steviez steviez changed the title turbine: Avoid wrapping shred reference tick turbine: Adjust reference tick calculation Jan 27, 2025
bw-solana
bw-solana previously approved these changes Jan 27, 2025
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.

Comment here to remember why we put the hack in would be nice. Other than that, LGTM

turbine/src/broadcast_stage/standard_broadcast_run.rs Outdated Show resolved Hide resolved
@behzadnouri
Copy link

Can we remove the as type casts as well?

https://github.com/anza-xyz/agave/blob/f5d6ebcfb/turbine/src/broadcast_stage/standard_broadcast_run.rs#L276
it better be

u8::try_from(reference_tick).unwrap_or(u8::MAX),

and this line:
https://github.com/anza-xyz/agave/blob/f5d6ebcfb/turbine/src/broadcast_stage/standard_broadcast_run.rs#L212

u8::try_from(bank.ticks_per_slot()).unwrap_or(u8::MAX)

bw-solana
bw-solana previously approved these changes Jan 27, 2025
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 assuming my understanding is correct

turbine/src/broadcast_stage/standard_broadcast_run.rs Outdated Show resolved Hide resolved
behzadnouri
behzadnouri previously approved these changes Jan 28, 2025
Copy link

@behzadnouri behzadnouri left a comment

Choose a reason for hiding this comment

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

lgtm

bw-solana
bw-solana previously approved these changes Jan 28, 2025
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

The current reference tick calculation results in the reference tick
being recorded as 0 when a Bank has reached max tick_height. The
reference tick is used to determine if/when shreds should be repaired,
so adjust the calculation to saturate at bank.ticks_per_slot() - 1
instead.
@steviez steviez dismissed stale reviews from bw-solana and behzadnouri via 624ad06 January 28, 2025 04:37
@steviez steviez force-pushed the broadcast_saturate_ref_tick branch from 1d61261 to 624ad06 Compare January 28, 2025 04:37
No need to apply the mask in turbine code as the underlying code will do
it for us
@steviez steviez force-pushed the broadcast_saturate_ref_tick branch from 624ad06 to 55ed445 Compare January 28, 2025 04:41
@steviez
Copy link
Author

steviez commented Jan 28, 2025

I know you both gave me ship-its, but I decided to push the cleanup into a separate PR (#4653) for the sake of keeping the diff in this PR as small as possible. I also force pushed to cleanup commit history + rebase to tip of master.

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 c1fb66b into anza-xyz:master Jan 28, 2025
47 checks passed
@steviez steviez deleted the broadcast_saturate_ref_tick branch January 28, 2025 19:08
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.

3 participants