feat(cli): add tx simulate and trace subcommands#667
Draft
ByteYue wants to merge 2 commits into
Draft
Conversation
Three new read-only helpers that wrap reth's debug RPC for the common
\"what would happen / what happened\" developer questions:
- `tx simulate --from --to --data [--value] [--block]` runs eth_call
+ eth_estimateGas and pretty-prints the outcome. Reverts are decoded
for the two standard ABI signatures (`Error(string)`, `Panic(uint256)`);
unknown selectors fall back to raw hex. Exit code is non-zero on
revert so simulate can gate scripts.
- `tx trace <hash> [--tracer call|prestate|4byte|opcode|noop]` wraps
`debug_traceTransaction`. The `call` tracer is rendered as an
indented tree; everything else prints pretty JSON.
- `tx trace-call --from --to --data [--value] [--block] [--tracer ...]`
wraps `debug_traceCall` for hypothetical calls, using the same
tracers and rendering.
Revert decoding logic lives in tx/common.rs with unit tests for the
standard selectors, the empty-data case, and the hex-fallback case.
No node-side changes — purely a CLI wrapper over methods reth already
exposes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three new read-only helpers that wrap reth's debug RPC for the common "what would happen / what happened" developer questions:
tx simulate --from --to --data [--value] [--block]— runseth_call+eth_estimateGasand pretty-prints the outcome. Reverts are decoded for the two standard ABI signatures (Error(string),Panic(uint256)); unknown selectors fall back to raw hex. Exit code is non-zero on revert so simulate can gate scripts.tx trace <hash> [--tracer call|prestate|4byte|opcode|noop]— wrapsdebug_traceTransaction. Thecalltracer is rendered as an indented tree (• CALL 0xfrom → 0xto value=N gas=used/limit); everything else prints pretty JSON.tx trace-call --from --to --data [--value] [--block] [--tracer ...]— wrapsdebug_traceCallfor hypothetical calls, using the same tracers and rendering.--output jsonon any of the three produces machine-readable output for scripting.Design notes
eth_call,eth_estimateGas,debug_traceTransaction,debug_traceCall).tx/common.rswith unit tests for the standard selectors, the empty-data case, and the hex-fallback case. Custom-error ABI support is deferred.cast:castcovers vanilla EVM flows; this PR focuses on gravity-specific simulation flow + making revert output first-class. No overlap we're duplicating.Test plan
tx simulatesuccessful EOA transfer against localnet → printssuccess / return / gastx simulatewith insufficient balance →reverted, exit 1tx trace <real tx hash>(callTracer) → tree output with from/to/value/gastx trace --tracer prestate→ pretty JSON passthroughtx trace-call→ successfully traces hypothetical call--output jsonproduces structured output for simulate and trace--rpc-url→ clear error withinithint