Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
Signed-off-by: Karim Taam <[email protected]>
  • Loading branch information
matkt committed Jul 10, 2024
1 parent 7911566 commit 7ec17b6
Show file tree
Hide file tree
Showing 34 changed files with 267 additions and 307 deletions.
3 changes: 1 addition & 2 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1905,8 +1905,7 @@ public BesuControllerBuilder getControllerBuilder() {
.pkiBlockCreationConfiguration(maybePkiBlockCreationConfiguration())
.clock(Clock.systemUTC())
.isRevertReasonEnabled(isRevertReasonEnabled)
.isParallelPreloadTxEnabled(
dataStorageConfiguration.getUnstable().isParallelPreloadTxEnabled())
.isParallelTxEnabled(dataStorageConfiguration.getUnstable().isParallelTxEnabled())
.storageProvider(storageProvider)
.gasLimitCalculator(
miningParametersSupplier.get().getTargetGasLimit().isPresent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ public static class Unstable {

@CommandLine.Option(
hidden = true,
names = {"--Xbonsai-parallel-preload-tx-enabled"},
names = {"--Xbonsai-parallel-tx-enabled"},
arity = "1",
description =
"Enables parallel preloading of transactions to optimize processing speed by concurrently loading and executing necessary data in advance. (default: ${DEFAULT-VALUE})")
private Boolean isParallelPreloadTxEnabled = false;
"Enables parallelization of transactions to optimize processing speed by concurrently loading and executing necessary data in advance. (default: ${DEFAULT-VALUE})")
private Boolean isParallelTxEnabled = false;

/** Default Constructor. */
Unstable() {}
Expand Down Expand Up @@ -188,7 +188,7 @@ public void validate(final CommandLine commandLine, final SyncMode syncMode) {
}
}
} else {
if (unstableOptions.isParallelPreloadTxEnabled) {
if (unstableOptions.isParallelTxEnabled) {
throw new CommandLine.ParameterException(
commandLine,
"Transaction parallelization is not supported unless operating in a 'diffbased' mode, such as Bonsai.");
Expand All @@ -214,8 +214,8 @@ public static DataStorageOptions fromConfig(final DataStorageConfiguration domai
domainObject.getUnstable().getBonsaiFullFlatDbEnabled();
dataStorageOptions.unstableOptions.bonsaiCodeUsingCodeHashEnabled =
domainObject.getUnstable().getBonsaiCodeStoredByCodeHashEnabled();
dataStorageOptions.unstableOptions.isParallelPreloadTxEnabled =
domainObject.getUnstable().isParallelPreloadTxEnabled();
dataStorageOptions.unstableOptions.isParallelTxEnabled =
domainObject.getUnstable().isParallelTxEnabled();

return dataStorageOptions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides

private int numberOfBlocksToCache = 0;

protected boolean isParallelPreloadTxEnabled;
protected boolean isParallelTxEnabled;

/** Instantiates a new Besu controller builder. */
protected BesuControllerBuilder() {}
Expand Down Expand Up @@ -531,9 +531,8 @@ public BesuControllerBuilder randomPeerPriority(final Boolean randomPeerPriority
return this;
}

public BesuControllerBuilder isParallelPreloadTxEnabled(
final boolean isParallelPreloadTxEnabled) {
this.isParallelPreloadTxEnabled = isParallelPreloadTxEnabled;
public BesuControllerBuilder isParallelTxEnabled(final boolean isParallelTxEnabled) {
this.isParallelTxEnabled = isParallelTxEnabled;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected ProtocolSchedule createProtocolSchedule() {
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ protected ProtocolSchedule createProtocolSchedule() {
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected ProtocolSchedule createProtocolSchedule() {
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected ProtocolSchedule createProtocolSchedule() {
isRevertReasonEnabled,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ protected ProtocolSchedule createProtocolSchedule() {
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void initMocks() throws Exception {
when(mockControllerBuilder.cacheLastBlocks(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.genesisStateHashCacheEnabled(any()))
.thenReturn(mockControllerBuilder);
when(mockControllerBuilder.isParallelPreloadTxEnabled(false)).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.isParallelTxEnabled(false)).thenReturn(mockControllerBuilder);

// doReturn used because of generic BesuController
doReturn(mockController).when(mockControllerBuilder).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static ProtocolSchedule create(
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {

final CliqueConfigOptions cliqueConfig = config.getCliqueConfigOptions();

Expand Down Expand Up @@ -112,7 +112,7 @@ public static ProtocolSchedule create(
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled)
isParallelTxEnabled)
.createProtocolSchedule();
}

Expand All @@ -137,7 +137,7 @@ public static ProtocolSchedule create(
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
return create(
config,
forksSchedule,
Expand All @@ -147,7 +147,7 @@ public static ProtocolSchedule create(
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

private static ProtocolSpecBuilder applyCliqueSpecificModifications(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public BftProtocolSchedule createProtocolSchedule(
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
final Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> specMap = new HashMap<>();

forksSchedule
Expand All @@ -92,7 +92,7 @@ public BftProtocolSchedule createProtocolSchedule(
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled)
isParallelTxEnabled)
.createProtocolSchedule();
return new BftProtocolSchedule((DefaultProtocolSchedule) protocolSchedule);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ protected BlockHeaderValidator.Builder createBlockHeaderRuleset(
bftExtraDataCodec,
EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager());
new BadBlockManager(),
false);
}

private BftConfigOptions createBftConfig(final BigInteger blockReward) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static BftProtocolSchedule create(
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
return new IbftProtocolScheduleBuilder()
.createProtocolSchedule(
config,
Expand All @@ -68,7 +68,7 @@ public static BftProtocolSchedule create(
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

/**
Expand All @@ -89,7 +89,7 @@ public static BftProtocolSchedule create(
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
return create(
config,
forksSchedule,
Expand All @@ -99,7 +99,7 @@ public static BftProtocolSchedule create(
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public static ProtocolSchedule create(
final boolean isRevertReasonEnabled,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
return create(
config,
PrivacyParameters.DEFAULT,
isRevertReasonEnabled,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

/**
Expand All @@ -82,7 +82,7 @@ public static ProtocolSchedule create(
final boolean isRevertReasonEnabled,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {

Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> postMergeModifications =
new HashMap<>();
Expand All @@ -102,7 +102,7 @@ public static ProtocolSchedule create(
EvmConfiguration.DEFAULT,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled)
isParallelTxEnabled)
.createProtocolSchedule();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,13 @@ public static TransitionProtocolSchedule fromConfig(
final GenesisConfigOptions genesisConfigOptions,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
ProtocolSchedule preMergeProtocolSchedule =
MainnetProtocolSchedule.fromConfig(
genesisConfigOptions, miningParameters, badBlockManager, isParallelPreloadTxEnabled);
genesisConfigOptions, miningParameters, badBlockManager, isParallelTxEnabled);
ProtocolSchedule postMergeProtocolSchedule =
MergeProtocolSchedule.create(
genesisConfigOptions,
false,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
genesisConfigOptions, false, miningParameters, badBlockManager, isParallelTxEnabled);
return new TransitionProtocolSchedule(
preMergeProtocolSchedule, postMergeProtocolSchedule, PostMergeContext.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static BftProtocolSchedule create(
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
return new QbftProtocolScheduleBuilder()
.createProtocolSchedule(
config,
Expand All @@ -72,7 +72,7 @@ public static BftProtocolSchedule create(
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

/**
Expand All @@ -93,7 +93,7 @@ public static BftProtocolSchedule create(
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
return create(
config,
qbftForksSchedule,
Expand All @@ -103,7 +103,7 @@ public static BftProtocolSchedule create(
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

/**
Expand All @@ -124,7 +124,7 @@ public static ProtocolSchedule create(
final BftExtraDataCodec bftExtraDataCodec,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
return create(
config,
qbftForksSchedule,
Expand All @@ -134,7 +134,7 @@ public static ProtocolSchedule create(
EvmConfiguration.DEFAULT,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static ProtocolSchedule create(
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
return new ProtocolScheduleBuilder(
config,
ProtocolSpecAdapters.create(
Expand All @@ -45,7 +45,7 @@ public static ProtocolSchedule create(
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled)
isParallelTxEnabled)
.createProtocolSchedule();
}

Expand All @@ -55,30 +55,30 @@ public static ProtocolSchedule create(
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
return create(
config,
PrivacyParameters.DEFAULT,
isRevertReasonEnabled,
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}

public static ProtocolSchedule create(
final GenesisConfigOptions config,
final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager,
final boolean isParallelPreloadTxEnabled) {
final boolean isParallelTxEnabled) {
return create(
config,
PrivacyParameters.DEFAULT,
false,
evmConfiguration,
miningParameters,
badBlockManager,
isParallelPreloadTxEnabled);
isParallelTxEnabled);
}
}
Loading

0 comments on commit 7ec17b6

Please sign in to comment.