Skip to content

feat: seal verification + Heimdall span cache in BorConsensus#85

Merged
VAIBHAVJINDAL3012 merged 1 commit intomainfrom
feature/seal-verification-heimdall
Mar 11, 2026
Merged

feat: seal verification + Heimdall span cache in BorConsensus#85
VAIBHAVJINDAL3012 merged 1 commit intomainfrom
feature/seal-verification-heimdall

Conversation

@VAIBHAVJINDAL3012
Copy link
Copy Markdown
Contributor

Summary

  • Add compute_seal_hash() function that computes keccak256(RLP(header)) with the 65-byte seal stripped from extra data, matching Go Bor's SealHash behavior
  • Enhance BorConsensus with Mutex<SpanCache> and Mutex<Recents> for thread-safe validator set lookups and anti-double-sign tracking during block validation
  • Wire full seal verification into validate_block_pre_execution: ecrecover signer from seal, verify against authorized validator set from cached Heimdall spans, enforce anti-double-sign window
  • Expose insert_span() for eager span cache population from Heimdall before block validation
  • Add Debug derive to SpanCache

Architecture

  • Header validation (validate_header): structural checks only (sync-safe, no external state needed)
  • Block pre-execution (validate_block_pre_execution): full seal verification using cached spans
  • Span cache is populated eagerly by an external component before blocks reach consensus validation
  • If a span is not cached, validation logs a warning and skips signer authorization (graceful degradation during initial sync)

Test plan

  • All 201 tests pass across bor-consensus + heimdall-client
  • New compute_seal_hash determinism test
  • New seal hash round-trip test (sign → compute_seal_hash → ecrecover → verify signer)
  • Full workspace cargo check passes

🤖 Generated with Claude Code

- Add compute_seal_hash() to compute keccak256(RLP(header)) with the
  65-byte seal stripped from extra data, matching Go Bor's SealHash
- Enhance BorConsensus with Mutex<SpanCache> and Mutex<Recents> for
  thread-safe validator set lookups and anti-double-sign tracking
- In validate_block_pre_execution: ecrecover signer from seal, verify
  against authorized validator set from cached spans, enforce
  anti-double-sign window
- Expose insert_span() for eager span cache population from Heimdall
- Add Debug derive to SpanCache
- Add seal hash determinism and round-trip ecrecover tests
@VAIBHAVJINDAL3012 VAIBHAVJINDAL3012 merged commit d135236 into main Mar 11, 2026
2 of 3 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.

1 participant