-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Verify number of hashes for each block of entries #6262
Conversation
23a43d3
to
51b67b2
Compare
Codecov Report
@@ Coverage Diff @@
## master #6262 +/- ##
========================================
+ Coverage 72.2% 78.5% +6.3%
========================================
Files 212 213 +1
Lines 44405 41129 -3276
========================================
+ Hits 32076 32308 +232
+ Misses 12329 8821 -3508 |
51b67b2
to
76115e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we're only verifying the hash count when blocktree processor first loads the ledger from disk. We also need to verify the hash count in replay stage as each new block is ingested
core/src/entry.rs
Outdated
@@ -299,6 +287,20 @@ impl EntrySlice for [Entry] { | |||
); | |||
res | |||
} | |||
|
|||
fn validate_hash_separation(&self, hashes_per_tick: u64) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of the name of this function: validate_hash_separation()
validate_hash_count()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, do you think that it would be surprising that validate_hash_count
rejects an entry slice that doesn't end in a tick entry? I want to enforce that but maybe it would be better do in another place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to do that. There's no guarantee an entry slice always ends with a tick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, what about slots? Should we enforce that they end in ticks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need that as the number of ticks in a slot is something that's computed dynamically by the bank on each node. The incoming ledger data itself has no "slot marker".
eg,
Lines 807 to 810 in 5468be2
} else if current_tick_height % self.ticks_per_slot == 0 { | |
// Register a new block hash if at the last tick in the slot | |
Some(self.blockhash_queue.write().unwrap()) | |
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aeyakovenko, @rob-solana, maybe marking this type of failure as a dead slot isn't the correct approach? Summary of concerns here: #6498
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carllin so from your last comment here: #6498 (comment) is the conclusion that this PR is fine with the last entry check? Between #6498 and #6512 I think we're covered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jstarry So from my understanding, in this PR, the situation that will trigger BlockError::TrailingEntry
in both replay_stage
and blocktree_processor
:
Observed max_tick_height
, and the last entry was not a tick (extra trailing entry after the last tick)
This is a slightly larger set of conditions under which BlockError::TrailingEntry
should be triggered than what was proposed in #6512, which was:
Observed max_tick_height
, and the last tick shred was not marked with LAST_SHRED_IN_SLOT
.
Essentially the difference between the proposal and what's in this PR is, if the If the last tick shred was marked with LAST_SHRED_IN_SLOT
, this slot shouldn't be marked as dead, even if there are trailing entries (because there might be a subset of this slot transmission that reaches consensus). If the last tick shred wasn't marked with LAST_SHRED_IN_SLOT
, then this should be marked as dead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carllin the reason there's a separate issue for the "last tick needs to coincide with last shred" is that this PR doesn't cover it yet, and can land on its own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup agreed, just summarizing the difference for clarity.
Yes, my mistake, working on a fix now EDIT: Fixed |
ef84bdb
to
64e4727
Compare
e3a39e4
to
22cfa26
Compare
} | ||
|
||
#[test] | ||
fn test_dead_fork_invalid_slot_tick_count() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rob-solana in response to this comment: #6262 (comment)...
I have a test here for making sure the fork is marked as dead. Looks like mark_dead_slot
sets the BankProgress to dead as well as the blocktree slot 👍
694a3b3
to
05685bb
Compare
d5f8650
to
e1fa7dd
Compare
Hm CI says not so fast, investigating... |
wow @sagar-solana local-cluster catching things 😛 |
fad6bda
to
edf509b
Compare
edf509b
to
86545d6
Compare
Problem
We don't currently verify the number of ticks per block and the number of hashes per tick
Summary of Changes
create_ticks
to accept number of hashes per tickBlobError
and replace it withBlockError
BlocktreeProcessorError
Fixes #4282