Skip to content

fix: detect state overrides that set the same account with different address casing - #5604

Merged
jxom merged 1 commit into
wevm:mainfrom
mortezashojaei:fix/state-override-address-casing
Nov 19, 2026
Merged

jxom merged 1 commit into
wevm:mainfrom
mortezashojaei:fix/state-override-address-casing

Conversation

@mortezashojaei

Copy link
Copy Markdown
Contributor

serializeStateOverride detects an account that is set more than once by looking up the exact address string, but it accepts addresses in any casing (isAddress(address, { strict: false })). A checksummed address and its lowercase form were treated as two accounts and both sent as separate keys in the RPC state override.

Nodes decode the override into a map keyed by address, so the later entry silently replaces the earlier one. For example, call with stateOverride: [{ address: '0xd8dA…6045', balance: 1n }, { address: '0xd8da…6045', balance: 2n }] resolves using balance 2 and drops the first override without an error, which is the case AccountStateConflictError exists to catch. On a local Anvil, swapping the order of the two entries swaps the balance the call observes.

This compares addresses case-insensitively when checking for conflicts, consistent with hasStateOverrideForAddress in call, which uses isAddressEqual. Override keys are still sent with the casing the caller provided, so output for valid input is unchanged. This applies to every action that uses serializeStateOverride (call, estimateGas, simulateBlocks, and others).

  • Added a serializeStateOverride test with the same account in checksummed and lowercase form. It fails without this change (snapshot function didn't throw).
  • Added a patch changeset.

Checks run: pnpm test --run src/utils/stateOverride.test.ts, tsc -b src/tsconfig.json, Biome.

@vercel

vercel Bot commented Nov 19, 2026

Copy link
Copy Markdown

@mortezashojaei is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 43625d3

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

@jxom jxom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: mixed-casing duplicates now throw AccountStateConflictError; distinct addresses and caller casing unchanged. The getProof CI failure is unrelated (fork PRs don't receive VITE_ANVIL_FORK_URL, so the public RPC rejects proofs for the pinned fork block).

@jxom
jxom merged commit d90ffc7 into wevm:main Nov 19, 2026
74 of 93 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 19, 2026
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