Skip to content

Commit a120e12

Browse files
asdacapkamilchodola
authored andcommitted
Fix debug module wrong configuration (#8185)
1 parent 836748d commit a120e12

File tree

2 files changed

+40
-49
lines changed

2 files changed

+40
-49
lines changed

src/Nethermind/Nethermind.Consensus/Tracing/GethStyleTracer.cs

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,17 @@ public GethLikeTxTrace Trace(Hash256 blockHash, int txIndex, GethTraceOptions op
122122
if (tx.Hash is null) throw new InvalidOperationException("Cannot trace transactions without tx hash set.");
123123

124124
block = block.WithReplacedBodyCloned(BlockBody.WithOneTransactionOnly(tx));
125-
lock (_env) //env shouldn't be shared, but can't find the root cause where it could be
125+
using IOverridableTxProcessingScope scope = _env.BuildAndOverride(block.Header, options.StateOverrides);
126+
IBlockTracer<GethLikeTxTrace> blockTracer = CreateOptionsTracer(block.Header, options with { TxHash = tx.Hash });
127+
try
126128
{
127-
using IOverridableTxProcessingScope scope = _env.BuildAndOverride(block.Header, options.StateOverrides);
128-
IBlockTracer<GethLikeTxTrace> blockTracer = CreateOptionsTracer(block.Header, options with { TxHash = tx.Hash });
129-
try
130-
{
131-
_processor.Process(block, ProcessingOptions.Trace, blockTracer.WithCancellation(cancellationToken));
132-
return blockTracer.BuildResult().SingleOrDefault();
133-
}
134-
catch
135-
{
136-
blockTracer.TryDispose();
137-
throw;
138-
}
129+
_processor.Process(block, ProcessingOptions.Trace, blockTracer.WithCancellation(cancellationToken));
130+
return blockTracer.BuildResult().SingleOrDefault();
131+
}
132+
catch
133+
{
134+
blockTracer.TryDispose();
135+
throw;
139136
}
140137
}
141138

@@ -195,21 +192,18 @@ public IEnumerable<string> TraceBadBlockToFile(Hash256 blockHash, GethTraceOptio
195192
{
196193
ArgumentNullException.ThrowIfNull(txHash);
197194

198-
lock (_env) //env shouldn't be shared, but can't find the root cause where it could be
199-
{
200-
using IOverridableTxProcessingScope scope = _env.BuildAndOverride(block.Header, options.StateOverrides);
201-
IBlockTracer<GethLikeTxTrace> tracer = CreateOptionsTracer(block.Header, options with { TxHash = txHash });
195+
using IOverridableTxProcessingScope scope = _env.BuildAndOverride(block.Header, options.StateOverrides);
196+
IBlockTracer<GethLikeTxTrace> tracer = CreateOptionsTracer(block.Header, options with { TxHash = txHash });
202197

203-
try
204-
{
205-
_processor.Process(block, processingOptions, tracer.WithCancellation(cancellationToken));
206-
return tracer.BuildResult().SingleOrDefault();
207-
}
208-
catch
209-
{
210-
tracer.TryDispose();
211-
throw;
212-
}
198+
try
199+
{
200+
_processor.Process(block, processingOptions, tracer.WithCancellation(cancellationToken));
201+
return tracer.BuildResult().SingleOrDefault();
202+
}
203+
catch
204+
{
205+
tracer.TryDispose();
206+
throw;
213207
}
214208
}
215209

@@ -236,20 +230,17 @@ private IReadOnlyCollection<GethLikeTxTrace> TraceBlock(Block? block, GethTraceO
236230
if (!_blockTree.IsMainChain(parent.Hash)) throw new InvalidOperationException("Cannot trace orphaned blocks");
237231
}
238232

239-
lock (_env) //env shouldn't be shared, but can't find the root cause where it could be
233+
using IOverridableTxProcessingScope scope = _env.BuildAndOverride(block.Header, options.StateOverrides);
234+
IBlockTracer<GethLikeTxTrace> tracer = CreateOptionsTracer(block.Header, options);
235+
try
240236
{
241-
using IOverridableTxProcessingScope scope = _env.BuildAndOverride(block.Header, options.StateOverrides);
242-
IBlockTracer<GethLikeTxTrace> tracer = CreateOptionsTracer(block.Header, options);
243-
try
244-
{
245-
_processor.Process(block, ProcessingOptions.Trace, tracer.WithCancellation(cancellationToken));
246-
return tracer.BuildResult();
247-
}
248-
catch
249-
{
250-
tracer.TryDispose();
251-
throw;
252-
}
237+
_processor.Process(block, ProcessingOptions.Trace, tracer.WithCancellation(cancellationToken));
238+
return tracer.BuildResult();
239+
}
240+
catch
241+
{
242+
tracer.TryDispose();
243+
throw;
253244
}
254245
}
255246

src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugRpcModule.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,31 @@ public interface IDebugRpcModule : IRpcModule
2727
IsSharable = true)]
2828
ResultWrapper<bool> debug_resetHead(Hash256 blockHash);
2929

