Refactor: take blockchain out of MainnetTransactionProcessor (#6962)

Remove an unused parameter in MainnetTransactionProcessor, as well as
all code supporting sending that parameter.

Signed-off-by: Danno Ferrin <danno@numisight.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/6982/head
Danno Ferrin 6 months ago committed by GitHub
parent 32dae8ff87
commit 381e692b1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java
  2. 1
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/ExecuteTransactionStep.java
  3. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockReplay.java
  4. 1
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java
  5. 1
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java
  6. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracerTest.java
  7. 1
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java
  8. 4
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java
  9. 3
      ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java
  10. 1
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java
  11. 18
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java
  12. 1
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java
  13. 1
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java
  14. 1
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java
  15. 6
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java
  16. 2
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java
  17. 2
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java
  18. 4
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java
  19. 4
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java
  20. 3
      ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTestTools.java

@ -212,7 +212,6 @@ public class TraceServiceImpl implements TraceService {
final WorldUpdater worldUpdater = chainUpdater.getNextUpdater();
final TransactionProcessingResult result =
transactionProcessor.processTransaction(
blockchain,
worldUpdater,
header,
transaction,

@ -98,7 +98,6 @@ public class ExecuteTransactionStep implements Function<TransactionTrace, Transa
final BlockHashLookup blockHashLookup = new CachingBlockHashLookup(header, blockchain);
result =
transactionProcessor.processTransaction(
blockchain,
chainUpdater.getNextUpdater(),
header,
transactionTrace.getTransaction(),

@ -107,7 +107,6 @@ public class BlockReplay {
transaction, header, blockchain, transactionProcessor, blobGasPrice));
} else {
transactionProcessor.processTransaction(
blockchain,
mutableWorldState.updater(),
header,
transaction,
@ -134,7 +133,6 @@ public class BlockReplay {
(transaction, blockHeader, blockchain, transactionProcessor, blobGasPrice) -> {
final ProtocolSpec spec = protocolSchedule.getByBlockHeader(blockHeader);
transactionProcessor.processTransaction(
blockchain,
mutableWorldState.updater(),
blockHeader,
transaction,

@ -64,7 +64,6 @@ public class BlockTracer {
chainedUpdater = chainedUpdater.updater();
final TransactionProcessingResult result =
transactionProcessor.processTransaction(
blockchain,
chainedUpdater,
header,
transaction,

@ -187,7 +187,6 @@ public class TransactionTracer {
final OperationTracer tracer,
final Wei blobGasPrice) {
return transactionProcessor.processTransaction(
blockchain,
worldUpdater,
header,
transaction,

@ -180,7 +180,6 @@ public class TransactionTracerTest {
final WorldUpdater updater = mock(WorldUpdater.class);
when(mutableWorldState.updater()).thenReturn(updater);
when(transactionProcessor.processTransaction(
eq(blockchain),
eq(updater),
eq(blockHeader),
eq(transaction),
@ -269,7 +268,6 @@ public class TransactionTracerTest {
final WorldUpdater stackedUpdater = mock(StackedUpdater.class);
when(updater.updater()).thenReturn(stackedUpdater);
when(transactionProcessor.processTransaction(
eq(blockchain),
eq(stackedUpdater),
eq(blockHeader),
eq(transaction),

@ -326,7 +326,6 @@ public class BlockTransactionSelector {
final BlockHashLookup blockHashLookup =
new CachingBlockHashLookup(blockSelectionContext.processableBlockHeader(), blockchain);
return transactionProcessor.processTransaction(
blockchain,
worldStateUpdater,
blockSelectionContext.processableBlockHeader(),
pendingTransaction.getTransaction(),

@ -1345,7 +1345,7 @@ public abstract class AbstractBlockTransactionSelectorTest {
final long gasRemaining,
final long processingTime) {
when(transactionProcessor.processTransaction(
any(), any(), any(), eq(tx), any(), any(), any(), anyBoolean(), any(), any()))
any(), any(), eq(tx), any(), any(), any(), anyBoolean(), any(), any()))
.thenAnswer(
invocation -> {
if (processingTime > 0) {
@ -1370,7 +1370,7 @@ public abstract class AbstractBlockTransactionSelectorTest {
final TransactionInvalidReason invalidReason,
final long processingTime) {
when(transactionProcessor.processTransaction(
any(), any(), any(), eq(tx), any(), any(), any(), anyBoolean(), any(), any()))
any(), any(), eq(tx), any(), any(), any(), anyBoolean(), any(), any()))
.thenAnswer(
invocation -> {
if (processingTime > 0) {

@ -100,7 +100,6 @@ public class TraceTransactionIntegrationTest {
final WorldUpdater createTransactionUpdater = worldState.updater();
TransactionProcessingResult result =
transactionProcessor.processTransaction(
blockchain,
createTransactionUpdater,
genesisBlockHeader,
createTransaction,
@ -133,7 +132,6 @@ public class TraceTransactionIntegrationTest {
final WorldUpdater storeUpdater = worldState.updater();
result =
transactionProcessor.processTransaction(
blockchain,
storeUpdater,
genesisBlockHeader,
executeTransaction,
@ -172,7 +170,6 @@ public class TraceTransactionIntegrationTest {
new BytesValueRLPInput(Bytes.fromHexString(CONTRACT_CREATION_TX), false));
final BlockHeader genesisBlockHeader = genesisBlock.getHeader();
transactionProcessor.processTransaction(
blockchain,
worldStateArchive
.getMutable(genesisBlockHeader.getStateRoot(), genesisBlockHeader.getHash())
.get()

@ -138,7 +138,6 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {
final TransactionProcessingResult result =
transactionProcessor.processTransaction(
blockchain,
worldStateUpdater,
blockHeader,
transaction,

@ -23,7 +23,6 @@ import org.hyperledger.besu.collections.trie.BytesTrieSet;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.feemarket.CoinbaseFeePriceCalculator;
@ -101,7 +100,6 @@ public class MainnetTransactionProcessor {
/**
* Applies a transaction to the current system state.
*
* @param blockchain The current blockchain
* @param worldState The current world state
* @param blockHeader The current block header
* @param transaction The transaction to process
@ -115,7 +113,6 @@ public class MainnetTransactionProcessor {
* @see TransactionValidationParams
*/
public TransactionProcessingResult processTransaction(
final Blockchain blockchain,
final WorldUpdater worldState,
final ProcessableBlockHeader blockHeader,
final Transaction transaction,
@ -125,7 +122,6 @@ public class MainnetTransactionProcessor {
final TransactionValidationParams transactionValidationParams,
final Wei blobGasPrice) {
return processTransaction(
blockchain,
worldState,
blockHeader,
transaction,
@ -141,7 +137,6 @@ public class MainnetTransactionProcessor {
/**
* Applies a transaction to the current system state.
*
* @param blockchain The current blockchain
* @param worldState The current world state
* @param blockHeader The current block header
* @param transaction The transaction to process
@ -156,7 +151,6 @@ public class MainnetTransactionProcessor {
* @see TransactionValidationParams
*/
public TransactionProcessingResult processTransaction(
final Blockchain blockchain,
final WorldUpdater worldState,
final ProcessableBlockHeader blockHeader,
final Transaction transaction,
@ -167,7 +161,6 @@ public class MainnetTransactionProcessor {
final OperationTracer operationTracer,
final Wei blobGasPrice) {
return processTransaction(
blockchain,
worldState,
blockHeader,
transaction,
@ -183,18 +176,16 @@ public class MainnetTransactionProcessor {
/**
* Applies a transaction to the current system state.
*
* @param blockchain The current blockchain
* @param worldState The current world state
* @param blockHeader The current block header
* @param transaction The transaction to process
* @param operationTracer The tracer to record results of each EVM operation
* @param miningBeneficiary The address which is to receive the transaction fee
* @param operationTracer The tracer to record results of each EVM operation
* @param blockHashLookup The {@link BlockHashLookup} to use for BLOCKHASH operations
* @param isPersistingPrivateState Whether the resulting private state will be persisted
* @return the transaction result
*/
public TransactionProcessingResult processTransaction(
final Blockchain blockchain,
final WorldUpdater worldState,
final ProcessableBlockHeader blockHeader,
final Transaction transaction,
@ -204,7 +195,6 @@ public class MainnetTransactionProcessor {
final Boolean isPersistingPrivateState,
final Wei blobGasPrice) {
return processTransaction(
blockchain,
worldState,
blockHeader,
transaction,
@ -220,19 +210,17 @@ public class MainnetTransactionProcessor {
/**
* Applies a transaction to the current system state.
*
* @param blockchain The current blockchain
* @param worldState The current world state
* @param blockHeader The current block header
* @param transaction The transaction to process
* @param operationTracer The tracer to record results of each EVM operation
* @param miningBeneficiary The address which is to receive the transaction fee
* @param operationTracer The tracer to record results of each EVM operation
* @param blockHashLookup The {@link BlockHashLookup} to use for BLOCKHASH operations
* @param isPersistingPrivateState Whether the resulting private state will be persisted
* @param transactionValidationParams The transaction validation parameters to use
* @return the transaction result
*/
public TransactionProcessingResult processTransaction(
final Blockchain blockchain,
final WorldUpdater worldState,
final ProcessableBlockHeader blockHeader,
final Transaction transaction,
@ -243,7 +231,6 @@ public class MainnetTransactionProcessor {
final TransactionValidationParams transactionValidationParams,
final Wei blobGasPrice) {
return processTransaction(
blockchain,
worldState,
blockHeader,
transaction,
@ -257,7 +244,6 @@ public class MainnetTransactionProcessor {
}
public TransactionProcessingResult processTransaction(
final Blockchain ignoredBlockchain,
final WorldUpdater worldState,
final ProcessableBlockHeader blockHeader,
final Transaction transaction,

@ -171,7 +171,6 @@ public class PrivateGroupRehydrationBlockProcessor {
// depend on public state
final TransactionProcessingResult result =
transactionProcessor.processTransaction(
blockchain,
worldStateUpdater,
blockHeader,
transaction,

@ -103,7 +103,6 @@ public class PrivateMigrationBlockProcessor {
final TransactionProcessingResult result =
transactionProcessor.processTransaction(
blockchain,
worldStateUpdater,
blockHeader,
transaction,

@ -277,7 +277,6 @@ public class TransactionSimulator {
final Transaction transaction = maybeTransaction.get();
final TransactionProcessingResult result =
transactionProcessor.processTransaction(
blockchain,
updater,
blockHeaderToProcess,
transaction,

@ -22,7 +22,6 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.feemarket.CoinbaseFeePriceCalculator;
@ -69,7 +68,6 @@ class MainnetTransactionProcessorTest {
@Mock private AbstractMessageProcessor contractCreationProcessor;
@Mock private AbstractMessageProcessor messageCallProcessor;
@Mock private Blockchain blockchain;
@Mock private WorldUpdater worldState;
@Mock private ProcessableBlockHeader blockHeader;
@Mock private Transaction transaction;
@ -124,7 +122,6 @@ class MainnetTransactionProcessorTest {
var transactionProcessor = createTransactionProcessor(true);
transactionProcessor.processTransaction(
blockchain,
worldState,
blockHeader,
transaction,
@ -138,7 +135,6 @@ class MainnetTransactionProcessorTest {
transactionProcessor = createTransactionProcessor(false);
transactionProcessor.processTransaction(
blockchain,
worldState,
blockHeader,
transaction,
@ -187,7 +183,6 @@ class MainnetTransactionProcessorTest {
var transactionProcessor = createTransactionProcessor(true);
try {
transactionProcessor.processTransaction(
blockchain,
worldState,
blockHeader,
transaction,
@ -237,7 +232,6 @@ class MainnetTransactionProcessorTest {
var transactionProcessor = createTransactionProcessor(false);
transactionProcessor.processTransaction(
blockchain,
worldState,
blockHeader,
transaction,

@ -202,7 +202,7 @@ class PrivacyBlockProcessorTest {
final MainnetTransactionProcessor mockPublicTransactionProcessor =
mock(MainnetTransactionProcessor.class);
when(mockPublicTransactionProcessor.processTransaction(
any(), any(), any(), any(), any(), any(), anyBoolean(), any(), any()))
any(), any(), any(), any(), any(), anyBoolean(), any(), any()))
.thenReturn(
TransactionProcessingResult.successful(
Collections.emptyList(), 0, 0, Bytes.EMPTY, ValidationResult.valid()));

@ -742,7 +742,6 @@ public class TransactionSimulatorTest {
}
when(transactionProcessor.processTransaction(
any(),
any(),
any(),
eq(transaction),
@ -758,7 +757,6 @@ public class TransactionSimulatorTest {
private void verifyTransactionWasProcessed(final Transaction expectedTransaction) {
verify(transactionProcessor)
.processTransaction(
any(),
any(),
any(),
eq(expectedTransaction),

@ -34,7 +34,6 @@ import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.referencetests.GeneralStateTestCaseEipSpec;
import org.hyperledger.besu.ethereum.referencetests.GeneralStateTestCaseSpec;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.evm.account.Account;
@ -248,14 +247,11 @@ public class StateTestSubCommand implements Runnable {
final ProtocolSpec protocolSpec = protocolSchedule.getByBlockHeader(blockHeader);
final MainnetTransactionProcessor processor = protocolSpec.getTransactionProcessor();
final WorldUpdater worldStateUpdater = worldState.updater();
final ReferenceTestBlockchain blockchain =
new ReferenceTestBlockchain(blockHeader.getNumber());
final Stopwatch timer = Stopwatch.createStarted();
// Todo: EIP-4844 use the excessBlobGas of the parent instead of BlobGas.ZERO
final Wei blobGasPrice = protocolSpec.getFeeMarket().blobGasPricePerGas(BlobGas.ZERO);
final TransactionProcessingResult result =
processor.processTransaction(
blockchain,
worldStateUpdater,
blockHeader,
transaction,

@ -43,7 +43,6 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestEnv;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestWorldState;
@ -253,8 +252,6 @@ public class T8nExecutor {
final BlockHeader blockHeader = referenceTestEnv.updateFromParentValues(protocolSpec);
final MainnetTransactionProcessor processor = protocolSpec.getTransactionProcessor();
final WorldUpdater worldStateUpdater = worldState.updater();
final ReferenceTestBlockchain blockchain = new ReferenceTestBlockchain(blockHeader.getNumber());
final Wei blobGasPrice =
protocolSpec
.getFeeMarket()
@ -297,7 +294,6 @@ public class T8nExecutor {
tracer.traceStartTransaction(worldStateUpdater, transaction);
result =
processor.processTransaction(
blockchain,
worldStateUpdater,
blockHeader,
transaction,

@ -153,8 +153,7 @@ public class GeneralStateReferenceTestTools {
.blobGasPricePerGas(blockHeader.getExcessBlobGas().orElse(BlobGas.ZERO));
final TransactionProcessingResult result =
processor.processTransaction(
blockchain,
worldStateUpdater,
worldStateUpdater,
blockHeader,
transaction,
blockHeader.getCoinbase(),

Loading…
Cancel
Save