Skip to content

Commit efbce65

Browse files
committed
fix: hex-encode prefix in list_prefix to match hex-encoded storage keys
Keys are stored as hex::encode(raw_bytes) via build_challenge_storage_key, so the prefix scan must also hex-encode the prefix for matching to work.
1 parent 3fe5cf5 commit efbce65

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

bins/validator-node/src/challenge_storage.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,19 @@ impl StorageBackend for ChallengeStorageBackend {
173173
prefix: &[u8],
174174
limit: u32,
175175
) -> Result<Vec<(Vec<u8>, Vec<u8>)>, StorageHostError> {
176-
let prefix_bytes = if prefix.is_empty() {
176+
// Keys are stored hex-encoded (see build_challenge_storage_key),
177+
// so the prefix must also be hex-encoded for the scan to match.
178+
let hex_prefix = hex::encode(prefix);
179+
let prefix_filter: Option<&[u8]> = if prefix.is_empty() {
177180
None
178181
} else {
179-
Some(prefix)
182+
Some(hex_prefix.as_bytes())
180183
};
181184

182185
let result = tokio::task::block_in_place(|| {
183186
tokio::runtime::Handle::current().block_on(self.storage.list_prefix(
184187
challenge_id,
185-
prefix_bytes,
188+
prefix_filter,
186189
limit as usize,
187190
None,
188191
))

0 commit comments

Comments
 (0)