Skip to content

Commit

Permalink
Renaming
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
fab-10 committed Feb 29, 2024
1 parent e665326 commit 7fca6f8
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 60 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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
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.Percentage;

Expand Down Expand Up @@ -788,13 +788,13 @@ public void shouldAcceptRemoteTransactionEvenIfFeeCapExceeded(final boolean hasP
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void transactionNotRejectedByPluginShouldBeAdded(final boolean noLocalPriority) {
final PluginTransactionPoolValidatorService pluginTransactionPoolValidatorService =
final TransactionPoolValidatorService transactionPoolValidatorService =
getPluginTransactionPoolValidatorServiceReturning(null); // null -> not rejecting !!
this.transactionPool =
createTransactionPool(
b ->
b.noLocalPriority(noLocalPriority)
.pluginTransactionValidatorService(pluginTransactionPoolValidatorService));
.pluginTransactionValidatorService(transactionPoolValidatorService));

givenTransactionIsValid(transaction0);

Expand All @@ -804,13 +804,13 @@ public void transactionNotRejectedByPluginShouldBeAdded(final boolean noLocalPri
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void transactionRejectedByPluginShouldNotBeAdded(final boolean noLocalPriority) {
final PluginTransactionPoolValidatorService pluginTransactionPoolValidatorService =
final TransactionPoolValidatorService transactionPoolValidatorService =
getPluginTransactionPoolValidatorServiceReturning("false");
this.transactionPool =
createTransactionPool(
b ->
b.noLocalPriority(noLocalPriority)
.pluginTransactionValidatorService(pluginTransactionPoolValidatorService));
.pluginTransactionValidatorService(transactionPoolValidatorService));

givenTransactionIsValid(transaction0);

Expand All @@ -820,11 +820,11 @@ public void transactionRejectedByPluginShouldNotBeAdded(final boolean noLocalPri

@Test
public void remoteTransactionRejectedByPluginShouldNotBeAdded() {
final PluginTransactionPoolValidatorService pluginTransactionPoolValidatorService =
final TransactionPoolValidatorService transactionPoolValidatorService =
getPluginTransactionPoolValidatorServiceReturning("false");
this.transactionPool =
createTransactionPool(
b -> b.pluginTransactionValidatorService(pluginTransactionPoolValidatorService));
b -> b.pluginTransactionValidatorService(transactionPoolValidatorService));

givenTransactionIsValid(transaction0);

Expand Down Expand Up @@ -1270,17 +1270,17 @@ public void addRemoteTransactionsShouldAllowDuplicates() {
.containsExactlyInAnyOrder(transaction1, transaction2a, transaction3);
}

private static PluginTransactionPoolValidatorService
getPluginTransactionPoolValidatorServiceReturning(final String errorMessage) {
return new PluginTransactionPoolValidatorService() {
private static TransactionPoolValidatorService getPluginTransactionPoolValidatorServiceReturning(
final String errorMessage) {
return new TransactionPoolValidatorService() {
@Override
public PluginTransactionPoolTransactionValidator createTransactionValidator() {
public PluginTransactionPoolValidator createTransactionValidator() {
return (transaction, isLocal, hasPriority) -> Optional.ofNullable(errorMessage);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@
package org.hyperledger.besu.plugin.services;

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

/** Transaction validator for addition of transactions to the transaction pool */
@Unstable
public interface PluginTransactionPoolValidatorService extends BesuService {
public interface TransactionPoolValidatorService extends BesuService {

/**
* Returns the transaction validator to be used in the txpool
*
* @return the transaction validator
*/
PluginTransactionPoolTransactionValidator createTransactionValidator();
PluginTransactionPoolValidator createTransactionValidator();

/**
* Registers the transaction validator factory with the service
*
* @param transactionValidatorFactory transaction validator factory to be used
* @param pluginTransactionPoolValidatorFactory transaction validator factory to be used
*/
void registerTransactionValidatorFactory(
PluginTransactionPoolValidatorFactory transactionValidatorFactory);
void registerPluginTransactionValidatorFactory(
PluginTransactionPoolValidatorFactory pluginTransactionPoolValidatorFactory);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

/** Interface for the transaction validator plugin for txpool usage */
@Unstable
public interface PluginTransactionPoolTransactionValidator {
public interface PluginTransactionPoolValidator {
/** Plugin transaction pool validator that unconditionally validates every transaction */
PluginTransactionPoolTransactionValidator VALIDATE_ALL =
PluginTransactionPoolValidator VALIDATE_ALL =
(transaction, isLocal, hasPriority) -> Optional.empty();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ public interface PluginTransactionPoolValidatorFactory {
*
* @return the transaction validator
*/
PluginTransactionPoolTransactionValidator createTransactionValidator();
PluginTransactionPoolValidator createTransactionValidator();
}

0 comments on commit 7fca6f8

Please sign in to comment.