Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass miningBeneficiary address to BlockAwareOperationTracer::traceStartBlock calls #8096

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Breaking Changes
- `--host-whitelist` has been deprecated since 2020 and this option is removed. Use the equivalent `--host-allowlist` instead.
- Changed tracer API to include the mining beneficiary in BlockAwareOperationTracer::traceStartBlock [#8096](https://github.com/hyperledger/besu/pull/8096)

### Upcoming Breaking Changes
- `MetricSystem::createLabelledGauge` is deprecated and will be removed in a future release, replace it with `MetricSystem::createLabelledSuppliedGauge`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.BlobGas;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
Expand Down Expand Up @@ -152,16 +153,13 @@ public void trace(
.toList();
Tracer.processTracing(
blockchainQueries,
blocks.get(0).getHash(),
blocks.getFirst().getHash(),
traceableState -> {
final WorldUpdater worldStateUpdater = traceableState.updater();
final ChainUpdater chainUpdater = new ChainUpdater(traceableState, worldStateUpdater);
beforeTracing.accept(worldStateUpdater);
final List<TransactionProcessingResult> results = new ArrayList<>();
blocks.forEach(
block -> {
results.addAll(trace(blockchain, block, chainUpdater, tracer));
});
blocks.forEach(block -> results.addAll(trace(blockchain, block, chainUpdater, tracer)));
afterTracing.accept(chainUpdater.getNextUpdater());
return Optional.of(results);
});
Expand Down Expand Up @@ -191,7 +189,9 @@ 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());
final Address miningBeneficiary =
protocolSpec.getMiningBeneficiaryCalculator().calculateBeneficiary(block.getHeader());
tracer.traceStartBlock(block.getHeader(), block.getBody(), miningBeneficiary);

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have been great to keep the previous methods signature (marking them deprecated for removal) so existing plugins will not break.
Since this is already merged, that can be done in a following PR.

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
Loading