Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix sanity check in relay chain selection #3749

Closed
wants to merge 1 commit into from

Conversation

Lldenaurois
Copy link
Contributor

Closes #3678

The sanity check was including the current unfinalized block in the sanity check for sending subchain_block_descriptions to the dispute coordinator.

@Lldenaurois Lldenaurois added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. labels Aug 31, 2021
@@ -417,7 +417,7 @@ where

let lag = if cfg!(feature = "disputes") {
// Prevent sending flawed data to the dispute-coordinator.
if Some(subchain_block_descriptions.len() as _) !=
if Some(subchain_block_descriptions.len() as u32 - 1) !=
Copy link
Member

@ordian ordian Aug 31, 2021

Choose a reason for hiding this comment

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

Do we guarantee that block descriptions are always not-empty?
Would be nice to add a comment why -1.

@@ -417,7 +417,7 @@ where

let lag = if cfg!(feature = "disputes") {
// Prevent sending flawed data to the dispute-coordinator.
if Some(subchain_block_descriptions.len() as _) !=
if Some(subchain_block_descriptions.len() as u32 - 1) !=
subchain_number.checked_sub(target_number)
Copy link
Member

Choose a reason for hiding this comment

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

while equivalent, I would suggest to use the same calculation as in approval voting. So instead of doing the -1, I would change the checked_sub(target_number) to checked_sub(target_number + 1).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix off-by-one in expected approved block-descriptions
4 participants