Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

adds more sanity checks to shreds #21675

Merged
merged 1 commit into from
Dec 9, 2021

Conversation

behzadnouri
Copy link
Contributor

Problem

shreds inner fields need sanity checks.

Summary of Changes

added sanity checks

@codecov
Copy link

codecov bot commented Dec 7, 2021

Codecov Report

Merging #21675 (eaca402) into master (0224a8b) will decrease coverage by 0.2%.
The diff coverage is 89.2%.

@@            Coverage Diff            @@
##           master   #21675     +/-   ##
=========================================
- Coverage    81.6%    81.4%   -0.3%     
=========================================
  Files         511      511             
  Lines      143320   143453    +133     
=========================================
- Hits       116976   116795    -181     
- Misses      26344    26658    +314     

self.common_header.fec_set_index
}

// Returns true if the shred sanity checks.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: if the shred passes sanity checks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

match self.shred_type() {
ShredType::Data => {
let parent_offset = Slot::try_from(self.data_header.parent_offset);
self.slot().checked_sub(parent_offset.ok()?)
// TODO What if parent_offset is zero and slot != 0?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the call to this filter in window service will drop the shred

Some(parent) => blockstore::verify_shred_slots(shred.slot(), parent, root),

if parent_slot >= slot {
   return false;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

carllin
carllin previously approved these changes Dec 9, 2021
@mergify mergify bot dismissed carllin’s stale review December 9, 2021 14:29

Pull request has been modified.

@behzadnouri behzadnouri merged commit 8063273 into solana-labs:master Dec 9, 2021
@behzadnouri behzadnouri deleted the shred-sanitize branch December 9, 2021 16:44
mergify bot pushed a commit that referenced this pull request Dec 9, 2021
mergify bot added a commit that referenced this pull request Dec 9, 2021
(cherry picked from commit 8063273)

Co-authored-by: behzad nouri <[email protected]>
@brooksprumo brooksprumo mentioned this pull request Jan 5, 2022
mergify bot pushed a commit that referenced this pull request Feb 1, 2022
(cherry picked from commit 8063273)

# Conflicts:
#	ledger/src/blockstore.rs
mergify bot added a commit that referenced this pull request Feb 1, 2022
* adds more sanity checks to shreds (#21675)

(cherry picked from commit 8063273)

# Conflicts:
#	ledger/src/blockstore.rs

* removes mergify merge conflicts

Co-authored-by: behzad nouri <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants