fix(store): return error instead of asserting on unsupported nullifier prefix length#2317
Open
Ollie202 wants to merge 1 commit into
Open
fix(store): return error instead of asserting on unsupported nullifier prefix length#2317Ollie202 wants to merge 1 commit into
Ollie202 wants to merge 1 commit into
Conversation
9f1afbd to
4d9fb08
Compare
…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.
4d9fb08 to
655029f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2290.
select_nullifiers_by_prefixatcrates/store/src/db/models/queries/nullifiers.rsvalidated itsprefix_lenparameter withassert_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 aStatus::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
DatabaseError::UnsupportedNullifierPrefixLength { prefix_len }variant.assert_eq!with an earlyreturn Err(...), matching the existingInvalidBlockRangevalidation 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
InvalidBlockRangeerror path.Changelog