Skip to content

chore: bump @ethereumjs/tx to v5 - #321

Merged
cryptodev-2s merged 1 commit into
mainfrom
migrate/pr2g-ethereumjs
Sep 10, 2026
Merged

chore: bump @ethereumjs/tx to v5#321
cryptodev-2s merged 1 commit into
mainfrom
migrate/pr2g-ethereumjs

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Top of stack #315, on #320. Last of the PR#2 bumps.

Dep From To
@ethereumjs/tx ^4.2.0 ^5.4.0

This is not breaking, but only because of a one word change

The bump compiles with no source change at all, which is the trap. @ethereumjs/tx@5 reuses the name TxData for something entirely different:

// v4
interface TxData { nonce?, gasPrice?, gasLimit?, to?, value?, data?, v?, r?, s? }

// v5
interface TxData {
  [TransactionType.Legacy]: LegacyTxData;
  [TransactionType.AccessListEIP2930]: AccessListEIP2930TxData;
  ...
}

v4's meaning is now called LegacyTxData. keyring.ts declares signTransaction as returning Promise<TxData>, so bumping alone would silently change that public type from "a signed legacy transaction" into "an object carrying every transaction type at once", and still build clean.

Typechecking a v4 era consumer against the unpatched build confirms it:

Type '{ nonce, gasPrice, gasLimit, to, value, data, v, r, s }' is missing the following
properties from type 'TxData': [TransactionType.Legacy], [TransactionType.AccessListEIP2930], ...

Mapping TxData to LegacyTxData restores the original contract exactly, and that same consumer typechecks again.

TypedTxData would also accept it, but it is a union, so callers would have to narrow the result. LegacyTxData keeps the API identical to v4.

Note Keyring is already deprecated in favour of @metamask/keyring-utils, so the blast radius is small either way.


Note

Medium Risk
Touches transaction typing on a deprecated but public Keyring API; the explicit LegacyTxData fix avoids a silent type break, but downstream packages must align with @ethereumjs/tx v5.

Overview
Upgrades @ethereumjs/tx from ^4.2.0 to ^5.4.0 (with transitive bumps to @ethereumjs/common, util, rlp, and related crypto packages in the lockfile).

Because v5 redefines TxData as a per–transaction-type map instead of a single legacy field bag, the deprecated Keyring.signTransaction return type is updated from Promise<TxData> to Promise<LegacyTxData>, preserving the same runtime shape and v4-era TypeScript contract for consumers. No implementation changes are required for keyring authors.

Reviewed by Cursor Bugbot for commit 7d78cba. Bugbot is set up for automated code reviews on this repo. Configure here.

@socket-security

socket-security Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​ethereumjs/​tx@​4.2.0 ⏵ 5.4.0100 +110010090 -170

View full report

@socket-security

socket-security Bot commented Sep 4, 2026

Copy link
Copy Markdown

Warning

MetaMask internal reviewing guidelines:

  • Do not ignore-all
  • Each alert has instructions on how to review if you don't know what it means. If lost, ask your Security Liaison or the supply-chain group
  • Copy-paste ignore lines for specific packages or a group of one kind with a note on what research you did to deem it safe.
    @SocketSecurity ignore npm/PACKAGE@VERSION
Action Severity Alert  (click "▶" to expand/collapse)
Warn Medium
Network access: npm @ethereumjs/util in module globalThis["fetch"]

Module: globalThis["fetch"]

Location: Package overview

From: package.jsonnpm/@ethereumjs/tx@5.4.0npm/@ethereumjs/util@9.1.0

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@ethereumjs/util@9.1.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch 2 times, most recently from 33fab99 to d1ea1a7 Compare September 7, 2026 12:31
@cryptodev-2s
cryptodev-2s removed this pull request from stack #329 September 9, 2026 11:46
@cryptodev-2s
cryptodev-2s added this pull request to stack #331 September 9, 2026 11:47
@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch from d1ea1a7 to 0a2afb5 Compare September 9, 2026 16:09
@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch 2 times, most recently from a050878 to d6b02aa Compare September 9, 2026 16:32
@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch from d6b02aa to 6f38d4e Compare September 9, 2026 18:31
@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch from 6f38d4e to e72ff48 Compare September 9, 2026 18:47
Mrtenz
Mrtenz previously approved these changes Sep 10, 2026
@cryptodev-2s
cryptodev-2s dismissed Mrtenz’s stale review September 10, 2026 10:15

The merge-base changed after approval.

