Skip to content

Commit

Permalink
default target gas limit for holesky (#8125)
Browse files Browse the repository at this point in the history
* default target gas limit for holesky

---------

Signed-off-by: Sally MacFarlane <[email protected]>
Signed-off-by: Justin Florentine <[email protected]>
Co-authored-by: Justin Florentine <[email protected]>
  • Loading branch information
macfarla and jflo authored Jan 16, 2025
1 parent 1e7f6f6 commit 870f3b7
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- Improve debug_traceBlock calls performance and reduce output size [#8076](https://github.com/hyperledger/besu/pull/8076)
- Add support for EIP-7702 transaction in the txpool [#8018](https://github.com/hyperledger/besu/pull/8018) [#7984](https://github.com/hyperledger/besu/pull/7984)
- Add support for `movePrecompileToAddress` in `StateOverrides` (`eth_call`)[8115](https://github.com/hyperledger/besu/pull/8115)
- Default target-gas-limit to 36M for holesky [#8125](https://github.com/hyperledger/besu/pull/8125)
- Add EIP-7623 - Increase calldata cost [#8093](https://github.com/hyperledger/besu/pull/8093)

### Bug fixes
Expand Down
7 changes: 7 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,13 @@ 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)) {
logger.info(
"Setting target gas limit for holesky: {}",
MiningConfiguration.DEFAULT_TARGET_GAS_LIMIT_HOLESKY);
miningParameters.setTargetGasLimit(MiningConfiguration.DEFAULT_TARGET_GAS_LIMIT_HOLESKY);
}
return miningParameters;
}

Expand Down
52 changes: 52 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,58 @@ 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(MiningConfiguration.DEFAULT_TARGET_GAS_LIMIT_HOLESKY);

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

0 comments on commit 870f3b7

Please sign in to comment.