Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit 92ac37f

Browse files
lu-pintogaryschulte
authored andcommitted
Pass miningBeneficiary address to BlockAwareOperationTracer::traceStartBlock calls (#8096)
Signed-off-by: Luis Pinto <[email protected]>
1 parent 4a97d57 commit 92ac37f

File tree

7 files changed

+32
-17
lines changed

7 files changed

+32
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

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

89
### Upcoming Breaking Changes
910
- `MetricSystem::createLabelledGauge` is deprecated and will be removed in a future release, replace it with `MetricSystem::createLabelledSuppliedGauge`

besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import static com.google.common.base.Preconditions.checkArgument;
1818
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;
1919

20+
import org.hyperledger.besu.datatypes.Address;
2021
import org.hyperledger.besu.datatypes.BlobGas;
2122
import org.hyperledger.besu.datatypes.Hash;
2223
import org.hyperledger.besu.datatypes.Wei;
@@ -152,16 +153,13 @@ public void trace(
152153
.toList();
153154
Tracer.processTracing(
154155
blockchainQueries,
155-
blocks.get(0).getHash(),
156+
blocks.getFirst().getHash(),
156157
traceableState -> {
157158
final WorldUpdater worldStateUpdater = traceableState.updater();
158159
final ChainUpdater chainUpdater = new ChainUpdater(traceableState, worldStateUpdater);
159160
beforeTracing.accept(worldStateUpdater);
160161
final List<TransactionProcessingResult> results = new ArrayList<>();
161-
blocks.forEach(
162-
block -> {
163-
results.addAll(trace(blockchain, block, chainUpdater, tracer));
164-
});
162+
blocks.forEach(block -> results.addAll(trace(blockchain, block, chainUpdater, tracer)));
165163
afterTracing.accept(chainUpdater.getNextUpdater());
166164
return Optional.of(results);
167165
});
@@ -191,7 +189,9 @@ private List<TransactionProcessingResult> trace(
191189
final ProtocolSpec protocolSpec = protocolSchedule.getByBlockHeader(block.getHeader());
192190
final MainnetTransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor();
193191
final BlockHeader header = block.getHeader();
194-
tracer.traceStartBlock(block.getHeader(), block.getBody());
192+
final Address miningBeneficiary =
193+
protocolSpec.getMiningBeneficiaryCalculator().calculateBeneficiary(block.getHeader());
194+
tracer.traceStartBlock(block.getHeader(), block.getBody(), miningBeneficiary);
195195

196196
block
197197
.getBody()

besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ void shouldRetrieveStateUpdatePostTracingForOneBlock() {
114114

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

117-
verify(opTracer).traceStartBlock(tracedBlock.getHeader(), tracedBlock.getBody());
117+
verify(opTracer)
118+
.traceStartBlock(
119+
tracedBlock.getHeader(), tracedBlock.getBody(), tracedBlock.getHeader().getCoinbase());
118120

119121
tracedBlock
120122
.getBody()
@@ -163,7 +165,11 @@ void shouldRetrieveStateUpdatePostTracingForAllBlocks() {
163165
.map(Optional::get)
164166
.forEach(
165167
tracedBlock -> {
166-
verify(opTracer).traceStartBlock(tracedBlock.getHeader(), tracedBlock.getBody());
168+
verify(opTracer)
169+
.traceStartBlock(
170+
tracedBlock.getHeader(),
171+
tracedBlock.getBody(),
172+
tracedBlock.getHeader().getCoinbase());
167173
tracedBlock
168174
.getBody()
169175
.getTransactions()
@@ -312,7 +318,8 @@ public void traceEndTransaction(
312318
}
313319

314320
@Override
315-
public void traceStartBlock(final BlockHeader blockHeader, final BlockBody blockBody) {
321+
public void traceStartBlock(
322+
final BlockHeader blockHeader, final BlockBody blockBody, final Address miningBeneficiary) {
316323
if (!traceStartBlockCalled.add(blockHeader.getBlockHash())) {
317324
fail("traceStartBlock already called for block " + blockHeader);
318325
}

ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ protected BlockCreationResult createBlock(
221221
final BlockAwareOperationTracer operationTracer =
222222
pluginTransactionSelector.getOperationTracer();
223223

224-
operationTracer.traceStartBlock(processableBlockHeader);
224+
operationTracer.traceStartBlock(processableBlockHeader, miningBeneficiary);
225225
timings.register("preTxsSelection");
226226
final TransactionSelectionResults transactionResults =
227227
selectTransactions(

ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/InterruptibleOperationTracer.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ public InterruptibleOperationTracer(final BlockAwareOperationTracer delegate) {
4141
}
4242

4343
@Override
44-
public void traceStartBlock(final BlockHeader blockHeader, final BlockBody blockBody) {
45-
delegate.traceStartBlock(blockHeader, blockBody);
44+
public void traceStartBlock(
45+
final BlockHeader blockHeader, final BlockBody blockBody, final Address miningBeneficiary) {
46+
delegate.traceStartBlock(blockHeader, blockBody, miningBeneficiary);
4647
}
4748

4849
@Override
@@ -51,8 +52,9 @@ public void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockBo
5152
}
5253

5354
@Override
54-
public void traceStartBlock(final ProcessableBlockHeader processableBlockHeader) {
55-
delegate.traceStartBlock(processableBlockHeader);
55+
public void traceStartBlock(
56+
final ProcessableBlockHeader processableBlockHeader, final Address miningBeneficiary) {
57+
delegate.traceStartBlock(processableBlockHeader, miningBeneficiary);
5658
}
5759

5860
@Override

plugin-api/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Calculated : ${currentHash}
7171
tasks.register('checkAPIChanges', FileStateChecker) {
7272
description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
7373
files = sourceSets.main.allJava.files
74-
knownHash = 'By1EMWJvyXiRxNf52xZ0BUC2LpE6D4VlNHI0jYJryj0='
74+
knownHash = 'b/u9Ety5B+Ni8UwGhvU8dq4jcZtulNczsVQZgG0Q5fw='
7575
}
7676
check.dependsOn('checkAPIChanges')
7777

plugin-api/src/main/java/org/hyperledger/besu/plugin/services/tracer/BlockAwareOperationTracer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
package org.hyperledger.besu.plugin.services.tracer;
1616

17+
import org.hyperledger.besu.datatypes.Address;
1718
import org.hyperledger.besu.evm.tracing.OperationTracer;
1819
import org.hyperledger.besu.plugin.data.BlockBody;
1920
import org.hyperledger.besu.plugin.data.BlockHeader;
@@ -37,8 +38,10 @@ public interface BlockAwareOperationTracer extends OperationTracer {
3738
*
3839
* @param blockHeader the header of the block which is traced
3940
* @param blockBody the body of the block which is traced
41+
* @param miningBeneficiary the address of miner building the block
4042
*/
41-
default void traceStartBlock(final BlockHeader blockHeader, final BlockBody blockBody) {}
43+
default void traceStartBlock(
44+
final BlockHeader blockHeader, final BlockBody blockBody, final Address miningBeneficiary) {}
4245

4346
/**
4447
* Trace the end of a block.
@@ -52,8 +55,10 @@ default void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockB
5255
* When building a block this API is called at the start of the process
5356
*
5457
* @param processableBlockHeader the processable header
58+
* @param miningBeneficiary the address of miner building the block
5559
*/
56-
default void traceStartBlock(final ProcessableBlockHeader processableBlockHeader) {}
60+
default void traceStartBlock(
61+
final ProcessableBlockHeader processableBlockHeader, final Address miningBeneficiary) {}
5762

5863
@Override
5964
default boolean isExtendedTracing() {

0 commit comments

Comments
 (0)