Skip to content

Conversation

@gabrocheleau
Copy link
Contributor

@gabrocheleau gabrocheleau commented Nov 27, 2025

This PR:

Summary of the decisions and rationale (relevant with regards to our previous discussion on #3180 @jochem-brouwer )

  • bigIntToBytes(0n)

    • Keep returning [0].
    • Use bigIntToUnpaddedBytes when an empty array is desired.
    • [0] = “the number zero”, [] = “empty/absence”; semantically distinct and encoded differently in RLP.
  • setLengthLeft truncation behavior

    • Default: throw if truncation would occur.
    • Add an explicit allowTruncate option to opt into truncation.
    • A padding helper should not silently lose data; callers must explicitly choose left vs right truncation.
  • bytesToBigInt([])

    • Keep returning 0n.
    • Treat empty bytes as zero and preserve roundtrips with bigIntToUnpaddedBytes.
  • Runtime type checks

    • Add an assertIsBytes() helper (checking instanceof Uint8Array) and use it in bytesToBigInt and other bytes-accepting functions.
  • Mutation bug in bytesToBigInt

    • Fix by using .slice().reverse() instead of .reverse() directly on the input.

@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.58%. Comparing base (0430b7e) to head (09c1562).

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 88.44% <ø> (ø)
blockchain 88.85% <ø> (ø)
common 93.38% <ø> (ø)
evm 62.01% <ø> (ø)
mpt 90.11% <ø> (ø)
statemanager 78.10% <ø> (ø)
static 91.35% <ø> (ø)
tx 88.01% <ø> (ø)
util 85.07% <91.66%> (+0.12%) ⬆️
vm 65.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Nov 27, 2025

📦 Bundle Size Analysis

Package Size (gzip) Δ
binarytree 30.1 KB ⚪ ±0%
block 45.4 KB ⚪ ±0%
blockchain 52.4 KB ⚪ ±0%
client 181.7 KB ⚪ ±0%
common 44.9 KB ⚪ ±0%
devp2p 76.4 KB ⚪ ±0%
e2store 30.3 KB ⚪ ±0%
ethash 8.4 KB ⚪ ±0%
evm 201.4 KB ⚪ ±0%
genesis 519.5 KB ⚪ ±0%
mpt 55.1 KB ⚪ ±0%
rlp 7.2 KB ⚪ ±0%
statemanager 57.2 KB ⚪ ±0%
testdata 60.2 KB ⚪ ±0%
tx 87.0 KB ⚪ ±0%
util 62.1 KB 🔴 +0.3 KB (+0.44%)
vm 61.3 KB ⚪ ±0%
wallet 14.0 KB ⚪ ±0%

Generated by bundle-size workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mutation bug in bytesToBigInt Improve BigInt<>Bytes conversion helpers test coverage & address edge case issues

2 participants