Skip to content

feat(api): additive API-consistency aliases, error taxonomy & events guarantee#4327

Open
gabrocheleau wants to merge 4 commits into
masterfrom
chore/api-consistency-aliases
Open

feat(api): additive API-consistency aliases, error taxonomy & events guarantee#4327
gabrocheleau wants to merge 4 commits into
masterfrom
chore/api-consistency-aliases

Conversation

@gabrocheleau

Copy link
Copy Markdown
Contributor

Summary

Harmonizes the public API across the active packages so they read as if written by one person. Fully additive — no existing export is renamed or removed; legacy names are kept and marked @deprecated (JSDoc only, no runtime warnings). A full audit of the current surface is added at docs/api-conventions-audit.md, and the conventions are documented in an new "API Conventions" chapter in DEVELOPER.md.

Construction / naming aliases

The monorepo-wide convention is the createX() factory. This aligns the holdouts and fixes one mis-ordered name:

  • tx — add createFeeMarket1559TxFromBytesArray; the existing create1559FeeMarketTxFromBytesArray (whose token order didn't match the FeeMarket1559Tx class or its sibling factories) is kept and deprecated.
  • binarytree — add createBinaryTreeFromProof to match createMPTFromProof; binaryTreeFromProof kept and deprecated.
  • common — add createCommon(opts) factory (the Common constructor stays fully supported).
  • statemanager — add createMerkleStateManager, createSimpleStateManager, createRPCStateManager, createStatefulBinaryTreeStateManager (constructors stay supported).

Errors

  • Add a shared structural contract EthereumJSErrorLike { readonly code: string } (defined in @ethereumjs/rlp, re-exported from @ethereumjs/util).
  • EVMError now exposes a stable machine-readable code (EVMErrorCode, e.g. EVM_OUT_OF_GAS) and conforms to the contract without being reparented onto the Error/EthereumJSError prototype chain — so instanceof EVMError keeps working. The message-only constructor still works; an explicit code can be passed as a second argument.
  • EthereumJSError now exposes code (mirrors type.code).
  • Remove the dead commented-out UsageError machinery in util/src/errors.ts.

Events

  • Document the always-defined events guarantee on EVM / VM / Blockchain (runtime already always-assigns it; the EVMInterface / BlockchainInterface types keep the optional typing for backwards compatibility). Typed event maps (EVMEvent, VMEvent, BlockchainEvent, CommonEvent) remain exported from each types.ts.

Tests

Per-package specs assert each new alias matches its legacy name (identical output / same class) and that events is always a defined EventEmitter.

Verification

  • Root npm run tsc clean (the only failures are the un-checked-out ethereum-tests / execution-spec-tests submodules, pre-existing and unrelated).
  • biome clean on all changed files; lint:diff green.
  • New + affected specs pass for tx, binarytree, common, statemanager, evm, vm, blockchain, rlp, util.

🤖 Generated with Claude Code

…guarantee

Harmonize the public API across the active packages. Fully additive: no existing
export is renamed or removed; legacy names are kept and marked `@deprecated`.

Naming/construction aliases (legacy kept + deprecated where a name was wrong):
- tx: add `createFeeMarket1559TxFromBytesArray` (deprecate the mis-ordered
  `create1559FeeMarketTxFromBytesArray`)
- binarytree: add `createBinaryTreeFromProof` (deprecate `binaryTreeFromProof`)
- common: add `createCommon(opts)` factory (constructor stays supported)
- statemanager: add `createMerkleStateManager`, `createSimpleStateManager`,
  `createRPCStateManager`, `createStatefulBinaryTreeStateManager`

Errors:
- add shared structural contract `EthereumJSErrorLike { readonly code: string }`
  (in rlp, re-exported from util)
- `EVMError` now exposes a stable `code` (`EVMErrorCode` map) and conforms to the
  contract without being reparented (keeps `instanceof EVMError` working)
- `EthereumJSError` exposes `code` (mirrors `type.code`)
- remove dead commented-out `UsageError` machinery in util/src/errors.ts

Events:
- document the always-defined `events` guarantee on EVM/VM/Blockchain (runtime
  already always-defines; interface types keep optional typing for compat)

Docs & tests:
- add docs/api-conventions-audit.md and an "API Conventions" chapter in DEVELOPER.md
- per-package specs asserting each alias matches its legacy name / always-defined events

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.91%. Comparing base (df11a68) to head (76c4d16).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 87.33% <ø> (ø)
blockchain 88.82% <ø> (ø)
common 93.46% <100.00%> (+0.02%) ⬆️
evm 59.15% <100.00%> (+0.06%) ⬆️
mpt 89.64% <ø> (-0.09%) ⬇️
statemanager 78.16% <100.00%> (+0.12%) ⬆️
static 90.37% <0.00%> (-0.98%) ⬇️
tx 87.83% <100.00%> (+0.02%) ⬆️
util 80.84% <100.00%> (+0.01%) ⬆️
vm 53.45% <ø> (ø)

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

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown

📦 Bundle Size Analysis

Package Size (min+gzip) Δ
binarytree 17.5 KB 🔴 +0.0 KB (+0.10%)
block 43.8 KB 🔴 +0.0 KB (+0.02%)
blockchain 69.9 KB ⚪ ±0%
common 25.4 KB 🔴 +0.0 KB (+0.09%)
devp2p 17.7 KB 🔴 +0.0 KB (+0.04%)
e2store 87.4 KB ⚪ ±0%
ethash 61.8 KB 🔴 +0.0 KB (+0.01%)
evm 64.8 KB 🔴 +0.1 KB (+0.15%)
genesis 272.2 KB ⚪ ±0%
mpt 21.9 KB 🔴 +0.0 KB (+0.03%)
rlp 1.7 KB 🔴 +0.0 KB (+0.46%)
statemanager 40.8 KB 🟢 -0.5 KB (-1.32%)
testdata 47.1 KB 🔴 +0.0 KB (+0.02%)
tx 20.9 KB 🔴 +0.0 KB (+0.14%)
util 14.2 KB 🔴 +0.0 KB (+0.05%)
vm 159.1 KB 🔴 +0.1 KB (+0.06%)
wallet 15.0 KB 🔴 +0.0 KB (+0.05%)

Values are minified+gzipped bundles of each package entry. Workspace deps are bundled; external deps are excluded.

Generated by bundle-size workflow

gabrocheleau and others added 3 commits June 14, 2026 13:20
Allowlist the technical term `reparent`/`reparented`/`reparenting` (cspell-ts +
cspell-md) and `epoc` (cspell-md, mirroring the existing ethash override; quoted
`getEpoc` export name). Reword two coinages in the audit doc (`subfolders` →
`subdirectories`, `undeprecated` → "not deprecated").

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant