Skip to content

Conversation

@milando12
Copy link

Description

Fixes a compatibility issue where debug_traceBlockByNumber and related JSON-RPC endpoints reject requests containing tracerConfig as a JSON object. While standard Ethereum clients send tracerConfig as a raw object, the current Protobuf definition expects an escaped JSON string, causing unmarshal errors.

Changes introduced:

  1. Polyglot Unmarshaling: Implemented custom UnmarshalJSON and MarshalJSON methods for TraceConfig in x/vm/types/trace_config.go.
    • It now accepts Standard JSON Objects (Ethereum compliant).
    • It still accepts Escaped JSON Strings (Backwards compatible for legacy Cosmos clients).
  2. Testing: Added comprehensive unit tests in x/vm/types/trace_config_test.go covering object format, string format, and round-trip serialization.

Critical files to review:

  • x/vm/types/trace_config.go (New custom JSON logic)
  • x/vm/types/trace_config_test.go (Verification of the fix)

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
    • Reviewer Note: Please run go test -v ./x/vm/types/ -run TestTraceConfig to verify both JSON formats are accepted.
  • targeted the main branch

Previously, debug_traceBlockByNumber and related endpoints only accepted
tracerConfig as an escaped JSON string due to protobuf type definitions.
This caused incompatibility with standard Ethereum (like curl requests) which sends tracerConfig as a JSON object.

This commit implements custom MarshalJSON and UnmarshalJSON methods for
TraceConfig. It creates a polyglot unmarshaler that accepts both:
1. Standard JSON Objects (Ethereum compliant)
2. Escaped JSON Strings (Legacy/Backwards compatible)
@milando12 milando12 marked this pull request as draft December 11, 2025 12:16
Copy link

@y0930711070-debug y0930711070-debug left a comment

Choose a reason for hiding this comment

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

H

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