7311: Remove PeerTaskFeatureToggle in favor of including isPeerTaskSystemEnabled in SynchronizerConfiguration

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
pull/7633/head
Matilda Clerke 2 months ago
parent 98aefcd8d6
commit 6e734f95a8
  1. 3
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  2. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java
  3. 59
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskFeatureToggle.java
  4. 18
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SynchronizerConfiguration.java

@ -119,7 +119,6 @@ import org.hyperledger.besu.ethereum.core.MiningParametersMetrics;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.VersionMetadata;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskFeatureToggle;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
@ -1925,8 +1924,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
instantiateSignatureAlgorithmFactory();
PeerTaskFeatureToggle.initialize(unstableSynchronizerOptions.isPeerTaskSystemEnabled());
logger.info(generateConfigurationOverview());
logger.info("Security Module: {}", securityModuleName);
}

@ -436,7 +436,7 @@ public class SynchronizerOptions implements CLIOptions<SynchronizerConfiguration
.isSnapSyncBftEnabled(snapsyncBftEnabled)
.build());
builder.checkpointPostMergeEnabled(checkpointPostMergeSyncEnabled);
builder.isPeerTaskSystemEnabled(isPeerTaskSystemEnabled);
return builder;
}

@ -1,59 +0,0 @@
/*
* Copyright contributors to Hyperledger Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.eth.manager.peertask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Temporary class to allow easy access to the PeerTask feature toggle. This class can be removed
* once we've properly tested the PeerTask system and want to enable it permanently
*/
public class PeerTaskFeatureToggle {
private static final Logger LOGGER = LoggerFactory.getLogger(PeerTaskFeatureToggle.class);
private static Boolean USE_PEER_TASK_SYSTEM = null;
/**
* Initialize the PeerTaskFeatureToggle with the supplied usePeerTaskSystem Boolean.
* PeerTaskFeatureToggle may only be initialized once!
*
* @param usePeerTaskSystem Boolean indicating whether or not the PeerTask system should be used
*/
public static void initialize(final Boolean usePeerTaskSystem) {
if (USE_PEER_TASK_SYSTEM != null) {
LOGGER.warn(
"PeerTaskFeatureToggle has already been initialized, and cannot be initialized again");
} else {
USE_PEER_TASK_SYSTEM = usePeerTaskSystem;
}
}
/**
* Indicates whether or not to use the PeerTask system. PeerTaskFeatureToggle must have been
* initialized before this method can be called!
*
* @return whether or not to use the PeerTask system
* @throws IllegalStateException if the PeerTaskFeatureToggle has not been initialized
*/
public static Boolean usePeerTaskSystem() {
if (USE_PEER_TASK_SYSTEM == null) {
throw new IllegalStateException(
"PeerTaskFeatureToggle has not been initialized, but getUsePeerTaskSystem() has been called");
}
return USE_PEER_TASK_SYSTEM;
}
private PeerTaskFeatureToggle() {}
}

@ -85,6 +85,7 @@ public class SynchronizerConfiguration {
private final int maxTrailingPeers;
private final long worldStateMinMillisBeforeStalling;
private final long propagationManagerGetBlockTimeoutMillis;
private final boolean isPeerTaskSystemEnabled;
private SynchronizerConfiguration(
final int syncPivotDistance,
@ -108,7 +109,8 @@ public class SynchronizerConfiguration {
final int computationParallelism,
final int maxTrailingPeers,
final long propagationManagerGetBlockTimeoutMillis,
final boolean checkpointPostMergeEnabled) {
final boolean checkpointPostMergeEnabled,
final boolean isPeerTaskSystemEnabled) {
this.syncPivotDistance = syncPivotDistance;
this.fastSyncFullValidationRate = fastSyncFullValidationRate;
this.syncMinimumPeerCount = syncMinimumPeerCount;
@ -131,6 +133,7 @@ public class SynchronizerConfiguration {
this.maxTrailingPeers = maxTrailingPeers;
this.propagationManagerGetBlockTimeoutMillis = propagationManagerGetBlockTimeoutMillis;
this.checkpointPostMergeEnabled = checkpointPostMergeEnabled;
this.isPeerTaskSystemEnabled = isPeerTaskSystemEnabled;
}
public static Builder builder() {
@ -256,6 +259,10 @@ public class SynchronizerConfiguration {
return propagationManagerGetBlockTimeoutMillis;
}
public boolean isPeerTaskSystemEnabled() {
return isPeerTaskSystemEnabled;
}
public static class Builder {
private SyncMode syncMode = SyncMode.FULL;
private int syncMinimumPeerCount = DEFAULT_SYNC_MINIMUM_PEERS;
@ -280,6 +287,7 @@ public class SynchronizerConfiguration {
DEFAULT_WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS;
private long worldStateMinMillisBeforeStalling = DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING;
private int worldStateTaskCacheSize = DEFAULT_WORLD_STATE_TASK_CACHE_SIZE;
private boolean isPeerTaskSystemEnabled = false;
private long propagationManagerGetBlockTimeoutMillis =
DEFAULT_PROPAGATION_MANAGER_GET_BLOCK_TIMEOUT_MILLIS;
@ -406,6 +414,11 @@ public class SynchronizerConfiguration {
return this;
}
public Builder isPeerTaskSystemEnabled(final boolean isPeerTaskSystemEnabled) {
this.isPeerTaskSystemEnabled = isPeerTaskSystemEnabled;
return this;
}
public SynchronizerConfiguration build() {
return new SynchronizerConfiguration(
syncPivotDistance,
@ -429,7 +442,8 @@ public class SynchronizerConfiguration {
computationParallelism,
maxTrailingPeers,
propagationManagerGetBlockTimeoutMillis,
checkpointPostMergeEnabled);
checkpointPostMergeEnabled,
isPeerTaskSystemEnabled);
}
}
}

Loading…
Cancel
Save