Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support state override for debug_traceTransaction ("offchain events") #7410

Closed

Conversation

hananbeer
Copy link
Contributor

@hananbeer hananbeer commented Apr 1, 2024

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 .

note:
the format may differ a bit from other nodes (eg. in geth the keys ("stateOverride", "code") are case insensitive, in reth they are case sensitive)
this is unrelated to this patch.

see equivalent implementations:

geth: ethereum/go-ethereum#29423
erigon: erigontech/erigon#9847

async fn debug_trace_transaction_overrides(
&self,
tx_hash: B256,
opts: Option<GethDebugTracingCallOptions>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the same as adding support for overrides in debug_trace_transaction?

GethDebugTracingCallOptions contains two optional objects but is otherwise the same as GethDebugTracingOptions

so I think we can integrate this without breaking anything and avoid a new endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is, but as I mentioned this distinction is to avoid confusion.
also see this reply in my geth version:
ethereum/go-ethereum#29423 (comment)

it seems they support this within debug_traceCall (less convenient imo) but I've never seen this documented for any node before.

I want a standardized api across nodes, each node makes their own modifications and then things break when, for example, using load balancers across different providers.

@github-actions github-actions bot added the S-stale This issue/PR is stale and will close with no further activity label Apr 23, 2024
@github-actions github-actions bot closed this May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-stale This issue/PR is stale and will close with no further activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants