Skip to content

fix(app): prune block headers and improve sync value handling - #210

Merged
mpoke merged 9 commits into
mainfrom
marius/sync-refactor
Feb 10, 2026
Merged

fix(app): prune block headers and improve sync value handling#210
mpoke merged 9 commits into
mainfrom
marius/sync-refactor

Conversation

@mpoke

@mpoke mpoke commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Return decoding errors instead of panicking in decode_value
  • Handle decode failures gracefully in on_process_synced_value by sending None reply
  • Treat invalid synced payloads as errors (since 2/3+ validators accepted them, failure indicates serious issues)
  • Ensure synced values are stored as undecided so on_decided() can retrieve block data
  • Add caching for earliest certificate and value heights to avoid repeated DB lookups
  • Fix unbounded growth of DECIDED_BLOCK_HEADERS_TABLE by pruning it alongside certificates
  • Expand store tests to verify block header pruning

Changes

Error handling improvements

  • decode_value now returns Result instead of unwrapping
  • replay_heights_to_engine propagates decode errors with context
  • on_process_synced_value sends None reply on decode failure instead of panicking

Sync value handling

  • Invalid synced payloads now return an error (indicates state divergence or Byzantine behavior)
  • Synced values are stored as undecided so block data is available when decided

Performance

  • Cache earliest_certificate_height and earliest_value_height in State
  • Cache is lazily loaded on first access and updated after pruning

Bug fix

  • DECIDED_BLOCK_HEADERS_TABLE is now pruned alongside certificates (was growing unbounded)

@mpoke
mpoke requested a review from a team as a code owner February 5, 2026 18:03
Comment thread app/src/app.rs
// This indicates a serious issue: 2/3+ validators accepted this value,
// but our validation failed. This suggests state divergence, execution
// client problems, or Byzantine behavior.
return Err(eyre::eyre!(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder whether the panic here is an attack vector on a node. Namely, if you send me an invalid proposal, instead of making it invalid, I crash here without holding you accountable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Malachite verifies the certificate before passing the proposal to the application. This means that a peer can only send an invalid proposal if it can create a valid certificate, which is only possible if more than 1/3 of the voting power is malicious.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok so indeed this is an invalid scenario, I checked malachite's code to make sure that the certificates are indeed validated before the value is validated (in a previous version, those validations were happening in parallel). So yes, this is a serious problem which should be cause a crash,

Comment thread app/src/app.rs
@mpoke
mpoke merged commit a4e9afa into main Feb 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants