Skip to content

Commit

Permalink
Renaming
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <[email protected]>
  • Loading branch information
fab-10 committed Feb 29, 2024
1 parent e665326 commit 8581c4d
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 71 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Add bft-style blockperiodseconds transitions to Clique [#6596](https://github.com/hyperledger/besu/pull/6596)
- RocksDB database metadata refactoring [#6555](https://github.com/hyperledger/besu/pull/6555)
- Make layered txpool aware of minGasPrice and minPriorityFeePerGas dynamic options [#6611](https://github.com/hyperledger/besu/pull/6611)
- Refactor and extend `TransactionPoolValidatorService` [#6636](https://github.com/hyperledger/besu/pull/6636)

### Bug fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@
import org.hyperledger.besu.plugin.services.BesuConfiguration;
import org.hyperledger.besu.plugin.services.BesuEvents;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.PluginTransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.SecurityModuleService;
import org.hyperledger.besu.plugin.services.StorageService;
import org.hyperledger.besu.plugin.services.TransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBPlugin;
import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuEventsImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PicoCLIOptionsImpl;
import org.hyperledger.besu.services.PluginTransactionPoolValidatorServiceImpl;
import org.hyperledger.besu.services.RpcEndpointServiceImpl;
import org.hyperledger.besu.services.SecurityModuleServiceImpl;
import org.hyperledger.besu.services.StorageServiceImpl;
import org.hyperledger.besu.services.TransactionPoolValidatorServiceImpl;
import org.hyperledger.besu.services.TransactionSelectionServiceImpl;

import java.io.File;
Expand Down Expand Up @@ -103,8 +103,7 @@ private BesuPluginContextImpl buildPluginContext(
besuPluginContext.addService(
TransactionSelectionService.class, transactionSelectionServiceImpl);
besuPluginContext.addService(
PluginTransactionPoolValidatorService.class,
new PluginTransactionPoolValidatorServiceImpl());
TransactionPoolValidatorService.class, new TransactionPoolValidatorServiceImpl());
final Path pluginsPath;
final String pluginDir = System.getProperty("besu.plugins.dir");
if (pluginDir == null || pluginDir.isEmpty()) {
Expand Down
12 changes: 6 additions & 6 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.PermissioningService;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.PluginTransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.PrivacyPluginService;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.SecurityModuleService;
import org.hyperledger.besu.plugin.services.StorageService;
import org.hyperledger.besu.plugin.services.TraceService;
import org.hyperledger.besu.plugin.services.TransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.plugin.services.exception.StorageException;
import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
Expand All @@ -180,12 +180,12 @@
import org.hyperledger.besu.services.BlockchainServiceImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PicoCLIOptionsImpl;
import org.hyperledger.besu.services.PluginTransactionPoolValidatorServiceImpl;
import org.hyperledger.besu.services.PrivacyPluginServiceImpl;
import org.hyperledger.besu.services.RpcEndpointServiceImpl;
import org.hyperledger.besu.services.SecurityModuleServiceImpl;
import org.hyperledger.besu.services.StorageServiceImpl;
import org.hyperledger.besu.services.TraceServiceImpl;
import org.hyperledger.besu.services.TransactionPoolValidatorServiceImpl;
import org.hyperledger.besu.services.TransactionSelectionServiceImpl;
import org.hyperledger.besu.services.kvstore.InMemoryStoragePlugin;
import org.hyperledger.besu.util.InvalidConfigurationException;
Expand Down Expand Up @@ -369,7 +369,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
P2PDiscoveryOptionGroup p2PDiscoveryOptionGroup = new P2PDiscoveryOptionGroup();

private final TransactionSelectionServiceImpl transactionSelectionServiceImpl;
private final PluginTransactionPoolValidatorServiceImpl transactionValidatorServiceImpl;
private final TransactionPoolValidatorServiceImpl transactionValidatorServiceImpl;
private final BlockchainServiceImpl blockchainServiceImpl;

static class P2PDiscoveryOptionGroup {
Expand Down Expand Up @@ -955,7 +955,7 @@ public BesuCommand(
new PkiBlockCreationConfigurationProvider(),
new RpcEndpointServiceImpl(),
new TransactionSelectionServiceImpl(),
new PluginTransactionPoolValidatorServiceImpl(),
new TransactionPoolValidatorServiceImpl(),
new BlockchainServiceImpl());
}

Expand Down Expand Up @@ -997,7 +997,7 @@ protected BesuCommand(
final PkiBlockCreationConfigurationProvider pkiBlockCreationConfigProvider,
final RpcEndpointServiceImpl rpcEndpointServiceImpl,
final TransactionSelectionServiceImpl transactionSelectionServiceImpl,
final PluginTransactionPoolValidatorServiceImpl transactionValidatorServiceImpl,
final TransactionPoolValidatorServiceImpl transactionValidatorServiceImpl,
final BlockchainServiceImpl blockchainServiceImpl) {
this.besuComponent = besuComponent;
this.logger = besuComponent.getBesuCommandLogger();
Expand Down Expand Up @@ -1209,7 +1209,7 @@ private void preparePlugins() {
besuPluginContext.addService(
TransactionSelectionService.class, transactionSelectionServiceImpl);
besuPluginContext.addService(
PluginTransactionPoolValidatorService.class, transactionValidatorServiceImpl);
TransactionPoolValidatorService.class, transactionValidatorServiceImpl);
besuPluginContext.addService(BlockchainService.class, blockchainServiceImpl);

// register built-in plugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.plugin.services.PluginTransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.TransactionPoolValidatorService;
import org.hyperledger.besu.util.number.Fraction;
import org.hyperledger.besu.util.number.Percentage;

Expand Down Expand Up @@ -58,7 +58,7 @@ public class TransactionPoolOptions implements CLIOptions<TransactionPoolConfigu
private static final String TX_POOL_PRIORITY_SENDERS = "--tx-pool-priority-senders";
private static final String TX_POOL_MIN_GAS_PRICE = "--tx-pool-min-gas-price";

private PluginTransactionPoolValidatorService pluginTransactionPoolValidatorService;
private TransactionPoolValidatorService transactionPoolValidatorService;

@CommandLine.Option(
names = {TX_POOL_IMPLEMENTATION},
Expand Down Expand Up @@ -258,11 +258,11 @@ public static TransactionPoolOptions create() {
/**
* Set the plugin txpool validator service
*
* @param pluginTransactionPoolValidatorService the plugin txpool validator service
* @param transactionPoolValidatorService the plugin txpool validator service
*/
public void setPluginTransactionValidatorService(
final PluginTransactionPoolValidatorService pluginTransactionPoolValidatorService) {
this.pluginTransactionPoolValidatorService = pluginTransactionPoolValidatorService;
final TransactionPoolValidatorService transactionPoolValidatorService) {
this.transactionPoolValidatorService = transactionPoolValidatorService;
}

/**
Expand Down Expand Up @@ -290,7 +290,7 @@ public static TransactionPoolOptions fromConfig(final TransactionPoolConfigurati
config.getTxPoolLimitByAccountPercentage();
options.sequencedOptions.txPoolMaxSize = config.getTxPoolMaxSize();
options.sequencedOptions.pendingTxRetentionPeriod = config.getPendingTxRetentionPeriod();
options.pluginTransactionPoolValidatorService = config.getPluginTransactionValidatorService();
options.transactionPoolValidatorService = config.getPluginTransactionValidatorService();
options.unstableOptions.txMessageKeepAliveSeconds =
config.getUnstable().getTxMessageKeepAliveSeconds();
options.unstableOptions.eth65TrxAnnouncedBufferingPeriod =
Expand Down Expand Up @@ -345,7 +345,7 @@ public TransactionPoolConfiguration toDomainObject() {
.txPoolLimitByAccountPercentage(sequencedOptions.txPoolLimitByAccountPercentage)
.txPoolMaxSize(sequencedOptions.txPoolMaxSize)
.pendingTxRetentionPeriod(sequencedOptions.pendingTxRetentionPeriod)
.pluginTransactionValidatorService(pluginTransactionPoolValidatorService)
.pluginTransactionValidatorService(transactionPoolValidatorService)
.unstable(
ImmutableTransactionPoolConfiguration.Unstable.builder()
.txMessageKeepAliveSeconds(unstableOptions.txMessageKeepAliveSeconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,27 @@
*/
package org.hyperledger.besu.services;

import org.hyperledger.besu.plugin.services.PluginTransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionPoolTransactionValidator;
import org.hyperledger.besu.plugin.services.TransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionPoolValidator;
import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionPoolValidatorFactory;

import java.util.Optional;

/** The Transaction Validation service implementation. */
public class PluginTransactionPoolValidatorServiceImpl
implements PluginTransactionPoolValidatorService {
/** The Transaction pool validator service implementation. */
public class TransactionPoolValidatorServiceImpl implements TransactionPoolValidatorService {

private Optional<PluginTransactionPoolValidatorFactory> factory = Optional.empty();

@Override
public PluginTransactionPoolTransactionValidator createTransactionValidator() {
public PluginTransactionPoolValidator createTransactionValidator() {
return factory
.map(PluginTransactionPoolValidatorFactory::createTransactionValidator)
.orElse(PluginTransactionPoolTransactionValidator.VALIDATE_ALL);
.orElse(PluginTransactionPoolValidator.VALIDATE_ALL);
}

@Override
public void registerTransactionValidatorFactory(
final PluginTransactionPoolValidatorFactory transactionValidatorFactory) {
factory = Optional.ofNullable(transactionValidatorFactory);
public void registerPluginTransactionValidatorFactory(
final PluginTransactionPoolValidatorFactory pluginTransactionPoolValidatorFactory) {
factory = Optional.ofNullable(pluginTransactionPoolValidatorFactory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@
import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.BlockchainServiceImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PluginTransactionPoolValidatorServiceImpl;
import org.hyperledger.besu.services.PrivacyPluginServiceImpl;
import org.hyperledger.besu.services.RpcEndpointServiceImpl;
import org.hyperledger.besu.services.SecurityModuleServiceImpl;
import org.hyperledger.besu.services.StorageServiceImpl;
import org.hyperledger.besu.services.TransactionPoolValidatorServiceImpl;
import org.hyperledger.besu.services.TransactionSelectionServiceImpl;
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;

Expand Down Expand Up @@ -569,7 +569,7 @@ public static class TestBesuCommand extends BesuCommand {
pkiBlockCreationConfigProvider,
rpcEndpointServiceImpl,
new TransactionSelectionServiceImpl(),
new PluginTransactionPoolValidatorServiceImpl(),
new TransactionPoolValidatorServiceImpl(),
new BlockchainServiceImpl());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static RpcErrorType convertTransactionInvalidReason(
return RpcErrorType.TOTAL_BLOB_GAS_TOO_HIGH;
case TX_POOL_DISABLED:
return RpcErrorType.TX_POOL_DISABLED;
case PLUGIN_TX_VALIDATOR:
case PLUGIN_TX_POOL_VALIDATOR:
return RpcErrorType.PLUGIN_TX_VALIDATOR;
case INVALID_BLOBS:
return RpcErrorType.INVALID_BLOBS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private JsonRpcResponse getJsonRpcResponse(
if (sendEmptyHashOnInvalidBlock) {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), Hash.EMPTY.toString());
} else {
if (errorReason == TransactionInvalidReason.PLUGIN_TX_VALIDATOR) {
if (errorReason == TransactionInvalidReason.PLUGIN_TX_POOL_VALIDATOR) {
final RpcErrorType rpcErrorType =
JsonRpcErrorConverter.convertTransactionInvalidReason(
validationResult.getInvalidReason());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,11 @@ public void transactionSelectionPluginShouldBeNotifiedWhenTransactionSelectionCo
final Transaction transaction = createTransaction(0, Wei.of(10), 21_000);
ensureTransactionIsValid(transaction, 21_000, 0);

final TransactionInvalidReason invalidReason = TransactionInvalidReason.PLUGIN_TX_VALIDATOR;
final TransactionInvalidReason invalidReason =
TransactionInvalidReason.PLUGIN_TX_POOL_VALIDATOR;
final Transaction invalidTransaction = createTransaction(1, Wei.of(10), 21_000);
ensureTransactionIsInvalid(invalidTransaction, TransactionInvalidReason.PLUGIN_TX_VALIDATOR);
ensureTransactionIsInvalid(
invalidTransaction, TransactionInvalidReason.PLUGIN_TX_POOL_VALIDATOR);

final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public enum TransactionInvalidReason {
INTERNAL_ERROR,
TX_POOL_DISABLED,
INVALID_BLOBS,
PLUGIN_TX_VALIDATOR,
PLUGIN_TX_POOL_VALIDATOR,
EXECUTION_HALTED,
// Private Transaction Invalid Reasons
PRIVATE_TRANSACTION_INVALID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,15 +435,14 @@ && strictReplayProtectionShouldBeEnforcedLocally(chainHeadBlockHeader)
}

// Call the transaction validator plugin

final Optional<String> maybeError =
final Optional<String> maybePluginInvalid =
configuration
.getPluginTransactionValidatorService()
.createTransactionValidator()
.validateTransaction(transaction, isLocal, hasPriority);
if (maybeError.isPresent()) {
if (maybePluginInvalid.isPresent()) {
return ValidationResultAndAccount.invalid(
TransactionInvalidReason.PLUGIN_TX_VALIDATOR, maybeError.get());
TransactionInvalidReason.PLUGIN_TX_POOL_VALIDATOR, maybePluginInvalid.get());
}

try (final var worldState =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.plugin.services.PluginTransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionPoolTransactionValidator;
import org.hyperledger.besu.plugin.services.TransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionPoolValidator;
import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionPoolValidatorFactory;
import org.hyperledger.besu.util.number.Fraction;
import org.hyperledger.besu.util.number.Percentage;
Expand Down Expand Up @@ -158,16 +158,16 @@ default Wei getMinGasPrice() {
}

@Value.Default
default PluginTransactionPoolValidatorService getPluginTransactionValidatorService() {
return new PluginTransactionPoolValidatorService() {
default TransactionPoolValidatorService getPluginTransactionValidatorService() {
return new TransactionPoolValidatorService() {
@Override
public PluginTransactionPoolTransactionValidator createTransactionValidator() {
return PluginTransactionPoolTransactionValidator.VALIDATE_ALL;
public PluginTransactionPoolValidator createTransactionValidator() {
return PluginTransactionPoolValidator.VALIDATE_ALL;
}

@Override
public void registerTransactionValidatorFactory(
final PluginTransactionPoolValidatorFactory transactionValidatorFactory) {}
public void registerPluginTransactionValidatorFactory(
final PluginTransactionPoolValidatorFactory pluginTransactionPoolValidatorFactory) {}
};
}

Expand Down
Loading

0 comments on commit 8581c4d

Please sign in to comment.