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

approval-voting: Make sure we always mark approved candidates approved in a different relay chain context #4153

Merged
merged 13 commits into from
Apr 18, 2024
25 changes: 22 additions & 3 deletions polkadot/node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ const APPROVAL_CACHE_SIZE: u32 = 1024;

const TICK_TOO_FAR_IN_FUTURE: Tick = 20; // 10 seconds.
const APPROVAL_DELAY: Tick = 2;

/// Interval to check if no show was covered by approval
/// of the same candidate on a different fork.
const CHECK_NO_SHOW_COVERED: Tick = 36;
alexggh marked this conversation as resolved.
Show resolved Hide resolved
pub(crate) const LOG_TARGET: &str = "parachain::approval-voting";

// The max number of ticks we delay sending the approval after we are ready to issue the approval
Expand Down Expand Up @@ -2176,9 +2180,24 @@ fn schedule_wakeup_action(
.map(|t| t as Tick + block_tick + clock_drift)
};

min_prefer_some(next_non_empty_tranche, next_no_show).map(|tick| {
Action::ScheduleWakeup { block_hash, block_number, candidate_hash, tick }
})
min_prefer_some(next_non_empty_tranche, next_no_show)
.map(|tick| Action::ScheduleWakeup {
block_hash,
block_number,
candidate_hash,
tick,
})
// Make sure we always wake-up if we have pending tranches.
// We might end up in this situation if our assignment was already triggered,
// and all assignments that we know of have already been no-showed, so we need
// to wake up from time to time to check if the no-show was maybe covered by an
// approval for the same candidate, but on a different relay chain fork.
.or(Some(Action::ScheduleWakeup {
block_hash,
block_number,
candidate_hash,
tick: tick_now + CHECK_NO_SHOW_COVERED,
}))
},
};

Expand Down
Loading