Repository navigation
Conversation
…elete formatTransaction leaves fields a transaction type does not have out of the copy instead of deleting them, so results stay fast-properties objects. Fee fields are still parsed for every type, so errors are unchanged. The OP Stack, Celo, and zkSync block formatters format each transaction once and pass formatBlock an empty list, in the same order of errors as before. Co-authored-by: jxom <[email protected]> Amp-Thread-ID: https://ampcode.com/threads/T-01a1e1b3-ce83-72d3-b448-f29dd09b6e57
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 40b621a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Published pnpm add viem@pr-5540
pnpm add [email protected] |
|
Bundled into #5543 as its own commit, so this PR is superseded. Closing in favour of the bundle. |
Speeds up block and transaction formatting (B4 from the perf audit). Outputs and errors are unchanged.
Changes
formatTransactionno longer usesdelete. Deleting properties pushed every legacy, EIP-2930 and EIP-1559 result into dictionary mode. Fields a type doesn't have are now left out with object rest destructuring, and the result is built as one object literal.__proto__key.maxFeePerBlobGason a legacy transaction still throws.yParityis only assigned for non-legacy types.%HasFastPropertiesis nowtruefor the results of every type. Onmainit wasfalsefor legacy, 2930 and 1559.formatBlockand again in the chain override. They now followsrc/tempo/Formatters.ts.formatBlockgetstransactions: [].formatZksyncTransaction, shared bydefineTransactionand the block formatter.{ exclude: undefined, format, type: 'block' }shapedefineBlockreturns, soextractChain/ client resolver snapshots are unchanged.src/utils/formatters/block.bench.tswith deterministic 300-transaction blocks forformatBlockand each chain, plusformatTransactionper type.Benchmarks
SKIP_GLOBAL_SETUP=true ./node_modules/.bin/vitest bench -c ./test/vitest.config.ts --project core --run src/utils/formatters/block.bench.ts,origin/mainvs this branch (ops/s):formatBlock, 300 txsformatTransactionlegacyformatTransactionEIP-1559Memory, 300-tx block (
node --expose-gc):formatBlockRetention drops because fast-properties objects are much smaller than dictionary-mode ones.
Correctness
origin/main: a scratch harness compared values, key order, error class and message against copies of theorigin/mainmodules. It coveredformatTransaction,formatBlock, and the OP Stack, Celo and zkSync block and transaction formatters. Inputs included every type, missing and malformed fields, own__proto__keys, symbol keys and shuffled key order. 5 seeds, all 8 comparisons identical.transaction.test.ts, with snapshots written againstorigin/main:__proto__keysrc/utils/formatters,getBlock,getTransaction,src/utils/chain,createClientResolverandsrc/zksyncpass (75 files, 261 tests).coreproject. I ran them with a temporary config and they fail identically onorigin/main: the OP Stack ones because of fork snapshots with staleblockTimestamp, and Celotransaction > actionbecause the live Celo RPC now returnschainId: nullfor that transaction.tsconsrcpasses, and so do the touched tests and bench.Size
Local
size-limitdeltas are small, at most +140 B onviem/chains, and stay under the current limits. Other perf PRs (#5525, #5532, #5533, #5539) bump the same limits, so whichever lands later may need a rebase there.