Skip to content

Restrict maximum OutputNote size #2195

@PhilippGackstatter

Description

@PhilippGackstatter

Right now, a note may have up to 1024 input elements (8KB), and we'll probably need to impose script size limit on a note, and we'll also soon have "note attachments", which we'll also probably limit to 8KB or 16KB.

Overall, maybe we impose a general limit on the size of a note to be something like 32KB. At this limit, we could allow up to 100 notes. So, let's reduce the limit on this endpoint to 100.

Originally posted by @bobbinth in 0xMiden/miden-node#1443 (comment)

I think this could be done similarly to enforcing AccountUpdateDetails size:

let account_update_size = account_update.details.get_size_hint();
if account_update_size > ACCOUNT_UPDATE_MAX_SIZE as usize {
return Err(ProvenTransactionError::AccountUpdateSizeLimitExceeded {
account_id,
update_size: account_update_size,
});
}

For this issue, I think we need to:

  • Add a note size constant in crates/miden-objects/src/constants.rs.
  • Implement get_size_hint starting from OutputNote recursively for all contained types, e.g. for Note, PartialNote, etc. We should also add tests for at least OutputNote::get_size_hint, making sure the size hint and the actual number of serialized bytes match.
  • Enforce size limit in OutputNotes::new.

Ultimately, I think we need to implement both account and note size restrictions in the tx kernel as well, though this can be done separately, together with the work on storage fees, since both will require computing the size of account deltas or notes in the kernl.

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomersrustIssues that affect or pull requests that update Rust code

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions