more changes

Signed-off-by: Stefan <stefan.pingel@consensys.net>
TransactionValidatorService
Stefan 1 year ago
parent 8dd80a781a
commit e609f5b370
  1. 19
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
  2. 1
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java
  3. 21
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  4. 8
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  5. 4
      besu/src/main/java/org/hyperledger/besu/services/PluginTransactionValidatorServiceImpl.java
  6. 6
      besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
  7. 2
      plugin-api/build.gradle
  8. 2
      plugin-api/src/main/java/org/hyperledger/besu/plugin/services/PluginTransactionValidatorService.java
  9. 1
      plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txvalidator/PluginTransactionValidator.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> 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<PluginTransactionValidatorService> txValidatorService =
besuPluginContext.getService(PluginTransactionValidatorService.class);
return txValidatorService.map(PluginTransactionValidatorService::get).orElse(null);
}
}

@ -117,6 +117,7 @@ public class BesuNodeFactory {
.name(name)
.miningEnabled()
.jsonRpcEnabled()
.jsonRpcTxPool()
.webSocketEnabled()
.extraCLIOptions(extraCliOptions);
builder = configModifier.apply(builder);

@ -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<TransactionValidatorService> txSValidatorService =
besuPluginContext.getService(TransactionValidatorService.class);
return txSValidatorService.map(TransactionValidatorService::get).orElse(null);
final Optional<PluginTransactionValidatorService> 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)

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

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

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

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

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

@ -29,5 +29,4 @@ public interface PluginTransactionValidator {
* @return true if the transaction can be added, false otherwise
*/
boolean validateTransaction(final Transaction transaction);
;
}

Loading…
Cancel
Save