Skip to content

Commit

Permalink
Pass miningBeneficiary address to BlockAwareOperationTracer::traceSta…
Browse files Browse the repository at this point in the history
…rtBlock calls

Signed-off-by: Luis Pinto <[email protected]>
  • Loading branch information
lu-pinto committed Jan 9, 2025
1 parent 8448743 commit bf28c88
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private List<TransactionProcessingResult> trace(
final ProtocolSpec protocolSpec = protocolSchedule.getByBlockHeader(block.getHeader());
final MainnetTransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor();
final BlockHeader header = block.getHeader();
tracer.traceStartBlock(block.getHeader(), block.getBody());
tracer.traceStartBlock(block.getHeader(), block.getBody(), block.getHeader().getCoinbase());

block
.getBody()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ void shouldRetrieveStateUpdatePostTracingForOneBlock() {

final Block tracedBlock = blockchain.getBlockByNumber(blockNumber).get();

verify(opTracer).traceStartBlock(tracedBlock.getHeader(), tracedBlock.getBody());
verify(opTracer)
.traceStartBlock(
tracedBlock.getHeader(), tracedBlock.getBody(), tracedBlock.getHeader().getCoinbase());

tracedBlock
.getBody()
Expand Down Expand Up @@ -163,7 +165,11 @@ void shouldRetrieveStateUpdatePostTracingForAllBlocks() {
.map(Optional::get)
.forEach(
tracedBlock -> {
verify(opTracer).traceStartBlock(tracedBlock.getHeader(), tracedBlock.getBody());
verify(opTracer)
.traceStartBlock(
tracedBlock.getHeader(),
tracedBlock.getBody(),
tracedBlock.getHeader().getCoinbase());
tracedBlock
.getBody()
.getTransactions()
Expand Down Expand Up @@ -312,7 +318,8 @@ public void traceEndTransaction(
}

@Override
public void traceStartBlock(final BlockHeader blockHeader, final BlockBody blockBody) {
public void traceStartBlock(
final BlockHeader blockHeader, final BlockBody blockBody, final Address miningBeneficiary) {
if (!traceStartBlockCalled.add(blockHeader.getBlockHash())) {
fail("traceStartBlock already called for block " + blockHeader);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ protected BlockCreationResult createBlock(
final BlockAwareOperationTracer operationTracer =
pluginTransactionSelector.getOperationTracer();

operationTracer.traceStartBlock(processableBlockHeader);
operationTracer.traceStartBlock(processableBlockHeader, miningBeneficiary);
timings.register("preTxsSelection");
final TransactionSelectionResults transactionResults =
selectTransactions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ public InterruptibleOperationTracer(final BlockAwareOperationTracer delegate) {
}

@Override
public void traceStartBlock(final BlockHeader blockHeader, final BlockBody blockBody) {
delegate.traceStartBlock(blockHeader, blockBody);
public void traceStartBlock(
final BlockHeader blockHeader, final BlockBody blockBody, final Address miningBeneficiary) {
delegate.traceStartBlock(blockHeader, blockBody, miningBeneficiary);
}

@Override
Expand All @@ -51,8 +52,9 @@ public void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockBo
}

@Override
public void traceStartBlock(final ProcessableBlockHeader processableBlockHeader) {
delegate.traceStartBlock(processableBlockHeader);
public void traceStartBlock(
final ProcessableBlockHeader processableBlockHeader, final Address miningBeneficiary) {
delegate.traceStartBlock(processableBlockHeader, miningBeneficiary);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion plugin-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files
knownHash = 'By1EMWJvyXiRxNf52xZ0BUC2LpE6D4VlNHI0jYJryj0='
knownHash = 'b/u9Ety5B+Ni8UwGhvU8dq4jcZtulNczsVQZgG0Q5fw='
}
check.dependsOn('checkAPIChanges')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.plugin.services.tracer;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.plugin.data.BlockBody;
import org.hyperledger.besu.plugin.data.BlockHeader;
Expand All @@ -37,8 +38,10 @@ public interface BlockAwareOperationTracer extends OperationTracer {
*
* @param blockHeader the header of the block which is traced
* @param blockBody the body of the block which is traced
* @param miningBeneficiary the address of miner building the block
*/
default void traceStartBlock(final BlockHeader blockHeader, final BlockBody blockBody) {}
default void traceStartBlock(
final BlockHeader blockHeader, final BlockBody blockBody, final Address miningBeneficiary) {}

/**
* Trace the end of a block.
Expand All @@ -52,8 +55,10 @@ default void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockB
* When building a block this API is called at the start of the process
*
* @param processableBlockHeader the processable header
* @param miningBeneficiary the address of miner building the block
*/
default void traceStartBlock(final ProcessableBlockHeader processableBlockHeader) {}
default void traceStartBlock(
final ProcessableBlockHeader processableBlockHeader, final Address miningBeneficiary) {}

@Override
default boolean isExtendedTracing() {
Expand Down

0 comments on commit bf28c88

Please sign in to comment.