Skip to content

fix(codec): pad zero integers with zeros not sign extension - #493

Merged
dmitry123 merged 1 commit into
fix/audit-fixes-2026-augfrom
fix/int-zero-encoding
Aug 11, 2026
Merged

fix(codec): pad zero integers with zeros not sign extension#493
dmitry123 merged 1 commit into
fix/audit-fixes-2026-augfrom
fix/int-zero-encoding

Conversation

@d1r1

@d1r1 d1r1 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor
  • zero uint16..uint64 and int16..int64 stop encoding as 0xff padding
  • indexed event topics of zero values now match solidity
  • fixes FLU-1111
  • pins the rule against alloy-sol-types, not a self round-trip

Summary by CodeRabbit

  • Bug Fixes
    • Corrected integer encoding so negative values use sign extension, while zero and unsigned values use zero padding.
    • Fixed canonical zero encoding across supported integer types, alignments, byte orders, and widths.
    • Ensured zero-valued members remain correctly encoded in arrays and tuples, including dynamic and fixed-size containers.

- zero uint16..uint64 and int16..int64 stop encoding as 0xff padding
- indexed event topics of zero values now match solidity
- fixes FLU-1111, a bug predating the branch by 16 months
- pins the rule against alloy-sol-types, not a self round-trip
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Integer Padding Correction

Layer / File(s) Summary
Correct integer padding and primitive coverage
crates/codec/src/primitive.rs
Integer encoding uses 0xFF only for negative values and 0x00 for zero or unsigned values. Tests cover widths, byte orders, alignments, boundaries, and canonical zero encoding.
Topic and container regression coverage
crates/codec/tests/topic.rs
Topic tests cover zero padding, negative sign extension, positive boundaries, and zero-valued members in arrays and tuples.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: dmitry123

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main codec fix: zero integers use zero padding instead of sign extension.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/int-zero-encoding

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@d1r1

d1r1 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Criterion results (vs baseline)


running 131 tests


Heads-up: runner perf is noisy; treat deltas as a smoke check.

@dmitry123
dmitry123 merged commit 253f726 into devel Aug 11, 2026
16 checks passed
@dmitry123
dmitry123 deleted the fix/int-zero-encoding branch August 11, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants