erigon
erigon copied to clipboard
support state override for debug_traceTransaction ("offchain events")
the debug_traceCall function supports state overrides, but debug_traceTransaction does not - it only accepts a transaction hash.
I wrote this originally as the backbone for generating "offchain events" (as developed by shadow / ghost logs)
to prevent confusion with nodes that don't implement this feature I created a distinct function debug_traceTransactionOverrides.
by overriding contracts bytecode it is possible to reexecute onchain transactions in different context, specifically to emit so called "offchain events" but not limited to this.
usage:
cast rpc debug_traceTransactionOverrides $txhash '{ "stateOverrides": { "$addr": { "code": "$bytecode" } } }'
eg for mainnet:
cast rpc debug_traceTransactionOverrides 0xc9ab90a1796613b0fbccb33827de583901d4c0775e89c0f25d604b7c3a71771e '{ "stateOverrides": { "0x0000001D0000F38CC10d0028474a9c180058B091": { "code": "0x6000ff" } } }' | jq .
see equivalent implementations:
geth: https://github.com/ethereum/go-ethereum/pull/29423 reth: https://github.com/paradigmxyz/reth/pull/7410