Skip to content
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

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

ssonthal
Copy link
Contributor

@ssonthal ssonthal commented Sep 16, 2024

Resolves #6662

Changes

  • debug_traceCallMany method implementation in DebugRpcModule.cs file.
  • added two methods in DebugBridge class to support the new traceCallMany method.
  • To add the methods, had to add one additional parameter to DebugBridge constructor - an IStateReader object.
  • Fixed the initiation of DebugBridge class in DebugModuleFactory by adding the new parameter.
  • Fixed the initiation of DebugModuleFactory class in src/Nethermind/Nethermind.Init/Steps/RegisterRpcModules.cs by adding the new parameter.
  • Test case for debug_traceCallMany.

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • [] No

Documentation

Requires documentation update

  • Yes
  • No

If yes, link the PR to the docs update or the issue with the details labeled docs. Remove if not applicable.

Requires explanation in Release Notes

  • Yes
  • No

If yes, fill in the details here. Remove if not applicable.

@ssonthal ssonthal marked this pull request as ready for review September 16, 2024 15:18
@ssonthal
Copy link
Contributor Author

image

@ssonthal
Copy link
Contributor Author

@MarekM25 does this look good for the debug_traceCallMany functionality?

@ssonthal
Copy link
Contributor Author

ssonthal commented Oct 5, 2024

@smartprogrammer93 @LukaszRozmej requesting your review on this.

@@ -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)]
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about the description. @rubo ?

txs[i] = tx;
}

Block block = new(headerSearch.Object!, txs, Enumerable.Empty<BlockHeader>());
Copy link
Member

Choose a reason for hiding this comment

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

This block is constructed but never used?

Comment on lines +98 to +117
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;
}
Copy link
Member

Choose a reason for hiding this comment

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

All logic should live in GethStyleTracer

Copy link
Contributor Author

@ssonthal ssonthal Oct 9, 2024

Choose a reason for hiding this comment

The 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 GethStyleTracer instead of GethLikeTrace as 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);
Copy link
Member

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)

@@ -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)]
ResultWrapper<IEnumerable<GethLikeTxTrace>> debug_traceCallMany(TransactionForRpcWithTraceTypes[] calls, BlockParameter? blockParameter = null);
Copy link
Member

Choose a reason for hiding this comment

The 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
For overrides, please wait for this PR: #7362

@ssonthal ssonthal marked this pull request as draft October 8, 2024 17:02
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.

Implement debug_traceCallMany
2 participants