Skip to content

feat(evm-simulation): ecrecover precompile override for signature simulation#806

Draft
Foulks-Plb wants to merge 1 commit into
mainfrom
ecrecover-shim-state-override
Draft

feat(evm-simulation): ecrecover precompile override for signature simulation#806
Foulks-Plb wants to merge 1 commit into
mainfrom
ecrecover-shim-state-override

Conversation

@Foulks-Plb

Copy link
Copy Markdown
Contributor

Motivation

Simulating a signature-gated call (e.g. an EIP-2612 permit) previously required a real signature or prepending an approve() authorization. To preview such flows without a signature, the ecrecover precompile must be overridden so the on-chain signature check resolves to the expected signer.

Solution

Add an opt-in SimulateParams.ecrecoverOverride that installs an ecrecover shim at 0x…0001 on both backends via a code state-override (PUSH20 <owner>; MSTORE; RETURN), making signature recovery resolve to that address. The Tenderly backend also relocates the genuine precompile via movePrecompileToAddress; the eth_simulateV1 fallback installs the shim only, because viem 2.52's state-override serializer drops the relocation field — behaviourally identical for standard contracts that call 0x…0001 directly. The param is threaded through the pipeline (including the Tenderly→V1 fallback), validated against malformed/zero addresses, and exported alongside buildEcrecoverShimCode and the precompile/relocation address constants, with full unit coverage and a minor changeset.

… simulation

Add `SimulateParams.ecrecoverOverride` to simulate signature-gated calls
(e.g. EIP-2612 permit) without a real signature. Both backends install an
ecrecover shim at 0x…0001 via a `code` state-override so signature recovery
resolves to the given address; Tenderly also relocates the genuine precompile
via `movePrecompileToAddress`, while the eth_simulateV1 fallback installs the
shim only (viem's serializer drops the relocation field). Exports
buildEcrecoverShimCode and the precompile/relocation address constants.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Foulks-Plb Foulks-Plb added the enhancement New feature or request label Jun 18, 2026
@Foulks-Plb Foulks-Plb self-assigned this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant