From e85a436032caab7abf022fe3fefbb00da495fa06 Mon Sep 17 00:00:00 2001 From: Matt Whitehead Date: Wed, 20 Nov 2024 13:27:28 +0000 Subject: [PATCH] Don't create reward account if no reward (#7826) * Don't create reward account if no reward Signed-off-by: Matthew Whitehead * Remove unnecessary test stub Signed-off-by: Matthew Whitehead * Extra check to only create 0 balance accounts if clearEmptyAccounts isn't set Signed-off-by: Matthew Whitehead --------- Signed-off-by: Matthew Whitehead --- .../besu/ethereum/mainnet/MainnetTransactionProcessor.java | 7 ++++--- .../ethereum/mainnet/MainnetTransactionProcessorTest.java | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java index 5ff2129972..c662c18864 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java @@ -532,9 +532,10 @@ public class MainnetTransactionProcessor { coinbaseCalculator.price(usedGas, transactionGasPrice, blockHeader.getBaseFee()); operationTracer.traceBeforeRewardTransaction(worldUpdater, transaction, coinbaseWeiDelta); - - final var coinbase = evmWorldUpdater.getOrCreate(miningBeneficiary); - coinbase.incrementBalance(coinbaseWeiDelta); + if (!coinbaseWeiDelta.isZero() || !clearEmptyAccounts) { + final var coinbase = evmWorldUpdater.getOrCreate(miningBeneficiary); + coinbase.incrementBalance(coinbaseWeiDelta); + } operationTracer.traceEndTransaction( evmWorldUpdater.updater(), diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java index d8d9f3777e..c40da7210e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java @@ -108,7 +108,6 @@ class MainnetTransactionProcessorTest { .thenReturn(ValidationResult.valid()); when(transactionValidatorFactory.get().validateForSender(any(), any(), any())) .thenReturn(ValidationResult.valid()); - when(worldState.getOrCreate(any())).thenReturn(senderAccount); when(worldState.getOrCreateSenderAccount(any())).thenReturn(senderAccount); when(worldState.updater()).thenReturn(worldState);