Repository navigation
perf(0.x): backport hot-path regexes and signature hash cache - #571
Merged
Merged
Conversation
Backports #569 and #570 from main. #569: Regex literals inside a function body allocate a fresh RegExp on every evaluation. Move the ones on hot validation paths to module scope: `Hex.assert` (strict), `Value.format`/`Value.from`, `TypedData` type dependency and field validation, `Siwe.isUri`, frame nonce RPC decoding, and the integer and fixed-bytes checks in ABI overload resolution. All of them are non-global and non-sticky, so sharing them holds no `lastIndex` state. `isArgOfType` also reads the integer bit size from the integer type regex capture instead of running a second `replace` regex. 0.x has no `ox/zod` entrypoint, and keeps its own `Value.from` decimal pattern, so behavior is unchanged. #570: `AbiItem.getSignatureHash` keccak-hashed the signature on every call for ABI items without a precomputed `hash`. Memoize the hash in a bounded (8192-entry) LRU map keyed by the normalized signature string, next to the checksum cache in a new `internal/caches.ts`, so `Caches.clear()` resets it. Only `Caches.checksum` stays public. 0.x has no `Engine`, so keccak256 cannot be swapped and the engine test is not ported.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Published pnpm add ox@pr-571
pnpm add [email protected] |
Merged
gakonst
added a commit
to tempoxyz/accounts
that referenced
this pull request
Nov 3, 2026
Updates `ox` from 0.14.59 to 0.14.62 (`legacy-v0`, published 2026-11-03T04:23:31Z). The catalog, the override and the package's own dependency range all change. The range goes from `~0.14.59` to `~0.14.62`, so this adds a patch changeset. Follows #943, which updated Viem. ## What 0.14.62 brings - wevm/ox#571 backports #569 and #570: - `Hex.assert`, `Value`, `TypedData`, `Siwe.isUri` and ABI overload resolution reuse module-level regular expressions instead of building new ones on every call. - `AbiItem.getSignatureHash` and `AbiItem.getSelector` cache signature hashes in a bounded cache that `Caches.clear` resets. So do the selector lookups in `AbiItem.fromAbi`, `AbiFunction.decodeData`, `AbiEvent.decodeLog` and `AbiEvent.extractLogs`. - wevm/ox#565: `AbiEvent.decode` and `AbiEvent.encode` handle anonymous events. The range also picks up 0.14.60 and 0.14.61. The `eth_fillTransaction` result `tx` is now typed as a `OneOf` union. `AbiItem.fromAbi` throws `AmbiguityError` for overloads it can't tell apart. `AbiParameters.decode` checks integer ranges and address padding. Envelope `assert` rejects a tip above a zero `maxFeePerGas`. `TypedData` validates types more strictly. `KeyAuthorization` `isAdmin` is deprecated for TIP-1137. None of these needed changes here, and every suite passes unchanged. ## Lockfile As in #943, the lockfile is edited directly, because a full resolution adds a real `[email protected]` peer. Only the `ox` entries change: the version, the integrity, and the specifiers set by the override. `ox` 0.14.62 has the same dependencies as 0.14.59. It isn't a peer of any package, so no hashed peer suffix includes it. `ox` is excluded from `minimumReleaseAge`. ## Validation - `pnpm install --frozen-lockfile` from empty `node_modules`: passed. - `pnpm check:types`: passed. - `pnpm check`: 0 errors; the 5 warnings are already on `main`. - `pnpm build`: passed. - `pnpm test --project lib/pure --reporter=dot`: 50 files, 889 tests passed. - `VITE_NODE_ENV=localnet VITE_NODE_TAG=latest pnpm test --project lib/localnet --reporter=dot --maxWorkers=4` against `ghcr.io/tempoxyz/tempo:latest` in OrbStack: 10 files, 658 tests passed.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports #569 and #570 from
mainto0.x, so the0.14.xline (legacy-v0) gets them.#569: hoist per-call regular expressions in hot validation paths
Regex literals inside a function body allocate a fresh
RegExpon every evaluation. This moves the ones on hot validation paths to module scope:Hex.assert(strict),Value.format/Value.from,TypedDatatype dependency and field validation,Siwe.isUri, frame nonce RPC decoding, and the integer and fixed-bytes checks in ABI overload resolution (isArgOfType). None is global or sticky, so sharing them holds nolastIndexstate.isArgOfTypereads the integer bit size from the integer type regex's capture instead of running a secondreplace.Differences from
main:ox/zodentrypoint, so those schema changes don't apply.Siwehas noisAuthorityhelper, so only theisUriandsplitUriregexes move.Value.fromkeeps 0.x's own decimal pattern (/^(-?)([0-9]*)\.?([0-9]*)$/), now hoisted, so its accepted inputs don't change.main,isArgOfTypealready had module-levelintegerTypeRegex/fixedBytesTypeRegex. 0.x had inline literals, so this PR hoists both.#570: cache signature hashes by normalized signature
AbiItem.getSignatureHashkeccak-hashed the signature on every call for ABI items without a precomputedhash. Selector lookups call it for every item they compare:AbiItem.fromAbiwith a selector,AbiFunction.decodeDatawith an ABI, andAbiEvent.decodeLog/AbiEvent.extractLogsfor each log. The hash is now memoized in a bounded (8192-entry) map keyed by the normalized signature string. The map sits next to the checksum cache in a newinternal/caches.ts, soCaches.clear()resets it. OnlyCaches.checksumstays public.Differences from
main:LruMap(the same class as the checksum cache) rather thanmain'sBoundedMap.Engine, so keccak256 can't be swapped and the engine-change test isn't ported. The normalized-signature andCaches.cleartests are ported.Public API is unchanged. Each change has its own patch changeset.
Local checks
pnpm check:types: passedpnpm check:tsdoc: passedbiome checkon the changed files, plus thepnpm checkpre-commit hook: passedvitest --project coreonAbiItem,Caches,Hex,Siwe,TypedDataandValue: 378 tests passedcore,tmp_framesandtempo-unitprojects: everything passed except the Anvil fork network tests (RPC,Provider, transaction envelopes,AbiEvent/AbiErrornetwork cases). WithoutVITE_ANVIL_FORK_URLthose get HTTP 400s or time out against the public fallback RPC, so CI is the check for them.