Skip to content

fix(store): return error instead of asserting on unsupported nullifier prefix length#2317

Open
Ollie202 wants to merge 1 commit into
0xMiden:nextfrom
Ollie202:fix/store-prefix-len-error
Open

fix(store): return error instead of asserting on unsupported nullifier prefix length#2317
Ollie202 wants to merge 1 commit into
0xMiden:nextfrom
Ollie202:fix/store-prefix-len-error

Conversation

@Ollie202

@Ollie202 Ollie202 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #2290.

select_nullifiers_by_prefix at crates/store/src/db/models/queries/nullifiers.rs validated its prefix_len parameter with assert_eq!(prefix_len, 16, ...), which panics in release builds when called with any other value. The RPC handler (sync_nullifiers.rs) already guards this with a Status::invalid_argument, but the store function itself panicked on invalid input rather than returning an error, so any future caller or test that skips the RPC guard would hit a panic.

Change

  • Added a DatabaseError::UnsupportedNullifierPrefixLength { prefix_len } variant.
  • Replaced the assert_eq! with an early return Err(...), matching the existing InvalidBlockRange validation in the same function.

Testing

The store crate requires the RocksDB/libclang toolchain which isn't available in my local environment, so I'm relying on CI to compile. The change is a minimal, type-checked mirror of the adjacent InvalidBlockRange error path.

Changelog

[[entry]]
scope       = "internal"
impact      = "fixed"
description = "Return an error instead of panicking on an unsupported nullifier prefix length in the store."

@Ollie202 Ollie202 force-pushed the fix/store-prefix-len-error branch 2 times, most recently from 9f1afbd to 4d9fb08 Compare July 6, 2026 20:34
…ength

`select_nullifiers_by_prefix` used `assert_eq!(prefix_len, 16, ...)`,
which panics in release builds if called with any other value. The RPC
handler guards against this, but the store function panicked on invalid
input rather than returning an error. Return a new
`DatabaseError::UnsupportedNullifierPrefixLength` instead.

Closes 0xMiden#2290.
@Ollie202 Ollie202 force-pushed the fix/store-prefix-len-error branch from 4d9fb08 to 655029f Compare July 7, 2026 21:59
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.

store: assert_eq!(prefix_len, 16) panics in release builds on invalid prefix_len

1 participant