Skip to content

store: limit number of requested storage map keys / smt proofs returned#1517

Merged
drahnr merged 5 commits intonextfrom
bernhard-1514-smt-proof-limit
Jan 16, 2026
Merged

store: limit number of requested storage map keys / smt proofs returned#1517
drahnr merged 5 commits intonextfrom
bernhard-1514-smt-proof-limit

Conversation

@drahnr
Copy link
Contributor

@drahnr drahnr commented Jan 15, 2026

Closes #1514

Returns `LimitExceeded` when the number of requested keys exceeds
`MAX_SMT_PROOF_ENTRIES`.

Closes #1514
… proofs

When opening a storage map for specific keys, now returns all entries instead
of individual SMT proofs when the total proof nodes would exceed the number
of entries. This reduces response size and CPU cost.

Adds `StorageMapResponse` enum and `storage_map_response()` helper.
@drahnr drahnr requested a review from igamigo January 15, 2026 10:14
@drahnr drahnr merged commit 0cefaf6 into next Jan 16, 2026
7 checks passed
@drahnr drahnr deleted the bernhard-1514-smt-proof-limit branch January 16, 2026 17:05
Comment on lines +438 to +442
/// Maximum number of SMT proofs that can be returned in a single response.
///
/// This limit is more restrictive than [`Self::MAX_RETURN_ENTRIES`] because SMT proofs
/// are larger (up to 64 inner nodes each) and more CPU-intensive to generate.
pub const MAX_SMT_PROOF_ENTRIES: usize = 16;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also be checking this on the request side - i.e., if the user requests 1000 proofs, this should be rejected by the RPC rather than being forwarded to the store. And ideally we'd use the same constant in both places. Let's create an issue for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I just re-opened #1514.

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.

Limit number of SmtProofs in get_account API

3 participants