-
Notifications
You must be signed in to change notification settings - Fork 103
Description
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:
miden-base/crates/miden-objects/src/transaction/proven_tx.rs
Lines 469 to 475 in 0f1ce86
| 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_hintstarting fromOutputNoterecursively for all contained types, e.g. forNote,PartialNote, etc. We should also add tests for at leastOutputNote::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.