|
|
@ -17,27 +17,27 @@ package org.hyperledger.besu.cli.options; |
|
|
|
import static com.google.common.base.Preconditions.checkNotNull; |
|
|
|
import static com.google.common.base.Preconditions.checkNotNull; |
|
|
|
import static java.util.Arrays.asList; |
|
|
|
import static java.util.Arrays.asList; |
|
|
|
import static java.util.Collections.singletonList; |
|
|
|
import static java.util.Collections.singletonList; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_POA_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.MiningParameters.MutableInitValues.DEFAULT_EXTRA_DATA; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_EXTRA_DATA; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_PRIORITY_FEE_PER_GAS; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_PRIORITY_FEE_PER_GAS; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_MAX_OMMERS_DEPTH; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_MAX_OMMERS_DEPTH; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POW_JOB_TTL; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POW_JOB_TTL; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_TTL; |
|
|
|
import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_TTL; |
|
|
|
|
|
|
|
|
|
|
|
import org.hyperledger.besu.cli.converter.PositiveNumberConverter; |
|
|
|
import org.hyperledger.besu.cli.converter.PositiveNumberConverter; |
|
|
|
import org.hyperledger.besu.cli.util.CommandLineUtils; |
|
|
|
import org.hyperledger.besu.cli.util.CommandLineUtils; |
|
|
|
import org.hyperledger.besu.config.GenesisConfigOptions; |
|
|
|
import org.hyperledger.besu.config.GenesisConfigOptions; |
|
|
|
import org.hyperledger.besu.datatypes.Address; |
|
|
|
import org.hyperledger.besu.datatypes.Address; |
|
|
|
import org.hyperledger.besu.datatypes.Wei; |
|
|
|
import org.hyperledger.besu.datatypes.Wei; |
|
|
|
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; |
|
|
|
import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; |
|
|
|
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; |
|
|
|
import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; |
|
|
|
import org.hyperledger.besu.ethereum.core.MiningParameters; |
|
|
|
import org.hyperledger.besu.ethereum.core.MiningConfiguration; |
|
|
|
import org.hyperledger.besu.plugin.services.TransactionSelectionService; |
|
|
|
import org.hyperledger.besu.plugin.services.TransactionSelectionService; |
|
|
|
import org.hyperledger.besu.util.number.PositiveNumber; |
|
|
|
import org.hyperledger.besu.util.number.PositiveNumber; |
|
|
|
|
|
|
|
|
|
|
@ -50,7 +50,7 @@ import picocli.CommandLine.Option; |
|
|
|
import picocli.CommandLine.ParameterException; |
|
|
|
import picocli.CommandLine.ParameterException; |
|
|
|
|
|
|
|
|
|
|
|
/** The Mining CLI options. */ |
|
|
|
/** The Mining CLI options. */ |
|
|
|
public class MiningOptions implements CLIOptions<MiningParameters> { |
|
|
|
public class MiningOptions implements CLIOptions<MiningConfiguration> { |
|
|
|
|
|
|
|
|
|
|
|
@Option( |
|
|
|
@Option( |
|
|
|
names = {"--miner-enabled"}, |
|
|
|
names = {"--miner-enabled"}, |
|
|
@ -300,43 +300,45 @@ public class MiningOptions implements CLIOptions<MiningParameters> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static MiningOptions fromConfig(final MiningParameters miningParameters) { |
|
|
|
static MiningOptions fromConfig(final MiningConfiguration miningConfiguration) { |
|
|
|
final MiningOptions miningOptions = MiningOptions.create(); |
|
|
|
final MiningOptions miningOptions = MiningOptions.create(); |
|
|
|
miningOptions.setTransactionSelectionService(miningParameters.getTransactionSelectionService()); |
|
|
|
miningOptions.setTransactionSelectionService( |
|
|
|
miningOptions.isMiningEnabled = miningParameters.isMiningEnabled(); |
|
|
|
miningConfiguration.getTransactionSelectionService()); |
|
|
|
miningOptions.iStratumMiningEnabled = miningParameters.isStratumMiningEnabled(); |
|
|
|
miningOptions.isMiningEnabled = miningConfiguration.isMiningEnabled(); |
|
|
|
miningOptions.stratumNetworkInterface = miningParameters.getStratumNetworkInterface(); |
|
|
|
miningOptions.iStratumMiningEnabled = miningConfiguration.isStratumMiningEnabled(); |
|
|
|
miningOptions.stratumPort = miningParameters.getStratumPort(); |
|
|
|
miningOptions.stratumNetworkInterface = miningConfiguration.getStratumNetworkInterface(); |
|
|
|
miningOptions.extraData = miningParameters.getExtraData(); |
|
|
|
miningOptions.stratumPort = miningConfiguration.getStratumPort(); |
|
|
|
miningOptions.minTransactionGasPrice = miningParameters.getMinTransactionGasPrice(); |
|
|
|
miningOptions.extraData = miningConfiguration.getExtraData(); |
|
|
|
miningOptions.minPriorityFeePerGas = miningParameters.getMinPriorityFeePerGas(); |
|
|
|
miningOptions.minTransactionGasPrice = miningConfiguration.getMinTransactionGasPrice(); |
|
|
|
miningOptions.minBlockOccupancyRatio = miningParameters.getMinBlockOccupancyRatio(); |
|
|
|
miningOptions.minPriorityFeePerGas = miningConfiguration.getMinPriorityFeePerGas(); |
|
|
|
|
|
|
|
miningOptions.minBlockOccupancyRatio = miningConfiguration.getMinBlockOccupancyRatio(); |
|
|
|
miningOptions.nonPoaBlockTxsSelectionMaxTime = |
|
|
|
miningOptions.nonPoaBlockTxsSelectionMaxTime = |
|
|
|
miningParameters.getNonPoaBlockTxsSelectionMaxTime(); |
|
|
|
miningConfiguration.getNonPoaBlockTxsSelectionMaxTime(); |
|
|
|
miningOptions.poaBlockTxsSelectionMaxTime = miningParameters.getPoaBlockTxsSelectionMaxTime(); |
|
|
|
miningOptions.poaBlockTxsSelectionMaxTime = |
|
|
|
|
|
|
|
miningConfiguration.getPoaBlockTxsSelectionMaxTime(); |
|
|
|
|
|
|
|
|
|
|
|
miningOptions.unstableOptions.remoteSealersLimit = |
|
|
|
miningOptions.unstableOptions.remoteSealersLimit = |
|
|
|
miningParameters.getUnstable().getRemoteSealersLimit(); |
|
|
|
miningConfiguration.getUnstable().getRemoteSealersLimit(); |
|
|
|
miningOptions.unstableOptions.remoteSealersTimeToLive = |
|
|
|
miningOptions.unstableOptions.remoteSealersTimeToLive = |
|
|
|
miningParameters.getUnstable().getRemoteSealersTimeToLive(); |
|
|
|
miningConfiguration.getUnstable().getRemoteSealersTimeToLive(); |
|
|
|
miningOptions.unstableOptions.powJobTimeToLive = |
|
|
|
miningOptions.unstableOptions.powJobTimeToLive = |
|
|
|
miningParameters.getUnstable().getPowJobTimeToLive(); |
|
|
|
miningConfiguration.getUnstable().getPowJobTimeToLive(); |
|
|
|
miningOptions.unstableOptions.maxOmmersDepth = |
|
|
|
miningOptions.unstableOptions.maxOmmersDepth = |
|
|
|
miningParameters.getUnstable().getMaxOmmerDepth(); |
|
|
|
miningConfiguration.getUnstable().getMaxOmmerDepth(); |
|
|
|
miningOptions.unstableOptions.stratumExtranonce = |
|
|
|
miningOptions.unstableOptions.stratumExtranonce = |
|
|
|
miningParameters.getUnstable().getStratumExtranonce(); |
|
|
|
miningConfiguration.getUnstable().getStratumExtranonce(); |
|
|
|
miningOptions.unstableOptions.posBlockCreationMaxTime = |
|
|
|
miningOptions.unstableOptions.posBlockCreationMaxTime = |
|
|
|
miningParameters.getUnstable().getPosBlockCreationMaxTime(); |
|
|
|
miningConfiguration.getUnstable().getPosBlockCreationMaxTime(); |
|
|
|
miningOptions.unstableOptions.posBlockCreationRepetitionMinDuration = |
|
|
|
miningOptions.unstableOptions.posBlockCreationRepetitionMinDuration = |
|
|
|
miningParameters.getUnstable().getPosBlockCreationRepetitionMinDuration(); |
|
|
|
miningConfiguration.getUnstable().getPosBlockCreationRepetitionMinDuration(); |
|
|
|
|
|
|
|
|
|
|
|
miningParameters.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase); |
|
|
|
miningConfiguration.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase); |
|
|
|
miningParameters.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl); |
|
|
|
miningConfiguration.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl); |
|
|
|
return miningOptions; |
|
|
|
return miningOptions; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public MiningParameters toDomainObject() { |
|
|
|
public MiningConfiguration toDomainObject() { |
|
|
|
checkNotNull( |
|
|
|
checkNotNull( |
|
|
|
transactionSelectionService, |
|
|
|
transactionSelectionService, |
|
|
|
"transactionSelectionService must be set before using this object"); |
|
|
|
"transactionSelectionService must be set before using this object"); |
|
|
@ -356,7 +358,7 @@ public class MiningOptions implements CLIOptions<MiningParameters> { |
|
|
|
updatableInitValuesBuilder.coinbase(coinbase); |
|
|
|
updatableInitValuesBuilder.coinbase(coinbase); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ImmutableMiningParameters.builder() |
|
|
|
return ImmutableMiningConfiguration.builder() |
|
|
|
.transactionSelectionService(transactionSelectionService) |
|
|
|
.transactionSelectionService(transactionSelectionService) |
|
|
|
.mutableInitValues(updatableInitValuesBuilder.build()) |
|
|
|
.mutableInitValues(updatableInitValuesBuilder.build()) |
|
|
|
.isStratumMiningEnabled(iStratumMiningEnabled) |
|
|
|
.isStratumMiningEnabled(iStratumMiningEnabled) |
|
|
@ -365,7 +367,7 @@ public class MiningOptions implements CLIOptions<MiningParameters> { |
|
|
|
.nonPoaBlockTxsSelectionMaxTime(nonPoaBlockTxsSelectionMaxTime) |
|
|
|
.nonPoaBlockTxsSelectionMaxTime(nonPoaBlockTxsSelectionMaxTime) |
|
|
|
.poaBlockTxsSelectionMaxTime(poaBlockTxsSelectionMaxTime) |
|
|
|
.poaBlockTxsSelectionMaxTime(poaBlockTxsSelectionMaxTime) |
|
|
|
.unstable( |
|
|
|
.unstable( |
|
|
|
ImmutableMiningParameters.Unstable.builder() |
|
|
|
ImmutableMiningConfiguration.Unstable.builder() |
|
|
|
.remoteSealersLimit(unstableOptions.remoteSealersLimit) |
|
|
|
.remoteSealersLimit(unstableOptions.remoteSealersLimit) |
|
|
|
.remoteSealersTimeToLive(unstableOptions.remoteSealersTimeToLive) |
|
|
|
.remoteSealersTimeToLive(unstableOptions.remoteSealersTimeToLive) |
|
|
|
.powJobTimeToLive(unstableOptions.powJobTimeToLive) |
|
|
|
.powJobTimeToLive(unstableOptions.powJobTimeToLive) |
|
|
|