create_triedb_key and create_range_key both silently return (vec![], 0) when key_nibbles.len() exceeds the bounds of the key and gets truncated into num_nibbles.
let num_nibbles: u8 = match key_nibbles.len().try_into() {
Ok(len) => len,
Err(_) => {
warn!("Key too big, returning an empty key");
return (vec![], 0); <-- returns an empty key
}
};
This is informational only since the nibble lengths currently stay within those bounds, but it could become a problem in the future. Failing explicitly rather than silently degrading would make this easier to catch early. One possible mitigation is to explicitly return an Error instead of the empty key.
key.rs#L148-L202
triedb_env.rs#L1075-L1103
create_triedb_keyandcreate_range_keyboth silently return(vec![], 0)whenkey_nibbles.len()exceeds the bounds of the key and gets truncated intonum_nibbles.This is informational only since the nibble lengths currently stay within those bounds, but it could become a problem in the future. Failing explicitly rather than silently degrading would make this easier to catch early. One possible mitigation is to explicitly return an Error instead of the empty key.
key.rs#L148-L202
triedb_env.rs#L1075-L1103