Collapse MainnetTransactionProcessor Class and Transaction Processor Interface (#1544)

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
pull/1553/head
Ratan (Rai) Sur 4 years ago committed by GitHub
parent bd59966212
commit 4ff73342b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java
  2. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceReplayBlockTransactions.java
  3. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockReplay.java
  4. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java
  5. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTrace.java
  6. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java
  7. 5
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAtTest.java
  8. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHashTest.java
  9. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumberTest.java
  10. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java
  11. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransactionTest.java
  12. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java
  13. 5
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCallTest.java
  14. 10
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracerTest.java
  15. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/RewardTraceGeneratorTest.java
  16. 4
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java
  17. 11
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java
  18. 28
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java
  19. 5
      ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java
  20. 8
      ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java
  21. 12
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java
  22. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java
  23. 5
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java
  24. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java
  25. 7
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
  26. 262
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java
  27. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java
  28. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java
  29. 292
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/TransactionProcessor.java
  30. 17
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContract.java
  31. 12
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java
  32. 11
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyController.java
  33. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyController.java
  34. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java
  35. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivacyController.java
  36. 21
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java
  37. 127
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java
  38. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionReceipt.java
  39. 11
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionSimulator.java
  40. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/VersionedPrivateTransaction.java
  41. 15
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java
  42. 189
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/processing/TransactionProcessingResult.java
  43. 7
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java
  44. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResult.java
  45. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/StandardJsonTracer.java
  46. 3
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java
  47. 8
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java
  48. 10
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContractTest.java
  49. 9
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java
  50. 10
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyControllerTest.java
  51. 5
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyControllerOnchainTest.java
  52. 5
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyControllerTest.java
  53. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationTest.java
  54. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResultTest.java
  55. 37
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java
  56. 9
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTestTools.java
  57. 7
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java
  58. 5
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningControllerTest.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 {

@ -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)) {

@ -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);
}
}

@ -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,

@ -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<TraceFrame> traceFrames;
public TransactionTrace(
final Transaction transaction, final Result result, final List<TraceFrame> traceFrames) {
final Transaction transaction,
final TransactionProcessingResult result,
final List<TraceFrame> 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;
}

@ -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,

@ -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);

@ -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);

@ -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);

@ -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);

@ -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(

@ -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());

@ -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);

@ -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));

@ -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"));

@ -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<List<Transaction>> transactions)
throws RuntimeException {
final TransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor();
final MainnetTransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor();
final AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory =
protocolSpec.getTransactionReceiptFactory();

@ -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<Boolean> 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()) {

@ -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);
}

@ -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),

@ -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,

@ -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,

@ -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,

@ -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,

@ -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,

@ -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,

@ -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<Log> logs;
private final Bytes output;
private final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult;
private final Optional<Bytes> revertReason;
public static Result invalid(
final ValidationResult<TransactionValidator.TransactionInvalidReason> 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<TransactionValidator.TransactionInvalidReason> validationResult,
final Optional<Bytes> revertReason) {
return new Result(
Status.FAILED,
new ArrayList<>(),
gasUsedByTransaction,
gasRemaining,
Bytes.EMPTY,
validationResult,
revertReason);
}
public static Result successful(
final List<Log> logs,
final long gasUsedByTransaction,
final long gasRemaining,
final Bytes output,
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult) {
return new Result(
Status.SUCCESSFUL,
logs,
gasUsedByTransaction,
gasRemaining,
output,
validationResult,
Optional.empty());
}
Result(
final Status status,
final List<Log> logs,
final long estimateGasUsedByTransaction,
final long gasRemaining,
final Bytes output,
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult,
final Optional<Bytes> 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<Log> 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<TransactionValidator.TransactionInvalidReason> 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<Bytes> 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()));

@ -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;
}

@ -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,

@ -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.
*
* <p>This is only valid when {@code TransactionProcessor#isSuccessful} returns {@code true}.
*
* @return the logs produced by the transaction
*/
List<Log> 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.
*
* <p>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<TransactionValidator.TransactionInvalidReason> getValidationResult();
/**
* Returns the reason why a transaction was reverted (if applicable).
*
* @return the revert reason.
*/
Optional<Bytes> 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);
}

