Skip to content

Add block context fields to TransportNote#81

Open
Dominik1999 wants to merge 3 commits intonextfrom
dominik1999-claude/block-context
Open

Add block context fields to TransportNote#81
Dominik1999 wants to merge 3 commits intonextfrom
dominik1999-claude/block-context

Conversation

@Dominik1999
Copy link
Copy Markdown
Contributor

@Dominik1999 Dominik1999 commented Apr 23, 2026

Summary

  • Added optional commitment_block_num and note_metadata fields to TransportNote proto
  • New DB migration adds nullable columns for block context
  • Updated models, types, and gRPC handlers to pass through block context
  • Backward-compatible: old clients unaffected (fields are proto3 optional)
  • Uses i64/BigInt for DB storage to support full u32 block number range
  • Includes note_metadata in payload size validation

This PR ships the proto + storage primitive only. The NTL is intentionally lean: it stores whatever the sender provides verbatim, with no validation, backfill, or chain awareness. The policy of when and how to populate the new fields lives entirely on the sender (see proto doc comments for strategies).

Client-side follow-up: 0xMiden/miden-client#2108 - consume the new fields to eliminate the note sync race condition. The current client-side workaround is a 20-block lookback window.

Test plan

  • make test passes (15/15, including 2 new tests)
  • make lint passes
  • Proto regeneration produces correct bindings with docstrings
  • Round-trip test: store with block context, fetch back, verify through proto conversion
  • Boundary test: u32::MAX survives the u32 -> i64 -> u32 round-trip
  • Conversion guard test: out-of-range i64 returns DatabaseError, not panic
  • Old clients work (fields are proto3 optional)
  • SendNote accepts optional block context
  • FetchNotes/StreamNotes return block context when present

🤖 Generated with Claude Code

Closes #68

claude added 2 commits April 23, 2026 08:37
- Add optional commitment_block_num and note_metadata to TransportNote proto
- New DB migration adds nullable columns for block context
- Update models, types, and gRPC handlers to pass through block context
- Backward-compatible: old clients unaffected (fields are proto3 optional)

Enables clients to resolve on-chain note commitments deterministically,
eliminating the race condition where fast-syncing clients could
permanently miss a note's commitment block.

Closes #68

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Use i64/BigInt for commitment_block_num DB column to support full u32 range
- Return DatabaseError instead of panicking on invalid block number reads
- Include note_metadata in payload size validation check
- Fix clippy lints (doc backticks, redundant closure)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@Dominik1999 Dominik1999 added this to the Release v0.4.0 milestone Apr 23, 2026
- Expand proto doc comments for commitment_block_num and note_metadata
  with detailed sender-policy documentation (exact, lower bound, unset)
- Regenerate proto bindings with updated docstrings
- Add round-trip test: store with block context, fetch, verify through
  proto conversion, including u32::MAX boundary
- Add conversion guard test in models.rs: verify out-of-range i64 values
  return DatabaseError instead of panicking

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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.

NTL should include block context to prevent client sync race condition

2 participants