use of org.ethereum.vm.trace.ProgramTraceProcessor in project rskj by rsksmart.
the class DebugModuleImpl method traceBlock.
@Override
public JsonNode traceBlock(String blockHash, Map<String, String> traceOptions) {
logger.trace("debug_traceBlockByHash({}, {})", blockHash, traceOptions);
if (traceOptions != null && !traceOptions.isEmpty()) {
// TODO: implement the logic that takes into account trace options.
logger.warn("Received {} trace options. For now trace options are being ignored", traceOptions);
}
byte[] bHash = stringHexToByteArray(blockHash);
Block block = blockStore.getBlockByHash(bHash);
if (block == null) {
logger.trace("No block is found for {}", bHash);
return null;
}
Block parent = blockStore.getBlockByHash(block.getParentHash().getBytes());
ProgramTraceProcessor programTraceProcessor = new ProgramTraceProcessor();
blockExecutor.traceBlock(programTraceProcessor, 0, block, parent.getHeader(), false, false);
List<Keccak256> txHashes = block.getTransactionsList().stream().map(Transaction::getHash).collect(Collectors.toList());
return programTraceProcessor.getProgramTracesAsJsonNode(txHashes);
}
use of org.ethereum.vm.trace.ProgramTraceProcessor in project rskj by rsksmart.
the class TraceModuleImpl method traceTransaction.
@Override
public JsonNode traceTransaction(String transactionHash) throws Exception {
logger.trace("trace_transaction({})", transactionHash);
byte[] hash = stringHexToByteArray(transactionHash);
TransactionInfo txInfo = this.receiptStore.getInMainChain(hash, this.blockStore).orElse(null);
if (txInfo == null) {
logger.trace("No transaction info for {}", transactionHash);
return null;
}
Block block = this.blockchain.getBlockByHash(txInfo.getBlockHash());
Block parent = this.blockchain.getBlockByHash(block.getParentHash().getBytes());
Transaction tx = block.getTransactionsList().get(txInfo.getIndex());
txInfo.setTransaction(tx);
ProgramTraceProcessor programTraceProcessor = new ProgramTraceProcessor();
this.blockExecutor.traceBlock(programTraceProcessor, VmConfig.LIGHT_TRACE, block, parent.getHeader(), false, false);
SummarizedProgramTrace programTrace = (SummarizedProgramTrace) programTraceProcessor.getProgramTrace(tx.getHash());
if (programTrace == null) {
return null;
}
List<TransactionTrace> traces = TraceTransformer.toTraces(programTrace, txInfo, block.getNumber());
return OBJECT_MAPPER.valueToTree(traces);
}
use of org.ethereum.vm.trace.ProgramTraceProcessor in project rskj by rsksmart.
the class TraceModuleImpl method traceBlock.
@Override
public JsonNode traceBlock(String blockArgument) throws Exception {
logger.trace("trace_block({})", blockArgument);
Block block = this.getByJsonArgument(blockArgument);
if (block == null) {
logger.trace("No block for {}", blockArgument);
return null;
}
Block parent = this.blockchain.getBlockByHash(block.getParentHash().getBytes());
List<TransactionTrace> blockTraces = new ArrayList<>();
if (block.getNumber() != 0) {
ProgramTraceProcessor programTraceProcessor = new ProgramTraceProcessor();
this.blockExecutor.traceBlock(programTraceProcessor, VmConfig.LIGHT_TRACE, block, parent.getHeader(), false, false);
for (Transaction tx : block.getTransactionsList()) {
TransactionInfo txInfo = receiptStore.getInMainChain(tx.getHash().getBytes(), this.blockStore).orElse(null);
Objects.requireNonNull(txInfo);
txInfo.setTransaction(tx);
SummarizedProgramTrace programTrace = (SummarizedProgramTrace) programTraceProcessor.getProgramTrace(tx.getHash());
if (programTrace == null) {
return null;
}
List<TransactionTrace> traces = TraceTransformer.toTraces(programTrace, txInfo, block.getNumber());
blockTraces.addAll(traces);
}
}
return OBJECT_MAPPER.valueToTree(blockTraces);
}
use of org.ethereum.vm.trace.ProgramTraceProcessor in project rskj by rsksmart.
the class DebugModuleImpl method traceTransaction.
@Override
public JsonNode traceTransaction(String transactionHash, Map<String, String> traceOptions) {
logger.trace("debug_traceTransaction({}, {})", transactionHash, traceOptions);
if (traceOptions != null && !traceOptions.isEmpty()) {
// TODO: implement the logic that takes into account trace options.
logger.warn("Received {} trace options. For now trace options are being ignored", traceOptions);
}
byte[] hash = stringHexToByteArray(transactionHash);
TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore).orElse(null);
if (txInfo == null) {
logger.trace("No transaction info for {}", transactionHash);
return null;
}
Block block = blockStore.getBlockByHash(txInfo.getBlockHash());
Block parent = blockStore.getBlockByHash(block.getParentHash().getBytes());
Transaction tx = block.getTransactionsList().get(txInfo.getIndex());
txInfo.setTransaction(tx);
ProgramTraceProcessor programTraceProcessor = new ProgramTraceProcessor();
blockExecutor.traceBlock(programTraceProcessor, 0, block, parent.getHeader(), false, false);
return programTraceProcessor.getProgramTraceAsJsonNode(tx.getHash());
}
Aggregations