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 all commits
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
19 changes: 19 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,25 @@ impl Client {
// wait for validation to finish.
self.send_state_witness_ack(&witness);

// Avoid processing 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(),
shard_id=witness.chunk_header.shard_id(),
witness_height=witness.chunk_header.height_created(),
final_height=final_head.height,
pugachAG marked this conversation as resolved.
Show resolved Hide resolved
"Skipping state witness below the last final block",
);
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