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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

The current reference tick calculation results in the reference tick
being recorded as 0 when a Bank has reached max tick height. This could
lead a node to incorrectly believe they are late in receiving this
shread which could lead to a premature repair request being sent.

So, adjust the calculation to sature at bank.ticks_per_slot() - 1
@steviez steviez changed the title turbine: Avoid wrapping shred reference tick turbine: Adjust reference tick calculation 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

@@ -268,7 +268,11 @@ impl StandardBroadcastRun {

// 2) Convert entries to shreds and coding shreds
let is_last_in_slot = last_tick_height == bank.max_tick_height();
let reference_tick = bank.tick_height() % bank.ticks_per_slot();
let reference_tick = if is_last_in_slot {
bank.ticks_per_slot() - 1

Choose a reason for hiding this comment

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

comment here would be good

@@ -268,7 +268,11 @@ impl StandardBroadcastRun {

// 2) Convert entries to shreds and coding shreds
let is_last_in_slot = last_tick_height == bank.max_tick_height();
let reference_tick = bank.tick_height() % bank.ticks_per_slot();

Choose a reason for hiding this comment

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

If we are changing this I would rather to change it to:

let reference_tick = last_tick_height
    .saturating_add(bank.ticks_per_slot())
    .saturating_sub(bank.max_tick_height());

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