Search in sources :

Example 1 with VmTraceGenerator

use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.vm.VmTraceGenerator in project besu by hyperledger.

the class TraceReplayBlockTransactions method handleTransactionTrace.

private void handleTransactionTrace(final TransactionTrace transactionTrace, final Block block, final Set<TraceTypeParameter.TraceType> traceTypes, final ObjectMapper mapper, final ArrayNode resultArrayNode, final AtomicInteger traceCounter) {
    final ObjectNode resultNode = mapper.createObjectNode();
    TransactionProcessingResult result = transactionTrace.getResult();
    resultNode.put("output", result.getOutput().toString());
    result.getRevertReason().ifPresent(r -> resultNode.put("revertReason", r.toHexString()));
    if (traceTypes.contains(TraceType.STATE_DIFF)) {
        generateTracesFromTransactionTrace(trace -> resultNode.putPOJO("stateDiff", trace), protocolSchedule, transactionTrace, block, (__, txTrace, currentBlock, ignored) -> stateDiffGenerator.get().generateStateDiff(txTrace), traceCounter);
    }
    setNullNodesIfNotPresent(resultNode, "stateDiff");
    if (traceTypes.contains(TraceTypeParameter.TraceType.TRACE)) {
        generateTracesFromTransactionTrace(resultNode.putArray("trace")::addPOJO, protocolSchedule, transactionTrace, block, FlatTraceGenerator::generateFromTransactionTrace, traceCounter);
    }
    setEmptyArrayIfNotPresent(resultNode, "trace");
    resultNode.put("transactionHash", transactionTrace.getTransaction().getHash().toHexString());
    if (traceTypes.contains(VM_TRACE)) {
        generateTracesFromTransactionTrace(trace -> resultNode.putPOJO("vmTrace", trace), protocolSchedule, transactionTrace, block, (protocolSchedule, txTrace, currentBlock, ignored) -> new VmTraceGenerator(transactionTrace).generateTraceStream(), traceCounter);
    }
    setNullNodesIfNotPresent(resultNode, "vmTrace");
    resultArrayNode.add(resultNode);
}
Also used : FlatTraceGenerator(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.flat.FlatTraceGenerator) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) VmTraceGenerator(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.vm.VmTraceGenerator) TransactionProcessingResult(org.hyperledger.besu.ethereum.processing.TransactionProcessingResult)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 FlatTraceGenerator (org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.flat.FlatTraceGenerator)1 VmTraceGenerator (org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.vm.VmTraceGenerator)1 TransactionProcessingResult (org.hyperledger.besu.ethereum.processing.TransactionProcessingResult)1