-
Notifications
You must be signed in to change notification settings - Fork 69
feat(ethclient): add tracing API methods #31510 #2050
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
base: dev-upgrade
Are you sure you want to change the base?
Conversation
Added methods `TraceCallWithCallTracer` and `TraceTransactionWithCallTracer`. Fixes ethereum#28182 --------- Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds typed wrappers in ethclient/gethclient for Geth’s callTracer output to make debug_traceTransaction / debug_traceCall easier to consume from Go.
Changes:
- Added
TraceTransactionWithCallTracerandTraceCallWithCallTracermethods returning a typedCallFrame. - Introduced
CallTracerConfig,CallFrame, andCallLogtypes for call-tracer configuration and results. - Added gencodec-generated JSON marshal/unmarshal implementations for
CallFrameandCallLog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ethclient/gethclient/gethclient.go | Adds the new typed tracing APIs, config, and result structs plus config-to-wire helpers. |
| ethclient/gethclient/gen_calllog_json.go | Generated JSON marshaling for CallLog using hexutil wrappers. |
| ethclient/gethclient/gen_callframe_json.go | Generated JSON marshaling for CallFrame using hexutil wrappers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cfg, _ := json.Marshal(struct { | ||
| OnlyTopCall bool `json:"onlyTopCall"` | ||
| WithLog bool `json:"withLog"` | ||
| }{config.OnlyTopCall, config.WithLog}) |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callTracerConfig ignores the json.Marshal error. Even though marshaling this simple struct is unlikely to fail, ignoring the error can trip linters and makes failures harder to diagnose. Consider handling the error (e.g., return it from callTracerConfig and propagate through the public methods) or otherwise make the non-failure guarantee explicit.
| cfg, _ := json.Marshal(struct { | |
| OnlyTopCall bool `json:"onlyTopCall"` | |
| WithLog bool `json:"withLog"` | |
| }{config.OnlyTopCall, config.WithLog}) | |
| cfg, err := json.Marshal(struct { | |
| OnlyTopCall bool `json:"onlyTopCall"` | |
| WithLog bool `json:"withLog"` | |
| }{config.OnlyTopCall, config.WithLog}) | |
| if err != nil { | |
| // Marshaling this simple struct is expected to never fail. | |
| // Panic to make any unexpected failure visible. | |
| panic(fmt.Sprintf("gethclient: failed to marshal CallTracerConfig: %v", err)) | |
| } |
| type CallTracerConfig struct { | ||
| // OnlyTopCall, when true, limits tracing to the main (top-level) call only. | ||
| OnlyTopCall bool | ||
| // WithLog, when true, includes log emissions in the trace output. | ||
| WithLog bool |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CallTracerConfig only exposes call-tracer-specific options plus Timeout, but debug_traceTransaction/debug_traceCall also support generic trace options like reexec (and debug_traceCall supports txIndex). With the current API, callers can’t set these even though they may be required to trace older blocks reliably. Consider adding optional fields (e.g., Reexec *uint64, TxIndex *uint) and wiring them into the generated tracers.TraceConfig / trace-call config object.
| // TraceTransactionWithCallTracer traces a transaction with the call tracer | ||
| // and returns a typed CallFrame. If config is nil, defaults are used. | ||
| func (ec *Client) TraceTransactionWithCallTracer(ctx context.Context, txHash common.Hash, config *CallTracerConfig) (*CallFrame, error) { | ||
| var result CallFrame | ||
| err := ec.c.CallContext(ctx, &result, "debug_traceTransaction", txHash, callTracerConfig(config)) |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New RPC wrappers/config builders were added, but there are no unit tests covering the JSON that gets sent (e.g., that callTracerConfig produces the expected tracer, timeout, and tracerConfig fields and that callTraceCallConfig correctly embeds stateOverrides/blockOverrides). Since this package already has JSON marshaling tests, adding similar tests here would help prevent silent wire-format regressions.
Proposed changes
Added methods
TraceCallWithCallTracerandTraceTransactionWithCallTracer.Ref: ethereum#31510
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that