Repository navigation
fix: reject uint64 values above MAX_SAFE_INTEGER in UintNumberType deserialization - #564
Conversation
…` deserialization `UintNumberType(8)` decodes a uint64 into a `Number`, which rounds any value above `Number.MAX_SAFE_INTEGER`, so the decoded value no longer matches the encoded bytes. `fromJson` already throws for these values, deserialization now does the same. `2^64-1` still decodes to `Infinity` with `clipInfinity`.
The check now lives in `UintNumberType`, see ChainSafe/ssz#564. Validator identities type `activationEpoch` as `EpochInf` since a pending validator has `FAR_FUTURE_EPOCH`.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Performance Report✔️ no performance regression detected Full benchmark results
|
|
Follow-up from ChainSafe/lodestar#10688: on 348f94f the check covers const U = new UintNumberType(8);
const S = new ContainerType({x: U, slashings: new VectorBasicType(U, 4), balances: new ListUintNum64Type(16), scores: new ListBasicType(U, 16)});
// bytes: 2^53 + 1 as the first element of each array
S.deserialize(bytes); // throws "Invalid serialized number > MAX_SAFE_INTEGER"
S.deserializeToViewDU(bytes).slashings.get(0); // 9007199254740992
S.deserializeToViewDU(bytes).balances.get(0); // 9007199254740992
S.deserializeToViewDU(bytes).scores.get(0); // 9007199254740992In Lodestar these are One option that leaves reads untouched: in |
|
Thanks, reproduced. This is intended: the fix targets decoded values whose root no longer matches the bytes. Tree-backed packed arrays keep the original bytes, so their root stays exact. A load-time check would also reject values above 2^53 that a Number holds exactly. For example, Clarified the doc comment in 80f19b8. |
🤖 I have created a release *beep* *boop* --- <details><summary>ssz: 1.9.1</summary> ## [1.9.1](ssz-v1.9.0...ssz-v1.9.1) (2026-11-20) ### Bug Fixes * reject uint64 values above `MAX_SAFE_INTEGER` in `UintNumberType` deserialization ([#564](#564)) ([930bac4](930bac4)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ization (#10688) Bumps `@chainsafe/ssz` to 1.9.1, which includes ChainSafe/ssz#564 and makes `UintNumberType` reject uint64 values above `Number.MAX_SAFE_INTEGER` on deserialization instead of silently rounding them. Lodestar assumes `UintNum64` and `UintNumInf64` fields never exceed that limit, the remaining changes adapt to the stricter decoding. - type `activationEpoch` of validator identities as `EpochInf`, a pending validator has `FAR_FUTURE_EPOCH` - run `invalid_large_withdrawable_epoch` as an expected decode error instead of skipping it - decode `merkle_proof` vector inputs with bigint types, as the test already does for these vectors
UintNumberType(8)decodes a uint64 into aNumber, which rounds any value aboveNumber.MAX_SAFE_INTEGER, so the decoded value no longer matches the encoded bytes.fromJsonalready throws for these values to prevent precision errors downstream, deserialization now does the same.value_deserializeFromByteswhen the high 32 bits exceed0x1fffff,tree_deserializeFromBytesand container decoding go through the same check2^64-1still decodes toInfinitywithclipInfinityMAX_SAFE_INTEGERround trips and for rejected values, directly and as container fields