Search in sources :

Example 1 with TRACE

use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType.TRACE in project besu by hyperledger.

the class TraceReplayBlockTransactions method resultByBlockNumber.

@Override
protected Object resultByBlockNumber(final JsonRpcRequestContext request, final long blockNumber) {
    final TraceTypeParameter traceTypeParameter = request.getRequiredParameter(1, TraceTypeParameter.class);
    LOG.trace("Received RPC rpcName={} block={} traceType={}", getName(), blockNumber, traceTypeParameter);
    if (blockNumber == BlockHeader.GENESIS_BLOCK_NUMBER) {
        // Nothing to trace for the genesis block
        return emptyResult();
    }
    return getBlockchainQueries().getBlockchain().getBlockByNumber(blockNumber).map((block) -> traceBlock(block, traceTypeParameter)).orElse(null);
}
Also used : TRACE(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType.TRACE) TraceType(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType) TraceOptions(org.hyperledger.besu.ethereum.debug.TraceOptions) Arrays(java.util.Arrays) TraceTypeParameter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter) LoggerFactory(org.slf4j.LoggerFactory) TraceFormatter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.TraceFormatter) Supplier(java.util.function.Supplier) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProtocolSchedule(org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BlockParameter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter) JsonRpcRequestContext(org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext) BlockTrace(org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace) Suppliers(com.google.common.base.Suppliers) JsonNode(com.fasterxml.jackson.databind.JsonNode) Block(org.hyperledger.besu.ethereum.core.Block) FlatTraceGenerator(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.flat.FlatTraceGenerator) TraceWriter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.TraceWriter) TransactionTrace(org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace) Logger(org.slf4j.Logger) VmTraceGenerator(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.vm.VmTraceGenerator) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) BlockchainQueries(org.hyperledger.besu.ethereum.api.query.BlockchainQueries) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) DebugOperationTracer(org.hyperledger.besu.ethereum.vm.DebugOperationTracer) TransactionProcessingResult(org.hyperledger.besu.ethereum.processing.TransactionProcessingResult) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) List(java.util.List) RpcMethod(org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod) Optional(java.util.Optional) StateDiffGenerator(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.diff.StateDiffGenerator) VM_TRACE(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType.VM_TRACE) BlockTracer(org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer) TraceTypeParameter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter)

Example 2 with TRACE

use of org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType.TRACE in project besu by hyperledger.

the class TraceReplayBlockTransactions method traceBlock.

private Object traceBlock(final Block block, final TraceTypeParameter traceTypeParameter) {
    if (block == null || block.getBody().getTransactions().isEmpty()) {
        return emptyResult();
    }
    final Set<TraceTypeParameter.TraceType> traceTypes = traceTypeParameter.getTraceTypes();
    final TraceOptions traceOptions = new TraceOptions(false, false, traceTypes.contains(VM_TRACE) || traceTypes.contains(TRACE));
    return blockTracerSupplier.get().trace(block, new DebugOperationTracer(traceOptions)).map(BlockTrace::getTransactionTraces).map((traces) -> generateTracesFromTransactionTrace(traces, block, traceTypes)).orElse(null);
}
Also used : TRACE(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType.TRACE) TraceType(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType) TraceOptions(org.hyperledger.besu.ethereum.debug.TraceOptions) Arrays(java.util.Arrays) TraceTypeParameter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter) LoggerFactory(org.slf4j.LoggerFactory) TraceFormatter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.TraceFormatter) Supplier(java.util.function.Supplier) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProtocolSchedule(org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BlockParameter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter) JsonRpcRequestContext(org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext) BlockTrace(org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace) Suppliers(com.google.common.base.Suppliers) JsonNode(com.fasterxml.jackson.databind.JsonNode) Block(org.hyperledger.besu.ethereum.core.Block) FlatTraceGenerator(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.flat.FlatTraceGenerator) TraceWriter(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.TraceWriter) TransactionTrace(org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace) Logger(org.slf4j.Logger) VmTraceGenerator(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.vm.VmTraceGenerator) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) BlockchainQueries(org.hyperledger.besu.ethereum.api.query.BlockchainQueries) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) DebugOperationTracer(org.hyperledger.besu.ethereum.vm.DebugOperationTracer) TransactionProcessingResult(org.hyperledger.besu.ethereum.processing.TransactionProcessingResult) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) List(java.util.List) RpcMethod(org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod) Optional(java.util.Optional) StateDiffGenerator(org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.diff.StateDiffGenerator) VM_TRACE(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType.VM_TRACE) BlockTracer(org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer) TraceType(org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType) DebugOperationTracer(org.hyperledger.besu.ethereum.vm.DebugOperationTracer) TraceOptions(org.hyperledger.besu.ethereum.debug.TraceOptions) BlockTrace(org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Suppliers (com.google.common.base.Suppliers)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Supplier (java.util.function.Supplier)2 RpcMethod (org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod)2 JsonRpcRequestContext (org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext)2 BlockParameter (org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter)2 TraceTypeParameter (org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter)2 TraceType (org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType)2 TRACE (org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType.TRACE)2 VM_TRACE (org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType.VM_TRACE)2 BlockTrace (org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace)2 BlockTracer (org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer)2