@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch from e72ff48 to 580b594 Compare September 10, 2026 10:15
@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch from 580b594 to 35af8e3 Compare September 10, 2026 10:28
@cryptodev-2s
cryptodev-2s removed this pull request from stack #331 September 10, 2026 10:40
@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch from 35af8e3 to a39b3bc Compare September 10, 2026 10:40
@cryptodev-2s
cryptodev-2s changed the base branch from migrate/pr2f-tsbridge to migrate/pr2e-jest30 September 10, 2026 10:40
@cryptodev-2s
cryptodev-2s added this pull request to stack #335 September 10, 2026 10:41
@cryptodev-2s
cryptodev-2s requested a review from Mrtenz September 10, 2026 10:46
@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch from a39b3bc to 76cdf67 Compare September 10, 2026 12:46
stack merge was automatically disabled September 10, 2026 13:02

Pull Request is not mergeable

@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch from 76cdf67 to 1de0a93 Compare September 10, 2026 13:03
Base automatically changed from migrate/pr2e-jest30 to main September 10, 2026 13:08
  @ethereumjs/tx  ^4.2.0 -> ^5.4.0

The bump compiles with no source change, which is exactly the trap here.
@ethereumjs/tx@5 reuses the name TxData for something entirely different:

  v4  TxData  = a legacy transaction data object
  v5  TxData  = { [TransactionType.Legacy]: LegacyTxData, [AccessListEIP2930]: ..., ... }

v4's meaning is now called LegacyTxData. Since keyring.ts declares
signTransaction as returning Promise<TxData>, the bump alone would silently
change that public type from "a signed legacy transaction" to "an object
carrying every transaction type at once", and still build clean.

Confirmed by typechecking a v4 era consumer against the unpatched build:

  Type '{ nonce, gasPrice, gasLimit, to, value, data, v, r, s }' is missing
  the following properties from type 'TxData': [TransactionType.Legacy],
  [TransactionType.AccessListEIP2930], ...

Mapping TxData to LegacyTxData restores the original contract exactly, so
the same consumer typechecks again and the bump is not breaking. TypedTxData
would also accept it, but it is a union, so callers would have to narrow the
result. LegacyTxData keeps the API identical to v4.
@cryptodev-2s
cryptodev-2s force-pushed the migrate/pr2g-ethereumjs branch from 1de0a93 to 7d78cba Compare September 10, 2026 13:08
@cryptodev-2s
cryptodev-2s merged commit 300b7c1 into main Sep 10, 2026
22 checks passed
@cryptodev-2s
cryptodev-2s deleted the migrate/pr2g-ethereumjs branch September 10, 2026 13:15
cryptodev-2s added a commit that referenced this pull request Sep 10, 2026
Top of stack #315, on #321.

`yarn test:types` runs bare `tsd`, which finds **no test files at all**.
It produces no output and exits 0 regardless, so the 460 lines of type
assertions across `src/*.test-d.ts` have not been checking anything.

Proof, before this change:

```
$ printf 'expectAssignable<Hex>(999);' >> src/hex.test-d.ts
$ yarn test:types
$ echo $?
0
```

Pointing tsd at the files explicitly reports it properly and exits 1:

```
✖  Argument of type 999 is not assignable to parameter of type `0x${string}`.
```

## Cause

tsd resolves test files relative to the `types` field, which has pointed
at `./dist/index.d.cts` since ts-bridge was adopted in #182
(2024-04-23). tsd 0.29 does not resolve `.d.cts`, and the
`tsd.directory` setting does not compensate. **26 releases** have
shipped since, all with this check silently passing.

## Fix

```diff
- "test:types": "tsd"
+ "test:types": "tsd --files 'src/*.test-d.ts'"
```

Fixing the invocation rather than the `types` field, since the field is
correct for consumers and only tsd is confused by it.

All four files pass once actually executed, so none of them needed
changing. `yarn test:types` now exits 1 on a bad assertion and 0 when
clean.

## Relevance to the migration

This was found while working out what to do with tsd in Phase B, since
core has no way to run it. Worth knowing the honest baseline before
deciding: these assertions have been dormant for 17 months, so whatever
we do with them in core, we are not losing coverage we currently have.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Only the npm script for type testing changed; runtime package behavior
and public types are unchanged.
> 
> **Overview**
> **`yarn test:types` was a no-op:** bare `tsd` never picked up the
`src/*.test-d.ts` suites (because of how it resolves files vs the
package `types` entry), so type assertions could fail silently while CI
still exited 0.
> 
> The script now runs **`tsd --files 'src/*.test-d.ts'`**, so those
assertions actually execute and **`yarn test:types` fails when a type
check is wrong**. No changes to the test files themselves were required
once they were being run.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
b934063. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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.

2 participants