The map_entry_address function is not outputting the correct address when used on a serialized const array for a storage Map. Specifically, when using a custom Digest type (which is a [u32; 8]) with a .into() trait that outputs its content as a span of felts, the computed address is incorrect.
When running the following code:
let found_address = map_entry_address(selector!("blocks"), block1_digest.into());
let spann: Span<felt252> = block1_digest.into();
println!("serialized: {:?}", spann);
println!("selector: {}", selector!("blocks"));
println!("found_address: {:?}", found_address);
Both LegacyMap and Map agree with the documented address computation. The issue here is that Serde (used in your into implementation) adds a length prefix which messes up the hash.
Which component is your bug related to?
snforge
Foundry Version
snforge 0.31.0
What operating system are you using?
MacOS
What system architecture are you using?
arm
What happened
The
map_entry_address
function is not outputting the correct address when used on a serialized const array for a storageMap
. Specifically, when using a customDigest
type (which is a[u32; 8]
) with a.into()
trait that outputs its content as a span of felts, the computed address is incorrect.When running the following code:
The output is:
However, when printing the actual storage address in the contract:
The output is:
The
found_address
computed bymap_entry_address
should match theaddress
printed by the contract's storage pointer but it doesn't.Trait to serialize it:
Trace
No response
Is there an existing issue for this?