Collapse Transaction Validator (#1548)

Moves TransactionInvalidReason to top level so it can be accessed by 
privacy code while also allowing the TransactionValidator to be 
collapsed as it's only used on the permissionless side.

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
pull/1560/head
Ratan (Rai) Sur 4 years ago committed by GitHub
parent 4ff73342b6
commit 9062140452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java
  2. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java
  3. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/response/GraphQLError.java
  4. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java
  5. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugBatchSendRawTransaction.java
  6. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java
  7. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransaction.java
  8. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransaction.java
  9. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivDistributeRawTransaction.java
  10. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java
  11. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java
  12. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverterTest.java
  13. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java
  14. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransactionTest.java
  15. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/EeaSendRawTransactionTest.java
  16. 4
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java
  17. 11
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java
  18. 18
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java
  19. 38
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java
  20. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java
  21. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java
  22. 93
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/TransactionValidator.java
  23. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyController.java
  24. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/MultiTenancyPrivacyController.java
  25. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivacyController.java
  26. 13
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java
  27. 33
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionValidator.java
  28. 14
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/processing/TransactionProcessingResult.java
  29. 46
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionInvalidReason.java
  30. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorResult.java
  31. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java
  32. 7
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java
  33. 37
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java
  34. 5
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContractTest.java
  35. 5
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java
  36. 6
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/DefaultPrivacyControllerTest.java
  37. 16
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionValidatorTest.java
  38. 2
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactions.java
  39. 8
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java
  40. 5
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java
  41. 13
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java
  42. 2
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractV2PermissioningControllerTest.java

@ -44,9 +44,9 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolFactory;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
@ -88,7 +88,7 @@ public class BesuEventsImplTest {
@Mock private EthContext mockEthContext;
@Mock private EthMessages mockEthMessages;
@Mock private EthScheduler mockEthScheduler;
@Mock private TransactionValidator mockTransactionValidator;
@Mock private MainnetTransactionValidator mockTransactionValidator;
@Mock private ProtocolSpec mockProtocolSpec;
@Mock private WorldStateArchive mockWorldStateArchive;
@Mock private WorldState mockWorldState;

@ -39,11 +39,11 @@ import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.plugin.data.SyncStatus;
import java.util.ArrayList;

@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.graphql.internal.response;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonGetter;

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.api.jsonrpc;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
public class JsonRpcErrorConverter {

@ -20,8 +20,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.util.DomainObjectDecodeUtils;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.util.ArrayList;
import java.util.List;
@ -65,7 +65,7 @@ public class DebugBatchSendRawTransaction implements JsonRpcMethod {
private ExecutionStatus process(final int index, final String rawTransaction) {
try {
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult =
final ValidationResult<TransactionInvalidReason> validationResult =
transactionPool
.get()
.addLocalTransaction(DomainObjectDecodeUtils.decodeRawTransaction(rawTransaction));

@ -25,10 +25,10 @@ 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.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.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult;
import org.hyperledger.besu.ethereum.vm.EstimateGasOperationTracer;
@ -128,7 +128,7 @@ public class EthEstimateGas implements JsonRpcMethod {
final JsonRpcRequestContext request, final TransactionSimulatorResult result) {
final JsonRpcError jsonRpcError;
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult =
final ValidationResult<TransactionInvalidReason> validationResult =
result.getValidationResult();
if (validationResult != null && !validationResult.isValid()) {
jsonRpcError =

@ -26,8 +26,8 @@ import org.hyperledger.besu.ethereum.api.util.DomainObjectDecodeUtils;
import org.hyperledger.besu.ethereum.core.Hash;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.util.function.Supplier;

@ -31,12 +31,12 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSucces
import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.util.Optional;

@ -30,13 +30,13 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.util.Base64;
import java.util.Optional;

@ -36,9 +36,9 @@ import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.util.RawBlockIterator;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.plugin.data.SyncStatus;

@ -38,10 +38,10 @@ import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.nat.NatService;

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.util.Arrays;
import java.util.Collection;

@ -31,10 +31,10 @@ 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.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.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult;
import org.hyperledger.besu.ethereum.vm.OperationTracer;

@ -27,8 +27,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.junit.Before;
import org.junit.Test;

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.PRIVATE_TRANSACTION_FAILED;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.PRIVATE_TRANSACTION_FAILED;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@ -40,13 +40,13 @@ import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import org.hyperledger.besu.ethereum.privacy.Restriction;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.math.BigInteger;
import java.util.Arrays;

@ -31,8 +31,8 @@ import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions.Transa
import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor;
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.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
import java.util.List;
@ -230,7 +230,7 @@ public class BlockTransactionSelector {
if (result
.getValidationResult()
.getInvalidReason()
.equals(TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE)) {
.equals(TransactionInvalidReason.INCORRECT_NONCE)) {
return TransactionSelectionResult.CONTINUE;
}
// If the transaction was invalid for any other reason, delete it, and continue.

@ -45,10 +45,10 @@ 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.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.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -200,8 +200,7 @@ public class BlockTransactionSelectorTest {
any()))
.thenReturn(
TransactionProcessingResult.invalid(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.NONCE_TOO_LOW)));
ValidationResult.invalid(TransactionInvalidReason.NONCE_TOO_LOW)));
// The block should fit 3 transactions only
final ProcessableBlockHeader blockHeader = createBlockWithGasLimit(5000);
@ -494,8 +493,7 @@ public class BlockTransactionSelectorTest {
any()))
.thenReturn(
TransactionProcessingResult.invalid(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.EXCEEDS_BLOCK_GAS_LIMIT)));
ValidationResult.invalid(TransactionInvalidReason.EXCEEDS_BLOCK_GAS_LIMIT)));
selector.buildTransactionListForBlock(blockHeader.getNumber(), blockHeader.getGasLimit());
@ -526,8 +524,7 @@ public class BlockTransactionSelectorTest {
any()))
.thenReturn(
TransactionProcessingResult.invalid(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE)));
ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE)));
final Address miningBeneficiary = AddressHelpers.ofValue(1);
final BlockTransactionSelector selector =

