Skip to content

feat(aztec-nr)!: embed BoundedVec max length in validation requests#23622

Merged
vezenovm merged 3 commits into
merge-train/fairiesfrom
nchamo/validation-requests-length
May 28, 2026
Merged

feat(aztec-nr)!: embed BoundedVec max length in validation requests#23622
vezenovm merged 3 commits into
merge-train/fairiesfrom
nchamo/validation-requests-length

Conversation

@nchamo
Copy link
Copy Markdown
Contributor

@nchamo nchamo commented May 28, 2026

Problem

NoteValidationRequest and EventValidationRequest contain a BoundedVec whose maxLen is needed for deserialization, but it was passed as a separate oracle parameter (maxNotePackedLen / maxEventSerializedLen). This meant that we can't build a self-contained TypeMapping for it, and we wouldn't be able to build auto generated mappings in the future

Fix

Each struct now includes its own max length field (max_note_packed_len / max_event_serialized_len) that is populated automatically via a new constructor from the compile-time constant. The TypeScript fromFields methods read the length from the field stream instead of taking it as a parameter, making them self-contained.

@nchamo nchamo requested a review from nventuro as a code owner May 28, 2026 14:14
@nchamo nchamo self-assigned this May 28, 2026
@nchamo nchamo changed the title refactor(aztec-nr)!: embed BoundedVec max length in validation requests feat(aztec-nr)!: embed BoundedVec max length in validation requests May 28, 2026
}

impl EventValidationRequest {
pub(crate) fn new(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new constructor, because it didn't make much sense to expose max_event_serialized_len

}

impl NoteValidationRequest {
pub fn new(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new constructor, because it didn't make much sense to expose max_note_packed_len

@nchamo nchamo requested a review from vezenovm May 28, 2026 14:43
Comment thread noir-projects/aztec-nr/aztec/src/messages/processing/event_validation_request.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/processing/note_validation_request.nr Outdated
'0x0000000000000000000000000000000000000000000000000000000000000002', // storage slot
'0x000000000000000000000000000000000000000000000000000000000000002a', // randomness
'0x0000000000000000000000000000000000000000000000000000000000000003', // note nonce
'0x0000000000000000000000000000000000000000000000000000000000000008', // max_note_packed_len
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BoundedVec serialization is already storage: [T; MaxLen] followed by len (looking at noir-projects/noir-protocol-circuits/crates/serde/src/type_impls.nr). Noir deserialization knows MaxLen from the type parameter and uses that layout to locate the trailing len, so the serialized value does not include the capacity (which is type information).

TS is working over raw fields and does not have the Noir type parameter MaxLen at runtime, but we should be able to infer it from the fields.length itself because the struct contains a single BoundedVec and it has known fixed fields before and after it.

We already have a shared type schema in the ABI. Longer term, this parser should use ABI type metadata for the struct layout when converting from fields.

For now, I do think we could get rid of this extra payload field. But ultimately, we should utilize the ABI here long-term.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed it offline, we will go with the approach in this PR for now

@nchamo nchamo requested a review from vezenovm May 28, 2026 16:48
@vezenovm vezenovm merged commit a42bff4 into merge-train/fairies May 28, 2026
14 checks passed
@vezenovm vezenovm deleted the nchamo/validation-requests-length branch May 28, 2026 17:39
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