add worldstate to traceEndBlock

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
pull/7386/head
Daniel Lehrner 4 months ago
parent 76a3df704e
commit 1428ed4f55
  1. 5
      besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java
  2. 14
      besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java
  3. 2
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java
  4. 4
      plugin-api/src/main/java/org/hyperledger/besu/plugin/services/tracer/BlockAwareOperationTracer.java

@ -194,6 +194,7 @@ public class TraceServiceImpl implements TraceService {
final BlockHeader header = block.getHeader(); final BlockHeader header = block.getHeader();
tracer.traceStartBlock(block.getHeader(), block.getBody()); tracer.traceStartBlock(block.getHeader(), block.getBody());
final WorldUpdater worldUpdater = chainUpdater.getNextUpdater();
block block
.getBody() .getBody()
.getTransactions() .getTransactions()
@ -209,7 +210,6 @@ public class TraceServiceImpl implements TraceService {
.map(parent -> calculateExcessBlobGasForParent(protocolSpec, parent)) .map(parent -> calculateExcessBlobGasForParent(protocolSpec, parent))
.orElse(BlobGas.ZERO)); .orElse(BlobGas.ZERO));
final WorldUpdater worldUpdater = chainUpdater.getNextUpdater();
final TransactionProcessingResult result = final TransactionProcessingResult result =
transactionProcessor.processTransaction( transactionProcessor.processTransaction(
worldUpdater, worldUpdater,
@ -224,7 +224,8 @@ public class TraceServiceImpl implements TraceService {
results.add(result); results.add(result);
}); });
tracer.traceEndBlock(block.getHeader(), block.getBody()); tracer.traceEndBlock(
block.getHeader(), block.getBody(), blockchainQueries.getWorldStateArchive().getMutable());
return results; return results;
} }

@ -34,6 +34,7 @@ import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.log.Log; import org.hyperledger.besu.evm.log.Log;
import org.hyperledger.besu.evm.worldstate.WorldState;
import org.hyperledger.besu.evm.worldstate.WorldView; import org.hyperledger.besu.evm.worldstate.WorldView;
import org.hyperledger.besu.plugin.data.BlockBody; import org.hyperledger.besu.plugin.data.BlockBody;
import org.hyperledger.besu.plugin.data.BlockHeader; import org.hyperledger.besu.plugin.data.BlockHeader;
@ -128,7 +129,9 @@ class TraceServiceImplTest {
any(), eq(tx), anyBoolean(), any(), any(), anyLong(), any(), anyLong()); any(), eq(tx), anyBoolean(), any(), any(), anyLong(), any(), anyLong());
}); });
verify(opTracer).traceEndBlock(tracedBlock.getHeader(), tracedBlock.getBody()); verify(opTracer)
.traceEndBlock(
tracedBlock.getHeader(), tracedBlock.getBody(), worldStateArchive.getMutable());
} }
@Test @Test
@ -183,7 +186,11 @@ class TraceServiceImplTest {
anyLong()); anyLong());
}); });
verify(opTracer).traceEndBlock(tracedBlock.getHeader(), tracedBlock.getBody()); verify(opTracer)
.traceEndBlock(
tracedBlock.getHeader(),
tracedBlock.getBody(),
worldStateArchive.getMutable());
}); });
} }
@ -319,7 +326,8 @@ class TraceServiceImplTest {
} }
@Override @Override
public void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockBody) { public void traceEndBlock(
final BlockHeader blockHeader, final BlockBody blockBody, final WorldState worldState) {
if (!traceEndBlockCalled.add(blockHeader.getBlockHash())) { if (!traceEndBlockCalled.add(blockHeader.getBlockHash())) {
fail("traceEndBlock already called for block " + blockHeader); fail("traceEndBlock already called for block " + blockHeader);
} }

@ -308,7 +308,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator {
transactionResults.getSelectedTransactions(), ommers, withdrawals, maybeRequests); transactionResults.getSelectedTransactions(), ommers, withdrawals, maybeRequests);
final Block block = new Block(blockHeader, blockBody); final Block block = new Block(blockHeader, blockBody);
operationTracer.traceEndBlock(blockHeader, blockBody); operationTracer.traceEndBlock(blockHeader, blockBody, disposableWorldState);
timings.register("blockAssembled"); timings.register("blockAssembled");
return new BlockCreationResult(block, transactionResults, timings); return new BlockCreationResult(block, transactionResults, timings);
} catch (final SecurityModuleException ex) { } catch (final SecurityModuleException ex) {

@ -15,6 +15,7 @@
package org.hyperledger.besu.plugin.services.tracer; package org.hyperledger.besu.plugin.services.tracer;
import org.hyperledger.besu.evm.tracing.OperationTracer; import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.worldstate.WorldState;
import org.hyperledger.besu.plugin.data.BlockBody; import org.hyperledger.besu.plugin.data.BlockBody;
import org.hyperledger.besu.plugin.data.BlockHeader; import org.hyperledger.besu.plugin.data.BlockHeader;
import org.hyperledger.besu.plugin.data.ProcessableBlockHeader; import org.hyperledger.besu.plugin.data.ProcessableBlockHeader;
@ -46,7 +47,8 @@ public interface BlockAwareOperationTracer extends OperationTracer {
* @param blockHeader the header of the block which is traced * @param blockHeader the header of the block which is traced
* @param blockBody the body of the block which is traced * @param blockBody the body of the block which is traced
*/ */
default void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockBody) {} default void traceEndBlock(
final BlockHeader blockHeader, final BlockBody blockBody, final WorldState worldState) {}
/** /**
* When building a block this API is called at the start of the process * When building a block this API is called at the start of the process

Loading…
Cancel
Save