Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default target gas limit for holesky #8125

Merged
merged 7 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,10 @@ private MiningConfiguration getMiningParameters() {
getGenesisBlockPeriodSeconds(genesisConfigOptionsSupplier.get())
.ifPresent(miningParameters::setBlockPeriodSeconds);
initMiningParametersMetrics(miningParameters);
// if network = holesky, set targetGasLimit to 36,000,000 unless otherwise specified
if (miningParameters.getTargetGasLimit().isEmpty() && NetworkName.HOLESKY.equals(network)) {
miningParameters.setTargetGasLimit(MiningConfiguration.DEFAULT_TARGET_GAS_LIMIT_HOLESKY);
}
return miningParameters;
}

Expand Down
51 changes: 51 additions & 0 deletions besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,57 @@ public void holeskyValuesAreUsed() {
verify(mockLogger, never()).warn(contains("Holesky is deprecated and will be shutdown"));
}

@Test
public void holeskyTargetGasLimitIsSetToHoleskyDefaultWhenNoValueSpecified() {
parseCommand("--network", "holesky");

final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);

final ArgumentCaptor<MiningConfiguration> miningArg =
ArgumentCaptor.forClass(MiningConfiguration.class);

verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
verify(mockControllerBuilder).miningParameters(miningArg.capture());
verify(mockControllerBuilder).build();

assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.getNetworkConfig(HOLESKY));

assertThat(miningArg.getValue().getCoinbase()).isEqualTo(Optional.empty());
assertThat(miningArg.getValue().getMinTransactionGasPrice()).isEqualTo(Wei.of(1000));
assertThat(miningArg.getValue().getExtraData()).isEqualTo(Bytes.EMPTY);
assertThat(miningArg.getValue().getTargetGasLimit().getAsLong()).isEqualTo(36000000);
macfarla marked this conversation as resolved.
Show resolved Hide resolved

assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}

@Test
public void holeskyTargetGasLimitIsSetToSpecifiedValueWhenValueSpecified() {
long customGasLimit = 99000000;
parseCommand("--network", "holesky", "--target-gas-limit", String.valueOf(customGasLimit));

final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);

final ArgumentCaptor<MiningConfiguration> miningArg =
ArgumentCaptor.forClass(MiningConfiguration.class);

verify(mockControllerBuilderFactory).fromEthNetworkConfig(networkArg.capture(), any());
verify(mockControllerBuilder).miningParameters(miningArg.capture());
verify(mockControllerBuilder).build();

assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.getNetworkConfig(HOLESKY));

assertThat(miningArg.getValue().getCoinbase()).isEqualTo(Optional.empty());
assertThat(miningArg.getValue().getMinTransactionGasPrice()).isEqualTo(Wei.of(1000));
assertThat(miningArg.getValue().getExtraData()).isEqualTo(Bytes.EMPTY);
assertThat(miningArg.getValue().getTargetGasLimit().getAsLong()).isEqualTo(customGasLimit);

assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}

@Test
public void luksoValuesAreUsed() {
parseCommand("--network", "lukso");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@Value.Immutable
@Value.Enclosing
public abstract class MiningConfiguration {
public static final long DEFAULT_TARGET_GAS_LIMIT_HOLESKY = 36_000_000L;
public static final PositiveNumber DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME =
PositiveNumber.fromInt((int) Duration.ofSeconds(5).toMillis());
public static final PositiveNumber DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME =
Expand Down
Loading