Skip to content

Conversation

@cloudgray
Copy link
Contributor

Description

Add debug namespace apis below.

  • debug_traceCall
  • debug_traceBlock
  • debug_getRawBlock

Closes: #692

Original PR: #691


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

@cloudgray cloudgray marked this pull request as ready for review October 10, 2025 17:04
@cloudgray cloudgray mentioned this pull request Oct 10, 2025
3 tasks
@cloudgray cloudgray self-assigned this Oct 10, 2025
Copy link
Member

@vladjdk vladjdk left a comment

Choose a reason for hiding this comment

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

Overall nice, looks good! Added a few questions. Would also like to add some stricter validation on the tests.


// Verify response contains expected trace data
if tc.traceResponse != "" {
s.Require().Contains(string(res.Data), tc.traceResponse)
Copy link
Member

Choose a reason for hiding this comment

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

Why not get more specific and have strict equalities with the strings here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

applied (11e5dc5)

}

// Check for expected fields in callTracer format
requiredFields := []string{"from", "gas", "gasUsed", "to", "type"}
Copy link
Member

Choose a reason for hiding this comment

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

Any way we can validate the entire trace, or is there indeterminism?

Copy link
Member

Choose a reason for hiding this comment

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

Should probably also check that there aren't any extra fields here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

applied (11e5dc5)

The response type comparison is like below. (evmd vs geth)

Actual logs

2025/10/11 19:00:10 Structure Comparison for debug_traceCall:
2025/10/11 19:00:10   Structure Match: true
2025/10/11 19:00:10   Type Match: true (object vs object)
2025/10/11 19:00:10   Errors Match: true


// Check gas fields exist and are hex strings
if gasStr, ok := traceResult["gas"].(string); ok {
if !strings.HasPrefix(gasStr, "0x") {
Copy link
Member

Choose a reason for hiding this comment

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

I mostly just want more strict validation everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

applied (11e5dc5)

}

func DebugTraceCall(rCtx *types.RPCContext) (*types.RpcResult, error) {
if result := rCtx.AlreadyTested(MethodNameDebugTraceCall); result != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain this line? What do you mean already tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was originally a design to prevent wasting resources by redundantly testing the same API multiple times.

I had some reasoning behind it back then, but now it looks unnecessary. I’ll remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

applied (f58bfa1)

}, nil
}

result := &types.RpcResult{
Copy link
Member

Choose a reason for hiding this comment

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

Let's run some validation on the data wtihin the trace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think comparison between return data from geth can be substitution for that.
applied (11e5dc5)

// get the context of block beginning
requestedHeight := req.BlockNumber
if requestedHeight < 1 {
// 0 is a special value in `ContextWithHeight`
Copy link
Member

Choose a reason for hiding this comment

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

Again, need explanation for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto (#711 (comment))

}

ctx := sdk.UnwrapSDKContext(c)
// the caller sets the `ctx.BlockHeight()` to be `requestedHeight - 1`, so we can get the context of block beginning
Copy link
Member

Choose a reason for hiding this comment

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

Is this documented anywhere? Don't quite understand this either

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto (#711 (comment))

@vladjdk
Copy link
Member

vladjdk commented Oct 10, 2025

Could we also add a simple timeout? #691 (comment)

@cloudgray
Copy link
Contributor Author

Could we also add a simple timeout? #691 (comment)

Could you check this comment?

Actually, timeout has already been applied.

@vladjdk vladjdk enabled auto-merge October 13, 2025 16:32
@vladjdk vladjdk disabled auto-merge October 13, 2025 16:33
@vladjdk vladjdk merged commit 296b5ea into main Oct 13, 2025
24 of 25 checks passed
@vladjdk vladjdk deleted the feat(rpc)-traceCall branch October 13, 2025 16:33
@cloudgray cloudgray mentioned this pull request Oct 14, 2025
3 tasks
zsystm pushed a commit to zsystm/evm that referenced this pull request Nov 2, 2025
* add debug_traceBlock api

* add test cases for debug_traceCall

* chore: update CHANGELOG.md

* add debug_traceBlock api

* feat(rpc): add debug_getRawBlock api and fix debug_traceBlock api

* test(rpc): fix test cases for debug apis

* test(rpc): modify test case for debug_traceCall

* chore: fix lint

* fix test code

* Merge branch 'main' into feat(rpc)-traceCall

* chore: modify comments

* fix(x/vm): apply default args to TraceCall method

* test(jsonrpc): add type comparison of debug_traceCall response from evmd vs geth

* chore: remove useless method call

* fix: non-deterministic system test result

* fix: non-deterministic system test result

* fix: non-deterministic system test result

* fix: non-deterministic system test result

* fix: non-deterministic system test result

* fix: non-deterministic system test result

* fix: non-deterministic system test result

* fix: non-deterministic system test result

* fix: non-deterministic system test result

* fix: return type of eth apis

* fix: non-deterministic system test result

* chore: non-deterministic calculation for query

* fix: non-deterministic system test result

* test: fix eth_feeHistory api test code

* test: fix eth_feeHistory api test code

---------

Co-authored-by: Vlad J <vladjdk@gmail.com>
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.

debug_traceCall api is missing

3 participants