Add eth_call state overrides and eth_createAccessList support - #271
Conversation
alisinabh
commented
Jul 29, 2026
- New :state_overrides option on Ethers.call/2 and Ethers.estimate_gas/2 to simulate against modified chain state (balances, nonces, code, storage slots)
- New Ethers.StateOverride module validating and encoding override sets into their JSON-RPC representation
- New Ethers.create_access_list/2 (+ bang variant) wrapping eth_createAccessList, returning the access list in the format transaction overrides accept so it can be fed straight back into send_transaction
- New optional RPC adapter callbacks (eth_call/4, eth_estimate_gas/4, eth_create_access_list/3) - custom adapters remain backwards compatible and get {:error, :state_overrides_not_supported} / {:error, :not_supported} when they do not implement them
There was a problem hiding this comment.
🟡 Not ready to approve
Batch usage for :create_access_list appears to be enabled by preprocessing but will send an unmapped RPC method name, leading to incorrect batch requests at runtime.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR extends the Ethers Elixir client with Ethereum simulation features: state overrides for eth_call / eth_estimateGas, plus eth_createAccessList support to generate EIP-2930 access lists that can be fed back into transactions.
Changes:
- Add
:state_overridestoEthers.call/2andEthers.estimate_gas/2, including optional RPC adapter callbacks for override-capable clients. - Introduce
Ethers.StateOverridefor validating/encoding override sets into JSON-RPC format. - Add
Ethers.create_access_list/2(+ bang variant) and decode the RPC result into the transaction-override-compatible access list format.
File summaries
| File | Description |
|---|---|
| test/ethers/state_override_test.exs | Adds coverage for encoding and for call/estimate_gas behavior with state overrides. |
| test/ethers_test.exs | Adds tests for create_access_list/2 result shape and error behavior. |
| lib/ethers/state_override.ex | New module implementing validation + JSON-RPC encoding for state overrides. |
| lib/ethers/rpc_client/ethereumex_http_client.ex | Adds manual implementations for the new RPC calls not directly exposed by Ethereumex. |
| lib/ethers/rpc_client/adapter.ex | Extends the adapter behaviour with optional callbacks for overrides and access list creation. |
| lib/ethers.ex | Wires new options/APIs into the high-level client and adds post-processing for access list responses. |
| CHANGELOG.md | Documents the new features under Unreleased enhancements. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 3
- Review effort level: Low
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
There was a problem hiding this comment.
🟢 Ready to approve
The implementation matches the PR description, preserves adapter backwards compatibility via optional callbacks and feature detection, and includes solid automated test coverage for the new behaviors.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0 new
- Review effort level: Low
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
- New :state_overrides option on Ethers.call/2 and Ethers.estimate_gas/2 to
simulate against modified chain state (balances, nonces, code, storage slots)
- New Ethers.StateOverride module validating and encoding override sets into
their JSON-RPC representation
- New Ethers.create_access_list/2 (+ bang variant) wrapping eth_createAccessList,
returning the access list in the format transaction overrides accept so it can
be fed straight back into send_transaction
- New optional RPC adapter callbacks (eth_call/4, eth_estimate_gas/4,
eth_create_access_list/3) - custom adapters remain backwards compatible and
get {:error, :state_overrides_not_supported} / {:error, :not_supported} when
they do not implement them
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pKYp3j1ew76CY7HA2nBTF
Never dispatch on a 0x prefix to tell hex strings from raw binaries - a valid raw binary can itself start with the bytes "0x". Each field now accepts a single representation, following the library convention of native types: - addresses: hex strings only (no raw 20-byte binaries) - balance/nonce: non-negative integers only (no hex strings) - code: raw binary only, always hex encoded for the RPC (no hex strings) - storage slots/values: non-negative integers or raw 32-byte binaries (no hex strings) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012pKYp3j1ew76CY7HA2nBTF
The adapter delegated batch_request to Ethereumex.HttpClient.batch_request/2, which dispatches batch entries to named functions on Ethereumex.HttpClient - so methods Ethereumex does not implement (like eth_createAccessList) crashed with UndefinedFunctionError when batched. Build the batch payload in the adapter itself through Ethereumex's generic request/3 (deriving the JSON-RPC method name from the callback atom) and post it directly, making every method the adapter supports batchable without depending on Ethereumex's named function coverage. Map :create_access_list to eth_createAccessList in Ethers.batch/2 and document it as batchable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012pKYp3j1ew76CY7HA2nBTF
a5f3226 to
b92b4d3
Compare