You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ethlambda-rpc tests fail in debug builds: u8 overflow in ptc.rs test state builder #786
60 ethlambda-rpc unit tests fail in debug builds with attempt to add with overflow. CI does not see it because tests run with the release-fast profile, where overflow checks are off.
Cause
crates/net/rpc/src/beacon/ptc.rs:574, in a test state builder:
for slot in0..inner.block_roots.len(){
inner.block_roots[slot] = H256::repeat_byte(slot asu8 + 1);}
block_roots has more than 255 entries, so at slot == 255 the expression slot as u8 + 1 overflows (255u8 + 1). In release it wraps silently, which also means the "distinct roots per slot" intent breaks after slot 255 (roots repeat).
Reproduce
cargo test -p ethlambda-rpc --lib
(debug profile) → 60 failures at ptc.rs:574. Same result on mainc3f5f56 and on #783.
Suggested fix
Use a root that stays distinct for every slot, e.g. H256::from_low_u64_be(slot as u64 + 1), or (slot as u8).wrapping_add(1) if distinctness beyond 255 doesn't matter. Consider running unit tests in debug (or with overflow-checks = true) in CI.
Activity