Skip to content

Conversation

@gzliudan
Copy link
Collaborator

Proposed changes

Added methods TraceCallWithCallTracer and TraceTransactionWithCallTracer.

Ref: ethereum#31510

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

Added methods `TraceCallWithCallTracer` and `TraceTransactionWithCallTracer`.

Fixes ethereum#28182

---------

Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
Copilot AI review requested due to automatic review settings February 11, 2026 07:34
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a 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 TraceTransactionWithCallTracer and TraceCallWithCallTracer methods returning a typed CallFrame.
  • Introduced CallTracerConfig, CallFrame, and CallLog types for call-tracer configuration and results.
  • Added gencodec-generated JSON marshal/unmarshal implementations for CallFrame and CallLog.

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.

Comment on lines +259 to +262
cfg, _ := json.Marshal(struct {
OnlyTopCall bool `json:"onlyTopCall"`
WithLog bool `json:"withLog"`
}{config.OnlyTopCall, config.WithLog})
Copy link

Copilot AI Feb 11, 2026

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.

Suggested change
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))
}

Copilot uses AI. Check for mistakes.
Comment on lines +175 to +179
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
Copy link

Copilot AI Feb 11, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +228 to +232
// 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))
Copy link

Copilot AI Feb 11, 2026

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.

Copilot uses AI. Check for mistakes.
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