30-
[JsonRpcMethod(Description = "This method will attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.", IsImplemented = true, IsSharable = true)]
30+
[JsonRpcMethod(Description = "This method will attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.", IsImplemented = true, IsSharable = false)]
3131
ResultWrapper<GethLikeTxTrace> debug_traceTransaction(Hash256 transactionHash, GethTraceOptions options = null);
3232

33-
[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)]
33+
[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 = false)]
3434
ResultWrapper<GethLikeTxTrace> debug_traceCall(TransactionForRpc call, BlockParameter? blockParameter = null, GethTraceOptions? options = null);
3535

36-
[JsonRpcMethod(Description = "", IsSharable = true)]
36+
[JsonRpcMethod(Description = "", IsSharable = false)]
3737
ResultWrapper<GethLikeTxTrace> debug_traceTransactionByBlockAndIndex(BlockParameter blockParameter, int txIndex, GethTraceOptions options = null);
3838

39-
[JsonRpcMethod(Description = "", IsSharable = true)]
39+
[JsonRpcMethod(Description = "", IsSharable = false)]
4040
ResultWrapper<GethLikeTxTrace> debug_traceTransactionByBlockhashAndIndex(Hash256 blockHash, int txIndex, GethTraceOptions options = null);
4141

42-
[JsonRpcMethod(Description = "Returns the full stack trace of all invoked opcodes of all transactions that were included in the block specified. The parent of the block must be present or it will fail.", IsImplemented = true, IsSharable = true)]
42+
[JsonRpcMethod(Description = "Returns the full stack trace of all invoked opcodes of all transactions that were included in the block specified. The parent of the block must be present or it will fail.", IsImplemented = true, IsSharable = false)]
4343
ResultWrapper<IReadOnlyCollection<GethLikeTxTrace>> debug_traceBlock(byte[] blockRlp, GethTraceOptions options = null);
4444

45-
[JsonRpcMethod(Description = "Similar to debug_traceBlock, this method accepts a block number as well as \"latest\" or \"finalized\" and replays the block that is already present in the database.", IsImplemented = true, IsSharable = true)]
45+
[JsonRpcMethod(Description = "Similar to debug_traceBlock, this method accepts a block number as well as \"latest\" or \"finalized\" and replays the block that is already present in the database.", IsImplemented = true, IsSharable = false)]
4646
ResultWrapper<IReadOnlyCollection<GethLikeTxTrace>> debug_traceBlockByNumber(BlockParameter blockParameter, GethTraceOptions options = null);
4747

48-
[JsonRpcMethod(Description = "Similar to debug_traceBlock, this method accepts a block hash and replays the block that is already present in the database.", IsImplemented = true, IsSharable = true)]
48+
[JsonRpcMethod(Description = "Similar to debug_traceBlock, this method accepts a block hash and replays the block that is already present in the database.", IsImplemented = true, IsSharable = false)]
4949
ResultWrapper<IReadOnlyCollection<GethLikeTxTrace>> debug_traceBlockByHash(Hash256 blockHash, GethTraceOptions options = null);
5050

5151
[JsonRpcMethod(Description = "", IsImplemented = false, IsSharable = false)]
5252
ResultWrapper<GethLikeTxTrace[]> debug_traceBlockFromFile(string fileName, GethTraceOptions options = null);
5353

54-
[JsonRpcMethod(Description = "", IsImplemented = false, IsSharable = false)]
54+
[JsonRpcMethod(Description = "", IsImplemented = false, IsSharable = true)]
5555
ResultWrapper<object> debug_dumpBlock(BlockParameter blockParameter);
5656

5757
[JsonRpcMethod(Description = "", IsImplemented = false, IsSharable = true)]
@@ -60,7 +60,7 @@ public interface IDebugRpcModule : IRpcModule
6060
[JsonRpcMethod(Description = "Retrieves a block in the RLP-serialized form.", IsImplemented = true, IsSharable = true)]
6161
ResultWrapper<byte[]> debug_getBlockRlp(long number);
6262

63-
[JsonRpcMethod(Description = "Retrieves a block in the RLP-serialized form.", IsImplemented = true, IsSharable = false)]
63+
[JsonRpcMethod(Description = "Retrieves a block in the RLP-serialized form.", IsImplemented = true, IsSharable = true)]
6464
ResultWrapper<byte[]> debug_getBlockRlpByHash(Hash256 hash);
6565

6666
[JsonRpcMethod(Description = "", IsImplemented = false, IsSharable = true)]

0 commit comments

Comments
 (0)