Skip to content

refactor(storage): dedupe repeated u128 little-endian decode into a helper - #1585

Closed
minion1227 wants to merge 2 commits into
entrius:testfrom
minion1227:minion_dedupe_u128_decode
Closed

refactor(storage): dedupe repeated u128 little-endian decode into a helper#1585
minion1227 wants to merge 2 commits into
entrius:testfrom
minion1227:minion_dedupe_u128_decode

Conversation

@minion1227

Copy link
Copy Markdown
Contributor

Summary

The little-endian u128 reconstruction — lo, hi = struct.unpack_from('<QQ', data, offset) then lo + (hi << 64) — was repeated verbatim three times in storage_utils.py when decoding alpha_pool, bounty_amount, and target_bounty. This folds it into a single named _decode_u128le(data, offset) helper so the intent is explicit and the '<QQ' limb layout lives in one place.

Pure structural change — identical decoded values, and the struct.error/IndexError raised by struct.unpack_from still propagates to the same enclosing try/except as before.

The second commit is a one-line ruff format fix to submissions.py (pre-existing --all-files drift on test from the ruff 0.15.12 bump) so this PR's fork CI is green; no behavior change, happy to split it out if preferred.

Related Issues

None — small internal refactor.

Type of Change

  • Refactor (no functional change)

Testing

  • Full suite green (953 passed); ruff + pyright clean; pre-commit run --all-files passes.
  • No new tests needed: the existing round-trip tests in tests/utils/test_issue_competitions_storage_utils.py already exercise all three decode paths, including the nonzero-high-limb / max-u64 cases (test_decode_packed_contract_storage_handles_maximum_field_values).

Checklist

  • Code follows style guidelines (ruff/pyright clean)
  • Self-review performed
  • Tests added/updated (existing coverage confirmed)

The little-endian u128 reconstruction — `lo, hi = struct.unpack_from('<QQ',
data, offset)` then `lo + (hi << 64)` — was repeated verbatim three times
(alpha_pool, bounty_amount, target_bounty). Fold it into a named
_decode_u128le helper so the intent is explicit and the '<QQ' format lives
in one place. Behavior-preserving; already covered by the round-trip tests
in test_issue_competitions_storage_utils.py (incl. max-u64 high-limb cases).
Pre-existing drift on `test`: under the pinned ruff 0.15.12 the split
f-string in issues_submissions collapses onto one line. --all-files
surfaces it on any fork PR. No behavior change.
@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Code restructuring without behavior change label Jul 5, 2026
@anderdc anderdc closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants