From 8e3d46e5115cc215c84475bd3f4fc5a30266c488 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Fri, 22 Nov 2024 15:38:45 +1000 Subject: [PATCH] deprecation of PoW mining Signed-off-by: Sally MacFarlane --- .../besu/cli/options/MiningOptions.java | 37 ++++++++++++++----- .../methods/EthGetMinerDataByBlockHash.java | 1 + .../methods/EthGetMinerDataByBlockNumber.java | 1 + .../jsonrpc/internal/methods/EthGetWork.java | 1 + .../jsonrpc/internal/methods/EthHashrate.java | 1 + .../internal/methods/EthSubmitHashRate.java | 1 + .../internal/methods/EthSubmitWork.java | 1 + .../internal/methods/miner/MinerStart.java | 1 + .../internal/methods/miner/MinerStop.java | 1 + .../internal/results/MinerDataResult.java | 1 + .../blockcreation/PoWMiningCoordinator.java | 1 + .../ethereum/stratum/GetWorkProtocol.java | 1 + .../stratum/Stratum1EthProxyProtocol.java | 1 + .../ethereum/stratum/Stratum1Protocol.java | 1 + .../ethereum/stratum/StratumConnection.java | 1 + .../ethereum/stratum/StratumProtocol.java | 1 + .../besu/ethereum/stratum/StratumServer.java | 1 + 17 files changed, 43 insertions(+), 10 deletions(-) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java index fa0cf4dc068..55c8c167af9 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java @@ -52,27 +52,34 @@ /** The Mining CLI options. */ public class MiningOptions implements CLIOptions { + private static final String DEPRECATION_PREFIX = + "Deprecated. PoW consensus is deprecated. See CHANGELOG for alternative options. "; + @Option( names = {"--miner-enabled"}, - description = "Set if node will perform mining (default: ${DEFAULT-VALUE})") + description = + DEPRECATION_PREFIX + "Set if node will perform mining (default: ${DEFAULT-VALUE})") private Boolean isMiningEnabled = false; @Option( names = {"--miner-stratum-enabled"}, description = - "Set if node will perform Stratum mining (default: ${DEFAULT-VALUE})." + DEPRECATION_PREFIX + + "Set if node will perform Stratum mining (default: ${DEFAULT-VALUE})." + " Compatible with Proof of Work (PoW) only." + " Requires the network option (--network) to be set to CLASSIC.") private Boolean iStratumMiningEnabled = false; @Option( names = {"--miner-stratum-host"}, - description = "Host for Stratum network mining service (default: ${DEFAULT-VALUE})") + description = + DEPRECATION_PREFIX + + "Host for Stratum network mining service (default: ${DEFAULT-VALUE})") private String stratumNetworkInterface = "0.0.0.0"; @Option( names = {"--miner-stratum-port"}, - description = "Stratum port binding (default: ${DEFAULT-VALUE})") + description = DEPRECATION_PREFIX + "Stratum port binding (default: ${DEFAULT-VALUE})") private Integer stratumPort = 8008; @Option( @@ -124,7 +131,8 @@ public class MiningOptions implements CLIOptions { names = {"--block-txs-selection-max-time"}, converter = PositiveNumberConverter.class, description = - "Specifies the maximum time, in milliseconds, that could be spent selecting transactions to be included in the block." + DEPRECATION_PREFIX + + "Specifies the maximum time, in milliseconds, that could be spent selecting transactions to be included in the block." + " 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; @@ -146,34 +154,40 @@ static class Unstable { hidden = true, names = {"--Xminer-remote-sealers-limit"}, description = - "Limits the number of remote sealers that can submit their hashrates (default: ${DEFAULT-VALUE})") + DEPRECATION_PREFIX + + "Limits the number of remote sealers that can submit their hashrates (default: ${DEFAULT-VALUE})") private Integer remoteSealersLimit = DEFAULT_REMOTE_SEALERS_LIMIT; @CommandLine.Option( hidden = true, names = {"--Xminer-remote-sealers-hashrate-ttl"}, description = - "Specifies the lifetime of each entry in the cache. An entry will be automatically deleted if no update has been received before the deadline (default: ${DEFAULT-VALUE} minutes)") + DEPRECATION_PREFIX + + "Specifies the lifetime of each entry in the cache. An entry will be automatically deleted if no update has been received before the deadline (default: ${DEFAULT-VALUE} minutes)") private Long remoteSealersTimeToLive = DEFAULT_REMOTE_SEALERS_TTL; @CommandLine.Option( hidden = true, names = {"--Xminer-pow-job-ttl"}, description = - "Specifies the time PoW jobs are kept in cache and will accept a solution from miners (default: ${DEFAULT-VALUE} milliseconds)") + DEPRECATION_PREFIX + + "Specifies the time PoW jobs are kept in cache and will accept a solution from miners (default: ${DEFAULT-VALUE} milliseconds)") private Long powJobTimeToLive = DEFAULT_POW_JOB_TTL; @CommandLine.Option( hidden = true, names = {"--Xmax-ommers-depth"}, description = - "Specifies the depth of ommer blocks to accept when receiving solutions (default: ${DEFAULT-VALUE})") + DEPRECATION_PREFIX + + "Specifies the depth of ommer blocks to accept when receiving solutions (default: ${DEFAULT-VALUE})") private Integer maxOmmersDepth = DEFAULT_MAX_OMMERS_DEPTH; @CommandLine.Option( hidden = true, names = {"--Xminer-stratum-extranonce"}, - description = "Extranonce for Stratum network miners (default: ${DEFAULT-VALUE})") + description = + DEPRECATION_PREFIX + + "Extranonce for Stratum network miners (default: ${DEFAULT-VALUE})") private String stratumExtranonce = "080c"; @CommandLine.Option( @@ -230,6 +244,9 @@ public void validate( final GenesisConfigOptions genesisConfigOptions, final boolean isMergeEnabled, final Logger logger) { + if (Boolean.TRUE.equals(isMiningEnabled)) { + logger.warn("PoW consensus is deprecated. See CHANGELOG for alternative options."); + } if (Boolean.TRUE.equals(isMiningEnabled) && coinbase == null) { throw new ParameterException( commandLine, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockHash.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockHash.java index 8b54364a999..15fe654ea63 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockHash.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockHash.java @@ -41,6 +41,7 @@ import com.google.common.base.Suppliers; import org.apache.tuweni.units.bigints.BaseUInt256Value; +@Deprecated(since = "24.11.0") public class EthGetMinerDataByBlockHash implements JsonRpcMethod { private final Supplier blockchain; private final ProtocolSchedule protocolSchedule; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockNumber.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockNumber.java index e0fe2460626..9e7b488a892 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockNumber.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockNumber.java @@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +@Deprecated(since = "24.11.0") public class EthGetMinerDataByBlockNumber extends AbstractBlockParameterMethod { private final ProtocolSchedule protocolSchedule; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetWork.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetWork.java index 5c9a413eb3a..db17e804628 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetWork.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetWork.java @@ -35,6 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Deprecated(since = "24.11.0") public class EthGetWork implements JsonRpcMethod { private final MiningCoordinator miner; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthHashrate.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthHashrate.java index 855a757562f..372eaa64dc6 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthHashrate.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthHashrate.java @@ -23,6 +23,7 @@ import java.util.Optional; +@Deprecated(since = "24.11.0") public class EthHashrate implements JsonRpcMethod { private final MiningCoordinator miningCoordinator; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitHashRate.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitHashRate.java index 488f89b3a58..7ebe573e05e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitHashRate.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitHashRate.java @@ -25,6 +25,7 @@ import org.apache.tuweni.bytes.Bytes; +@Deprecated(since = "24.11.0") public class EthSubmitHashRate implements JsonRpcMethod { private final MiningCoordinator miningCoordinator; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitWork.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitWork.java index 9002b2a0ddf..0d18bd39b30 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitWork.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSubmitWork.java @@ -33,6 +33,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Deprecated(since = "24.11.0") public class EthSubmitWork implements JsonRpcMethod { private final MiningCoordinator miner; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerStart.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerStart.java index ca8c341823e..8976817457c 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerStart.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerStart.java @@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.blockcreation.CoinbaseNotSetException; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; +@Deprecated(since = "24.11.0") public class MinerStart implements JsonRpcMethod { private final MiningCoordinator miningCoordinator; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerStop.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerStop.java index 267fe0877b9..ea295c803c3 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerStop.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerStop.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; +@Deprecated(since = "24.11.0") public class MinerStop implements JsonRpcMethod { private final MiningCoordinator miningCoordinator; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/MinerDataResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/MinerDataResult.java index 63fb4dde513..4ba6a38e071 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/MinerDataResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/MinerDataResult.java @@ -19,6 +19,7 @@ import org.immutables.value.Value; @Value.Immutable +@Deprecated(since = "24.11.0") public abstract class MinerDataResult implements JsonRpcResult { public abstract String getNetBlockReward(); diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinator.java index 1c94bb7821a..884d0c167cf 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinator.java @@ -35,6 +35,7 @@ * Responsible for determining when a block mining operation should be started/stopped, then * creating an appropriate miner and starting it running in a thread. */ +@Deprecated(since = "24.11.0") public class PoWMiningCoordinator extends AbstractMiningCoordinator implements BlockAddedObserver { diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/GetWorkProtocol.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/GetWorkProtocol.java index 262956c32f9..794a5847c56 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/GetWorkProtocol.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/GetWorkProtocol.java @@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory; /** Protocol using JSON-RPC HTTP methods to provide getWork/submitWork methods. */ +@Deprecated(since = "24.11.0") public class GetWorkProtocol implements StratumProtocol { private static final Logger LOG = LoggerFactory.getLogger(GetWorkProtocol.class); private static final ObjectMapper mapper = new ObjectMapper(); diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1EthProxyProtocol.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1EthProxyProtocol.java index 0506fa1e25b..50545fb2bcc 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1EthProxyProtocol.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1EthProxyProtocol.java @@ -43,6 +43,7 @@ * *

This protocol allows miners to submit EthHash solutions over a persistent TCP connection. */ +@Deprecated(since = "24.11.0") public class Stratum1EthProxyProtocol implements StratumProtocol { private static final Logger LOG = LoggerFactory.getLogger(Stratum1EthProxyProtocol.class); private static final JsonMapper mapper = new JsonMapper(); diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1Protocol.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1Protocol.java index 4311647948d..a1c95a45051 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1Protocol.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/Stratum1Protocol.java @@ -50,6 +50,7 @@ * *

This protocol allows miners to submit EthHash solutions over a persistent TCP connection. */ +@Deprecated(since = "24.11.0") public class Stratum1Protocol implements StratumProtocol { private static final Logger LOG = LoggerFactory.getLogger(Stratum1Protocol.class); private static final JsonMapper mapper = new JsonMapper(); diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumConnection.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumConnection.java index 5db1957bfd0..a841cb3d2df 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumConnection.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumConnection.java @@ -24,6 +24,7 @@ * Persistent TCP connection using a variant of the Stratum protocol, connecting the client to * miners. */ +@Deprecated(since = "24.11.0") final class StratumConnection { private static final Logger LOG = LoggerFactory.getLogger(StratumConnection.class); diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumProtocol.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumProtocol.java index a6a8ac88071..585da71566f 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumProtocol.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumProtocol.java @@ -37,6 +37,7 @@ *

Manages the lifecycle of a TCP connection according to a particular variant of the Stratum * protocol. */ +@Deprecated(since = "24.11.0") public interface StratumProtocol { /** diff --git a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumServer.java b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumServer.java index 7990b883905..1eaf19fbcd2 100644 --- a/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumServer.java +++ b/ethereum/stratum/src/main/java/org/hyperledger/besu/ethereum/stratum/StratumServer.java @@ -65,6 +65,7 @@ * TCP server allowing miners to connect to the client over persistent TCP connections, using the * various Stratum protocols. */ +@Deprecated(since = "24.11.0") public class StratumServer implements PoWObserver { private static final Logger logger = LoggerFactory.getLogger(StratumServer.class);