Skip to content

lean_da: commit returns a typed error on a bad payload size (public API) - #705

Closed
tcoratger wants to merge 1 commit into
mainfrom
lean-da-commit-result
Closed

tcoratger wants to merge 1 commit into
mainfrom
lean-da-commit-result

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

Summary

Public API change. leanvm::lean_da::commit panicked on an empty payload, a partial blob, or more than DA_MAX_ROWS blobs, and its docs said nothing about it. A user computing the root they expect hit the panic, while aggregate checks the same rule and returns AggregationError::InvalidBlobSize. It now returns a typed error:

pub fn commit(rows: &[u64]) -> Result<(Hash, DaWitness), BlobSizeError>
pub struct BlobSizeError { pub symbols: usize }  // Display + Error, re-exported as leanvm::lean_da::BlobSizeError
input to commit before after
empty panic Err(BlobSizeError { symbols: 0 })
one symbol short of a blob, or one past it panic Err(..)
one blob past DA_MAX_ROWS panic Err(..)
whole blobs within the limit (root, witness) Ok((root, witness)), same root
  • One size check, checked_row_count, now backs both the error and the internal asserts. encode_rows and commit_codewords stay prover-internal, still assert, and now document it under # Panics.
  • aggregate drops its own copy of the rule and maps the commit's error through From<BlobSizeError> for AggregationError to the same InvalidBlobSize { symbols }. The order of its checks is unchanged (rate, then TooLarge, then the blob size), and an empty blobs still means a node with no DA payload.

Checks

  • New commit_rejects_payloads_that_are_not_whole_blobs_within_the_limit: red (a panic in encode_rows) with the check removed, green with it.
  • api.rs: checks the exact error of a partial blob through the public re-export.
  • cargo test --release -p lean_da -p rec_aggregation -p leanvm, clippy and rustdoc: pass. An independent review found no correctness issue, and its doc and duplication notes are applied.
  • No performance claim.

🤖 Generated with Claude Code

`lean_da::commit`, re-exported as `leanvm::lean_da::commit`, panicked on an empty payload, a partial blob, or more than `DA_MAX_ROWS` blobs, with no `# Panics` section, while `aggregate` checked the same size and returned `AggregationError::InvalidBlobSize`.

Public API change, kept minimal: `commit` now returns `Result<(Hash, DaWitness), BlobSizeError>`, and `BlobSizeError { symbols }` (std `Display` and `Error`, like `AggregationError`) is re-exported from `leanvm::lean_da`. Callers add `.unwrap()` or `?`; nothing else in the public surface moves.

- One size check, `checked_row_count`, behind both the error and the prover-internal asserts: `encode_rows` and `commit_codewords` keep panicking on a bad size and document it under `# Panics`.
- `aggregate` drops its own copy of the check and maps the commit's error to the unchanged `InvalidBlobSize { symbols }`; an empty `blobs` still means a node without DA.
- Negative tests: each rejected size (empty, one symbol short of and past a blob, one blob past the limit) returns the error with its length, and the api test checks a partial blob through the public re-export.

No proof, transcript or commitment changes: the lean_da, rec_aggregation and leanvm tests pass unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TomWambsgans added a commit that referenced this pull request Nov 8, 2026
…icking (#705)

Co-Authored-By: Thomas Coratger <60488569+tcoratger@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TomWambsgans

Copy link
Copy Markdown
Collaborator

merged here d3dcf43

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