@ -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<Bytes> getMembersFromResult(final PrivateTransactionProcessor.Result result) {
List<Bytes> getMembersFromResult(final TransactionProcessingResult result) {
List<Bytes> 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,

@ -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;

@ -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<PrivateTransactionProcessor.Result> simulatePrivateTransaction(
public Optional<TransactionProcessingResult> simulatePrivateTransaction(
final String privacyGroupId,
final String enclavePublicKey,
final CallParameter callParams,
final long blockNumber) {
final Optional<PrivateTransactionProcessor.Result> result =
final Optional<TransactionProcessingResult> result =
privateTransactionSimulator.process(privacyGroupId, callParams, blockNumber);
return result;
}
@ -286,7 +287,7 @@ public class DefaultPrivacyController implements PrivacyController {
public Optional<PrivacyGroup> retrieveOnChainPrivacyGroup(final Bytes privacyGroupId) {
// get the privateFor list from the management contract
final Optional<PrivateTransactionProcessor.Result> privateTransactionSimulatorResultOptional =
final Optional<TransactionProcessingResult> 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<PrivateTransactionProcessor.Result> privateTransactionSimulatorResultOptional =
final Optional<TransactionProcessingResult> 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<PrivateTransactionProcessor.Result> result =
final Optional<TransactionProcessingResult> result =
privateTransactionSimulator.process(
privateTransaction.getPrivacyGroupId().get().toBase64String(),
buildCallParams(GET_VERSION_METHOD_SIGNATURE));

@ -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<PrivateTransactionProcessor.Result> simulatePrivateTransaction(
public Optional<TransactionProcessingResult> simulatePrivateTransaction(
final String privacyGroupId,
final String enclavePublicKey,
final CallParameter callParams,

@ -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<Long> blockNumber) {
final CallParameter callParams = buildCallParams(GET_PARTICIPANTS_METHOD_SIGNATURE);
final Optional<PrivateTransactionProcessor.Result> result;
final Optional<TransactionProcessingResult> result;
if (blockHash.isPresent()) {
result = privateTransactionSimulator.process(privacyGroupId, callParams, blockHash.get());
@ -80,7 +80,7 @@ public class OnchainPrivacyGroupContract {
}
private Optional<PrivacyGroup> readPrivacyGroupFromResult(
final String privacyGroupId, final Optional<Result> result) {
final String privacyGroupId, final Optional<TransactionProcessingResult> result) {
if (result.isEmpty()) {
return Optional.empty();
}
@ -102,7 +102,7 @@ public class OnchainPrivacyGroupContract {
public Optional<Bytes32> getVersion(final String privacyGroupId, final Optional<Hash> blockHash) {
final CallParameter callParams = buildCallParams(GET_VERSION_METHOD_SIGNATURE);
final Optional<Result> result;
final Optional<TransactionProcessingResult> 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) {

@ -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<PrivateTransactionProcessor.Result> simulatePrivateTransaction(
Optional<TransactionProcessingResult> simulatePrivateTransaction(
final String privacyGroupId,
final String enclavePublicKey,
final CallParameter callParams,

@ -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());

@ -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<Log> logs;
private final Bytes output;
private final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult;
private final Optional<Bytes> revertReason;
public static Result invalid(
final ValidationResult<TransactionValidator.TransactionInvalidReason> 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<TransactionValidator.TransactionInvalidReason> validationResult,
final Optional<Bytes> revertReason) {
return new Result(
Status.FAILED,
new ArrayList<>(),
gasUsedByTransaction,
gasRemaining,
Bytes.EMPTY,
validationResult,
revertReason);
}
public static Result successful(
final List<Log> logs,
final long gasUsedByTransaction,
final long gasRemaining,
final Bytes output,
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult) {
return new Result(
Status.SUCCESSFUL,
logs,
gasUsedByTransaction,
gasRemaining,
output,
validationResult,
Optional.empty());
}
Result(
final Status status,
final List<Log> logs,
final long estimateGasUsedByTransaction,
final long gasRemaining,
final Bytes output,
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult,
final Optional<Bytes> 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<Log> 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<TransactionValidator.TransactionInvalidReason> getValidationResult() {
return validationResult;
}
@Override
public Optional<Bytes> 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<TransactionValidator.TransactionInvalidReason> 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()));

@ -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;

@ -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<PrivateTransactionProcessor.Result> process(
public Optional<TransactionProcessingResult> process(
final String privacyGroupId, final CallParameter callParams) {
final BlockHeader header = blockchain.getChainHeadHeader();
return process(privacyGroupId, callParams, header);
}
public Optional<PrivateTransactionProcessor.Result> process(
public Optional<TransactionProcessingResult> 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<PrivateTransactionProcessor.Result> process(
public Optional<TransactionProcessingResult> 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<PrivateTransactionProcessor.Result> process(
private Optional<TransactionProcessingResult> 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(),

@ -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<PrivateTransactionProcessor.Result> result) {
final Optional<TransactionProcessingResult> result) {
this(
privateTransaction,
result

@ -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());

@ -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<Log> logs;
private final Bytes output;
private final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult;
private final Optional<Bytes> revertReason;
public static TransactionProcessingResult invalid(
final ValidationResult<TransactionValidator.TransactionInvalidReason> 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<TransactionValidator.TransactionInvalidReason> validationResult,
final Optional<Bytes> revertReason) {
return new TransactionProcessingResult(
Status.FAILED,
new ArrayList<>(),
gasUsedByTransaction,
gasRemaining,
Bytes.EMPTY,
validationResult,
revertReason);
}
public static TransactionProcessingResult successful(
final List<Log> logs,
final long gasUsedByTransaction,
final long gasRemaining,
final Bytes output,
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult) {
return new TransactionProcessingResult(
Status.SUCCESSFUL,
logs,
gasUsedByTransaction,
gasRemaining,
output,
validationResult,
Optional.empty());
}
public TransactionProcessingResult(
final Status status,
final List<Log> logs,
final long estimateGasUsedByTransaction,
final long gasRemaining,
final Bytes output,
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult,
final Optional<Bytes> 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.
*
* <p>This is only valid when {@code TransactionProcessor#isSuccessful} returns {@code true}.
*
* @return the logs produced by the transaction
*/
public List<Log> getLogs() {
return logs;
}
/**
* Returns the gas remaining after the transaction was processed.
*
* <p>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<TransactionValidator.TransactionInvalidReason> getValidationResult() {
return validationResult;
}
/**
* Returns the reason why a transaction was reverted (if applicable).
*
* @return the revert reason.
*/
public Optional<Bytes> getRevertReason() {
return revertReason;
}
}

@ -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(),

@ -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;
}

@ -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(

@ -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);

@ -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 =

@ -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<Log> 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))));

@ -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<Log> 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))));

@ -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<PrivateTransactionProcessor.Result> result =
final Optional<TransactionProcessingResult> result =
privacyController.simulatePrivateTransaction(
"Group1", ENCLAVE_PUBLIC_KEY, callParameter, 1);
assertThat(result.isPresent()).isTrue();

@ -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<PrivateTransactionProcessor.Result> result =
final Optional<TransactionProcessingResult> result =
multiTenancyPrivacyController.simulatePrivateTransaction(
PRIVACY_GROUP_ID,
ENCLAVE_PUBLIC_KEY1,

@ -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<PrivateTransactionProcessor.Result> result =
final Optional<TransactionProcessingResult> result =
multiTenancyPrivacyController.simulatePrivateTransaction(
PRIVACY_GROUP_ID,
ENCLAVE_PUBLIC_KEY1,

@ -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;

@ -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() {

@ -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<TransactionSimulatorResult> 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<TransactionSimulatorResult> 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<TransactionSimulatorResult> 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<TransactionSimulatorResult> 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);

@ -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<String> 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,

@ -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,

@ -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<TransactionInvalidReason> 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));
}
}

Loading…
Cancel
Save