From e51ddd8f09979b4b960d8f02e3fd20b5c1e098a5 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 16 Jan 2025 10:30:42 +1000 Subject: [PATCH 1/4] default target gas limit for holesky Signed-off-by: Sally MacFarlane --- .../org/hyperledger/besu/cli/BesuCommand.java | 4 ++ .../hyperledger/besu/cli/BesuCommandTest.java | 51 +++++++++++++++++++ .../ethereum/core/MiningConfiguration.java | 1 + 3 files changed, 56 insertions(+) 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..3f062a769b9 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,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; } 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..7e17bb524cc 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,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 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(36000000); + + 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 = From e63407544eb7aca3eca1583bc3f09f3bf1214495 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 16 Jan 2025 12:26:52 +1000 Subject: [PATCH 2/4] add changelog Signed-off-by: Sally MacFarlane --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0185dace3..84c7f5f7c40 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) ### Bug fixes - Fix serialization of state overrides when `movePrecompileToAddress` is present [#8204](https://github.com/hyperledger/besu/pull/8024) From 06d59e9d7814b6aef7797114ff19ba5a0d45c6dd Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 16 Jan 2025 12:27:30 +1000 Subject: [PATCH 3/4] use constant Signed-off-by: Sally MacFarlane --- .../test/java/org/hyperledger/besu/cli/BesuCommandTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 7e17bb524cc..70cb4d507c4 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -1930,7 +1930,8 @@ public void holeskyTargetGasLimitIsSetToHoleskyDefaultWhenNoValueSpecified() { 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); + assertThat(miningArg.getValue().getTargetGasLimit().getAsLong()) + .isEqualTo(MiningConfiguration.DEFAULT_TARGET_GAS_LIMIT_HOLESKY); assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); From 2f6f6a93aa1d6f09dda6965627ae7c44e86ee43e Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 16 Jan 2025 16:00:19 +1000 Subject: [PATCH 4/4] log message Signed-off-by: Sally MacFarlane --- besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java | 3 +++ 1 file changed, 3 insertions(+) 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 3f062a769b9..8ee35458b2f 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -2134,6 +2134,9 @@ private MiningConfiguration getMiningParameters() { 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;