From 870f3b7857eb748bfa699f30e2ca8a45a6e35dfe Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Fri, 17 Jan 2025 05:55:29 +1000 Subject: [PATCH] default target gas limit for holesky (#8125) * default target gas limit for holesky --------- Signed-off-by: Sally MacFarlane Signed-off-by: Justin Florentine Co-authored-by: Justin Florentine --- CHANGELOG.md | 1 + .../org/hyperledger/besu/cli/BesuCommand.java | 7 +++ .../hyperledger/besu/cli/BesuCommandTest.java | 52 +++++++++++++++++++ .../ethereum/core/MiningConfiguration.java | 1 + 4 files changed, 61 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec39f72e065..fe2d341a3d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index edcc248ab34..8ee35458b2f 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -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; } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index a8bcde0e27d..70cb4d507c4 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -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 networkArg = + ArgumentCaptor.forClass(EthNetworkConfig.class); + + final ArgumentCaptor 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 networkArg = + ArgumentCaptor.forClass(EthNetworkConfig.class); + + final ArgumentCaptor 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"); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningConfiguration.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningConfiguration.java index fb39d164b75..55ffd5ba7d7 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningConfiguration.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningConfiguration.java @@ -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 =