Skip to content

Commit

Permalink
Add debug trace call method
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
  • Loading branch information
Gabriel-Trintinalia committed Sep 15, 2023
1 parent 3597ccb commit f774c44
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public enum RpcMethod {
DEBUG_STANDARD_TRACE_BLOCK_TO_FILE("debug_standardTraceBlockToFile"),
DEBUG_STANDARD_TRACE_BAD_BLOCK_TO_FILE("debug_standardTraceBadBlockToFile"),
DEBUG_TRACE_TRANSACTION("debug_traceTransaction"),
DEBUG_TRACE_CALL("debug_traceCall"),
DEBUG_BATCH_RAW_TRANSACTION("debug_batchSendRawTransaction"),
DEBUG_GET_BAD_BLOCKS("debug_getBadBlocks"),
DEBUG_GET_RAW_HEADER("debug_getRawHeader"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult;
import org.hyperledger.besu.ethereum.vm.DebugOperationTracer;

import java.util.Optional;
Expand Down Expand Up @@ -95,13 +96,19 @@ protected Object resultByBlockNumber(
new TransactionTrace(
result.getTransaction(), result.getResult(), tracer.getTraceFrames());

final Block block =
blockchainQueriesSupplier.get().getBlockchain().getChainHeadBlock();

return getTraceCallResult(
protocolSchedule, traceTypes, result, transactionTrace, block);
protocolSchedule, traceTypes, result, transactionTrace);
}),
maybeBlockHeader.get())
.orElse(new JsonRpcErrorResponse(requestContext.getRequest().getId(), INTERNAL_ERROR));
}

protected Object getTraceCallResult(
final ProtocolSchedule protocolSchedule,
final Set<TraceTypeParameter.TraceType> traceTypes,
final TransactionSimulatorResult result,
final TransactionTrace transactionTrace) {
final Block block = blockchainQueriesSupplier.get().getBlockchain().getChainHeadBlock();
return getTraceCallResult(protocolSchedule, traceTypes, result, transactionTrace, block);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugTraceBlock;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugTraceBlockByHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugTraceBlockByNumber;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugTraceCall;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugTraceTransaction;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockReplay;
Expand All @@ -45,6 +46,7 @@
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;

import java.nio.file.Path;
Expand Down Expand Up @@ -113,6 +115,13 @@ protected Map<String, JsonRpcMethod> create() {
new DebugGetRawHeader(blockchainQueries),
new DebugGetRawBlock(blockchainQueries),
new DebugGetRawReceipts(blockchainQueries),
new DebugGetRawTransaction(blockchainQueries));
new DebugGetRawTransaction(blockchainQueries),
new DebugTraceCall(
blockchainQueries,
protocolSchedule,
new TransactionSimulator(
blockchainQueries.getBlockchain(),
blockchainQueries.getWorldStateArchive(),
protocolSchedule)));
}
}

0 comments on commit f774c44

Please sign in to comment.