Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Collections.singletonList;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_PLUGIN_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_EXTRA_DATA;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_PRIORITY_FEE_PER_GAS;
Expand Down Expand Up @@ -50,10 +50,6 @@

/** The Mining CLI options. */
public class MiningOptions implements CLIOptions<MiningConfiguration> {

private static final String DEPRECATION_PREFIX =
"Deprecated. PoW consensus is deprecated. See CHANGELOG for alternative options. ";

@Option(
names = {"--miner-extra-data"},
description =
Expand Down Expand Up @@ -91,18 +87,16 @@ public class MiningOptions implements CLIOptions<MiningConfiguration> {
names = {"--block-txs-selection-max-time"},
converter = PositiveNumberConverter.class,
description =
DEPRECATION_PREFIX
+ "Specifies the maximum time, in milliseconds, that could be spent selecting transactions to be included in the block."
"Specifies the maximum time, in milliseconds, that could be spent selecting transactions to be included in the block on PoS networks."
+ " Not compatible with PoA networks, see poa-block-txs-selection-max-time. (default: ${DEFAULT-VALUE})")
private PositiveNumber nonPoaBlockTxsSelectionMaxTime =
DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
private PositiveNumber posBlockTxsSelectionMaxTime = DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME;

@Option(
names = {"--poa-block-txs-selection-max-time"},
converter = PositiveNumberConverter.class,
description =
"Specifies the maximum time that could be spent selecting transactions to be included in the block, as a percentage of the fixed block time of the PoA network."
+ " To be only used on PoA networks, for other networks see block-txs-selection-max-time."
+ " To be only used on PoA networks, for PoS networks see block-txs-selection-max-time."
+ " (default: ${DEFAULT-VALUE})")
private PositiveNumber poaBlockTxsSelectionMaxTime = DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;

Expand Down Expand Up @@ -268,8 +262,8 @@ static MiningOptions fromConfig(final MiningConfiguration miningConfiguration) {
miningOptions.minTransactionGasPrice = miningConfiguration.getMinTransactionGasPrice();
miningOptions.minPriorityFeePerGas = miningConfiguration.getMinPriorityFeePerGas();
miningOptions.minBlockOccupancyRatio = miningConfiguration.getMinBlockOccupancyRatio();
miningOptions.nonPoaBlockTxsSelectionMaxTime =
miningConfiguration.getNonPoaBlockTxsSelectionMaxTime();
miningOptions.posBlockTxsSelectionMaxTime =
miningConfiguration.getPosBlockTxsSelectionMaxTime();
miningOptions.poaBlockTxsSelectionMaxTime =
miningConfiguration.getPoaBlockTxsSelectionMaxTime();
miningOptions.pluginBlockTxsSelectionMaxTime =
Expand Down Expand Up @@ -318,7 +312,7 @@ public MiningConfiguration toDomainObject() {
.mutableInitValues(updatableInitValuesBuilder.build())
.maxBlobsPerBlock(
maxBlobsPerBlock != null ? OptionalInt.of(maxBlobsPerBlock) : OptionalInt.empty())
.nonPoaBlockTxsSelectionMaxTime(nonPoaBlockTxsSelectionMaxTime)
.posBlockTxsSelectionMaxTime(posBlockTxsSelectionMaxTime)
.poaBlockTxsSelectionMaxTime(poaBlockTxsSelectionMaxTime)
.pluginBlockTxsSelectionMaxTime(pluginBlockTxsSelectionMaxTime)
.unstable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package org.hyperledger.besu.cli.options;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_PLUGIN_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -180,8 +180,8 @@ public void blockTxsSelectionMaxTimeDefaultValue() {
internalTestSuccess(
this::runtimeConfiguration,
miningParams ->
assertThat(miningParams.getNonPoaBlockTxsSelectionMaxTime())
.isEqualTo(DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME));
assertThat(miningParams.getPosBlockTxsSelectionMaxTime())
.isEqualTo(DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME));
}

@Test
Expand Down Expand Up @@ -212,7 +212,7 @@ public void blockTxsSelectionMaxTimeRequiresPoSTransition() throws IOException {
internalTestSuccess(
this::runtimeConfiguration,
miningParams ->
assertThat(miningParams.getNonPoaBlockTxsSelectionMaxTime())
assertThat(miningParams.getPosBlockTxsSelectionMaxTime())
.isEqualTo(PositiveNumber.fromInt(2)),
"--genesis-file",
genesisFilePoS.toString(),
Expand All @@ -227,7 +227,7 @@ public void bothBlockTxsSelectionMaxTimeOptionsAllowedWhenPoSTransitionIsPresent
internalTestSuccess(
this::runtimeConfiguration,
miningParams -> {
assertThat(miningParams.getNonPoaBlockTxsSelectionMaxTime())
assertThat(miningParams.getPosBlockTxsSelectionMaxTime())
.isEqualTo(PositiveNumber.fromInt(2000));
assertThat(miningParams.getPoaBlockTxsSelectionMaxTime())
.isEqualTo(PositiveNumber.fromInt(80));
Expand All @@ -250,7 +250,7 @@ public void bothBlockTxsSelectionMaxTimeOptionsAllowedWhenPoSTransitionIsPresent
internalTestSuccess(
this::runtimeConfiguration,
miningParams -> {
assertThat(miningParams.getNonPoaBlockTxsSelectionMaxTime())
assertThat(miningParams.getPosBlockTxsSelectionMaxTime())
.isEqualTo(PositiveNumber.fromInt(2000));
assertThat(miningParams.getPoaBlockTxsSelectionMaxTime())
.isEqualTo(PositiveNumber.fromInt(80));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import static org.hyperledger.besu.ethereum.blockcreation.AbstractBlockTransactionSelectorTest.Sender.SENDER3;
import static org.hyperledger.besu.ethereum.blockcreation.AbstractBlockTransactionSelectorTest.Sender.SENDER4;
import static org.hyperledger.besu.ethereum.blockcreation.AbstractBlockTransactionSelectorTest.Sender.SENDER5;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.EXECUTION_INTERRUPTED;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.NONCE_TOO_LOW;
import static org.hyperledger.besu.plugin.data.TransactionSelectionResult.BLOCK_SELECTION_TIMEOUT;
Expand Down Expand Up @@ -165,7 +165,7 @@ public void setup() {
transactionSelectionService,
Wei.ZERO,
MIN_OCCUPANCY_80_PERCENT,
DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME);
DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME);

final Block genesisBlock =
GenesisState.fromConfig(genesisConfig, protocolSchedule, new CodeCache()).getBlock();
Expand Down Expand Up @@ -520,7 +520,7 @@ public void transactionSelectionStopsWhenBlockIsFull() {
transactionSelectionService,
Wei.ZERO,
MIN_OCCUPANCY_100_PERCENT,
DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME),
DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME),
transactionProcessor,
blockHeader,
miningBeneficiary,
Expand Down Expand Up @@ -582,7 +582,7 @@ public void transactionSelectionStopsWhenRemainingGasIsNotEnoughForAnyMoreTransa
transactionSelectionService,
Wei.ZERO,
MIN_OCCUPANCY_100_PERCENT,
DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME),
DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME),
transactionProcessor,
blockHeader,
miningBeneficiary,
Expand Down Expand Up @@ -824,7 +824,7 @@ public PluginTransactionSelector create(
transactionSelectionService,
Wei.ZERO,
MIN_OCCUPANCY_80_PERCENT,
DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME),
DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME),
transactionProcessor,
blockHeader,
miningBeneficiary,
Expand Down Expand Up @@ -1765,7 +1765,7 @@ protected MiningConfiguration createMiningParameters(
.minBlockOccupancyRatio(minBlockOccupancyRatio)
.build())
.transactionSelectionService(transactionSelectionService)
.nonPoaBlockTxsSelectionMaxTime(txsSelectionMaxTime)
.posBlockTxsSelectionMaxTime(txsSelectionMaxTime)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.assertj.core.api.Assertions.entry;
import static org.hyperledger.besu.ethereum.blockcreation.AbstractBlockTransactionSelectorTest.Sender.SENDER1;
import static org.hyperledger.besu.ethereum.blockcreation.AbstractBlockTransactionSelectorTest.Sender.SENDER2;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME;
import static org.mockito.Mockito.mock;

import org.hyperledger.besu.config.GenesisConfig;
Expand Down Expand Up @@ -122,7 +122,7 @@ public void eip1559TransactionCurrentGasPriceLessThanMinimumIsSkippedAndKeptInTh
transactionSelectionService,
Wei.of(6),
MIN_OCCUPANCY_80_PERCENT,
DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME),
DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME),
transactionProcessor,
blockHeader,
miningBeneficiary,
Expand Down Expand Up @@ -154,7 +154,7 @@ public void eip1559TransactionCurrentGasPriceGreaterThanMinimumIsSelected() {
transactionSelectionService,
Wei.of(6),
MIN_OCCUPANCY_80_PERCENT,
DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME),
DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME),
transactionProcessor,
blockHeader,
miningBeneficiary,
Expand Down Expand Up @@ -185,7 +185,7 @@ public void eip1559PriorityTransactionCurrentGasPriceLessThanMinimumIsSelected()
transactionSelectionService,
Wei.of(6),
MIN_OCCUPANCY_80_PERCENT,
DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME),
DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME),
transactionProcessor,
blockHeader,
miningBeneficiary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@Value.Immutable
@Value.Enclosing
public abstract class MiningConfiguration {
public static final PositiveNumber DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME =
public static final PositiveNumber DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME =
PositiveNumber.fromInt((int) Duration.ofSeconds(5).toMillis());
public static final PositiveNumber DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME =
PositiveNumber.fromInt(75);
Expand Down Expand Up @@ -168,8 +168,8 @@ public MiningConfiguration setEmptyBlockPeriodSeconds(final int emptyBlockPeriod
}

@Value.Default
public PositiveNumber getNonPoaBlockTxsSelectionMaxTime() {
return DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
public PositiveNumber getPosBlockTxsSelectionMaxTime() {
return DEFAULT_POS_BLOCK_TXS_SELECTION_MAX_TIME;
}

@Value.Default
Expand Down Expand Up @@ -214,7 +214,7 @@ public Duration getBlockTxsSelectionMaxTime(final boolean isPoS) {
}
}

return Duration.ofMillis(getNonPoaBlockTxsSelectionMaxTime().getValue());
return Duration.ofMillis(getPosBlockTxsSelectionMaxTime().getValue());
}

public Duration getPluginTxsSelectionMaxTime(final Duration blockTxsSelectionMaxTime) {
Expand Down
Loading