Skip to content

perf: share checksum cache across address casings and document checksum behavior - #5514

Merged
jxom merged 3 commits into
mainfrom
perf/address-checksum-cache
Nov 15, 2026
Merged

jxom merged 3 commits into
mainfrom
perf/address-checksum-cache

Conversation

@jxom

@jxom jxom commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Supersedes #5510 by @backseats, keeping their commit and adding review fixes on top.

checksumAddress now caches by the lowercase address (plus chainId), so every casing of an address shares one entry and one keccak. isAddress only touches its cache for the strict checksum comparison, keyed by the exact input, so a cached correct or lowercase form never makes a wrong-checksum input pass. Both LRUs stay at 8192 entries.

Follow-up commit:

  • Test that EIP-1191 checksums are cached separately from EIP-55 ones (dropping chainId from the cache key now fails a test).
  • Inline snapshots for the mixed-case isAddress cases.
  • Docs: all-uppercase addresses fail strict mode unless that is their checksummed form; getAddress and non-strict isAddress require the 0x prefix.

Rough benchmarks (median per op, main → this branch; Node via vitest, first-sight and getAddress→isAddress rows in Bun):

Scenario main branch
checksumAddress, 5k addresses × 4 casings 20.5 µs 0.3 µs
isAddress strict, 5k addresses × 4 casings 19.8 µs 3.4 µs
First sight of an address in 4 casings 14.7 µs 4.9 µs
isAddress(checksummed) after getAddress(lowercase) 14 µs 1 µs
checksumAddress, warm, 1k × 4 casings 450 300

backseats and others added 2 commits November 15, 2026 04:57
Pins that chain-specific checksums are cached separately from EIP-55
ones, snapshots the mixed-case isAddress cases, and corrects the docs on
all-uppercase addresses and the 0x prefix requirement.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1da0e-7acb-743d-adfc-a31e1e669eb6
Co-authored-by: jxom <[email protected]>
@vercel

vercel Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
viem Error Error Nov 15, 2026 5:16am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 461655c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T05:14:23.144548Z 461655c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jxom
jxom merged commit 9677703 into main Nov 15, 2026
35 of 37 checks passed
@jxom
jxom deleted the perf/address-checksum-cache branch November 15, 2026 05:15
@github-actions github-actions Bot mentioned this pull request Nov 15, 2026
jxom added a commit to wevm/ox that referenced this pull request Nov 15, 2026
…s.encodePacked` and `Address.checksum` (#684)

* fix: return false from the ERC-6492 validator when ecrecover yields the zero address

Ports wevm/viem#5468. ecrecover returns the zero address for a malformed signature, so the deployless validator accepted any such signature for the zero address. The bytecode is rebuilt from the updated UniversalSigValidator.sol with solc 0.8.26, 200 optimizer runs, the paris EVM version, and no metadata, which reproduces the previous constant from the previous source.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ddd3-d469-72eb-a88c-673c40859557
Co-authored-by: Amp <[email protected]>
Co-authored-by: jxom <[email protected]>

* fix: reject odd-length hex for bytes in AbiParameters.encodePacked

Ports the encodePacked half of wevm/viem#5466. An odd-length bytes value was concatenated as is, shifting every later value by a nibble. It now throws Hex.InvalidLengthError, matching AbiParameters.encode since #617; viem left-pads instead.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ddd3-d469-72eb-a88c-673c40859557
Co-authored-by: Amp <[email protected]>
Co-authored-by: jxom <[email protected]>

* perf: share the Address.checksum result across address casings

Ports wevm/viem#5514. The checksum depends only on the lowercase address, so a result computed for one casing is reused for the others instead of hashing again. main already does this.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ddd3-d469-72eb-a88c-673c40859557
Co-authored-by: Amp <[email protected]>
Co-authored-by: jxom <[email protected]>

---------

Co-authored-by: Amp <[email protected]>
Co-authored-by: jxom <[email protected]>

This branch had an error being deployed

1 failed deployment
Preview — 461655c4 Deployed Nov 15, 2026 by vercel[bot]
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.

3 participants