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

eth/tracers: trace without passing ctx #30337

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Aug 21, 2024

Since the tracers.Context is only utilized by the JS tracer and flatcall tracer, and we've previously introduced tracing hooks, I think we can eliminate passing the context directly. If the context is needed, it can be retrieved within the hooks.

This change will benefit the live tracer, as it is initialized once, whereas the debug tracer is initialized for each transaction.

The changes: in the updated js tracer, txHash and txIndex have been introduced in the OnTxStart and OnTxEnd hooks. Previously, these variables were introduced immediately after the trace was initialized.

@s1na ptal.

@s1na
Copy link
Contributor

s1na commented Aug 22, 2024

Hm good insight that context is not widely used. I guess what I like about your idea is that we don't have to call OnBlockStart everywhere, only where there is actually a block (e.g. traceBlock*, but not traceCall).
What I don't like is that it feels weird to have OnBlockStart without OnBlockEnd. And also it is a change to the tracing interface and will break people's code without adding any "feature".

@jsvisa
Copy link
Contributor Author

jsvisa commented Aug 22, 2024

What I don't like is that it feels weird to have OnBlockStart without OnBlockEnd.

This is considered to replace the original method of injecting the blockhash, txIndex, txHash fields during initialization. Originally, the context was set for each transaction, but now the VMContext data at OnTxStart is not as full as the context.

And also it is a change to the tracing interface and will break people's code without adding any "feature".

This PR is intended for live tracing(reuse the code in the eth/traces), as live tracing is always running and cannot pass in the context like debug_traceXXX. Therefore, it can only start from the few hooks at OnBlockStart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants