-
Notifications
You must be signed in to change notification settings - Fork 438
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
6662 debug trace call many #7441
base: master
Are you sure you want to change the base?
Changes from all commits
97618a1
a7e29c7
be56e2b
2b69915
bec9710
4664e3e
87acab8
a56858f
30da606
b2c4171
cdc01f0
bdc0e61
a140ff7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,16 @@ | |
using System.Collections.Generic; | ||
using Nethermind.JsonRpc.Modules.Eth; | ||
using Nethermind.Core.Specs; | ||
|
||
using Nethermind.Facade.Eth; | ||
using Nethermind.Evm.Tracing.ParityStyle; | ||
using Nethermind.Int256; | ||
using Newtonsoft.Json; | ||
using Nethermind.State; | ||
|
||
using Nethermind.Facade.Eth.RpcTransaction; | ||
|
||
|
||
namespace Nethermind.JsonRpc.Modules.DebugModule; | ||
|
||
public class DebugRpcModule : IDebugRpcModule | ||
|
@@ -85,6 +93,45 @@ public ResultWrapper<GethLikeTxTrace> debug_traceCall(TransactionForRpc call, Bl | |
if (_logger.IsTrace) _logger.Trace($"{nameof(debug_traceTransaction)} request {tx.Hash}, result: trace"); | ||
return ResultWrapper<GethLikeTxTrace>.Success(transactionTrace); | ||
} | ||
public ResultWrapper<IEnumerable<GethLikeTxTrace>> debug_traceCallMany(TransactionForRpcWithTraceTypes[] calls, BlockParameter? blockParameter = null) | ||
{ | ||
blockParameter ??= BlockParameter.Latest; | ||
using CancellationTokenSource cancellationTokenSource = new(_traceTimeout); | ||
CancellationToken cancellationToken = cancellationTokenSource.Token; | ||
|
||
SearchResult<BlockHeader> headerSearch = _debugBridge.SearchBlockHeaderForTraceCall(blockParameter); | ||
if (headerSearch.IsError) | ||
{ | ||
return ResultWrapper<IEnumerable<GethLikeTxTrace>>.Fail(headerSearch); | ||
} | ||
|
||
if (!_debugBridge.HasStateForBlock(headerSearch.Object)) | ||
{ | ||
return ResultWrapper<IEnumerable<GethLikeTxTrace>>.Fail($"No state available for block {headerSearch.Object.ToString(BlockHeader.Format.FullHashAndNumber)}", ErrorCodes.ResourceUnavailable); | ||
} | ||
|
||
Dictionary<Hash256, ParityTraceTypes> traceTypeByTransaction = new(calls.Length); | ||
Transaction[] txs = new Transaction[calls.Length]; | ||
for (int i = 0; i < calls.Length; i++) | ||
{ | ||
calls[i].Transaction.EnsureDefaults(_jsonRpcConfig.GasCap); | ||
Transaction tx = calls[i].Transaction.ToTransaction(); | ||
tx.Hash = new Hash256(new UInt256((ulong)i).ToBigEndian()); | ||
txs[i] = tx; | ||
} | ||
Comment on lines
+102
to
+121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All logic should live in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, I'm sorry but I didn't understand what you meant here. Did you mean using |
||
|
||
Block block = new(headerSearch.Object!, txs, Enumerable.Empty<BlockHeader>()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block is constructed but never used? |
||
|
||
IReadOnlyCollection<GethLikeTxTrace> traces = _debugBridge.GetBlockTrace(blockParameter, cancellationToken); | ||
|
||
if (traces is null) | ||
{ | ||
return ResultWrapper<IEnumerable<GethLikeTxTrace>>.Fail($"Failed to trace block transactions for input txns: {JsonConvert.SerializeObject(calls)}", ErrorCodes.ResourceNotFound); | ||
} | ||
|
||
if (_logger.IsTrace) _logger.Trace($"{nameof(debug_traceCallMany)} with input transactions: {calls} returned the result: {traces}"); | ||
return ResultWrapper<IEnumerable<GethLikeTxTrace>>.Success(traces); | ||
} | ||
|
||
public ResultWrapper<GethLikeTxTrace> debug_traceTransactionByBlockhashAndIndex(Hash256 blockhash, int index, GethTraceOptions options = null) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,9 @@ public interface IDebugRpcModule : IRpcModule | |
[JsonRpcMethod(Description = "This method lets you run an eth_call within the context of the given block execution using the final state of parent block as the base. The block can be specified either by hash or by number. It takes the same input object as a eth_call. It returns the same output as debug_traceTransaction.", IsImplemented = true, IsSharable = true)] | ||
ResultWrapper<GethLikeTxTrace> debug_traceCall(TransactionForRpc call, BlockParameter? blockParameter = null, GethTraceOptions? options = null); | ||
|
||
[JsonRpcMethod(Description = "This method lets you run trace_callMany for a list of transactions.It doesn't charge fees. It returns a list of Trace objects.", IsImplemented = true, IsSharable = true)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about the description. @rubo ? |
||
ResultWrapper<IEnumerable<GethLikeTxTrace>> debug_traceCallMany(TransactionForRpcWithTraceTypes[] calls, BlockParameter? blockParameter = null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the signature should be different: https://www.chainnodes.org/docs/ethereum/debug_traceCallMany |
||
|
||
[JsonRpcMethod(Description = "", IsSharable = true)] | ||
ResultWrapper<GethLikeTxTrace> debug_traceTransactionByBlockAndIndex(BlockParameter blockParameter, int txIndex, GethTraceOptions options = null); | ||
|
||
|
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.
ParityTraceType's have no sense in Geth style tracing (debug module)