use of org.hyperledger.besu.ethereum.vm.DebugOperationTracer in project besu by hyperledger.
the class DebugTraceBlockByNumber method resultByBlockNumber.
@Override
protected Object resultByBlockNumber(final JsonRpcRequestContext request, final long blockNumber) {
final Optional<Hash> blockHash = getBlockchainQueries().getBlockHashByNumber(blockNumber);
final TraceOptions traceOptions = request.getOptionalParameter(1, TransactionTraceParams.class).map(TransactionTraceParams::traceOptions).orElse(TraceOptions.DEFAULT);
return blockHash.flatMap(hash -> blockTracerSupplier.get().trace(hash, new DebugOperationTracer(traceOptions)).map(BlockTrace::getTransactionTraces).map(DebugTraceTransactionResult::of)).orElse(null);
}
use of org.hyperledger.besu.ethereum.vm.DebugOperationTracer in project besu by hyperledger.
the class TraceCallMany method getSingleCallResult.
private JsonNode getSingleCallResult(final JsonCallParameter callParameter, final TraceTypeParameter traceTypeParameter, final BlockHeader header, final WorldUpdater worldUpdater) {
final Set<TraceTypeParameter.TraceType> traceTypes = traceTypeParameter.getTraceTypes();
final DebugOperationTracer tracer = new DebugOperationTracer(buildTraceOptions(traceTypes));
final Optional<TransactionSimulatorResult> maybeSimulatorResult = transactionSimulator.processWithWorldUpdater(callParameter, buildTransactionValidationParams(), tracer, header, worldUpdater);
LOG.trace("Executing {} call for transaction {}", traceTypeParameter, callParameter);
if (maybeSimulatorResult.isEmpty()) {
throw new EmptySimulatorResultException();
}
final TransactionSimulatorResult simulatorResult = maybeSimulatorResult.get();
if (simulatorResult.isInvalid()) {
throw new TransactionInvalidException();
}
final TransactionTrace transactionTrace = new TransactionTrace(simulatorResult.getTransaction(), simulatorResult.getResult(), tracer.getTraceFrames());
final Block block = blockchainQueriesSupplier.get().getBlockchain().getChainHeadBlock();
return getTraceCallResult(protocolSchedule, traceTypes, maybeSimulatorResult, transactionTrace, block);
}
use of org.hyperledger.besu.ethereum.vm.DebugOperationTracer in project besu by hyperledger.
the class TraceRawTransaction method response.
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 2) {
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
}
final var rawTransaction = requestContext.getRequiredParameter(0, String.class);
final TraceTypeParameter traceTypeParameter = requestContext.getRequiredParameter(1, TraceTypeParameter.class);
LOG.trace("Received RPC rpcName={} rawTx={} traceType={}", getName(), rawTransaction, traceTypeParameter);
final Transaction transaction;
try {
transaction = DomainObjectDecodeUtils.decodeRawTransaction(rawTransaction);
LOG.trace("rawTx decoded to transaction {}", transaction);
} catch (final RLPException | IllegalArgumentException e) {
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
}
final Set<TraceTypeParameter.TraceType> traceTypes = traceTypeParameter.getTraceTypes();
final DebugOperationTracer tracer = new DebugOperationTracer(buildTraceOptions(traceTypes));
final long headBlockNumber = blockchainQueriesSupplier.get().headBlockNumber();
final Optional<TransactionSimulatorResult> maybeSimulatorResult = transactionSimulator.process(CallParameter.fromTransaction(transaction), buildTransactionValidationParams(), tracer, headBlockNumber);
if (maybeSimulatorResult.isEmpty()) {
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), INTERNAL_ERROR);
}
final TransactionTrace transactionTrace = new TransactionTrace(maybeSimulatorResult.get().getTransaction(), maybeSimulatorResult.get().getResult(), tracer.getTraceFrames());
final Optional<Block> maybeBlock = blockchainQueriesSupplier.get().getBlockchain().getBlockByNumber(headBlockNumber);
if (maybeBlock.isEmpty()) {
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), INTERNAL_ERROR);
}
final Block block = maybeBlock.get();
final Object response = getTraceCallResult(protocolSchedule, traceTypes, maybeSimulatorResult, transactionTrace, block);
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), response);
}
use of org.hyperledger.besu.ethereum.vm.DebugOperationTracer 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);
}
use of org.hyperledger.besu.ethereum.vm.DebugOperationTracer in project besu by hyperledger.
the class TraceBlock method traceBlock.
protected ArrayNodeWrapper traceBlock(final Block block, final Optional<FilterParameter> filterParameter) {
if (block == null) {
return emptyResult();
}
final ArrayNodeWrapper resultArrayNode = new ArrayNodeWrapper(MAPPER.createArrayNode());
blockTracerSupplier.get().trace(block, new DebugOperationTracer(new TraceOptions(false, false, true))).ifPresent(blockTrace -> generateTracesFromTransactionTraceAndBlock(filterParameter, blockTrace.getTransactionTraces(), block, resultArrayNode));
generateRewardsFromBlock(filterParameter, block, resultArrayNode);
return resultArrayNode;
}
Aggregations