diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd45cb4ef3..69ac2df1d42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ - Clique config option `createemptyblocks` to not create empty blocks [#6082](https://github.com/hyperledger/besu/pull/6082) - Upgrade EVM Reference Tests to v13 (Cancun) [#6114](https://github.com/hyperledger/besu/pull/6114) - Add `yParity` to GraphQL and JSON-RPC for relevant querise. [6119](https://github.com/hyperledger/besu/pull/6119) -- Force tx replacement price bump to zero when zero base fee market is configured. This allows for easier tx replacement in networks where there is not gas price. [#6079](https://github.com/hyperledger/besu/pull/6079) +- Force tx replacement price bump to zero when zero base fee market is configured or `--min-gas-price` is set to 0. This allows for easier tx replacement in networks where there is not gas price. [#6079](https://github.com/hyperledger/besu/pull/6079) ### Bug fixes - Upgrade netty to address CVE-2023-44487, CVE-2023-34462 [#6100](https://github.com/hyperledger/besu/pull/6100) 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 9b563a91ff9..d1af3efe7f5 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -2813,6 +2813,15 @@ private TransactionPoolConfiguration buildTransactionPoolConfiguration() { .saveFile((dataPath.resolve(txPoolConf.getSaveFile().getPath()).toFile())); if (getActualGenesisConfigOptions().isZeroBaseFee()) { + logger.info( + "Forcing price bump for transaction replacement to 0, since we are on a zero basefee network"); + txPoolConfBuilder.priceBump(Percentage.ZERO); + } + + if (getMiningParameters().getMinTransactionGasPrice().equals(Wei.ZERO) + && !transactionPoolOptions.isPriceBumpSet(commandLine)) { + logger.info( + "Forcing price bump for transaction replacement to 0, since min-gas-price is set to 0"); txPoolConfBuilder.priceBump(Percentage.ZERO); } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/TransactionPoolOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/TransactionPoolOptions.java index 68f33848fde..a8a50025f58 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/TransactionPoolOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/TransactionPoolOptions.java @@ -330,4 +330,14 @@ public TransactionPoolConfiguration toDomainObject() { public List getCLIOptions() { return CommandLineUtils.getCLIOptions(this, new TransactionPoolOptions()); } + + /** + * Is price bump option set? + * + * @param commandLine the command line + * @return true is tx-pool-price-bump is set + */ + public boolean isPriceBumpSet(final CommandLine commandLine) { + return CommandLineUtils.isOptionSet(commandLine, TransactionPoolOptions.TX_POOL_PRICE_BUMP); + } } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java b/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java index 33b531b5903..397592459c6 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/util/CommandLineUtils.java @@ -248,4 +248,17 @@ private static boolean isOptionSet(final CommandLine.Model.OptionSpec option) { return false; } } + + /** + * Is the option with that name set on the command line? + * + * @param commandLine the command line + * @param optionName the option name to check + * @return true if set + */ + public static boolean isOptionSet(final CommandLine commandLine, final String optionName) { + return commandLine.getCommandSpec().options().stream() + .filter(optionSpec -> Arrays.stream(optionSpec.names()).anyMatch(optionName::equals)) + .anyMatch(CommandLineUtils::isOptionSet); + } } 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 c0b730db827..cfd90bc42e1 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -5222,6 +5222,32 @@ public void txpoolPriceBumpOptionIncompatibleWithZeroWhenZeroBaseFeeMarket() thr .contains("Price bump option is not compatible with zero base fee market"); } + @Test + public void txpoolForcePriceBumpToZeroWhenMinGasPriceZero() { + parseCommand("--min-gas-price", "0"); + verify(mockControllerBuilder) + .transactionPoolConfiguration(transactionPoolConfigCaptor.capture()); + + final Percentage priceBump = transactionPoolConfigCaptor.getValue().getPriceBump(); + assertThat(priceBump).isEqualTo(Percentage.ZERO); + + assertThat(commandOutput.toString(UTF_8)).isEmpty(); + assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); + } + + @Test + public void txpoolPriceBumpKeepItsValueIfSetEvenWhenMinGasPriceZero() { + parseCommand("--min-gas-price", "0", "--tx-pool-price-bump", "1"); + verify(mockControllerBuilder) + .transactionPoolConfiguration(transactionPoolConfigCaptor.capture()); + + final Percentage priceBump = transactionPoolConfigCaptor.getValue().getPriceBump(); + assertThat(priceBump).isEqualTo(Percentage.fromInt(1)); + + assertThat(commandOutput.toString(UTF_8)).isEmpty(); + assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); + } + @Test public void snapsyncHealingOptionShouldBeDisabledByDefault() { final TestBesuCommand besuCommand = parseCommand();