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

feat: skip processing old state witnesses #11081

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions chain/client/src/stateless_validation/chunk_validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,24 @@ impl Client {
// wait for validation to finish.
self.send_state_witness_ack(&witness);

// Avoid validating state witness for old chunks.
// In particular it is impossible for a chunk created at a height
// that doesn't exceed the height of the current final block to be
// included in the chain. This addresses both network-delayed messages
// as well as malicious behavior of a chunk producer.
if let Ok(final_head) = self.chain.final_head() {
if witness.chunk_header.height_created() <= final_head.height {
tracing::debug!(
target: "stateless_validation",
chunk_hash=?witness.chunk_header.chunk_hash(),
witness_height=witness.chunk_header.height_created(),
final_height=final_head.height,
pugachAG marked this conversation as resolved.
Show resolved Hide resolved
"Skipping old state witness",
Copy link
Contributor

@tayfunelmas tayfunelmas Apr 16, 2024

Choose a reason for hiding this comment

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

maybe expand this string to say skipping old state witness generated for already final blocks? (as what "old" witness means may not be clear)

);
return Ok(());
}
}

match self.chain.get_block(witness.chunk_header.prev_block_hash()) {
Ok(block) => self.process_chunk_state_witness_with_prev_block(
witness,
Expand Down
Loading