From e609f5b370ac3d2c4cd8a716518954b28b7782c4 Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 22 Sep 2023 14:34:16 +1000 Subject: [PATCH] more changes Signed-off-by: Stefan --- .../dsl/node/ThreadBesuNodeRunner.java | 19 +++++++++++++---- .../node/configuration/BesuNodeFactory.java | 1 + .../org/hyperledger/besu/cli/BesuCommand.java | 21 +++++++++---------- .../controller/BesuControllerBuilder.java | 8 ++++++- ...luginTransactionValidatorServiceImpl.java} | 4 ++-- .../besu/cli/CommandTestAbstract.java | 6 +++--- plugin-api/build.gradle | 2 +- ...=> PluginTransactionValidatorService.java} | 2 +- .../PluginTransactionValidator.java | 1 - 9 files changed, 40 insertions(+), 24 deletions(-) rename besu/src/main/java/org/hyperledger/besu/services/{TransactionValidatorServiceImpl.java => PluginTransactionValidatorServiceImpl.java} (86%) rename plugin-api/src/main/java/org/hyperledger/besu/plugin/services/{TransactionValidatorService.java => PluginTransactionValidatorService.java} (94%) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java index acfb804211..e06aa8c964 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java @@ -43,22 +43,23 @@ import org.hyperledger.besu.plugin.data.EnodeURL; 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.PluginTransactionValidatorService; import org.hyperledger.besu.plugin.services.SecurityModuleService; import org.hyperledger.besu.plugin.services.StorageService; import org.hyperledger.besu.plugin.services.TransactionSelectionService; -import org.hyperledger.besu.plugin.services.TransactionValidatorService; import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBPlugin; import org.hyperledger.besu.plugin.services.txselection.TransactionSelectorFactory; +import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionValidatorFactory; 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.PluginTransactionValidatorServiceImpl; import org.hyperledger.besu.services.RpcEndpointServiceImpl; import org.hyperledger.besu.services.SecurityModuleServiceImpl; import org.hyperledger.besu.services.StorageServiceImpl; import org.hyperledger.besu.services.TransactionSelectionServiceImpl; -import org.hyperledger.besu.services.TransactionValidatorServiceImpl; import java.io.File; import java.nio.file.Path; @@ -100,7 +101,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { besuPluginContext.addService( TransactionSelectionService.class, new TransactionSelectionServiceImpl()); besuPluginContext.addService( - TransactionValidatorService.class, new TransactionValidatorServiceImpl()); + PluginTransactionValidatorService.class, new PluginTransactionValidatorServiceImpl()); final Path pluginsPath; final String pluginDir = System.getProperty("besu.plugins.dir"); if (pluginDir == null || pluginDir.isEmpty()) { @@ -187,6 +188,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { final Optional transactionSelectorFactory = getTransactionSelectorFactory(besuPluginContext); + final PluginTransactionValidatorFactory pluginTransactionValidatorFactory = + getPluginTransactionValidatorFactory(besuPluginContext); builder .synchronizerConfiguration(new SynchronizerConfiguration.Builder().build()) .dataDirectory(node.homeDirectory()) @@ -209,7 +212,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { .maxRemotelyInitiatedPeers(15) .networkConfiguration(node.getNetworkingConfiguration()) .randomPeerPriority(false) - .transactionSelectorFactory(transactionSelectorFactory); + .transactionSelectorFactory(transactionSelectorFactory) + .pluginTransactionValidatorFactory(pluginTransactionValidatorFactory); node.getGenesisConfig() .map(GenesisConfigFile::fromConfig) @@ -325,4 +329,11 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { besuPluginContext.getService(TransactionSelectionService.class); return txSelectionService.isPresent() ? txSelectionService.get().get() : Optional.empty(); } + + private PluginTransactionValidatorFactory getPluginTransactionValidatorFactory( + final BesuPluginContextImpl besuPluginContext) { + final Optional txValidatorService = + besuPluginContext.getService(PluginTransactionValidatorService.class); + return txValidatorService.map(PluginTransactionValidatorService::get).orElse(null); + } } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java index e3cdaefe08..cb9a25fad8 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java @@ -117,6 +117,7 @@ public class BesuNodeFactory { .name(name) .miningEnabled() .jsonRpcEnabled() + .jsonRpcTxPool() .webSocketEnabled() .extraCLIOptions(extraCliOptions); builder = configModifier.apply(builder); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index aff0165a23..75c4419887 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -164,13 +164,13 @@ import org.hyperledger.besu.plugin.services.BlockchainService; 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.PluginTransactionValidatorService; 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.TransactionSelectionService; -import org.hyperledger.besu.plugin.services.TransactionValidatorService; import org.hyperledger.besu.plugin.services.exception.StorageException; import org.hyperledger.besu.plugin.services.metrics.MetricCategory; import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry; @@ -184,13 +184,13 @@ import org.hyperledger.besu.services.BesuPluginContextImpl; import org.hyperledger.besu.services.BlockchainServiceImpl; import org.hyperledger.besu.services.PermissioningServiceImpl; import org.hyperledger.besu.services.PicoCLIOptionsImpl; +import org.hyperledger.besu.services.PluginTransactionValidatorServiceImpl; 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.TransactionSelectionServiceImpl; -import org.hyperledger.besu.services.TransactionValidatorServiceImpl; import org.hyperledger.besu.services.kvstore.InMemoryStoragePlugin; import org.hyperledger.besu.util.InvalidConfigurationException; import org.hyperledger.besu.util.LogConfigurator; @@ -375,7 +375,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { P2PDiscoveryOptionGroup p2PDiscoveryOptionGroup = new P2PDiscoveryOptionGroup(); private final TransactionSelectionServiceImpl transactionSelectionServiceImpl; - private final TransactionValidatorServiceImpl transactionValidatorServiceImpl; + private final PluginTransactionValidatorServiceImpl transactionValidatorServiceImpl; static class P2PDiscoveryOptionGroup { @@ -1360,7 +1360,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { new PkiBlockCreationConfigurationProvider(), new RpcEndpointServiceImpl(), new TransactionSelectionServiceImpl(), - new TransactionValidatorServiceImpl()); + new PluginTransactionValidatorServiceImpl()); } /** @@ -1400,7 +1400,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { final PkiBlockCreationConfigurationProvider pkiBlockCreationConfigProvider, final RpcEndpointServiceImpl rpcEndpointServiceImpl, final TransactionSelectionServiceImpl transactionSelectionServiceImpl, - final TransactionValidatorServiceImpl transactionValidatorServiceImpl) { + final PluginTransactionValidatorServiceImpl transactionValidatorServiceImpl) { this.besuComponent = besuComponent; this.logger = besuComponent.getBesuCommandLogger(); this.rlpBlockImporter = rlpBlockImporter; @@ -1602,7 +1602,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { besuPluginContext.addService( TransactionSelectionService.class, transactionSelectionServiceImpl); besuPluginContext.addService( - TransactionValidatorService.class, transactionValidatorServiceImpl); + PluginTransactionValidatorService.class, transactionValidatorServiceImpl); // register built-in plugins rocksDBPlugin = new RocksDBPlugin(); @@ -2243,7 +2243,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { .ethProtocolConfiguration(unstableEthProtocolOptions.toDomainObject()) .networkConfiguration(unstableNetworkingOptions.toDomainObject()) .transactionSelectorFactory(getTransactionSelectorFactory()) - .pluginTransactionSelectorFactory(getPluginTransactionValidatorFactory()) + .pluginTransactionValidatorFactory(getPluginTransactionValidatorFactory()) .dataDirectory(dataDir()) .miningParameters( new MiningParameters.Builder() @@ -2301,9 +2301,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } private PluginTransactionValidatorFactory getPluginTransactionValidatorFactory() { - final Optional txSValidatorService = - besuPluginContext.getService(TransactionValidatorService.class); - return txSValidatorService.map(TransactionValidatorService::get).orElse(null); + final Optional txSValidatorService = + besuPluginContext.getService(PluginTransactionValidatorService.class); + return txSValidatorService.map(PluginTransactionValidatorService::get).orElse(null); } private GraphQLConfiguration graphQLConfiguration() { @@ -2935,7 +2935,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } private TransactionPoolConfiguration buildTransactionPoolConfiguration() { - final var stableTxPoolOption = stableTransactionPoolOptions.toDomainObject(); return ImmutableTransactionPoolConfiguration.builder() .from(stableTxPoolOption) diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index f31d6bb24e..d023cdd76d 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -540,7 +540,13 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides return this; } - public BesuControllerBuilder pluginTransactionSelectorFactory( + /** + * sets the pluginTransactionValidatorFactory + * + * @param pluginTransactionValidatorFactory factory that creates plugin transaction Validators + * @return the besu controller builder + */ + public BesuControllerBuilder pluginTransactionValidatorFactory( final PluginTransactionValidatorFactory pluginTransactionValidatorFactory) { this.pluginTransactionValidatorFactory = pluginTransactionValidatorFactory; return this; diff --git a/besu/src/main/java/org/hyperledger/besu/services/TransactionValidatorServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/PluginTransactionValidatorServiceImpl.java similarity index 86% rename from besu/src/main/java/org/hyperledger/besu/services/TransactionValidatorServiceImpl.java rename to besu/src/main/java/org/hyperledger/besu/services/PluginTransactionValidatorServiceImpl.java index 50fdf38962..1d44700eb3 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/TransactionValidatorServiceImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/PluginTransactionValidatorServiceImpl.java @@ -14,11 +14,11 @@ */ package org.hyperledger.besu.services; -import org.hyperledger.besu.plugin.services.TransactionValidatorService; +import org.hyperledger.besu.plugin.services.PluginTransactionValidatorService; import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionValidatorFactory; /** The Transaction Selection service implementation. */ -public class TransactionValidatorServiceImpl implements TransactionValidatorService { +public class PluginTransactionValidatorServiceImpl implements PluginTransactionValidatorService { private PluginTransactionValidatorFactory factory; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java index 87ca1583de..126052df0b 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java @@ -76,12 +76,12 @@ import org.hyperledger.besu.plugin.services.storage.PrivacyKeyValueStorageFactor import org.hyperledger.besu.plugin.services.storage.SegmentIdentifier; import org.hyperledger.besu.services.BesuPluginContextImpl; import org.hyperledger.besu.services.PermissioningServiceImpl; +import org.hyperledger.besu.services.PluginTransactionValidatorServiceImpl; 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.TransactionSelectionServiceImpl; -import org.hyperledger.besu.services.TransactionValidatorServiceImpl; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; import java.io.ByteArrayOutputStream; @@ -241,7 +241,7 @@ public abstract class CommandTestAbstract { when(mockControllerBuilder.maxRemotelyInitiatedPeers(anyInt())) .thenReturn(mockControllerBuilder); when(mockControllerBuilder.transactionSelectorFactory(any())).thenReturn(mockControllerBuilder); - when(mockControllerBuilder.pluginTransactionSelectorFactory(any())) + when(mockControllerBuilder.pluginTransactionValidatorFactory(any())) .thenReturn(mockControllerBuilder); when(mockControllerBuilder.besuComponent(any(BesuComponent.class))) .thenReturn(mockControllerBuilder); @@ -493,7 +493,7 @@ public abstract class CommandTestAbstract { pkiBlockCreationConfigProvider, rpcEndpointServiceImpl, new TransactionSelectionServiceImpl(), - new TransactionValidatorServiceImpl()); + new PluginTransactionValidatorServiceImpl()); } @Override diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index 0bb671d740..9516578e85 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -69,7 +69,7 @@ Calculated : ${currentHash} tasks.register('checkAPIChanges', FileStateChecker) { description = "Checks that the API for the Plugin-API project does not change without deliberate thought" files = sourceSets.main.allJava.files - knownHash = 'efyGMh6uDklK9YBP8cAbXujTu4adsr/hG5Y6RUkj3P8=' + knownHash = 'Hk2/Iqa74WbVIJ/EWqb00iqxBN9lMi/A20eTIf1GoZE=' } check.dependsOn('checkAPIChanges') diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/TransactionValidatorService.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/PluginTransactionValidatorService.java similarity index 94% rename from plugin-api/src/main/java/org/hyperledger/besu/plugin/services/TransactionValidatorService.java rename to plugin-api/src/main/java/org/hyperledger/besu/plugin/services/PluginTransactionValidatorService.java index ec0846c977..7681d9b7e7 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/TransactionValidatorService.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/PluginTransactionValidatorService.java @@ -20,7 +20,7 @@ import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionValidat /** Transaction validator for addition of transactions to the transaction pool */ @Unstable -public interface TransactionValidatorService extends BesuService { +public interface PluginTransactionValidatorService extends BesuService { /** * Returns the transaction validator factory diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txvalidator/PluginTransactionValidator.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txvalidator/PluginTransactionValidator.java index 09ad4d411d..60f0449719 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txvalidator/PluginTransactionValidator.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txvalidator/PluginTransactionValidator.java @@ -29,5 +29,4 @@ public interface PluginTransactionValidator { * @return true if the transaction can be added, false otherwise */ boolean validateTransaction(final Transaction transaction); - ; }