@ -26,9 +26,9 @@ import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.core.WorldUpdater;
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.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
import org.hyperledger.besu.ethereum.vm.Code;
import org.hyperledger.besu.ethereum.vm.GasCalculator;
@ -51,7 +51,7 @@ public class MainnetTransactionProcessor {
private final GasCalculator gasCalculator;
private final TransactionValidator transactionValidator;
private final MainnetTransactionValidator transactionValidator;
private final AbstractMessageProcessor contractCreationProcessor;
@ -75,9 +75,9 @@ public class MainnetTransactionProcessor {
* @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}
* MainnetTransactionValidator}
* @return the transaction result
* @see TransactionValidator
* @see MainnetTransactionValidator
* @see TransactionValidationParams
*/
public TransactionProcessingResult processTransaction(
@ -112,10 +112,10 @@ public class MainnetTransactionProcessor {
* @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}
* MainnetTransactionValidator}
* @param operationTracer operation tracer {@link OperationTracer}
* @return the transaction result
* @see TransactionValidator
* @see MainnetTransactionValidator
* @see TransactionValidationParams
*/
public TransactionProcessingResult processTransaction(
@ -215,7 +215,7 @@ public class MainnetTransactionProcessor {
public MainnetTransactionProcessor(
final GasCalculator gasCalculator,
final TransactionValidator transactionValidator,
final MainnetTransactionValidator transactionValidator,
final AbstractMessageProcessor contractCreationProcessor,
final AbstractMessageProcessor messageCallProcessor,
final boolean clearEmptyAccounts,
@ -248,7 +248,7 @@ public class MainnetTransactionProcessor {
try {
LOG.trace("Starting execution of {}", transaction);
ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult =
ValidationResult<TransactionInvalidReason> validationResult =
transactionValidator.validate(transaction, blockHeader.getBaseFee());
// Make sure the transaction is intrinsically valid before trying to
// compare against a sender account (because the transaction may not
@ -405,7 +405,7 @@ public class MainnetTransactionProcessor {
gasUsedByTransaction.toLong(),
refunded.toLong(),
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.TRANSACTION_PRICE_TOO_LOW,
TransactionInvalidReason.TRANSACTION_PRICE_TOO_LOW,
"transaction price must be greater than base fee"),
Optional.empty());
}

@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.core.TransactionFilter;
import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.core.fees.EIP1559;
import org.hyperledger.besu.ethereum.core.fees.TransactionPriceCalculator;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.vm.GasCalculator;
import java.math.BigInteger;
@ -35,7 +36,7 @@ import java.util.Optional;
* <p>The {@link MainnetTransactionValidator} performs the intrinsic gas cost check on the given
* {@link Transaction}.
*/
public class MainnetTransactionValidator implements TransactionValidator {
public class MainnetTransactionValidator {
private final GasCalculator gasCalculator;
private final Optional<TransactionPriceCalculator> transactionPriceCalculator;
@ -76,7 +77,15 @@ public class MainnetTransactionValidator implements TransactionValidator {
this.acceptedTransactionTypes = acceptedTransactionTypes;
}
@Override
/**
* Asserts whether a transaction is valid.
*
* @param transaction the transaction to validate
* @param baseFee optional baseFee
* @return An empty @{link Optional} if the transaction is considered valid; otherwise an @{code
* Optional} containing a {@link TransactionInvalidReason} that identifies why the transaction
* is invalid.
*/
public ValidationResult<TransactionInvalidReason> validate(
final Transaction transaction, final Optional<Long> baseFee) {
final ValidationResult<TransactionInvalidReason> signatureResult =
@ -116,7 +125,6 @@ public class MainnetTransactionValidator implements TransactionValidator {
return ValidationResult.valid();
}
@Override
public ValidationResult<TransactionInvalidReason> validateForSender(
final Transaction transaction,
final Account sender,
@ -218,8 +226,30 @@ public class MainnetTransactionValidator implements TransactionValidator {
}
}
@Override
public void setTransactionFilter(final TransactionFilter transactionFilter) {
this.transactionFilter = Optional.of(transactionFilter);
}
/**
* Asserts whether a transaction is valid for the sender accounts current state.
*
* <p>Note: {@code validate} should be called before getting the sender {@link Account} used in
* this method to ensure that a sender can be extracted from the {@link Transaction}.
*
* @param transaction the transaction to validateMessageFrame.State.COMPLETED_FAILED
* @param sender the sender account state to validate against
* @param allowFutureNonce if true, transactions with nonce equal or higher than the account nonce
* will be considered valid (used when received transactions in the transaction pool). If
* false, only a transaction with the nonce equals the account nonce will be considered valid
* (used when processing transactions).
* @return An empty @{link Optional} if the transaction is considered valid; otherwise an @{code
* Optional} containing a {@link TransactionInvalidReason} that identifies why the transaction
* is invalid.
*/
public ValidationResult<TransactionInvalidReason> validateForSender(
final Transaction transaction, final Account sender, final boolean allowFutureNonce) {
final TransactionValidationParams validationParams =
new TransactionValidationParams.Builder().allowFutureNonce(allowFutureNonce).build();
return validateForSender(transaction, sender, validationParams);
}
}

@ -37,7 +37,7 @@ public class ProtocolSpec {
private final GasCalculator gasCalculator;
private final TransactionValidator transactionValidator;
private final MainnetTransactionValidator transactionValidator;
private final MainnetTransactionProcessor transactionProcessor;
@ -107,7 +107,7 @@ public class ProtocolSpec {
public ProtocolSpec(
final String name,
final EVM evm,
final TransactionValidator transactionValidator,
final MainnetTransactionValidator transactionValidator,
final MainnetTransactionProcessor transactionProcessor,
final PrivateTransactionProcessor privateTransactionProcessor,
final BlockHeaderValidator blockHeaderValidator,
@ -167,7 +167,7 @@ public class ProtocolSpec {
*
* @return the transaction validator
*/
public TransactionValidator getTransactionValidator() {
public MainnetTransactionValidator getTransactionValidator() {
return transactionValidator;
}

@ -47,7 +47,7 @@ public class ProtocolSpecBuilder {
private AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory;
private DifficultyCalculator difficultyCalculator;
private Function<GasCalculator, EVM> evmBuilder;
private Function<GasCalculator, TransactionValidator> transactionValidatorBuilder;
private Function<GasCalculator, MainnetTransactionValidator> transactionValidatorBuilder;
private BlockHeaderValidator.Builder blockHeaderValidatorBuilder;
private BlockHeaderValidator.Builder ommerHeaderValidatorBuilder;
private Function<ProtocolSchedule, BlockBodyValidator> blockBodyValidatorBuilder;
@ -109,7 +109,7 @@ public class ProtocolSpecBuilder {
}
public ProtocolSpecBuilder transactionValidatorBuilder(
final Function<GasCalculator, TransactionValidator> transactionValidatorBuilder) {
final Function<GasCalculator, MainnetTransactionValidator> transactionValidatorBuilder) {
this.transactionValidatorBuilder = transactionValidatorBuilder;
return this;
}
@ -268,7 +268,7 @@ public class ProtocolSpecBuilder {
final EVM evm = evmBuilder.apply(gasCalculator);
final PrecompiledContractConfiguration precompiledContractConfiguration =
new PrecompiledContractConfiguration(gasCalculator, privacyParameters);
final TransactionValidator transactionValidator =
final MainnetTransactionValidator transactionValidator =
transactionValidatorBuilder.apply(gasCalculator);
final AbstractMessageProcessor contractCreationProcessor =
contractCreationProcessorBuilder.apply(gasCalculator, evm);
@ -364,7 +364,7 @@ public class ProtocolSpecBuilder {
public interface TransactionProcessorBuilder {
MainnetTransactionProcessor apply(
GasCalculator gasCalculator,
TransactionValidator transactionValidator,
MainnetTransactionValidator transactionValidator,
AbstractMessageProcessor contractCreationProcessor,
AbstractMessageProcessor messageCallProcessor);
}
@ -372,7 +372,7 @@ public class ProtocolSpecBuilder {
public interface PrivateTransactionProcessorBuilder {
PrivateTransactionProcessor apply(
GasCalculator gasCalculator,
TransactionValidator transactionValidator,
MainnetTransactionValidator transactionValidator,
AbstractMessageProcessor contractCreationProcessor,
AbstractMessageProcessor messageCallProcessor,
PrivateTransactionValidator privateTransactionValidator);

@ -1,93 +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.core.Account;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionFilter;
import java.util.Optional;
/** Validates transaction based on some criteria. */
public interface TransactionValidator {
/**
* Asserts whether a transaction is valid.
*
* @param transaction the transaction to validate
* @param baseFee optional baseFee
* @return An empty @{link Optional} if the transaction is considered valid; otherwise an @{code
* Optional} containing a {@link TransactionInvalidReason} that identifies why the transaction
* is invalid.
*/
ValidationResult<TransactionInvalidReason> validate(
Transaction transaction, Optional<Long> baseFee);
/**
* Asserts whether a transaction is valid for the sender accounts current state.
*
* <p>Note: {@code validate} should be called before getting the sender {@link Account} used in
* this method to ensure that a sender can be extracted from the {@link Transaction}.
*
* @param transaction the transaction to validateMessageFrame.State.COMPLETED_FAILED
* @param sender the sender account state to validate against
* @param allowFutureNonce if true, transactions with nonce equal or higher than the account nonce
* will be considered valid (used when received transactions in the transaction pool). If
* false, only a transaction with the nonce equals the account nonce will be considered valid
* (used when processing transactions).
* @return An empty @{link Optional} if the transaction is considered valid; otherwise an @{code
* Optional} containing a {@link TransactionInvalidReason} that identifies why the transaction
* is invalid.
*/
default ValidationResult<TransactionInvalidReason> validateForSender(
final Transaction transaction, final Account sender, final boolean allowFutureNonce) {
final TransactionValidationParams validationParams =
new TransactionValidationParams.Builder().allowFutureNonce(allowFutureNonce).build();
return validateForSender(transaction, sender, validationParams);
}
ValidationResult<TransactionInvalidReason> validateForSender(
Transaction transaction, Account sender, TransactionValidationParams validationParams);
void setTransactionFilter(TransactionFilter transactionFilter);
enum TransactionInvalidReason {
WRONG_CHAIN_ID,
REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED,
INVALID_SIGNATURE,
UPFRONT_COST_EXCEEDS_BALANCE,
NONCE_TOO_LOW,
INCORRECT_NONCE,
INTRINSIC_GAS_EXCEEDS_GAS_LIMIT,
EXCEEDS_BLOCK_GAS_LIMIT,
TX_SENDER_NOT_AUTHORIZED,
CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE,
EXCEEDS_PER_TRANSACTION_GAS_LIMIT,
INVALID_TRANSACTION_FORMAT,
TRANSACTION_PRICE_TOO_LOW,
TRANSACTION_ALREADY_KNOWN,
TRANSACTION_REPLACEMENT_UNDERPRICED,
// Private Transaction Invalid Reasons
PRIVATE_TRANSACTION_FAILED,
PRIVATE_NONCE_TOO_LOW,
OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST,
INCORRECT_PRIVATE_NONCE,
GAS_PRICE_TOO_LOW,
TX_FEECAP_EXCEEDED,
PRIVATE_VALUE_NOT_ZERO,
PRIVATE_UNIMPLEMENTED_TRANSACTION_TYPE,
INTERNAL_ERROR;
}
}

@ -29,7 +29,6 @@ import org.hyperledger.besu.ethereum.core.Hash;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.markertransaction.PrivateMarkerTransactionFactory;
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap;
@ -41,6 +40,7 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.transaction.CallParameter;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.math.BigInteger;
import java.util.ArrayList;
@ -179,7 +179,7 @@ public class DefaultPrivacyController implements PrivacyController {
}
@Override
public ValidationResult<TransactionValidator.TransactionInvalidReason> validatePrivateTransaction(
public ValidationResult<TransactionInvalidReason> validatePrivateTransaction(
final PrivateTransaction privateTransaction, final String enclavePublicKey) {
final String privacyGroupId = privateTransaction.determinePrivacyGroupId().toBase64String();
return privateTransactionValidator.validate(

@ -20,10 +20,10 @@ import org.hyperledger.besu.enclave.types.ReceiveResponse;
import org.hyperledger.besu.ethereum.core.Address;
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 org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.math.BigInteger;
import java.util.Arrays;

@ -19,10 +19,10 @@ import org.hyperledger.besu.enclave.types.ReceiveResponse;
import org.hyperledger.besu.ethereum.core.Address;
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 org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.util.List;
import java.util.Optional;

@ -26,10 +26,10 @@ 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.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
import org.hyperledger.besu.ethereum.vm.Code;
import org.hyperledger.besu.ethereum.vm.GasCalculator;
@ -53,7 +53,7 @@ public class PrivateTransactionProcessor {
private final GasCalculator gasCalculator;
@SuppressWarnings("unused")
private final TransactionValidator transactionValidator;
private final MainnetTransactionValidator transactionValidator;
private final PrivateTransactionValidator privateTransactionValidator;
@ -70,7 +70,7 @@ public class PrivateTransactionProcessor {
public PrivateTransactionProcessor(
final GasCalculator gasCalculator,
final TransactionValidator transactionValidator,
final MainnetTransactionValidator transactionValidator,
final AbstractMessageProcessor contractCreationProcessor,
final AbstractMessageProcessor messageCallProcessor,
final boolean clearEmptyAccounts,
@ -109,7 +109,7 @@ public class PrivateTransactionProcessor {
? maybePrivateSender.getMutable()
: privateWorldState.createAccount(senderAddress, 0, Wei.ZERO).getMutable();
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult =
final ValidationResult<TransactionInvalidReason> validationResult =
privateTransactionValidator.validate(transaction, sender.getNonce(), false);
if (!validationResult.isValid()) {
return TransactionProcessingResult.invalid(validationResult);
@ -218,8 +218,7 @@ public class PrivateTransactionProcessor {
return TransactionProcessingResult.failed(
0,
0,
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.PRIVATE_TRANSACTION_FAILED),
ValidationResult.invalid(TransactionInvalidReason.PRIVATE_TRANSACTION_FAILED),
initialFrame.getRevertReason());
}
} catch (final RuntimeException re) {

@ -14,9 +14,8 @@
*/
package org.hyperledger.besu.ethereum.privacy;
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.transaction.TransactionInvalidReason;
import java.math.BigInteger;
import java.util.Optional;
@ -34,7 +33,7 @@ public class PrivateTransactionValidator {
this.chainId = chainId;
}
public ValidationResult<TransactionValidator.TransactionInvalidReason> validate(
public ValidationResult<TransactionInvalidReason> validate(
final PrivateTransaction transaction,
final Long accountNonce,
final boolean allowFutureNonces) {
@ -48,8 +47,8 @@ public class PrivateTransactionValidator {
return privateFieldsValidationResult;
}
final ValidationResult<TransactionValidator.TransactionInvalidReason>
signatureValidationResult = validateTransactionSignature(transaction);
final ValidationResult<TransactionInvalidReason> signatureValidationResult =
validateTransactionSignature(transaction);
if (!signatureValidationResult.isValid()) {
LOG.debug(
"Private Transaction failed signature validation {}, {}",
@ -68,8 +67,7 @@ public class PrivateTransactionValidator {
"Private Transaction nonce %s, is lower than sender account nonce %s.",
transactionNonce, accountNonce);
LOG.debug(errorMessage);
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.PRIVATE_NONCE_TOO_LOW, errorMessage);
return ValidationResult.invalid(TransactionInvalidReason.PRIVATE_NONCE_TOO_LOW, errorMessage);
}
if (!allowFutureNonces && accountNonce != transactionNonce) {
@ -79,32 +77,31 @@ public class PrivateTransactionValidator {
transactionNonce, accountNonce);
LOG.debug(errorMessage);
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INCORRECT_PRIVATE_NONCE, errorMessage);
TransactionInvalidReason.INCORRECT_PRIVATE_NONCE, errorMessage);
}
return ValidationResult.valid();
}
private ValidationResult<TransactionValidator.TransactionInvalidReason>
validatePrivateTransactionFields(final PrivateTransaction privateTransaction) {
private ValidationResult<TransactionInvalidReason> validatePrivateTransactionFields(
final PrivateTransaction privateTransaction) {
if (!privateTransaction.getValue().isZero()) {
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.PRIVATE_VALUE_NOT_ZERO);
return ValidationResult.invalid(TransactionInvalidReason.PRIVATE_VALUE_NOT_ZERO);
}
if (!privateTransaction.getRestriction().equals(Restriction.RESTRICTED)) {
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.PRIVATE_UNIMPLEMENTED_TRANSACTION_TYPE);
TransactionInvalidReason.PRIVATE_UNIMPLEMENTED_TRANSACTION_TYPE);
}
return ValidationResult.valid();
}
private ValidationResult<TransactionValidator.TransactionInvalidReason>
validateTransactionSignature(final PrivateTransaction transaction) {
private ValidationResult<TransactionInvalidReason> validateTransactionSignature(
final PrivateTransaction transaction) {
if (chainId.isPresent()
&& (transaction.getChainId().isPresent() && !transaction.getChainId().equals(chainId))) {
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.WRONG_CHAIN_ID,
TransactionInvalidReason.WRONG_CHAIN_ID,
String.format(
"Transaction was meant for chain id %s, not this chain id %s",
transaction.getChainId().get(), chainId.get()));
@ -112,7 +109,7 @@ public class PrivateTransactionValidator {
if (chainId.isEmpty() && transaction.getChainId().isPresent()) {
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED,
TransactionInvalidReason.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED,
"Replay protection (chainId) is not supported");
}
@ -122,7 +119,7 @@ public class PrivateTransactionValidator {
transaction.getSender();
} catch (final IllegalArgumentException e) {
return ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INVALID_SIGNATURE,
TransactionInvalidReason.INVALID_SIGNATURE,
"Sender could not be extracted from transaction signature");
}

@ -15,8 +15,8 @@
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 org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.util.ArrayList;
import java.util.List;
@ -49,11 +49,11 @@ public class TransactionProcessingResult {
private final Bytes output;
private final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult;
private final ValidationResult<TransactionInvalidReason> validationResult;
private final Optional<Bytes> revertReason;
public static TransactionProcessingResult invalid(
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult) {
final ValidationResult<TransactionInvalidReason> validationResult) {
return new TransactionProcessingResult(
Status.INVALID, new ArrayList<>(), -1, -1, Bytes.EMPTY, validationResult, Optional.empty());
}
@ -61,7 +61,7 @@ public class TransactionProcessingResult {
public static TransactionProcessingResult failed(
final long gasUsedByTransaction,
final long gasRemaining,
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult,
final ValidationResult<TransactionInvalidReason> validationResult,
final Optional<Bytes> revertReason) {
return new TransactionProcessingResult(
Status.FAILED,
@ -78,7 +78,7 @@ public class TransactionProcessingResult {
final long gasUsedByTransaction,
final long gasRemaining,
final Bytes output,
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult) {
final ValidationResult<TransactionInvalidReason> validationResult) {
return new TransactionProcessingResult(
Status.SUCCESSFUL,
logs,
@ -95,7 +95,7 @@ public class TransactionProcessingResult {
final long estimateGasUsedByTransaction,
final long gasRemaining,
final Bytes output,
final ValidationResult<TransactionValidator.TransactionInvalidReason> validationResult,
final ValidationResult<TransactionInvalidReason> validationResult,
final Optional<Bytes> revertReason) {
this.status = status;
this.logs = logs;
@ -174,7 +174,7 @@ public class TransactionProcessingResult {
*
* @return the validation result, with the reason for failure (if applicable.)
*/
public ValidationResult<TransactionValidator.TransactionInvalidReason> getValidationResult() {
public ValidationResult<TransactionInvalidReason> getValidationResult() {
return validationResult;
}

@ -0,0 +1,46 @@
/*
*
* * 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.transaction;
public enum TransactionInvalidReason {
WRONG_CHAIN_ID,
REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED,
INVALID_SIGNATURE,
UPFRONT_COST_EXCEEDS_BALANCE,
NONCE_TOO_LOW,
INCORRECT_NONCE,
INTRINSIC_GAS_EXCEEDS_GAS_LIMIT,
EXCEEDS_BLOCK_GAS_LIMIT,
TX_SENDER_NOT_AUTHORIZED,
CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE,
EXCEEDS_PER_TRANSACTION_GAS_LIMIT,
INVALID_TRANSACTION_FORMAT,
TRANSACTION_PRICE_TOO_LOW,
TRANSACTION_ALREADY_KNOWN,
TRANSACTION_REPLACEMENT_UNDERPRICED,
// Private Transaction Invalid Reasons
PRIVATE_TRANSACTION_FAILED,
PRIVATE_NONCE_TOO_LOW,
OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST,
INCORRECT_PRIVATE_NONCE,
GAS_PRICE_TOO_LOW,
TX_FEECAP_EXCEEDED,
PRIVATE_VALUE_NOT_ZERO,
PRIVATE_UNIMPLEMENTED_TRANSACTION_TYPE,
INTERNAL_ERROR;
}

@ -15,7 +15,6 @@
package org.hyperledger.besu.ethereum.transaction;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
@ -48,7 +47,7 @@ public class TransactionSimulatorResult {
return result.getOutput();
}
public ValidationResult<TransactionValidator.TransactionInvalidReason> getValidationResult() {
public ValidationResult<TransactionInvalidReason> getValidationResult() {
return result.getValidationResult();
}

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.core;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.testutil.JsonTestParameters;
@ -37,7 +37,7 @@ public class TransactionTest {
private static final ReferenceTestProtocolSchedules REFERENCE_TEST_PROTOCOL_SCHEDULES =
ReferenceTestProtocolSchedules.create();
private static TransactionValidator transactionValidator(final String name) {
private static MainnetTransactionValidator transactionValidator(final String name) {
return REFERENCE_TEST_PROTOCOL_SCHEDULES
.getByName(name)
.getByBlockNumber(0)

@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.WorldUpdater;
import org.hyperledger.besu.ethereum.core.fees.CoinbaseFeePriceCalculator;
import org.hyperledger.besu.ethereum.core.fees.TransactionPriceCalculator;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
import org.hyperledger.besu.ethereum.vm.GasCalculator;
@ -44,7 +45,7 @@ public class MainnetTransactionProcessorTest {
private MainnetTransactionProcessor transactionProcessor;
@Mock private GasCalculator gasCalculator;
@Mock private TransactionValidator transactionValidator;
@Mock private MainnetTransactionValidator transactionValidator;
@Mock private AbstractMessageProcessor contractCreationProcessor;
@Mock private AbstractMessageProcessor messageCallProcessor;
@ -97,9 +98,7 @@ public class MainnetTransactionProcessorTest {
when(transactionValidator.validate(any(), any())).thenReturn(ValidationResult.valid());
// returning invalid transaction to halt method execution
when(transactionValidator.validateForSender(any(), any(), txValidationParamCaptor.capture()))
.thenReturn(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE));
.thenReturn(ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE));
return txValidationParamCaptor;
}
}

@ -34,6 +34,7 @@ import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.core.fees.EIP1559;
import org.hyperledger.besu.ethereum.core.fees.FeeMarket;
import org.hyperledger.besu.ethereum.core.fees.TransactionPriceCalculator;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.vm.GasCalculator;
import java.math.BigInteger;
@ -80,8 +81,7 @@ public class MainnetTransactionValidatorTest {
assertThat(validator.validate(transaction, Optional.empty()))
.isEqualTo(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INTRINSIC_GAS_EXCEEDS_GAS_LIMIT));
ValidationResult.invalid(TransactionInvalidReason.INTRINSIC_GAS_EXCEEDS_GAS_LIMIT));
}
@Test
@ -91,8 +91,7 @@ public class MainnetTransactionValidatorTest {
assertThat(validator.validate(basicTransaction, Optional.empty()))
.isEqualTo(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason
.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED));
TransactionInvalidReason.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED));
}
@Test
@ -100,8 +99,7 @@ public class MainnetTransactionValidatorTest {
final MainnetTransactionValidator validator =
new MainnetTransactionValidator(gasCalculator, false, Optional.of(BigInteger.valueOf(2)));
assertThat(validator.validate(basicTransaction, Optional.empty()))
.isEqualTo(
ValidationResult.invalid(TransactionValidator.TransactionInvalidReason.WRONG_CHAIN_ID));
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.WRONG_CHAIN_ID));
}
@Test
@ -109,9 +107,7 @@ public class MainnetTransactionValidatorTest {
final MainnetTransactionValidator validator =
new MainnetTransactionValidator(gasCalculator, false, Optional.of(BigInteger.ONE));
assertThat(validator.validateForSender(basicTransaction, null, false))
.isEqualTo(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.UPFRONT_COST_EXCEEDS_BALANCE));
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.UPFRONT_COST_EXCEEDS_BALANCE));
}
@Test
@ -121,8 +117,7 @@ public class MainnetTransactionValidatorTest {
final Account account = accountWithNonce(basicTransaction.getNonce() + 1);
assertThat(validator.validateForSender(basicTransaction, account, false))
.isEqualTo(
ValidationResult.invalid(TransactionValidator.TransactionInvalidReason.NONCE_TOO_LOW));
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.NONCE_TOO_LOW));
}
@Test
@ -133,9 +128,7 @@ public class MainnetTransactionValidatorTest {
final Account account = accountWithNonce(basicTransaction.getNonce() - 1);
assertThat(validator.validateForSender(basicTransaction, account, false))
.isEqualTo(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE));
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE));
}
@Test
@ -159,9 +152,7 @@ public class MainnetTransactionValidatorTest {
final Account account = accountWithNonce(5);
assertThat(validator.validateForSender(transaction, account, false))
.isEqualTo(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE));
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE));
}
@Test
@ -185,9 +176,7 @@ public class MainnetTransactionValidatorTest {
validator.setTransactionFilter(transactionFilter(false));
assertThat(validator.validateForSender(basicTransaction, accountWithNonce(0), true))
.isEqualTo(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.TX_SENDER_NOT_AUTHORIZED));
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.TX_SENDER_NOT_AUTHORIZED));
}
@Test
@ -267,9 +256,7 @@ public class MainnetTransactionValidatorTest {
.chainId(Optional.empty())
.createTransaction(senderKeys);
assertThat(validator.validate(transaction, Optional.empty()))
.isEqualTo(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INVALID_TRANSACTION_FORMAT));
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.INVALID_TRANSACTION_FORMAT));
ExperimentalEIPs.eip1559Enabled = false;
}
@ -295,9 +282,7 @@ public class MainnetTransactionValidatorTest {
final Optional<Long> basefee = Optional.of(150000L);
when(transactionPriceCalculator.price(transaction, basefee)).thenReturn(Wei.of(1));
assertThat(validator.validate(transaction, basefee))
.isEqualTo(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INVALID_TRANSACTION_FORMAT));
.isEqualTo(ValidationResult.invalid(TransactionInvalidReason.INVALID_TRANSACTION_FORMAT));
ExperimentalEIPs.eip1559Enabled = false;
}

@ -39,7 +39,6 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.core.WorldUpdater;
import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
@ -50,6 +49,7 @@ 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.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
import org.hyperledger.besu.ethereum.vm.MessageFrame;
import org.hyperledger.besu.ethereum.vm.OperationTracer;
@ -277,8 +277,7 @@ public class OnChainPrivacyPrecompiledContractTest {
contract.setPrivateTransactionProcessor(
mockPrivateTxProcessor(
TransactionProcessingResult.invalid(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE))));
ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE))));
final OnChainPrivacyPrecompiledContract contractSpy = spy(contract);
Mockito.doNothing().when(contractSpy).maybeInjectDefaultManagementAndProxy(any(), any(), any());

@ -41,7 +41,6 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.core.WorldUpdater;
import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
@ -52,6 +51,7 @@ 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.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
import org.hyperledger.besu.ethereum.vm.MessageFrame;
import org.hyperledger.besu.ethereum.vm.OperationTracer;
@ -289,8 +289,7 @@ public class PrivacyPrecompiledContractTest {
contract.setPrivateTransactionProcessor(
mockPrivateTxProcessor(
TransactionProcessingResult.invalid(
ValidationResult.invalid(
TransactionValidator.TransactionInvalidReason.INCORRECT_NONCE))));
ValidationResult.invalid(TransactionInvalidReason.INCORRECT_NONCE))));
final PrivateTransaction privateTransaction = privateTransactionBesu();
final byte[] payload = convertPrivateTransactionToBytes(privateTransaction);

@ -19,8 +19,8 @@ import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.INCORRECT_PRIVATE_NONCE;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.PRIVATE_NONCE_TOO_LOW;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.INCORRECT_PRIVATE_NONCE;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.PRIVATE_NONCE_TOO_LOW;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyList;
@ -44,13 +44,13 @@ 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.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.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.orion.testutil.OrionKeyUtils;
import java.math.BigInteger;

@ -15,20 +15,20 @@
package org.hyperledger.besu.ethereum.privacy;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.INCORRECT_PRIVATE_NONCE;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.INVALID_SIGNATURE;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.PRIVATE_NONCE_TOO_LOW;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.PRIVATE_UNIMPLEMENTED_TRANSACTION_TYPE;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.PRIVATE_VALUE_NOT_ZERO;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.WRONG_CHAIN_ID;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.INCORRECT_PRIVATE_NONCE;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.INVALID_SIGNATURE;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.PRIVATE_NONCE_TOO_LOW;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.PRIVATE_UNIMPLEMENTED_TRANSACTION_TYPE;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.PRIVATE_VALUE_NOT_ZERO;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.WRONG_CHAIN_ID;
import static org.mockito.Mockito.when;
import org.hyperledger.besu.crypto.SECP256K1.KeyPair;
import org.hyperledger.besu.ethereum.core.PrivateTransactionTestFixture;
import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import java.math.BigInteger;
import java.util.Optional;

@ -26,7 +26,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.core.fees.EIP1559;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.metrics.Counter;

@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.eth.transactions;
import static java.util.Collections.singletonList;
import static org.apache.logging.log4j.LogManager.getLogger;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs;
import org.hyperledger.besu.ethereum.ProtocolContext;
@ -36,11 +36,11 @@ import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions.TransactionAddedStatus;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
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.transaction.TransactionInvalidReason;
import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.metrics.Counter;
@ -230,7 +230,7 @@ public class TransactionPool implements BlockAddedObserver {
addRemoteTransactions(event.getRemovedTransactions());
}
private TransactionValidator getTransactionValidator() {
private MainnetTransactionValidator getTransactionValidator() {
return protocolSchedule
.getByBlockNumber(protocolContext.getBlockchain().getChainHeadBlockNumber())
.getTransactionValidator();

@ -42,9 +42,9 @@ import org.hyperledger.besu.ethereum.eth.manager.ForkIdManager;
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions.TransactionAddedStatus;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
@ -145,7 +145,8 @@ public class TransactionPoolFactoryTest {
final SyncState state = mock(SyncState.class);
final TransactionsMessageSender transactionsMessageSender =
mock(TransactionsMessageSender.class);
final TransactionValidator transactionValidator = mock(TransactionValidator.class);
final MainnetTransactionValidator transactionValidator =
mock(MainnetTransactionValidator.class);
final WorldState worldState = mock(WorldState.class);
final WorldStateArchive worldStateArchive = mock(WorldStateArchive.class);

@ -20,10 +20,10 @@ import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.EXCEEDS_BLOCK_GAS_LIMIT;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.GAS_PRICE_TOO_LOW;
import static org.hyperledger.besu.ethereum.mainnet.TransactionValidator.TransactionInvalidReason.NONCE_TOO_LOW;
import static org.hyperledger.besu.ethereum.mainnet.ValidationResult.valid;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.EXCEEDS_BLOCK_GAS_LIMIT;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.GAS_PRICE_TOO_LOW;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.NONCE_TOO_LOW;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
@ -58,12 +58,12 @@ import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManagerTestUtil;
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
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.transaction.TransactionInvalidReason;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -97,7 +97,8 @@ public class TransactionPoolTest {
@SuppressWarnings("unchecked")
private final ProtocolSpec protocolSpec = mock(ProtocolSpec.class);
private final TransactionValidator transactionValidator = mock(TransactionValidator.class);
private final MainnetTransactionValidator transactionValidator =
mock(MainnetTransactionValidator.class);
private MutableBlockchain blockchain;
private PendingTransactions transactions;

@ -25,11 +25,11 @@ 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.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.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;

Loading…
Cancel
Save