Skip to content

fix: reduce notes limits to 100#1464

Merged
SantiagoPittella merged 4 commits intonextfrom
santiagopittella-reconsider-limits
Dec 19, 2025
Merged

fix: reduce notes limits to 100#1464
SantiagoPittella merged 4 commits intonextfrom
santiagopittella-reconsider-limits

Conversation

@SantiagoPittella
Copy link
Copy Markdown
Collaborator

This is a followup of #1443

In that PR the limits were generalized to 1000, but for notes it can exceed the maximum payload size.

Related to the docs:

Separately, it may be good to also include limits in the RPC endpoint docs. Let's create another issue for this (unless we already have one).

There is a draft to get the limits through a RPC call, so it could be documented in that endpoint. Should I add it anyways here? cc @bobbinth

@SantiagoPittella SantiagoPittella added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Dec 18, 2025
Copy link
Copy Markdown
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

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

LGTM. Something to keep in mind with the endpoint in terms of optimizing the bandwidth for the 4 MB limit is that the user could be querying for private notes, in which case the response size would be quite smaller since it would not contain note details (compared to the same amount of public notes), but I'm not sure we want to optimize it that much.

Comment thread crates/utils/src/limiter.rs Outdated
Co-authored-by: igamigo <ignacio.amigo@lambdaclass.com>
Copy link
Copy Markdown
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you! I left one small comment inline.

Comment thread crates/utils/src/limiter.rs Outdated
Comment on lines +87 to +88
/// The approximate maximum size for notes is around 32KB.
const LIMIT: usize = 100;
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.

I would maybe move the comment into the struct doc comments, and maybe expand it - e.g., "The limit is set to 100 notes to make sure that response size does not exceed 4 MB as note sizes are limited to 32 KB".

It may be nice to add similar comments to other structs here to make size assumptions explicit - but that could be done in a follow-up PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I did those changes in this PR

@SantiagoPittella SantiagoPittella merged commit 088b7ab into next Dec 19, 2025
6 checks passed
@SantiagoPittella SantiagoPittella deleted the santiagopittella-reconsider-limits branch December 19, 2025 13:50
Comment on lines +62 to 64
/// Capped at 1000 prefixes to keep queries and responses comfortably within the 4 MB payload
/// budget and to avoid unbounded prefix scans.
pub struct QueryParamNullifierPrefixLimit;
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.

It would be great to add the underlying assumptions to the comments explaining why 1000 is the right number. For example, 1000 prefixes could return a large number of nullifiers - but I think there is some pagination enforced where whatever is returned would still fit into 4 MB, right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's true for some of those endpoints, but does not apply to all of them since some are not paginated. I can add the approximation that was made to determine the limits

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.

For not-paginated ones we should also try to ensure that the response size does not exceed 4 MB. I think it would good to have documentation for every endpoint explaining how this limit is satisfied. This may highlight that we are not satisfying this limit somewhere.

The only endpoints that don't need that are the ones that are used for testing only (though, not sure if we have such user-facing endpoints).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants