feat(evm-simulation): ecrecover precompile override for signature simulation#806
Draft
Foulks-Plb wants to merge 1 commit into
Draft
feat(evm-simulation): ecrecover precompile override for signature simulation#806Foulks-Plb wants to merge 1 commit into
Foulks-Plb wants to merge 1 commit into
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Simulating a signature-gated call (e.g. an EIP-2612
permit) previously required a real signature or prepending anapprove()authorization. To preview such flows without a signature, theecrecoverprecompile must be overridden so the on-chain signature check resolves to the expected signer.Solution
Add an opt-in
SimulateParams.ecrecoverOverridethat installs anecrecovershim at0x…0001on both backends via acodestate-override (PUSH20 <owner>; MSTORE; RETURN), making signature recovery resolve to that address. The Tenderly backend also relocates the genuine precompile viamovePrecompileToAddress; theeth_simulateV1fallback installs the shim only, because viem 2.52's state-override serializer drops the relocation field — behaviourally identical for standard contracts that call0x…0001directly. The param is threaded through the pipeline (including the Tenderly→V1 fallback), validated against malformed/zero addresses, and exported alongsidebuildEcrecoverShimCodeand the precompile/relocation address constants, with full unit coverage and a minor changeset.