diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java index 370d382315..41914887b2 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java @@ -25,9 +25,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSucces import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult; @@ -135,7 +135,7 @@ public class EthEstimateGas implements JsonRpcMethod { JsonRpcErrorConverter.convertTransactionInvalidReason( validationResult.getInvalidReason()); } else { - final TransactionProcessor.Result resultTrx = result.getResult(); + final TransactionProcessingResult resultTrx = result.getResult(); if (resultTrx != null && resultTrx.getRevertReason().isPresent()) { jsonRpcError = JsonRpcError.REVERT_ERROR; } else { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceReplayBlockTransactions.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceReplayBlockTransactions.java index b721eaf80d..bdba0695cf 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceReplayBlockTransactions.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceReplayBlockTransactions.java @@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.debug.TraceOptions; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor.Result; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; import java.util.Arrays; @@ -135,7 +135,7 @@ public class TraceReplayBlockTransactions extends AbstractBlockParameterMethod { final AtomicInteger traceCounter) { final ObjectNode resultNode = mapper.createObjectNode(); - Result result = transactionTrace.getResult(); + TransactionProcessingResult result = transactionTrace.getResult(); resultNode.put("output", result.getRevertReason().orElse(result.getOutput()).toString()); if (traceTypes.contains(TraceType.STATE_DIFF)) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockReplay.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockReplay.java index 7d9905abc2..c2025488d3 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockReplay.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockReplay.java @@ -21,9 +21,9 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; @@ -140,7 +140,7 @@ public class BlockReplay { return Optional.empty(); } final ProtocolSpec protocolSpec = protocolSchedule.getByBlockNumber(header.getNumber()); - final TransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor(); + final MainnetTransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor(); final BlockHeader previous = blockchain.getBlockHeader(header.getParentHash()).orElse(null); if (previous == null) { return Optional.empty(); @@ -177,7 +177,7 @@ public class BlockReplay { BlockHeader blockHeader, Blockchain blockchain, MutableWorldState worldState, - TransactionProcessor transactionProcessor); + MainnetTransactionProcessor transactionProcessor); } @FunctionalInterface @@ -187,6 +187,6 @@ public class BlockReplay { BlockHeader blockHeader, Blockchain blockchain, MutableWorldState worldState, - TransactionProcessor transactionProcessor); + MainnetTransactionProcessor transactionProcessor); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java index c6b53de181..d63478f6f7 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java @@ -20,7 +20,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.debug.TraceFrame; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; @@ -57,7 +57,7 @@ public class BlockTracer { } // create an updater for just this tx chainedUpdater = chainedUpdater.updater(); - final TransactionProcessor.Result result = + final TransactionProcessingResult result = transactionProcessor.processTransaction( blockchain, chainedUpdater, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTrace.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTrace.java index 94c1eb13fc..dd66964334 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTrace.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTrace.java @@ -16,18 +16,20 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.debug.TraceFrame; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor.Result; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import java.util.List; public class TransactionTrace { private final Transaction transaction; - private final Result result; + private final TransactionProcessingResult result; private final List traceFrames; public TransactionTrace( - final Transaction transaction, final Result result, final List traceFrames) { + final Transaction transaction, + final TransactionProcessingResult result, + final List traceFrames) { this.transaction = transaction; this.result = result; this.traceFrames = traceFrames; @@ -45,7 +47,7 @@ public class TransactionTrace { return transaction.getGasLimit(); } - public Result getResult() { + public TransactionProcessingResult getResult() { return result; } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java index 5bc631b2ad..dc3e1e6e09 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java @@ -23,9 +23,9 @@ import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.debug.TraceOptions; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor.Result; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; import org.hyperledger.besu.ethereum.vm.OperationTracer; @@ -61,7 +61,7 @@ public class TransactionTracer { blockHash, transactionHash, (transaction, header, blockchain, worldState, transactionProcessor) -> { - final Result result = + final TransactionProcessingResult result = processTransaction( header, blockchain, @@ -106,7 +106,7 @@ public class TransactionTracer { final File traceFile = generateTraceFile(traceDir, blockHash, i, transaction); try (PrintStream out = new PrintStream(new FileOutputStream(traceFile))) { final Stopwatch timer = Stopwatch.createStarted(); - final Result result = + final TransactionProcessingResult result = processTransaction( header, blockchain, @@ -153,12 +153,12 @@ public class TransactionTracer { .toFile(); } - private Result processTransaction( + private TransactionProcessingResult processTransaction( final BlockHeader header, final Blockchain blockchain, final WorldUpdater worldUpdater, final Transaction transaction, - final TransactionProcessor transactionProcessor, + final MainnetTransactionProcessor transactionProcessor, final OperationTracer tracer) { return transactionProcessor.processTransaction( blockchain, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAtTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAtTest.java index 62171eee16..6b589458c1 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAtTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAtTest.java @@ -38,7 +38,7 @@ import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import java.util.ArrayList; import java.util.Collections; @@ -65,7 +65,8 @@ public class DebugStorageRangeAtTest { new DebugStorageRangeAt(blockchainQueries, blockReplay); private final MutableWorldState worldState = mock(MutableWorldState.class); private final Account account = mock(Account.class); - private final TransactionProcessor transactionProcessor = mock(TransactionProcessor.class); + private final MainnetTransactionProcessor transactionProcessor = + mock(MainnetTransactionProcessor.class); private final Transaction transaction = mock(Transaction.class); private final BlockHeader blockHeader = mock(BlockHeader.class); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHashTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHashTest.java index 63b053c415..1fb5079a49 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHashTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHashTest.java @@ -30,7 +30,7 @@ import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.debug.TraceFrame; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import java.util.Arrays; import java.util.Collection; @@ -85,8 +85,8 @@ public class DebugTraceBlockByHashTest { Optional.empty(), Optional.empty()); - final TransactionProcessor.Result transaction1Result = mock(TransactionProcessor.Result.class); - final TransactionProcessor.Result transaction2Result = mock(TransactionProcessor.Result.class); + final TransactionProcessingResult transaction1Result = mock(TransactionProcessingResult.class); + final TransactionProcessingResult transaction2Result = mock(TransactionProcessingResult.class); final TransactionTrace transaction1Trace = mock(TransactionTrace.class); final TransactionTrace transaction2Trace = mock(TransactionTrace.class); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumberTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumberTest.java index a9f78b5c82..bd6477a8d8 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumberTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumberTest.java @@ -34,7 +34,7 @@ import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.debug.TraceFrame; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import java.util.Collection; import java.util.Optional; @@ -90,8 +90,8 @@ public class DebugTraceBlockByNumberTest { Optional.empty(), Optional.empty()); - final TransactionProcessor.Result transaction1Result = mock(TransactionProcessor.Result.class); - final TransactionProcessor.Result transaction2Result = mock(TransactionProcessor.Result.class); + final TransactionProcessingResult transaction1Result = mock(TransactionProcessingResult.class); + final TransactionProcessingResult transaction2Result = mock(TransactionProcessingResult.class); final TransactionTrace transaction1Trace = mock(TransactionTrace.class); final TransactionTrace transaction2Trace = mock(TransactionTrace.class); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java index ec4a38d001..cd4651bc5d 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java @@ -37,7 +37,7 @@ import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import java.util.Collection; import java.util.Collections; @@ -103,8 +103,8 @@ public class DebugTraceBlockTest { Optional.empty(), Optional.empty()); - final TransactionProcessor.Result transaction1Result = mock(TransactionProcessor.Result.class); - final TransactionProcessor.Result transaction2Result = mock(TransactionProcessor.Result.class); + final TransactionProcessingResult transaction1Result = mock(TransactionProcessingResult.class); + final TransactionProcessingResult transaction2Result = mock(TransactionProcessingResult.class); final TransactionTrace transaction1Trace = mock(TransactionTrace.class); final TransactionTrace transaction2Trace = mock(TransactionTrace.class); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransactionTest.java index 801dab36e9..feaa719ba0 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransactionTest.java @@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.debug.TraceFrame; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor.Result; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; import java.util.Collections; @@ -76,7 +76,7 @@ public class DebugTraceTransactionTest { final Object[] params = new Object[] {transactionHash, map}; final JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("2.0", "debug_traceTransaction", params)); - final Result result = mock(Result.class); + final TransactionProcessingResult result = mock(TransactionProcessingResult.class); final Bytes32[] stackBytes = new Bytes32[] { @@ -150,7 +150,7 @@ public class DebugTraceTransactionTest { final Object[] params = new Object[] {transactionHash, map}; final JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("2.0", "debug_traceTransaction", params)); - final Result result = mock(Result.class); + final TransactionProcessingResult result = mock(TransactionProcessingResult.class); final TraceFrame traceFrame = new TraceFrame( diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java index ee0c78a458..80ada3fce6 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java @@ -31,9 +31,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult; @@ -171,7 +171,7 @@ public class EthEstimateGasTest { when(transactionSimulator.process( eq(modifiedCallParameter()), any(OperationTracer.class), eq(1L))) .thenReturn(Optional.of(mockTxSimResult)); - final TransactionProcessor.Result mockResult = mock(TransactionProcessor.Result.class); + final TransactionProcessingResult mockResult = mock(TransactionProcessingResult.class); when(mockResult.getEstimateGasUsedByTransaction()).thenReturn(estimateGas); when(mockResult.getRevertReason()) .thenReturn(isReverted ? Optional.of(Bytes.of(0)) : Optional.empty()); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCallTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCallTest.java index 07f035a92e..76720b4d08 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCallTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCallTest.java @@ -38,7 +38,7 @@ import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.privacy.DefaultPrivacyController; import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException; import org.hyperledger.besu.ethereum.privacy.PrivacyController; -import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import java.util.Optional; @@ -194,8 +194,7 @@ public class PrivCallTest { } private void mockTransactionProcessorSuccessResult(final Bytes output) { - final PrivateTransactionProcessor.Result result = - mock(PrivateTransactionProcessor.Result.class); + final TransactionProcessingResult result = mock(TransactionProcessingResult.class); when(result.getValidationResult()).thenReturn(ValidationResult.valid()); when(result.getOutput()).thenReturn(output); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracerTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracerTest.java index 2b7e84b7b8..9d5bb1a2ef 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracerTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracerTest.java @@ -31,10 +31,10 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.debug.TraceFrame; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor.Result; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; import org.hyperledger.besu.ethereum.vm.StandardJsonTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; @@ -83,7 +83,7 @@ public class TransactionTracerTest { @Mock private MutableWorldState mutableWorldState; - @Mock private TransactionProcessor transactionProcessor; + @Mock private MainnetTransactionProcessor transactionProcessor; private TransactionTracer transactionTracer; @@ -159,7 +159,7 @@ public class TransactionTracerTest { @Test public void traceTransactionShouldReturnResultFromProcessTransaction() { - final Result result = mock(Result.class); + final TransactionProcessingResult result = mock(TransactionProcessingResult.class); when(blockchain.getBlockHeader(blockHash)).thenReturn(Optional.of(blockHeader)); when(blockchain.getBlockHeader(previousBlockHash)).thenReturn(Optional.of(previousBlockHeader)); @@ -241,7 +241,7 @@ public class TransactionTracerTest { when(blockBody.getTransactions()).thenReturn(transactions); when(blockchain.getBlockBody(blockHash)).thenReturn(Optional.of(blockBody)); - final Result result = mock(Result.class); + final TransactionProcessingResult result = mock(TransactionProcessingResult.class); when(result.getOutput()).thenReturn(Bytes.of(0x01, 0x02)); when(blockchain.getBlockHeader(blockHash)).thenReturn(Optional.of(blockHeader)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGeneratorTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGeneratorTest.java index 42ab210e8d..dc497c20ce 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGeneratorTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGeneratorTest.java @@ -29,10 +29,10 @@ import org.hyperledger.besu.ethereum.core.fees.TransactionGasBudgetCalculator; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor; import org.hyperledger.besu.ethereum.mainnet.ClassicBlockProcessor; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockProcessor; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.MiningBeneficiaryCalculator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import java.util.Collections; import java.util.List; @@ -55,7 +55,7 @@ public class RewardTraceGeneratorTest { @Mock private ProtocolSchedule protocolSchedule; @Mock private ProtocolSpec protocolSpec; @Mock private MiningBeneficiaryCalculator miningBeneficiaryCalculator; - @Mock private TransactionProcessor transactionProcessor; + @Mock private MainnetTransactionProcessor transactionProcessor; private final Address ommerBeneficiary = Address.wrap(Bytes.fromHexString("0x095e7baea6a6c7c4c2dfeb977efac326af552d87")); diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java index 195aa807f9..be74a6b1e1 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java @@ -36,10 +36,10 @@ import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.DifficultyCalculator; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.plugin.services.securitymodule.SecurityModuleException; import java.math.BigInteger; @@ -203,7 +203,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { final MutableWorldState disposableWorldState, final Optional> transactions) throws RuntimeException { - final TransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor(); + final MainnetTransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor(); final AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory = protocolSpec.getTransactionReceiptFactory(); diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java index b41529f9e9..f175370d3d 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java @@ -29,9 +29,10 @@ import org.hyperledger.besu.ethereum.core.fees.TransactionPriceCalculator; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions.TransactionSelectionResult; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import java.util.List; @@ -106,7 +107,7 @@ public class BlockTransactionSelector { } private final Supplier isCancelled; - private final TransactionProcessor transactionProcessor; + private final MainnetTransactionProcessor transactionProcessor; private final ProcessableBlockHeader processableBlockHeader; private final Blockchain blockchain; private final MutableWorldState worldState; @@ -121,7 +122,7 @@ public class BlockTransactionSelector { new TransactionSelectionResults(); public BlockTransactionSelector( - final TransactionProcessor transactionProcessor, + final MainnetTransactionProcessor transactionProcessor, final Blockchain blockchain, final MutableWorldState worldState, final PendingTransactions pendingTransactions, @@ -210,7 +211,7 @@ public class BlockTransactionSelector { final WorldUpdater worldStateUpdater = worldState.updater(); final BlockHashLookup blockHashLookup = new BlockHashLookup(processableBlockHeader, blockchain); - final TransactionProcessor.Result result = + final TransactionProcessingResult result = transactionProcessor.processTransaction( blockchain, worldStateUpdater, @@ -243,7 +244,7 @@ public class BlockTransactionSelector { cumulative gas, world state root hash.). */ private void updateTransactionResultTracking( - final Transaction transaction, final TransactionProcessor.Result result) { + final Transaction transaction, final TransactionProcessingResult result) { final long gasUsedByTransaction = transaction.getGasLimit() - result.getGasRemaining(); final long cumulativeGasUsed; if (ExperimentalEIPs.eip1559Enabled && eip1559.isPresent()) { diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java index 4c67bb3065..39d89ed138 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java @@ -45,9 +45,9 @@ import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; @@ -81,7 +81,8 @@ public class BlockTransactionSelectorTest { Optional.empty(), TransactionPoolConfiguration.DEFAULT_PRICE_BUMP); private final MutableWorldState worldState = InMemoryStorageProvider.createInMemoryWorldState(); - private final TransactionProcessor transactionProcessor = mock(TransactionProcessor.class); + private final MainnetTransactionProcessor transactionProcessor = + mock(MainnetTransactionProcessor.class); private Boolean isCancelled() { return false; @@ -102,7 +103,7 @@ public class BlockTransactionSelectorTest { public void emptyPendingTransactionsResultsInEmptyVettingResult() { final ProtocolSchedule protocolSchedule = FixedDifficultyProtocolSchedule.create(GenesisConfigFile.development().getConfigOptions()); - final TransactionProcessor mainnetTransactionProcessor = + final MainnetTransactionProcessor mainnetTransactionProcessor = protocolSchedule.getByBlockNumber(0).getTransactionProcessor(); // The block should fit 5 transactions only @@ -142,8 +143,7 @@ public class BlockTransactionSelectorTest { when(transactionProcessor.processTransaction( any(), any(), any(), eq(transaction), any(), any(), anyBoolean(), any())) .thenReturn( - MainnetTransactionProcessor.Result.failed( - 0, 5, ValidationResult.valid(), Optional.empty())); + TransactionProcessingResult.failed(0, 5, ValidationResult.valid(), Optional.empty())); // The block should fit 3 transactions only final ProcessableBlockHeader blockHeader = createBlockWithGasLimit(5000); @@ -187,7 +187,7 @@ public class BlockTransactionSelectorTest { when(transactionProcessor.processTransaction( any(), any(), any(), any(), any(), any(), anyBoolean(), any())) .thenReturn( - MainnetTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( new ArrayList<>(), 0, 0, Bytes.EMPTY, ValidationResult.valid())); when(transactionProcessor.processTransaction( any(), @@ -199,7 +199,7 @@ public class BlockTransactionSelectorTest { anyBoolean(), any())) .thenReturn( - MainnetTransactionProcessor.Result.invalid( + TransactionProcessingResult.invalid( ValidationResult.invalid( TransactionValidator.TransactionInvalidReason.NONCE_TOO_LOW))); @@ -246,7 +246,7 @@ public class BlockTransactionSelectorTest { when(transactionProcessor.processTransaction( any(), any(), any(), any(), any(), any(), anyBoolean(), any())) .thenReturn( - MainnetTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( new ArrayList<>(), 0, 0, Bytes.EMPTY, ValidationResult.valid())); final ProcessableBlockHeader blockHeader = createBlockWithGasLimit(301); @@ -322,7 +322,7 @@ public class BlockTransactionSelectorTest { when(transactionProcessor.processTransaction( any(), any(), any(), any(), any(), any(), anyBoolean(), any())) .thenReturn( - MainnetTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( new ArrayList<>(), 0, 0, Bytes.EMPTY, ValidationResult.valid())); final Address miningBeneficiary = AddressHelpers.ofValue(1); @@ -380,7 +380,7 @@ public class BlockTransactionSelectorTest { when(transactionProcessor.processTransaction( any(), any(), any(), any(), any(), any(), anyBoolean(), any())) .thenReturn( - MainnetTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( new ArrayList<>(), 0, 0, Bytes.EMPTY, ValidationResult.valid())); final Address miningBeneficiary = AddressHelpers.ofValue(1); @@ -481,7 +481,7 @@ public class BlockTransactionSelectorTest { anyBoolean(), any())) .thenReturn( - MainnetTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( new ArrayList<>(), 2000, 10000, Bytes.EMPTY, ValidationResult.valid())); when(transactionProcessor.processTransaction( eq(blockchain), @@ -493,7 +493,7 @@ public class BlockTransactionSelectorTest { anyBoolean(), any())) .thenReturn( - MainnetTransactionProcessor.Result.invalid( + TransactionProcessingResult.invalid( ValidationResult.invalid( TransactionValidator.TransactionInvalidReason.EXCEEDS_BLOCK_GAS_LIMIT))); @@ -525,7 +525,7 @@ public class BlockTransactionSelectorTest { anyBoolean(), any())) .thenReturn( - MainnetTransactionProcessor.Result.invalid( + TransactionProcessingResult.invalid( ValidationResult.invalid( TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE))); @@ -569,7 +569,7 @@ public class BlockTransactionSelectorTest { // This is a duplicate of the MainnetProtocolSpec::frontierTransactionReceiptFactory private TransactionReceipt createReceipt( - final TransactionProcessor.Result result, final WorldState worldState, final long gasUsed) { + final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) { return new TransactionReceipt( worldState.rootHash(), gasUsed, Lists.newArrayList(), Optional.empty(), -1L); } diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java index ca215f22ed..9f86a6d18a 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java @@ -40,6 +40,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.MessageFrame; @@ -92,8 +93,8 @@ public class PrivacyPrecompiledContractIntegrationTest { private PrivateTransactionProcessor mockPrivateTxProcessor() { final PrivateTransactionProcessor mockPrivateTransactionProcessor = mock(PrivateTransactionProcessor.class); - final PrivateTransactionProcessor.Result result = - PrivateTransactionProcessor.Result.successful( + final TransactionProcessingResult result = + TransactionProcessingResult.successful( null, 0, 0, Bytes.fromHexString(DEFAULT_OUTPUT), null); when(mockPrivateTransactionProcessor.processTransaction( nullable(Blockchain.class), diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java index 0eaf375a8c..f5b85d24f2 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java @@ -29,10 +29,10 @@ import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.debug.TraceOptions; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor.Result; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; @@ -58,7 +58,7 @@ public class TraceTransactionIntegrationTest { private MutableBlockchain blockchain; private WorldStateArchive worldStateArchive; private Block genesisBlock; - private TransactionProcessor transactionProcessor; + private MainnetTransactionProcessor transactionProcessor; private BlockHashLookup blockHashLookup; @Before @@ -87,7 +87,7 @@ public class TraceTransactionIntegrationTest { final MutableWorldState worldState = worldStateArchive.getMutable(genesisBlock.getHeader().getStateRoot()).get(); final WorldUpdater createTransactionUpdater = worldState.updater(); - Result result = + TransactionProcessingResult result = transactionProcessor.processTransaction( blockchain, createTransactionUpdater, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java index 39dc870fcb..223fe01036 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java @@ -25,6 +25,7 @@ import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.core.fees.TransactionGasBudgetCalculator; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.OperationTracer; @@ -40,7 +41,7 @@ public abstract class AbstractBlockProcessor implements BlockProcessor { public interface TransactionReceiptFactory { TransactionReceipt create( - TransactionProcessor.Result result, WorldState worldState, long gasUsed); + TransactionProcessingResult result, WorldState worldState, long gasUsed); } private static final Logger LOG = LogManager.getLogger(); @@ -81,7 +82,7 @@ public abstract class AbstractBlockProcessor implements BlockProcessor { } } - private final TransactionProcessor transactionProcessor; + private final MainnetTransactionProcessor transactionProcessor; private final AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory; @@ -94,7 +95,7 @@ public abstract class AbstractBlockProcessor implements BlockProcessor { private final TransactionGasBudgetCalculator gasBudgetCalculator; protected AbstractBlockProcessor( - final TransactionProcessor transactionProcessor, + final MainnetTransactionProcessor transactionProcessor, final TransactionReceiptFactory transactionReceiptFactory, final Wei blockReward, final MiningBeneficiaryCalculator miningBeneficiaryCalculator, @@ -124,7 +125,8 @@ public abstract class AbstractBlockProcessor implements BlockProcessor { if (!gasBudgetCalculator.hasBudget( transaction, blockHeader.getNumber(), blockHeader.getGasLimit(), currentGasUsed)) { LOG.info( - "Block processing error: transaction gas limit {} exceeds available block budget remaining {}. Block {} Transaction {}", + "Block processing error: transaction gas limit {} exceeds available block budget" + + " remaining {}. Block {} Transaction {}", transaction.getGasLimit(), remainingGasBudget, blockHeader.getHash().toHexString(), @@ -137,7 +139,7 @@ public abstract class AbstractBlockProcessor implements BlockProcessor { final Address miningBeneficiary = miningBeneficiaryCalculator.calculateBeneficiary(blockHeader); - final TransactionProcessor.Result result = + final TransactionProcessingResult result = transactionProcessor.processTransaction( blockchain, worldStateUpdater, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java index cb14285e79..4b5555eb28 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java @@ -37,7 +37,7 @@ public class ClassicBlockProcessor extends AbstractBlockProcessor { private final long eraLength; public ClassicBlockProcessor( - final TransactionProcessor transactionProcessor, + final MainnetTransactionProcessor transactionProcessor, final TransactionReceiptFactory transactionReceiptFactory, final Wei blockReward, final MiningBeneficiaryCalculator miningBeneficiaryCalculator, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java index 6132c32b84..3508c0d05b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.core.fees.CoinbaseFeePriceCalculator; import org.hyperledger.besu.ethereum.core.fees.TransactionPriceCalculator; import org.hyperledger.besu.ethereum.mainnet.contractvalidation.MaxCodeSizeRule; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.MessageFrame; import java.math.BigInteger; @@ -207,7 +208,7 @@ public class ClassicProtocolSpecs { } private static TransactionReceipt byzantiumTransactionReceiptFactory( - final TransactionProcessor.Result result, final WorldState worldState, final long gasUsed) { + final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) { return new TransactionReceipt( result.isSuccessful() ? 1 : 0, gasUsed, @@ -217,7 +218,7 @@ public class ClassicProtocolSpecs { } private static TransactionReceipt byzantiumTransactionReceiptFactoryWithReasonEnabled( - final TransactionProcessor.Result result, final WorldState worldState, final long gasUsed) { + final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) { return new TransactionReceipt( result.isSuccessful() ? 1 : 0, gasUsed, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java index 25e05292c9..b72fbe3f29 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java @@ -32,7 +32,7 @@ public class MainnetBlockProcessor extends AbstractBlockProcessor { private static final Logger LOG = LogManager.getLogger(); public MainnetBlockProcessor( - final TransactionProcessor transactionProcessor, + final MainnetTransactionProcessor transactionProcessor, final AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory, final Wei blockReward, final MiningBeneficiaryCalculator miningBeneficiaryCalculator, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java index 1609363761..21560e0794 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java @@ -37,6 +37,7 @@ import org.hyperledger.besu.ethereum.mainnet.contractvalidation.MaxCodeSizeRule; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.MessageFrame; import java.io.IOException; @@ -404,7 +405,7 @@ public abstract class MainnetProtocolSpecs { } private static TransactionReceipt frontierTransactionReceiptFactory( - final TransactionProcessor.Result result, final WorldState worldState, final long gasUsed) { + final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) { return new TransactionReceipt( worldState.rootHash(), gasUsed, @@ -414,7 +415,7 @@ public abstract class MainnetProtocolSpecs { } private static TransactionReceipt byzantiumTransactionReceiptFactory( - final TransactionProcessor.Result result, final WorldState worldState, final long gasUsed) { + final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) { return new TransactionReceipt( result.isSuccessful() ? 1 : 0, gasUsed, @@ -424,7 +425,7 @@ public abstract class MainnetProtocolSpecs { } private static TransactionReceipt byzantiumTransactionReceiptFactoryWithReasonEnabled( - final TransactionProcessor.Result result, final WorldState worldState, final long gasUsed) { + final TransactionProcessingResult result, final WorldState worldState, final long gasUsed) { return new TransactionReceipt( result.isSuccessful() ? 1 : 0, gasUsed, 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 fc28e8f0d9..c7c43f2959 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 @@ -19,7 +19,6 @@ import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.Address; import org.hyperledger.besu.ethereum.core.EvmAccount; import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; @@ -29,6 +28,7 @@ import org.hyperledger.besu.ethereum.core.fees.CoinbaseFeePriceCalculator; import org.hyperledger.besu.ethereum.core.fees.TransactionPriceCalculator; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.Code; import org.hyperledger.besu.ethereum.vm.GasCalculator; @@ -39,14 +39,13 @@ import org.hyperledger.besu.ethereum.vm.operations.ReturnStack; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; -import java.util.List; import java.util.Optional; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; -public class MainnetTransactionProcessor implements TransactionProcessor { +public class MainnetTransactionProcessor { private static final Logger LOG = LogManager.getLogger(); @@ -65,115 +64,151 @@ public class MainnetTransactionProcessor implements TransactionProcessor { private final TransactionPriceCalculator transactionPriceCalculator; private final CoinbaseFeePriceCalculator coinbaseFeePriceCalculator; - public static class Result implements TransactionProcessor.Result { - - private final Status status; - - private final long estimateGasUsedByTransaction; - - private final long gasRemaining; - - private final List logs; - - private final Bytes output; - - private final ValidationResult validationResult; - private final Optional revertReason; - - public static Result invalid( - final ValidationResult validationResult) { - return new Result( - Status.INVALID, - new ArrayList<>(), - -1, - -1, - Bytes.EMPTY, - validationResult, - Optional.empty()); - } - - public static Result failed( - final long gasUsedByTransaction, - final long gasRemaining, - final ValidationResult validationResult, - final Optional revertReason) { - return new Result( - Status.FAILED, - new ArrayList<>(), - gasUsedByTransaction, - gasRemaining, - Bytes.EMPTY, - validationResult, - revertReason); - } - - public static Result successful( - final List logs, - final long gasUsedByTransaction, - final long gasRemaining, - final Bytes output, - final ValidationResult validationResult) { - return new Result( - Status.SUCCESSFUL, - logs, - gasUsedByTransaction, - gasRemaining, - output, - validationResult, - Optional.empty()); - } - - Result( - final Status status, - final List logs, - final long estimateGasUsedByTransaction, - final long gasRemaining, - final Bytes output, - final ValidationResult validationResult, - final Optional revertReason) { - this.status = status; - this.logs = logs; - this.estimateGasUsedByTransaction = estimateGasUsedByTransaction; - this.gasRemaining = gasRemaining; - this.output = output; - this.validationResult = validationResult; - this.revertReason = revertReason; - } - - @Override - public List getLogs() { - return logs; - } - - @Override - public long getGasRemaining() { - return gasRemaining; - } - - @Override - public long getEstimateGasUsedByTransaction() { - return estimateGasUsedByTransaction; - } - - @Override - public Status getStatus() { - return status; - } + /** + * 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 miningBeneficiary The address which is to receive the transaction fee + * @param blockHashLookup The {@link BlockHashLookup} to use for BLOCKHASH operations + * @param isPersistingPrivateState Whether the resulting private state will be persisted + * @param transactionValidationParams Validation parameters that will be used by the {@link + * TransactionValidator} + * @return the transaction result + * @see TransactionValidator + * @see TransactionValidationParams + */ + public TransactionProcessingResult processTransaction( + final Blockchain blockchain, + final WorldUpdater worldState, + final ProcessableBlockHeader blockHeader, + final Transaction transaction, + final Address miningBeneficiary, + final BlockHashLookup blockHashLookup, + final Boolean isPersistingPrivateState, + final TransactionValidationParams transactionValidationParams) { + return processTransaction( + blockchain, + worldState, + blockHeader, + transaction, + miningBeneficiary, + OperationTracer.NO_TRACING, + blockHashLookup, + isPersistingPrivateState, + transactionValidationParams); + } - @Override - public Bytes getOutput() { - return output; - } + /** + * 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 miningBeneficiary The address which is to receive the transaction fee + * @param blockHashLookup The {@link BlockHashLookup} to use for BLOCKHASH operations + * @param isPersistingPrivateState Whether the resulting private state will be persisted + * @param transactionValidationParams Validation parameters that will be used by the {@link + * TransactionValidator} + * @param operationTracer operation tracer {@link OperationTracer} + * @return the transaction result + * @see TransactionValidator + * @see TransactionValidationParams + */ + public TransactionProcessingResult processTransaction( + final Blockchain blockchain, + final WorldUpdater worldState, + final ProcessableBlockHeader blockHeader, + final Transaction transaction, + final Address miningBeneficiary, + final BlockHashLookup blockHashLookup, + final Boolean isPersistingPrivateState, + final TransactionValidationParams transactionValidationParams, + final OperationTracer operationTracer) { + return processTransaction( + blockchain, + worldState, + blockHeader, + transaction, + miningBeneficiary, + operationTracer, + blockHashLookup, + isPersistingPrivateState, + transactionValidationParams); + } - @Override - public ValidationResult getValidationResult() { - return validationResult; - } + /** + * 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 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, + final Address miningBeneficiary, + final OperationTracer operationTracer, + final BlockHashLookup blockHashLookup, + final Boolean isPersistingPrivateState) { + return processTransaction( + blockchain, + worldState, + blockHeader, + transaction, + miningBeneficiary, + operationTracer, + blockHashLookup, + isPersistingPrivateState, + new TransactionValidationParams.Builder().build()); + } - @Override - public Optional getRevertReason() { - return revertReason; - } + /** + * 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 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, + final Address miningBeneficiary, + final OperationTracer operationTracer, + final BlockHashLookup blockHashLookup, + final Boolean isPersistingPrivateState, + final TransactionValidationParams transactionValidationParams) { + return processTransaction( + blockchain, + worldState, + blockHeader, + transaction, + miningBeneficiary, + operationTracer, + blockHashLookup, + isPersistingPrivateState, + transactionValidationParams, + null); } private final boolean clearEmptyAccounts; @@ -199,8 +234,7 @@ public class MainnetTransactionProcessor implements TransactionProcessor { this.coinbaseFeePriceCalculator = coinbaseFeePriceCalculator; } - @Override - public Result processTransaction( + public TransactionProcessingResult processTransaction( final Blockchain blockchain, final WorldUpdater worldState, final ProcessableBlockHeader blockHeader, @@ -221,7 +255,7 @@ public class MainnetTransactionProcessor implements TransactionProcessor { // be signed correctly to extract the sender). if (!validationResult.isValid()) { LOG.warn("Invalid transaction: {}", validationResult.getErrorMessage()); - return Result.invalid(validationResult); + return TransactionProcessingResult.invalid(validationResult); } final Address senderAddress = transaction.getSender(); @@ -230,7 +264,7 @@ public class MainnetTransactionProcessor implements TransactionProcessor { transactionValidator.validateForSender(transaction, sender, transactionValidationParams); if (!validationResult.isValid()) { LOG.debug("Invalid transaction: {}", validationResult.getErrorMessage()); - return Result.invalid(validationResult); + return TransactionProcessingResult.invalid(validationResult); } final MutableAccount senderMutableAccount = sender.getMutable(); @@ -367,7 +401,7 @@ public class MainnetTransactionProcessor implements TransactionProcessor { if (blockHeader.getBaseFee().isPresent() && transaction.isEIP1559Transaction()) { final Wei baseFee = Wei.of(blockHeader.getBaseFee().get()); if (transactionGasPrice.compareTo(baseFee) < 0) { - return Result.failed( + return TransactionProcessingResult.failed( gasUsedByTransaction.toLong(), refunded.toLong(), ValidationResult.invalid( @@ -392,14 +426,14 @@ public class MainnetTransactionProcessor implements TransactionProcessor { } if (initialFrame.getState() == MessageFrame.State.COMPLETED_SUCCESS) { - return Result.successful( + return TransactionProcessingResult.successful( initialFrame.getLogs(), gasUsedByTransaction.toLong(), refunded.toLong(), initialFrame.getOutputData(), validationResult); } else { - return Result.failed( + return TransactionProcessingResult.failed( gasUsedByTransaction.toLong(), refunded.toLong(), validationResult, @@ -407,7 +441,7 @@ public class MainnetTransactionProcessor implements TransactionProcessor { } } catch (final RuntimeException re) { LOG.error("Critical Exception Processing Transaction", re); - return Result.invalid( + return TransactionProcessingResult.invalid( ValidationResult.invalid( TransactionInvalidReason.INTERNAL_ERROR, "Internal Error in Besu - " + re.toString())); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java index 15da7820e2..8f06025e72 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java @@ -39,7 +39,7 @@ public class ProtocolSpec { private final TransactionValidator transactionValidator; - private final TransactionProcessor transactionProcessor; + private final MainnetTransactionProcessor transactionProcessor; private final BlockHeaderValidator blockHeaderValidator; @@ -108,7 +108,7 @@ public class ProtocolSpec { final String name, final EVM evm, final TransactionValidator transactionValidator, - final TransactionProcessor transactionProcessor, + final MainnetTransactionProcessor transactionProcessor, final PrivateTransactionProcessor privateTransactionProcessor, final BlockHeaderValidator blockHeaderValidator, final BlockHeaderValidator ommerHeaderValidator, @@ -176,7 +176,7 @@ public class ProtocolSpec { * * @return the transaction processor */ - public TransactionProcessor getTransactionProcessor() { + public MainnetTransactionProcessor getTransactionProcessor() { return transactionProcessor; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java index 5efbd7a874..3f50d78f36 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java @@ -276,7 +276,7 @@ public class ProtocolSpecBuilder { precompileContractRegistryBuilder.apply(precompiledContractConfiguration); final AbstractMessageProcessor messageCallProcessor = messageCallProcessorBuilder.apply(evm, precompileContractRegistry); - final TransactionProcessor transactionProcessor = + final MainnetTransactionProcessor transactionProcessor = transactionProcessorBuilder.apply( gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor); @@ -362,7 +362,7 @@ public class ProtocolSpecBuilder { } public interface TransactionProcessorBuilder { - TransactionProcessor apply( + MainnetTransactionProcessor apply( GasCalculator gasCalculator, TransactionValidator transactionValidator, AbstractMessageProcessor contractCreationProcessor, @@ -384,7 +384,7 @@ public class ProtocolSpecBuilder { public interface BlockProcessorBuilder { BlockProcessor apply( - TransactionProcessor transactionProcessor, + MainnetTransactionProcessor transactionProcessor, AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory, Wei blockReward, MiningBeneficiaryCalculator miningBeneficiaryCalculator, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/TransactionProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/TransactionProcessor.java deleted file mode 100644 index 5e2c94dc4d..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/TransactionProcessor.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.mainnet; - -import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.Address; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; -import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.OperationTracer; - -import java.util.List; -import java.util.Optional; - -import org.apache.tuweni.bytes.Bytes; - -/** Processes transactions. */ -public interface TransactionProcessor { - - /** A transaction processing result. */ - interface Result { - - /** The status of the transaction after being processed. */ - enum Status { - - /** The transaction was invalid for processing. */ - INVALID, - - /** The transaction was successfully processed. */ - SUCCESSFUL, - - /** The transaction failed to be completely processed. */ - FAILED - } - - /** - * Return the logs produced by the transaction. - * - *

This is only valid when {@code TransactionProcessor#isSuccessful} returns {@code true}. - * - * @return the logs produced by the transaction - */ - List getLogs(); - - /** - * Returns the status of the transaction after being processed. - * - * @return the status of the transaction after being processed - */ - Status getStatus(); - - /** - * Returns the gas remaining after the transaction was processed. - * - *

This is only valid when {@code TransactionProcessor#isSuccessful} returns {@code true}. - * - * @return the gas remaining after the transaction was processed - */ - long getGasRemaining(); - - Bytes getOutput(); - - /** - * Returns whether or not the transaction was invalid. - * - * @return {@code true} if the transaction was invalid; otherwise {@code false} - */ - default boolean isInvalid() { - return getStatus() == Status.INVALID; - } - - /** - * Returns whether or not the transaction was successfully processed. - * - * @return {@code true} if the transaction was successfully processed; otherwise {@code false} - */ - default boolean isSuccessful() { - return getStatus() == Status.SUCCESSFUL; - } - - /** - * Returns the transaction validation result. - * - * @return the validation result, with the reason for failure (if applicable.) - */ - ValidationResult getValidationResult(); - - /** - * Returns the reason why a transaction was reverted (if applicable). - * - * @return the revert reason. - */ - Optional getRevertReason(); - - /** - * Returns the estimate gas used by the transaction Difference between the gas limit and the - * remaining gas - * - * @return the estimate gas used - */ - long getEstimateGasUsedByTransaction(); - } - - /** - * 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 miningBeneficiary The address which is to receive the transaction fee - * @param blockHashLookup The {@link BlockHashLookup} to use for BLOCKHASH operations - * @param isPersistingPrivateState Whether the resulting private state will be persisted - * @param transactionValidationParams Validation parameters that will be used by the {@link - * TransactionValidator} - * @return the transaction result - * @see TransactionValidator - * @see TransactionValidationParams - */ - default Result processTransaction( - final Blockchain blockchain, - final WorldUpdater worldState, - final ProcessableBlockHeader blockHeader, - final Transaction transaction, - final Address miningBeneficiary, - final BlockHashLookup blockHashLookup, - final Boolean isPersistingPrivateState, - final TransactionValidationParams transactionValidationParams) { - return processTransaction( - blockchain, - worldState, - blockHeader, - transaction, - miningBeneficiary, - OperationTracer.NO_TRACING, - blockHashLookup, - isPersistingPrivateState, - transactionValidationParams); - } - - /** - * 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 miningBeneficiary The address which is to receive the transaction fee - * @param blockHashLookup The {@link BlockHashLookup} to use for BLOCKHASH operations - * @param isPersistingPrivateState Whether the resulting private state will be persisted - * @param transactionValidationParams Validation parameters that will be used by the {@link - * TransactionValidator} - * @param operationTracer operation tracer {@link OperationTracer} - * @return the transaction result - * @see TransactionValidator - * @see TransactionValidationParams - */ - default Result processTransaction( - final Blockchain blockchain, - final WorldUpdater worldState, - final ProcessableBlockHeader blockHeader, - final Transaction transaction, - final Address miningBeneficiary, - final BlockHashLookup blockHashLookup, - final Boolean isPersistingPrivateState, - final TransactionValidationParams transactionValidationParams, - final OperationTracer operationTracer) { - return processTransaction( - blockchain, - worldState, - blockHeader, - transaction, - miningBeneficiary, - operationTracer, - blockHashLookup, - isPersistingPrivateState, - transactionValidationParams); - } - - /** - * 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 blockHashLookup The {@link BlockHashLookup} to use for BLOCKHASH operations - * @param isPersistingPrivateState Whether the resulting private state will be persisted - * @return the transaction result - */ - default Result processTransaction( - final Blockchain blockchain, - final WorldUpdater worldState, - final ProcessableBlockHeader blockHeader, - final Transaction transaction, - final Address miningBeneficiary, - final OperationTracer operationTracer, - final BlockHashLookup blockHashLookup, - final Boolean isPersistingPrivateState) { - return processTransaction( - blockchain, - worldState, - blockHeader, - transaction, - miningBeneficiary, - operationTracer, - blockHashLookup, - isPersistingPrivateState, - new TransactionValidationParams.Builder().build()); - } - - /** - * 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 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 - */ - default Result processTransaction( - final Blockchain blockchain, - final WorldUpdater worldState, - final ProcessableBlockHeader blockHeader, - final Transaction transaction, - final Address miningBeneficiary, - final OperationTracer operationTracer, - final BlockHashLookup blockHashLookup, - final Boolean isPersistingPrivateState, - final TransactionValidationParams transactionValidationParams) { - return processTransaction( - blockchain, - worldState, - blockHeader, - transaction, - miningBeneficiary, - operationTracer, - blockHashLookup, - isPersistingPrivateState, - transactionValidationParams, - null); - } - - /** - * 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 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 - * @param privateMetadataUpdater The updater to use for the private metadata - * @return the transaction result - */ - Result processTransaction( - Blockchain blockchain, - WorldUpdater worldState, - ProcessableBlockHeader blockHeader, - Transaction transaction, - Address miningBeneficiary, - OperationTracer operationTracer, - BlockHashLookup blockHashLookup, - Boolean isPersistingPrivateState, - TransactionValidationParams transactionValidationParams, - PrivateMetadataUpdater privateMetadataUpdater); -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContract.java index 373238074e..e95be6b052 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContract.java @@ -35,12 +35,12 @@ import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionEvent; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionObserver; -import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionReceipt; import org.hyperledger.besu.ethereum.privacy.Restriction; import org.hyperledger.besu.ethereum.privacy.VersionedPrivateTransaction; import org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPInput; @@ -171,7 +171,7 @@ public class OnChainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac return Bytes.EMPTY; } - final PrivateTransactionProcessor.Result result = + final TransactionProcessingResult result = processPrivateTransaction( messageFrame, privateTransaction, privacyGroupId, privateWorldStateUpdater); @@ -285,7 +285,8 @@ public class OnChainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac disposablePrivateState, privateWorldStateUpdater)) { LOG.debug( - "PrivateTransaction with hash {} cannot execute in privacy group {} because privateFrom {} is not a member.", + "PrivateTransaction with hash {} cannot execute in privacy group {} because privateFrom" + + " {} is not a member.", messageFrame.getTransactionHash(), privacyGroupId.toBase64String(), privateFrom.toBase64String()); @@ -306,7 +307,7 @@ public class OnChainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac final Blockchain blockchain, final MutableWorldState disposablePrivateState, final WorldUpdater privateWorldStateUpdater) { - final PrivateTransactionProcessor.Result result = + final TransactionProcessingResult result = simulateTransaction( messageFrame, currentBlockHeader, @@ -327,7 +328,7 @@ public class OnChainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac || participantsFromParameter.contains(privateFrom.toBase64String()); } - List getMembersFromResult(final PrivateTransactionProcessor.Result result) { + List getMembersFromResult(final TransactionProcessingResult result) { List list = Collections.emptyList(); if (result != null && result.isSuccessful()) { final RLPInput rlpInput = RLP.input(result.getOutput()); @@ -370,7 +371,7 @@ public class OnChainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac final Blockchain blockchain, final MutableWorldState disposablePrivateState, final WorldUpdater privateWorldStateUpdater) { - final PrivateTransactionProcessor.Result result = + final TransactionProcessingResult result = simulateTransaction( messageFrame, currentBlockHeader, @@ -383,7 +384,7 @@ public class OnChainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac return result.getOutput().toHexString().endsWith("0"); } - protected PrivateTransactionProcessor.Result simulateTransaction( + protected TransactionProcessingResult simulateTransaction( final MessageFrame messageFrame, final ProcessableBlockHeader currentBlockHeader, final WorldUpdater publicWorldState, @@ -455,7 +456,7 @@ public class OnChainPrivacyPrecompiledContract extends PrivacyPrecompiledContrac // call to affect the state // privateTransactionProcessor.processTransaction(...) commits the state if the process was // successful before it returns - final PrivateTransactionProcessor.Result getVersionResult = + final TransactionProcessingResult getVersionResult = simulateTransaction( messageFrame, currentBlockHeader, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java index dcdd2893a4..9eb603862e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java @@ -34,6 +34,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionReceipt; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.privacy.storage.PrivateTransactionMetadata; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; import org.hyperledger.besu.ethereum.vm.GasCalculator; @@ -161,7 +162,7 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract { final WorldUpdater privateWorldStateUpdater = disposablePrivateState.updater(); - final PrivateTransactionProcessor.Result result = + final TransactionProcessingResult result = processPrivateTransaction( messageFrame, privateTransaction, privacyGroupId, privateWorldStateUpdater); @@ -193,10 +194,10 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract { final Bytes32 privacyGroupId, final MutableWorldState disposablePrivateState, final PrivateMetadataUpdater privateMetadataUpdater, - final PrivateTransactionProcessor.Result result) { + final TransactionProcessingResult result) { final int txStatus = - result.getStatus() == PrivateTransactionProcessor.Result.Status.SUCCESSFUL ? 1 : 0; + result.getStatus() == TransactionProcessingResult.Status.SUCCESSFUL ? 1 : 0; final PrivateTransactionReceipt privateTransactionReceipt = new PrivateTransactionReceipt( @@ -209,7 +210,7 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract { new PrivateTransactionMetadata(commitmentHash, disposablePrivateState.rootHash())); } - PrivateTransactionProcessor.Result processPrivateTransaction( + TransactionProcessingResult processPrivateTransaction( final MessageFrame messageFrame, final PrivateTransaction privateTransaction, final Bytes32 privacyGroupId, @@ -261,7 +262,8 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract { isMining = true; } else { throw new IllegalArgumentException( - "The MessageFrame contains an illegal block header type. Cannot persist private block metadata without current block hash."); + "The MessageFrame contains an illegal block header type. Cannot persist private block" + + " metadata without current block hash."); } } return isMining; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyController.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyController.java index 5317efcf9b..b33dc62d1d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyController.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyController.java @@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.privacy.markertransaction.PrivateMarkerTran import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; import org.hyperledger.besu.ethereum.privacy.storage.PrivateTransactionMetadata; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.RLP; @@ -225,12 +226,12 @@ public class DefaultPrivacyController implements PrivacyController { } @Override - public Optional simulatePrivateTransaction( + public Optional simulatePrivateTransaction( final String privacyGroupId, final String enclavePublicKey, final CallParameter callParams, final long blockNumber) { - final Optional result = + final Optional result = privateTransactionSimulator.process(privacyGroupId, callParams, blockNumber); return result; } @@ -286,7 +287,7 @@ public class DefaultPrivacyController implements PrivacyController { public Optional retrieveOnChainPrivacyGroup(final Bytes privacyGroupId) { // get the privateFor list from the management contract - final Optional privateTransactionSimulatorResultOptional = + final Optional privateTransactionSimulatorResultOptional = privateTransactionSimulator.process( privacyGroupId.toBase64String(), buildCallParams(GET_PARTICIPANTS_METHOD_SIGNATURE)); @@ -316,7 +317,7 @@ public class DefaultPrivacyController implements PrivacyController { final String enclavePublicKey, final PrivateTransaction privateTransaction) { // get the privateFor list from the management contract - final Optional privateTransactionSimulatorResultOptional = + final Optional privateTransactionSimulatorResultOptional = privateTransactionSimulator.process( privacyGroupId.toBase64String(), buildCallParams(GET_PARTICIPANTS_METHOD_SIGNATURE)); @@ -482,7 +483,7 @@ public class DefaultPrivacyController implements PrivacyController { final PrivacyGroup privacyGroup = maybePrivacyGroup.get(); if (privacyGroup.getType() == PrivacyGroup.Type.ONCHAIN) { // onchain privacy group - final Optional result = + final Optional result = privateTransactionSimulator.process( privateTransaction.getPrivacyGroupId().get().toBase64String(), buildCallParams(GET_VERSION_METHOD_SIGNATURE)); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyController.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyController.java index bb94622ad5..58c5723202 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyController.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyController.java @@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import java.math.BigInteger; @@ -172,7 +173,7 @@ public class MultiTenancyPrivacyController implements PrivacyController { } @Override - public Optional simulatePrivateTransaction( + public Optional simulatePrivateTransaction( final String privacyGroupId, final String enclavePublicKey, final CallParameter callParams, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java index fc30ad96f9..dbd7a17237 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java @@ -21,7 +21,7 @@ import org.hyperledger.besu.enclave.types.PrivacyGroup; import org.hyperledger.besu.ethereum.core.Address; import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.Wei; -import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor.Result; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.transaction.CallParameter; @@ -67,7 +67,7 @@ public class OnchainPrivacyGroupContract { final Optional blockNumber) { final CallParameter callParams = buildCallParams(GET_PARTICIPANTS_METHOD_SIGNATURE); - final Optional result; + final Optional result; if (blockHash.isPresent()) { result = privateTransactionSimulator.process(privacyGroupId, callParams, blockHash.get()); @@ -80,7 +80,7 @@ public class OnchainPrivacyGroupContract { } private Optional readPrivacyGroupFromResult( - final String privacyGroupId, final Optional result) { + final String privacyGroupId, final Optional result) { if (result.isEmpty()) { return Optional.empty(); } @@ -102,7 +102,7 @@ public class OnchainPrivacyGroupContract { public Optional getVersion(final String privacyGroupId, final Optional blockHash) { final CallParameter callParams = buildCallParams(GET_VERSION_METHOD_SIGNATURE); - final Optional result; + final Optional result; if (blockHash.isPresent()) { result = privateTransactionSimulator.process(privacyGroupId, callParams, blockHash.get()); @@ -110,7 +110,7 @@ public class OnchainPrivacyGroupContract { result = privateTransactionSimulator.process(privacyGroupId, callParams); } - return result.map(Result::getOutput).map(Bytes32::wrap); + return result.map(TransactionProcessingResult::getOutput).map(Bytes32::wrap); } private CallParameter buildCallParams(final Bytes methodCall) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivacyController.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivacyController.java index cc1aa2b142..f3b882557a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivacyController.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivacyController.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import java.util.List; @@ -64,7 +65,7 @@ public interface PrivacyController { long determineBesuNonce(Address sender, String privacyGroupId, String enclavePublicKey); - Optional simulatePrivateTransaction( + Optional simulatePrivateTransaction( final String privacyGroupId, final String enclavePublicKey, final CallParameter callParams, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java index 4513111992..13c6865520 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java @@ -30,13 +30,14 @@ import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.MiningBeneficiaryCalculator; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; import org.hyperledger.besu.ethereum.privacy.storage.PrivateTransactionMetadata; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; @@ -56,7 +57,7 @@ public class PrivateGroupRehydrationBlockProcessor { static final int MAX_GENERATION = 6; - private final TransactionProcessor transactionProcessor; + private final MainnetTransactionProcessor transactionProcessor; private final PrivateTransactionProcessor privateTransactionProcessor; private final AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory; final Wei blockReward; @@ -64,7 +65,7 @@ public class PrivateGroupRehydrationBlockProcessor { private final MiningBeneficiaryCalculator miningBeneficiaryCalculator; public PrivateGroupRehydrationBlockProcessor( - final TransactionProcessor transactionProcessor, + final MainnetTransactionProcessor transactionProcessor, final PrivateTransactionProcessor privateTransactionProcessor, final AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory, final Wei blockReward, @@ -100,7 +101,8 @@ public class PrivateGroupRehydrationBlockProcessor { final long remainingGasBudget = blockHeader.getGasLimit() - gasUsed; if (Long.compareUnsigned(transaction.getGasLimit(), remainingGasBudget) > 0) { LOG.warn( - "Transaction processing error: transaction gas limit {} exceeds available block budget remaining {}", + "Transaction processing error: transaction gas limit {} exceeds available block budget" + + " remaining {}", transaction.getGasLimit(), remainingGasBudget); return AbstractBlockProcessor.Result.failed(); @@ -128,7 +130,7 @@ public class PrivateGroupRehydrationBlockProcessor { disposablePrivateState.rootHash(), transactionHash); - final PrivateTransactionProcessor.Result privateResult = + final TransactionProcessingResult privateResult = privateTransactionProcessor.processTransaction( blockchain, worldStateUpdater.updater(), @@ -156,7 +158,7 @@ public class PrivateGroupRehydrationBlockProcessor { // We have to process the public transactions here, because the private transactions can // depend on public state - final TransactionProcessor.Result result = + final TransactionProcessingResult result = transactionProcessor.processTransaction( blockchain, worldStateUpdater, @@ -190,10 +192,10 @@ public class PrivateGroupRehydrationBlockProcessor { final Bytes32 privacyGroupId, final MutableWorldState disposablePrivateState, final PrivateMetadataUpdater privateMetadataUpdater, - final PrivateTransactionProcessor.Result result) { + final TransactionProcessingResult result) { final int txStatus = - result.getStatus() == PrivateTransactionProcessor.Result.Status.SUCCESSFUL ? 1 : 0; + result.getStatus() == TransactionProcessingResult.Status.SUCCESSFUL ? 1 : 0; final PrivateTransactionReceipt privateTransactionReceipt = new PrivateTransactionReceipt( @@ -252,7 +254,8 @@ public class PrivateGroupRehydrationBlockProcessor { for (final BlockHeader ommerHeader : ommers) { if (ommerHeader.getNumber() - header.getNumber() > MAX_GENERATION) { LOG.warn( - "Block processing error: ommer block number {} more than {} generations current block number {}", + "Block processing error: ommer block number {} more than {} generations current block" + + " number {}", ommerHeader.getNumber(), MAX_GENERATION, header.getNumber()); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java index 4cf768b458..6b20c349ce 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java @@ -20,17 +20,16 @@ import org.hyperledger.besu.ethereum.core.Address; import org.hyperledger.besu.ethereum.core.EvmAccount; import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Hash; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.AbstractMessageProcessor; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.Code; import org.hyperledger.besu.ethereum.vm.GasCalculator; @@ -40,10 +39,7 @@ import org.hyperledger.besu.ethereum.vm.operations.ReturnStack; import org.hyperledger.besu.ethereum.worldstate.DefaultMutablePrivateWorldStateUpdater; import java.util.ArrayDeque; -import java.util.ArrayList; import java.util.Deque; -import java.util.List; -import java.util.Optional; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -69,117 +65,6 @@ public class PrivateTransactionProcessor { private final int createContractAccountVersion; - public static class Result implements TransactionProcessor.Result { - - private final Status status; - - private final long estimateGasUsedByTransaction; - - private final long gasRemaining; - - private final List logs; - - private final Bytes output; - - private final ValidationResult validationResult; - private final Optional revertReason; - - public static Result invalid( - final ValidationResult validationResult) { - return new Result( - Status.INVALID, - new ArrayList<>(), - -1, - -1, - Bytes.EMPTY, - validationResult, - Optional.empty()); - } - - public static Result failed( - final long gasUsedByTransaction, - final long gasRemaining, - final ValidationResult validationResult, - final Optional revertReason) { - return new Result( - Status.FAILED, - new ArrayList<>(), - gasUsedByTransaction, - gasRemaining, - Bytes.EMPTY, - validationResult, - revertReason); - } - - public static Result successful( - final List logs, - final long gasUsedByTransaction, - final long gasRemaining, - final Bytes output, - final ValidationResult validationResult) { - return new Result( - Status.SUCCESSFUL, - logs, - gasUsedByTransaction, - gasRemaining, - output, - validationResult, - Optional.empty()); - } - - Result( - final Status status, - final List logs, - final long estimateGasUsedByTransaction, - final long gasRemaining, - final Bytes output, - final ValidationResult validationResult, - final Optional revertReason) { - this.status = status; - this.logs = logs; - this.estimateGasUsedByTransaction = estimateGasUsedByTransaction; - this.gasRemaining = gasRemaining; - this.output = output; - this.validationResult = validationResult; - this.revertReason = revertReason; - } - - @Override - public List getLogs() { - return logs; - } - - @Override - public long getGasRemaining() { - return gasRemaining; - } - - @Override - public long getEstimateGasUsedByTransaction() { - return estimateGasUsedByTransaction; - } - - @Override - public Status getStatus() { - return status; - } - - @Override - public Bytes getOutput() { - return output; - } - - @Override - public ValidationResult getValidationResult() { - return validationResult; - } - - @Override - public Optional getRevertReason() { - return revertReason; - } - } - @SuppressWarnings("unused") private final boolean clearEmptyAccounts; @@ -203,7 +88,7 @@ public class PrivateTransactionProcessor { } @SuppressWarnings("unused") - public Result processTransaction( + public TransactionProcessingResult processTransaction( final Blockchain blockchain, final WorldUpdater publicWorldState, final WorldUpdater privateWorldState, @@ -227,7 +112,7 @@ public class PrivateTransactionProcessor { final ValidationResult validationResult = privateTransactionValidator.validate(transaction, sender.getNonce(), false); if (!validationResult.isValid()) { - return Result.invalid(validationResult); + return TransactionProcessingResult.invalid(validationResult); } final long previousNonce = sender.incrementNonce(); @@ -327,10 +212,10 @@ public class PrivateTransactionProcessor { } if (initialFrame.getState() == MessageFrame.State.COMPLETED_SUCCESS) { - return Result.successful( + return TransactionProcessingResult.successful( initialFrame.getLogs(), 0, 0, initialFrame.getOutputData(), ValidationResult.valid()); } else { - return Result.failed( + return TransactionProcessingResult.failed( 0, 0, ValidationResult.invalid( @@ -339,7 +224,7 @@ public class PrivateTransactionProcessor { } } catch (final RuntimeException re) { LOG.error("Critical Exception Processing Transaction", re); - return Result.invalid( + return TransactionProcessingResult.invalid( ValidationResult.invalid( TransactionInvalidReason.INTERNAL_ERROR, "Internal Error in Besu - " + re.toString())); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionReceipt.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionReceipt.java index e4d9339a3a..bb5ddc99ca 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionReceipt.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionReceipt.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.privacy; import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; @@ -64,7 +64,7 @@ public class PrivateTransactionReceipt { this.revertReason = revertReason; } - public PrivateTransactionReceipt(final TransactionProcessor.Result result) { + public PrivateTransactionReceipt(final TransactionProcessingResult result) { this( getStatusCode(result.getStatus()), result.getLogs(), @@ -72,7 +72,7 @@ public class PrivateTransactionReceipt { result.getRevertReason()); } - private static int getStatusCode(final TransactionProcessor.Result.Status result) { + private static int getStatusCode(final TransactionProcessingResult.Status result) { switch (result) { case SUCCESSFUL: return STATUS_SUCCESSFUL; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionSimulator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionSimulator.java index 735772e928..2b89276832 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionSimulator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionSimulator.java @@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.debug.TraceOptions; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; @@ -68,25 +69,25 @@ public class PrivateTransactionSimulator { this.privateStateRootResolver = privacyParameters.getPrivateStateRootResolver(); } - public Optional process( + public Optional process( final String privacyGroupId, final CallParameter callParams) { final BlockHeader header = blockchain.getChainHeadHeader(); return process(privacyGroupId, callParams, header); } - public Optional process( + public Optional process( final String privacyGroupId, final CallParameter callParams, final Hash blockHeaderHash) { final BlockHeader header = blockchain.getBlockHeader(blockHeaderHash).orElse(null); return process(privacyGroupId, callParams, header); } - public Optional process( + public Optional process( final String privacyGroupId, final CallParameter callParams, final long blockNumber) { final BlockHeader header = blockchain.getBlockHeader(blockNumber).orElse(null); return process(privacyGroupId, callParams, header); } - private Optional process( + private Optional process( final String privacyGroupIdString, final CallParameter callParams, final BlockHeader header) { if (header == null) { return Optional.empty(); @@ -114,7 +115,7 @@ public class PrivateTransactionSimulator { final PrivateTransactionProcessor privateTransactionProcessor = protocolSpec.getPrivateTransactionProcessor(); - final PrivateTransactionProcessor.Result result = + final TransactionProcessingResult result = privateTransactionProcessor.processTransaction( blockchain, publicWorldState.updater(), diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/VersionedPrivateTransaction.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/VersionedPrivateTransaction.java index 62c8912d75..36f590b6e1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/VersionedPrivateTransaction.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/VersionedPrivateTransaction.java @@ -14,6 +14,7 @@ */ package org.hyperledger.besu.ethereum.privacy; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.RLPException; import org.hyperledger.besu.ethereum.rlp.RLPInput; @@ -28,7 +29,7 @@ public class VersionedPrivateTransaction { public VersionedPrivateTransaction( final PrivateTransaction privateTransaction, - final Optional result) { + final Optional result) { this( privateTransaction, result diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java index cbcf4c5331..6981af364f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java @@ -25,10 +25,11 @@ import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.MiningBeneficiaryCalculator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import java.util.ArrayList; @@ -43,14 +44,14 @@ public class PrivateMigrationBlockProcessor { static final int MAX_GENERATION = 6; - private final TransactionProcessor transactionProcessor; + private final MainnetTransactionProcessor transactionProcessor; private final AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory; final Wei blockReward; private final boolean skipZeroBlockRewards; private final MiningBeneficiaryCalculator miningBeneficiaryCalculator; public PrivateMigrationBlockProcessor( - final TransactionProcessor transactionProcessor, + final MainnetTransactionProcessor transactionProcessor, final AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory, final Wei blockReward, final MiningBeneficiaryCalculator miningBeneficiaryCalculator, @@ -84,7 +85,8 @@ public class PrivateMigrationBlockProcessor { final long remainingGasBudget = blockHeader.getGasLimit() - gasUsed; if (Long.compareUnsigned(transaction.getGasLimit(), remainingGasBudget) > 0) { LOG.warn( - "Transaction processing error: transaction gas limit {} exceeds available block budget remaining {}", + "Transaction processing error: transaction gas limit {} exceeds available block budget" + + " remaining {}", transaction.getGasLimit(), remainingGasBudget); return AbstractBlockProcessor.Result.failed(); @@ -95,7 +97,7 @@ public class PrivateMigrationBlockProcessor { final Address miningBeneficiary = miningBeneficiaryCalculator.calculateBeneficiary(blockHeader); - final TransactionProcessor.Result result = + final TransactionProcessingResult result = transactionProcessor.processTransaction( blockchain, worldStateUpdater, @@ -140,7 +142,8 @@ public class PrivateMigrationBlockProcessor { for (final BlockHeader ommerHeader : ommers) { if (ommerHeader.getNumber() - header.getNumber() > MAX_GENERATION) { LOG.warn( - "Block processing error: ommer block number {} more than {} generations current block number {}", + "Block processing error: ommer block number {} more than {} generations current block" + + " number {}", ommerHeader.getNumber(), MAX_GENERATION, header.getNumber()); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/processing/TransactionProcessingResult.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/processing/TransactionProcessingResult.java new file mode 100644 index 0000000000..b363967cf9 --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/processing/TransactionProcessingResult.java @@ -0,0 +1,189 @@ +/* + * Copyright ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.ethereum.processing; + +import org.hyperledger.besu.ethereum.core.Log; +import org.hyperledger.besu.ethereum.mainnet.TransactionValidator; +import org.hyperledger.besu.ethereum.mainnet.ValidationResult; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.apache.tuweni.bytes.Bytes; + +public class TransactionProcessingResult { + + /** The status of the transaction after being processed. */ + public enum Status { + + /** The transaction was invalid for processing. */ + INVALID, + + /** The transaction was successfully processed. */ + SUCCESSFUL, + + /** The transaction failed to be completely processed. */ + FAILED + } + + private final Status status; + + private final long estimateGasUsedByTransaction; + + private final long gasRemaining; + + private final List logs; + + private final Bytes output; + + private final ValidationResult validationResult; + private final Optional revertReason; + + public static TransactionProcessingResult invalid( + final ValidationResult validationResult) { + return new TransactionProcessingResult( + Status.INVALID, new ArrayList<>(), -1, -1, Bytes.EMPTY, validationResult, Optional.empty()); + } + + public static TransactionProcessingResult failed( + final long gasUsedByTransaction, + final long gasRemaining, + final ValidationResult validationResult, + final Optional revertReason) { + return new TransactionProcessingResult( + Status.FAILED, + new ArrayList<>(), + gasUsedByTransaction, + gasRemaining, + Bytes.EMPTY, + validationResult, + revertReason); + } + + public static TransactionProcessingResult successful( + final List logs, + final long gasUsedByTransaction, + final long gasRemaining, + final Bytes output, + final ValidationResult validationResult) { + return new TransactionProcessingResult( + Status.SUCCESSFUL, + logs, + gasUsedByTransaction, + gasRemaining, + output, + validationResult, + Optional.empty()); + } + + public TransactionProcessingResult( + final Status status, + final List logs, + final long estimateGasUsedByTransaction, + final long gasRemaining, + final Bytes output, + final ValidationResult validationResult, + final Optional revertReason) { + this.status = status; + this.logs = logs; + this.estimateGasUsedByTransaction = estimateGasUsedByTransaction; + this.gasRemaining = gasRemaining; + this.output = output; + this.validationResult = validationResult; + this.revertReason = revertReason; + } + + /** + * Return the logs produced by the transaction. + * + *

This is only valid when {@code TransactionProcessor#isSuccessful} returns {@code true}. + * + * @return the logs produced by the transaction + */ + public List getLogs() { + return logs; + } + + /** + * Returns the gas remaining after the transaction was processed. + * + *

This is only valid when {@code TransactionProcessor#isSuccessful} returns {@code true}. + * + * @return the gas remaining after the transaction was processed + */ + public long getGasRemaining() { + return gasRemaining; + } + + /** + * Returns the estimate gas used by the transaction Difference between the gas limit and the + * remaining gas + * + * @return the estimate gas used + */ + public long getEstimateGasUsedByTransaction() { + return estimateGasUsedByTransaction; + } + + /** + * Returns the status of the transaction after being processed. + * + * @return the status of the transaction after being processed + */ + public Status getStatus() { + return status; + } + + public Bytes getOutput() { + return output; + } + + /** + * Returns whether or not the transaction was invalid. + * + * @return {@code true} if the transaction was invalid; otherwise {@code false} + */ + public boolean isInvalid() { + return getStatus() == Status.INVALID; + } + + /** + * Returns whether or not the transaction was successfully processed. + * + * @return {@code true} if the transaction was successfully processed; otherwise {@code false} + */ + public boolean isSuccessful() { + return getStatus() == Status.SUCCESSFUL; + } + + /** + * Returns the transaction validation result. + * + * @return the validation result, with the reason for failure (if applicable.) + */ + public ValidationResult getValidationResult() { + return validationResult; + } + + /** + * Returns the reason why a transaction was reverted (if applicable). + * + * @return the revert reason. + */ + public Optional getRevertReason() { + return revertReason; + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java index a590a2ae0c..dcc35cb91d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java @@ -23,10 +23,11 @@ import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Wei; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; @@ -125,9 +126,9 @@ public class TransactionSimulator { final ProtocolSpec protocolSpec = protocolSchedule.getByBlockNumber(header.getNumber()); - final TransactionProcessor transactionProcessor = + final MainnetTransactionProcessor transactionProcessor = protocolSchedule.getByBlockNumber(header.getNumber()).getTransactionProcessor(); - final TransactionProcessor.Result result = + final TransactionProcessingResult result = transactionProcessor.processTransaction( blockchain, worldState.updater(), diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResult.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResult.java index 3238b3343c..315c98c58a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResult.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResult.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.ethereum.transaction; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import java.util.Objects; @@ -27,11 +27,11 @@ import org.apache.tuweni.bytes.Bytes; public class TransactionSimulatorResult { private final Transaction transaction; - private final TransactionProcessor.Result result; + private final TransactionProcessingResult result; @VisibleForTesting public TransactionSimulatorResult( - final Transaction transaction, final TransactionProcessor.Result result) { + final Transaction transaction, final TransactionProcessingResult result) { this.transaction = transaction; this.result = result; } @@ -52,7 +52,7 @@ public class TransactionSimulatorResult { return result.getValidationResult(); } - public TransactionProcessor.Result getResult() { + public TransactionProcessingResult getResult() { return result; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/StandardJsonTracer.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/StandardJsonTracer.java index 05d682b5da..5e0817674b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/StandardJsonTracer.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/StandardJsonTracer.java @@ -18,7 +18,7 @@ package org.hyperledger.besu.ethereum.vm; import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.Operation.OperationResult; import org.hyperledger.besu.ethereum.vm.operations.ReturnStack; @@ -53,7 +53,7 @@ public class StandardJsonTracer implements OperationTracer { } public static String summaryTrace( - final Transaction transaction, final long timer, final TransactionProcessor.Result result) { + final Transaction transaction, final long timer, final TransactionProcessingResult result) { final ObjectNode summaryLine = OBJECT_MAPPER.createObjectNode(); summaryLine.put("output", result.getOutput().toUnprefixedHexString()); summaryLine.put( diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java index e5b2057ca2..83d7ef97e7 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java @@ -33,7 +33,8 @@ import org.junit.Test; public class MainnetBlockProcessorTest { - private final TransactionProcessor transactionProcessor = mock(TransactionProcessor.class); + private final MainnetTransactionProcessor transactionProcessor = + mock(MainnetTransactionProcessor.class); private final AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory = mock(AbstractBlockProcessor.TransactionReceiptFactory.class); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java index 57fcbdb517..78d9c89496 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java @@ -43,6 +43,7 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap; import org.hyperledger.besu.ethereum.privacy.storage.PrivateBlockMetadata; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; @@ -190,11 +191,12 @@ public class PrivacyBlockProcessorTest { @SuppressWarnings("rawtypes") private ProtocolSpec mockProtocolSpec() { final ProtocolSpec protocolSpec = mock(ProtocolSpec.class); - final TransactionProcessor mockPublicTransactionProcessor = mock(TransactionProcessor.class); + final MainnetTransactionProcessor mockPublicTransactionProcessor = + mock(MainnetTransactionProcessor.class); when(mockPublicTransactionProcessor.processTransaction( any(), any(), any(), any(), any(), any(), anyBoolean(), any())) .thenReturn( - MainnetTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( Collections.emptyList(), 0, 0, Bytes.EMPTY, ValidationResult.valid())); when(protocolSpec.getTransactionProcessor()).thenReturn(mockPublicTransactionProcessor); final PrivateTransactionProcessor mockPrivateTransactionProcessor = @@ -202,7 +204,7 @@ public class PrivacyBlockProcessorTest { when(mockPrivateTransactionProcessor.processTransaction( any(), any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( - PrivateTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( Collections.emptyList(), 0, 0, Bytes.EMPTY, ValidationResult.valid())); when(protocolSpec.getPrivateTransactionProcessor()).thenReturn(mockPrivateTransactionProcessor); final AbstractBlockProcessor.TransactionReceiptFactory mockTransactionReceiptFactory = diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContractTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContractTest.java index 23df2380de..c7339dc623 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContractTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContractTest.java @@ -48,6 +48,7 @@ import org.hyperledger.besu.ethereum.privacy.VersionedPrivateTransaction; import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.MessageFrame; @@ -82,7 +83,7 @@ public class OnChainPrivacyPrecompiledContractTest { new PrivateStateRootResolver(privateStateStorage); private PrivateTransactionProcessor mockPrivateTxProcessor( - final PrivateTransactionProcessor.Result result) { + final TransactionProcessingResult result) { final PrivateTransactionProcessor mockPrivateTransactionProcessor = mock(PrivateTransactionProcessor.class); when(mockPrivateTransactionProcessor.processTransaction( @@ -147,7 +148,7 @@ public class OnChainPrivacyPrecompiledContractTest { final List logs = new ArrayList<>(); contract.setPrivateTransactionProcessor( mockPrivateTxProcessor( - PrivateTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( logs, 0, 0, Bytes.fromHexString(DEFAULT_OUTPUT), null))); final VersionedPrivateTransaction versionedPrivateTransaction = @@ -240,8 +241,7 @@ public class OnChainPrivacyPrecompiledContractTest { Mockito.doReturn(true) .when(contractSpy) .onChainPrivacyGroupVersionMatches(any(), any(), any(), any(), any(), any(), any(), any()); - final PrivateTransactionProcessor.Result mockResult = - mock(PrivateTransactionProcessor.Result.class); + final TransactionProcessingResult mockResult = mock(TransactionProcessingResult.class); Mockito.doReturn(mockResult) .when(contractSpy) .simulateTransaction(any(), any(), any(), any(), any(), any(), any(), any()); @@ -276,7 +276,7 @@ public class OnChainPrivacyPrecompiledContractTest { contract.setPrivateTransactionProcessor( mockPrivateTxProcessor( - PrivateTransactionProcessor.Result.invalid( + TransactionProcessingResult.invalid( ValidationResult.invalid( TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE)))); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java index 47bc286f6b..5339301276 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java @@ -50,6 +50,7 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap; import org.hyperledger.besu.ethereum.privacy.storage.PrivateBlockMetadata; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.MessageFrame; @@ -85,7 +86,7 @@ public class PrivacyPrecompiledContractTest { new PrivateStateRootResolver(privateStateStorage); private PrivateTransactionProcessor mockPrivateTxProcessor( - final PrivateTransactionProcessor.Result result) { + final TransactionProcessingResult result) { final PrivateTransactionProcessor mockPrivateTransactionProcessor = mock(PrivateTransactionProcessor.class); when(mockPrivateTransactionProcessor.processTransaction( @@ -149,7 +150,7 @@ public class PrivacyPrecompiledContractTest { final List logs = new ArrayList<>(); contract.setPrivateTransactionProcessor( mockPrivateTxProcessor( - PrivateTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( logs, 0, 0, Bytes.fromHexString(DEFAULT_OUTPUT), null))); final PrivateTransaction privateTransaction = privateTransactionBesu(); @@ -251,7 +252,7 @@ public class PrivacyPrecompiledContractTest { final PrivacyPrecompiledContract contract = buildPrivacyPrecompiledContract(enclave); contract.setPrivateTransactionProcessor( mockPrivateTxProcessor( - PrivateTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( new ArrayList<>(), 0, 0, Bytes.fromHexString(DEFAULT_OUTPUT), null))); final PrivateTransaction privateTransaction = privateTransactionBesu(); @@ -287,7 +288,7 @@ public class PrivacyPrecompiledContractTest { contract.setPrivateTransactionProcessor( mockPrivateTxProcessor( - PrivateTransactionProcessor.Result.invalid( + TransactionProcessingResult.invalid( ValidationResult.invalid( TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE)))); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyControllerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyControllerTest.java index 53998d6e5b..300824fabf 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyControllerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyControllerTest.java @@ -44,12 +44,12 @@ import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Wei; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.privacy.markertransaction.FixedKeySigningPrivateMarkerTransactionFactory; import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import org.hyperledger.orion.testutil.OrionKeyUtils; @@ -244,8 +244,8 @@ public class DefaultPrivacyControllerTest { when(privateTransactionSimulator.process(any(), any())) .thenReturn( Optional.of( - new PrivateTransactionProcessor.Result( - TransactionProcessor.Result.Status.SUCCESSFUL, + new TransactionProcessingResult( + TransactionProcessingResult.Status.SUCCESSFUL, emptyList(), 0, 0, @@ -437,9 +437,9 @@ public class DefaultPrivacyControllerTest { when(privateTransactionSimulator.process(any(), any(), any(long.class))) .thenReturn( Optional.of( - PrivateTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( LOGS, 0, 0, Bytes.EMPTY, ValidationResult.valid()))); - final Optional result = + final Optional result = privacyController.simulatePrivateTransaction( "Group1", ENCLAVE_PUBLIC_KEY, callParameter, 1); assertThat(result.isPresent()).isTrue(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyControllerOnchainTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyControllerOnchainTest.java index 7157ae10b1..f2b2f47d3b 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyControllerOnchainTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyControllerOnchainTest.java @@ -25,6 +25,7 @@ import org.hyperledger.besu.ethereum.core.Address; import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import java.math.BigInteger; @@ -74,9 +75,9 @@ public class MultiTenancyPrivacyControllerOnchainTest { when(privacyController.simulatePrivateTransaction(any(), any(), any(), any(long.class))) .thenReturn( Optional.of( - PrivateTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( LOGS, 0, 0, Bytes.EMPTY, ValidationResult.valid()))); - final Optional result = + final Optional result = multiTenancyPrivacyController.simulatePrivateTransaction( PRIVACY_GROUP_ID, ENCLAVE_PUBLIC_KEY1, diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyControllerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyControllerTest.java index 6013db8eeb..42a5045021 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyControllerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyControllerTest.java @@ -30,6 +30,7 @@ import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import java.math.BigInteger; @@ -362,9 +363,9 @@ public class MultiTenancyPrivacyControllerTest { when(privacyController.simulatePrivateTransaction(any(), any(), any(), any(long.class))) .thenReturn( Optional.of( - PrivateTransactionProcessor.Result.successful( + TransactionProcessingResult.successful( LOGS, 0, 0, Bytes.EMPTY, ValidationResult.valid()))); - final Optional result = + final Optional result = multiTenancyPrivacyController.simulatePrivateTransaction( PRIVACY_GROUP_ID, ENCLAVE_PUBLIC_KEY1, diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationTest.java index 80a9f6f288..83e436a3f9 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationTest.java @@ -38,10 +38,10 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor.TransactionReceiptFactory; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.MiningBeneficiaryCalculator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver; import org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage; import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap; @@ -84,7 +84,7 @@ public class PrivateStorageMigrationTest { @Mock private WorldStateArchive publicWorldStateArchive; @Mock private MutableWorldState publicMutableWorldState; @Mock private LegacyPrivateStateStorage legacyPrivateStateStorage; - @Mock private TransactionProcessor transactionProcessor; + @Mock private MainnetTransactionProcessor transactionProcessor; @Mock private TransactionReceiptFactory transactionReceiptFactory; @Mock private MiningBeneficiaryCalculator miningBeneficiaryCalculator; @Mock private PrivateMigrationBlockProcessor privateMigrationBlockProcessor; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResultTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResultTest.java index 1db716dedf..8bec27c06e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResultTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResultTest.java @@ -19,7 +19,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor.Result; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.junit.Before; import org.junit.Test; @@ -33,7 +33,7 @@ public class TransactionSimulatorResultTest { private TransactionSimulatorResult transactionSimulatorResult; @Mock private Transaction transaction; - @Mock private Result result; + @Mock private TransactionProcessingResult result; @Before public void before() { diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java index 5eb83da2df..c883e28a79 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java @@ -31,11 +31,10 @@ import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Wei; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor.Result; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor.Result.Status; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import java.util.Optional; @@ -67,7 +66,7 @@ public class TransactionSimulatorTest { @Mock private MutableWorldState worldState; @Mock private ProtocolSchedule protocolSchedule; @Mock private ProtocolSpec protocolSpec; - @Mock private TransactionProcessor transactionProcessor; + @Mock private MainnetTransactionProcessor transactionProcessor; @Before public void setUp() { @@ -103,7 +102,8 @@ public class TransactionSimulatorTest { .payload(callParameter.getPayload()) .signature(FAKE_SIGNATURE) .build(); - mockProcessorStatusForTransaction(1L, expectedTransaction, Status.SUCCESSFUL); + mockProcessorStatusForTransaction( + 1L, expectedTransaction, TransactionProcessingResult.Status.SUCCESSFUL); final Optional result = transactionSimulator.process(callParameter, 1L); @@ -130,7 +130,8 @@ public class TransactionSimulatorTest { .payload(Bytes.EMPTY) .signature(FAKE_SIGNATURE) .build(); - mockProcessorStatusForTransaction(1L, expectedTransaction, Status.SUCCESSFUL); + mockProcessorStatusForTransaction( + 1L, expectedTransaction, TransactionProcessingResult.Status.SUCCESSFUL); transactionSimulator.process(callParameter, 1L); @@ -155,7 +156,8 @@ public class TransactionSimulatorTest { .payload(Bytes.EMPTY) .signature(FAKE_SIGNATURE) .build(); - mockProcessorStatusForTransaction(1L, expectedTransaction, Status.SUCCESSFUL); + mockProcessorStatusForTransaction( + 1L, expectedTransaction, TransactionProcessingResult.Status.SUCCESSFUL); transactionSimulator.process(callParameter, 1L); @@ -180,7 +182,8 @@ public class TransactionSimulatorTest { .payload(callParameter.getPayload()) .signature(FAKE_SIGNATURE) .build(); - mockProcessorStatusForTransaction(1L, expectedTransaction, Status.FAILED); + mockProcessorStatusForTransaction( + 1L, expectedTransaction, TransactionProcessingResult.Status.FAILED); final Optional result = transactionSimulator.process(callParameter, 1L); @@ -217,7 +220,8 @@ public class TransactionSimulatorTest { .payload(callParameter.getPayload()) .signature(FAKE_SIGNATURE) .build(); - mockProcessorStatusForTransaction(1L, expectedTransaction, Status.SUCCESSFUL); + mockProcessorStatusForTransaction( + 1L, expectedTransaction, TransactionProcessingResult.Status.SUCCESSFUL); final Optional result = transactionSimulator.process(callParameter, DEFAULT_BLOCK_HEADER_HASH); @@ -244,7 +248,8 @@ public class TransactionSimulatorTest { .payload(Bytes.EMPTY) .signature(FAKE_SIGNATURE) .build(); - mockProcessorStatusForTransaction(1L, expectedTransaction, Status.SUCCESSFUL); + mockProcessorStatusForTransaction( + 1L, expectedTransaction, TransactionProcessingResult.Status.SUCCESSFUL); transactionSimulator.process(callParameter, DEFAULT_BLOCK_HEADER_HASH); @@ -269,7 +274,8 @@ public class TransactionSimulatorTest { .payload(Bytes.EMPTY) .signature(FAKE_SIGNATURE) .build(); - mockProcessorStatusForTransaction(1L, expectedTransaction, Status.SUCCESSFUL); + mockProcessorStatusForTransaction( + 1L, expectedTransaction, TransactionProcessingResult.Status.SUCCESSFUL); transactionSimulator.process(callParameter, DEFAULT_BLOCK_HEADER_HASH); @@ -294,7 +300,8 @@ public class TransactionSimulatorTest { .payload(callParameter.getPayload()) .signature(FAKE_SIGNATURE) .build(); - mockProcessorStatusForTransaction(1L, expectedTransaction, Status.FAILED); + mockProcessorStatusForTransaction( + 1L, expectedTransaction, TransactionProcessingResult.Status.FAILED); final Optional result = transactionSimulator.process(callParameter, DEFAULT_BLOCK_HEADER_HASH); @@ -330,12 +337,14 @@ public class TransactionSimulatorTest { } private void mockProcessorStatusForTransaction( - final long blockNumber, final Transaction transaction, final Status status) { + final long blockNumber, + final Transaction transaction, + final TransactionProcessingResult.Status status) { when(protocolSchedule.getByBlockNumber(eq(blockNumber))).thenReturn(protocolSpec); when(protocolSpec.getTransactionProcessor()).thenReturn(transactionProcessor); when(protocolSpec.getMiningBeneficiaryCalculator()).thenReturn(BlockHeader::getCoinbase); - final Result result = mock(Result.class); + final TransactionProcessingResult result = mock(TransactionProcessingResult.class); switch (status) { case SUCCESSFUL: when(result.isSuccessful()).thenReturn(true); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTestTools.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTestTools.java index 7683ac64bf..4bd907bd83 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTestTools.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTestTools.java @@ -25,8 +25,9 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; 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; @@ -46,7 +47,7 @@ public class GeneralStateReferenceTestTools { private static final List SPECS_PRIOR_TO_DELETING_EMPTY_ACCOUNTS = Arrays.asList("Frontier", "Homestead", "EIP150"); - private static TransactionProcessor transactionProcessor(final String name) { + private static MainnetTransactionProcessor transactionProcessor(final String name) { return REFERENCE_TEST_PROTOCOL_SCHEDULES .getByName(name) .getByBlockNumber(0) @@ -126,10 +127,10 @@ public class GeneralStateReferenceTestTools { return; } - final TransactionProcessor processor = transactionProcessor(spec.getFork()); + final MainnetTransactionProcessor processor = transactionProcessor(spec.getFork()); final WorldUpdater worldStateUpdater = worldState.updater(); final ReferenceTestBlockchain blockchain = new ReferenceTestBlockchain(blockHeader.getNumber()); - final TransactionProcessor.Result result = + final TransactionProcessingResult result = processor.processTransaction( blockchain, worldStateUpdater, diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java index f1fe486531..4848d7f66c 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java @@ -27,8 +27,9 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.TransactionProcessor; +import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; 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; @@ -150,7 +151,7 @@ public class StateTestSubCommand implements Runnable { return; } - final TransactionProcessor processor = + final MainnetTransactionProcessor processor = referenceTestProtocolSchedules .getByName(fork == null ? spec.getFork() : fork) .getByBlockNumber(0) @@ -159,7 +160,7 @@ public class StateTestSubCommand implements Runnable { final ReferenceTestBlockchain blockchain = new ReferenceTestBlockchain(blockHeader.getNumber()); final Stopwatch timer = Stopwatch.createStarted(); - final TransactionProcessor.Result result = + final TransactionProcessingResult result = processor.processTransaction( blockchain, worldStateUpdater, diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningControllerTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningControllerTest.java index 4942fa2665..8b74e491ba 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningControllerTest.java @@ -25,10 +25,10 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.ethereum.core.Address; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor.Result; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL; +import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult; @@ -168,6 +168,7 @@ public class NodeSmartContractV2PermissioningControllerTest { final Bytes output, final ValidationResult validationResult) { return new TransactionSimulatorResult( blockDataGenerator.transaction(), - Result.successful(blockDataGenerator.logs(1, 1), 0L, 0L, output, validationResult)); + TransactionProcessingResult.successful( + blockDataGenerator.logs(1, 1), 0L, 0L, output, validationResult)); } }