Open dcposch opened 1 month ago
Do you know if this was always the case, or was there a regression in foundry or forge-std? The reverting values are actually 20 bytes long (40 hex chars), so my guess is that it's getting parsed as an address
cc @mattsse to assign someone to look into this :)
Regression. The test suite where we ran into this issue passed on an earlier version of forge-std
20 bytes
Yeah exactly, typo; fixed.
& yes: I think something internal is automatically parsing 20-byte hex as an address. If true, it's very similar to the the last bug we found in Foundry JSON handling: https://github.com/foundry-rs/foundry/issues/5808
Maybe a root cause fix: no automatic type inference. Users of stdJson
should always explicitly specify types + formats.
Looks like this is only happening on older forge-std versions
forge-std 1.2.0 does abi.decode(vm.parseJson(json, key), (bytes));
instead of vm.parseJsonBytes(json, key);
, so automatic coercion to address might cause errors during abi decoding. Not sure why it may have regressed, I think parseJson
always did that coercion?
Summary
stdJson appears to be broken in latest forge-std. Reading 20-byte values with
readBytes(json, path)
returns incorrect results or reverts.Versions
forge-std: v1.2.0
Minimal reproduction