Skip to content

eth_call with state overrides #12

Description

@koko1123

Summary

Add support for eth_call state overrides, allowing users to simulate transactions against modified blockchain state without forking a node.

Motivation

Searchers need to simulate "what if" scenarios: what if this token balance was X? What if this pool had Y liquidity? State overrides let you answer these questions with a single RPC call instead of running a local fork.

This is critical for:

  • Simulating sandwich attacks with modified token balances
  • Testing liquidation scenarios with modified collateral ratios
  • Evaluating arb profitability under different pool states

Proposed API

const eth = @import("eth");

// Override state for a specific contract
var overrides = eth.provider.StateOverrides.init(allocator);
defer overrides.deinit();

try overrides.setBalance(target_address, new_balance);
try overrides.setStorageAt(pool_address, slot, new_value);
try overrides.setCode(contract_address, new_bytecode);

const result = try provider.call(.{
    .to = target,
    .data = calldata,
}, .{ .state_overrides = &overrides });

Implementation Notes

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededl2L2 chain supportmevMEV/searcher tooling

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions