Skip to content

Commit

Permalink
Cleanup after refactoring TransactionSelectionService (hyperledger#6618)
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 authored Feb 27, 2024
1 parent 0c8dcfc commit aa38192
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
Expand Down Expand Up @@ -148,11 +149,16 @@ public void startNode(final BesuNode node) {
new TransactionSelectionServiceImpl();
final Path dataDir = node.homeDirectory();
final BesuConfigurationImpl commonPluginConfiguration = new BesuConfigurationImpl();
final var miningParameters =
ImmutableMiningParameters.builder()
.from(node.getMiningParameters())
.transactionSelectionService(transactionSelectionServiceImpl)
.build();
commonPluginConfiguration.init(
dataDir,
dataDir.resolve(DATABASE_PATH),
node.getDataStorageConfiguration(),
node.getMiningParameters());
miningParameters);
final BesuPluginContextImpl besuPluginContext =
besuPluginContextMap.computeIfAbsent(
node,
Expand Down Expand Up @@ -199,15 +205,12 @@ public void startNode(final BesuNode node) {

final int maxPeers = 25;

final TransactionSelectionService transactionSelectorService =
getTransactionSelectorService(besuPluginContext);

final PluginTransactionValidatorFactory pluginTransactionValidatorFactory =
getPluginTransactionValidatorFactory(besuPluginContext);
builder
.synchronizerConfiguration(new SynchronizerConfiguration.Builder().build())
.dataDirectory(node.homeDirectory())
.miningParameters(node.getMiningParameters())
.miningParameters(miningParameters)
.privacyParameters(node.getPrivacyParameters())
.nodeKey(new NodeKey(new KeyPairSecurityModule(KeyPairUtil.loadKeyPair(dataDir))))
.metricsSystem(metricsSystem)
Expand All @@ -226,7 +229,6 @@ public void startNode(final BesuNode node) {
.maxRemotelyInitiatedPeers(15)
.networkConfiguration(node.getNetworkingConfiguration())
.randomPeerPriority(false)
.transactionSelectorService(transactionSelectorService)
.pluginTransactionValidatorFactory(pluginTransactionValidatorFactory);

node.getGenesisConfig()
Expand Down Expand Up @@ -338,11 +340,6 @@ public String getConsoleContents() {
throw new RuntimeException("Console contents can only be captured in process execution");
}

private TransactionSelectionService getTransactionSelectorService(
final BesuPluginContextImpl besuPluginContext) {
return besuPluginContext.getService(TransactionSelectionService.class).orElseThrow();
}

private PluginTransactionValidatorFactory getPluginTransactionValidatorFactory(
final BesuPluginContextImpl besuPluginContext) {
final Optional<PluginTransactionValidatorService> txValidatorService =
Expand Down
5 changes: 0 additions & 5 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,6 @@ public BesuControllerBuilder getControllerBuilder() {
.synchronizerConfiguration(buildSyncConfig())
.ethProtocolConfiguration(unstableEthProtocolOptions.toDomainObject())
.networkConfiguration(unstableNetworkingOptions.toDomainObject())
.transactionSelectorService(getTransactionSelectorService())
.pluginTransactionValidatorFactory(getPluginTransactionValidatorFactory())
.dataDirectory(dataDir())
.dataStorageConfiguration(getDataStorageConfiguration())
Expand Down Expand Up @@ -1823,10 +1822,6 @@ public BesuControllerBuilder getControllerBuilder() {
.cacheLastBlocks(numberOfblocksToCache);
}

private TransactionSelectionService getTransactionSelectorService() {
return besuPluginContext.getService(TransactionSelectionService.class).orElseThrow();
}

private PluginTransactionValidatorFactory getPluginTransactionValidatorFactory() {
final Optional<PluginTransactionValidatorService> txSValidatorService =
besuPluginContext.getService(PluginTransactionValidatorService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.plugin.services.permissioning.NodeMessagePermissioningProvider;
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionValidatorFactory;
Expand Down Expand Up @@ -533,17 +532,6 @@ public BesuControllerBuilder randomPeerPriority(final Boolean randomPeerPriority
return this;
}

/**
* sets the transactionSelectionService in the builder
*
* @param transactionSelectionService the transaction selector service
* @return the besu controller builder
*/
public BesuControllerBuilder transactionSelectorService(
final TransactionSelectionService transactionSelectionService) {
return this;
}

/**
* sets the pluginTransactionValidatorFactory
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ public void initMocks() throws Exception {
when(mockControllerBuilder.maxPeers(anyInt())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.maxRemotelyInitiatedPeers(anyInt()))
.thenReturn(mockControllerBuilder);
when(mockControllerBuilder.transactionSelectorService(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.pluginTransactionValidatorFactory(any()))
.thenReturn(mockControllerBuilder);
when(mockControllerBuilder.besuComponent(any(BesuComponent.class)))
Expand Down

0 comments on commit aa38192

Please sign in to comment.