From 03a2b92f0011d6cd91e1068436a8abe48a3703cc Mon Sep 17 00:00:00 2001 From: Justin Florentine Date: Mon, 4 Nov 2024 15:36:11 -0500 Subject: [PATCH 01/20] IntelliJ do not fail me (#7855) Signed-off-by: jflo --- .../dsl/node/ProcessBesuNodeRunner.java | 2 +- .../org/hyperledger/besu/RunnerBuilder.java | 2 +- .../org/hyperledger/besu/cli/BesuCommand.java | 52 +++++++++---------- .../{stable => }/ApiConfigurationOptions.java | 2 +- .../{unstable => }/ChainPruningOptions.java | 3 +- .../options/{unstable => }/DnsOptions.java | 3 +- .../{stable => }/EngineRPCConfiguration.java | 2 +- .../{stable => }/EngineRPCOptions.java | 3 +- .../{unstable => }/EthProtocolOptions.java | 4 +- .../options/{stable => }/EthstatsOptions.java | 3 +- .../options/{unstable => }/EvmOptions.java | 3 +- .../options/{stable => }/GraphQlOptions.java | 2 +- .../{unstable => }/InProcessRpcOptions.java | 3 +- .../options/{unstable => }/IpcOptions.java | 2 +- .../{stable => }/JsonRpcHttpOptions.java | 2 +- .../{stable => }/LoggingLevelOption.java | 2 +- .../options/{stable => }/MetricsOptions.java | 3 +- .../options/{unstable => }/NatOptions.java | 2 +- .../{unstable => }/NativeLibraryOptions.java | 2 +- .../{unstable => }/NetworkingOptions.java | 4 +- .../NodePrivateKeyFileOption.java | 2 +- .../{stable => }/P2PDiscoveryOptions.java | 3 +- .../{unstable => }/P2PTLSConfigOptions.java | 2 +- .../{stable => }/PermissionsOptions.java | 2 +- .../PluginsConfigurationOptions.java | 3 +- .../{unstable => }/PrivacyPluginOptions.java | 2 +- .../options/{unstable => }/RPCOptions.java | 2 +- .../{stable => }/RpcWebsocketOptions.java | 2 +- .../{unstable => }/SynchronizerOptions.java | 4 +- .../cli/subcommands/PublicKeySubCommand.java | 2 +- .../besu/components/BesuCommandModule.java | 4 +- .../besu/services/BesuConfigurationImpl.java | 2 +- .../besu/cli/CommandTestAbstract.java | 8 +-- .../cli/options/EthProtocolOptionsTest.java | 1 - .../{stable => }/LoggingLevelOptionTest.java | 2 +- .../besu/cli/options/MetricsOptionsTest.java | 1 - .../cli/options/NetworkingOptionsTest.java | 1 - .../cli/options/SynchronizerOptionsTest.java | 1 - ...onfigDefaultValueProviderStrategyTest.java | 2 +- 39 files changed, 64 insertions(+), 83 deletions(-) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/ApiConfigurationOptions.java (99%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/ChainPruningOptions.java (98%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/DnsOptions.java (96%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/EngineRPCConfiguration.java (96%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/EngineRPCOptions.java (96%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/EthProtocolOptions.java (97%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/EthstatsOptions.java (96%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/EvmOptions.java (96%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/GraphQlOptions.java (98%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/InProcessRpcOptions.java (96%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/IpcOptions.java (98%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/JsonRpcHttpOptions.java (99%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/LoggingLevelOption.java (97%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/MetricsOptions.java (99%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/NatOptions.java (97%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/NativeLibraryOptions.java (98%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/NetworkingOptions.java (96%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/NodePrivateKeyFileOption.java (96%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/P2PDiscoveryOptions.java (98%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/P2PTLSConfigOptions.java (99%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/PermissionsOptions.java (99%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/PluginsConfigurationOptions.java (97%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/PrivacyPluginOptions.java (96%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/RPCOptions.java (97%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{stable => }/RpcWebsocketOptions.java (99%) rename besu/src/main/java/org/hyperledger/besu/cli/options/{unstable => }/SynchronizerOptions.java (99%) rename besu/src/test/java/org/hyperledger/besu/cli/options/{stable => }/LoggingLevelOptionTest.java (97%) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java index 75307d9520..ee865a8142 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java @@ -17,9 +17,9 @@ package org.hyperledger.besu.tests.acceptance.dsl.node; import static com.google.common.base.Preconditions.checkState; import static java.nio.charset.StandardCharsets.UTF_8; +import org.hyperledger.besu.cli.options.NetworkingOptions; import org.hyperledger.besu.cli.options.TransactionPoolOptions; import org.hyperledger.besu.cli.options.storage.DataStorageOptions; -import org.hyperledger.besu.cli.options.unstable.NetworkingOptions; import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index d6619d6c12..06dca6c6f0 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -23,7 +23,7 @@ import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIV import org.hyperledger.besu.cli.config.EthNetworkConfig; import org.hyperledger.besu.cli.config.NetworkName; -import org.hyperledger.besu.cli.options.stable.EthstatsOptions; +import org.hyperledger.besu.cli.options.EthstatsOptions; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.ethereum.ProtocolContext; 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 b974dcd315..8f4a1472fb 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -40,36 +40,36 @@ import org.hyperledger.besu.cli.config.ProfilesCompletionCandidates; import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty; import org.hyperledger.besu.cli.error.BesuExecutionExceptionHandler; import org.hyperledger.besu.cli.error.BesuParameterExceptionHandler; +import org.hyperledger.besu.cli.options.ApiConfigurationOptions; +import org.hyperledger.besu.cli.options.ChainPruningOptions; +import org.hyperledger.besu.cli.options.DnsOptions; +import org.hyperledger.besu.cli.options.EngineRPCConfiguration; +import org.hyperledger.besu.cli.options.EngineRPCOptions; +import org.hyperledger.besu.cli.options.EthProtocolOptions; +import org.hyperledger.besu.cli.options.EthstatsOptions; +import org.hyperledger.besu.cli.options.EvmOptions; +import org.hyperledger.besu.cli.options.GraphQlOptions; +import org.hyperledger.besu.cli.options.InProcessRpcOptions; +import org.hyperledger.besu.cli.options.IpcOptions; +import org.hyperledger.besu.cli.options.JsonRpcHttpOptions; +import org.hyperledger.besu.cli.options.LoggingLevelOption; +import org.hyperledger.besu.cli.options.MetricsOptions; import org.hyperledger.besu.cli.options.MiningOptions; +import org.hyperledger.besu.cli.options.NatOptions; +import org.hyperledger.besu.cli.options.NativeLibraryOptions; +import org.hyperledger.besu.cli.options.NetworkingOptions; +import org.hyperledger.besu.cli.options.NodePrivateKeyFileOption; +import org.hyperledger.besu.cli.options.P2PDiscoveryOptions; +import org.hyperledger.besu.cli.options.P2PTLSConfigOptions; +import org.hyperledger.besu.cli.options.PermissionsOptions; +import org.hyperledger.besu.cli.options.PluginsConfigurationOptions; +import org.hyperledger.besu.cli.options.PrivacyPluginOptions; +import org.hyperledger.besu.cli.options.RPCOptions; +import org.hyperledger.besu.cli.options.RpcWebsocketOptions; +import org.hyperledger.besu.cli.options.SynchronizerOptions; import org.hyperledger.besu.cli.options.TransactionPoolOptions; -import org.hyperledger.besu.cli.options.stable.ApiConfigurationOptions; -import org.hyperledger.besu.cli.options.stable.EngineRPCConfiguration; -import org.hyperledger.besu.cli.options.stable.EngineRPCOptions; -import org.hyperledger.besu.cli.options.stable.EthstatsOptions; -import org.hyperledger.besu.cli.options.stable.GraphQlOptions; -import org.hyperledger.besu.cli.options.stable.JsonRpcHttpOptions; -import org.hyperledger.besu.cli.options.stable.LoggingLevelOption; -import org.hyperledger.besu.cli.options.stable.MetricsOptions; -import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption; -import org.hyperledger.besu.cli.options.stable.P2PDiscoveryOptions; -import org.hyperledger.besu.cli.options.stable.PermissionsOptions; -import org.hyperledger.besu.cli.options.stable.PluginsConfigurationOptions; -import org.hyperledger.besu.cli.options.stable.RpcWebsocketOptions; import org.hyperledger.besu.cli.options.storage.DataStorageOptions; import org.hyperledger.besu.cli.options.storage.DiffBasedSubStorageOptions; -import org.hyperledger.besu.cli.options.unstable.ChainPruningOptions; -import org.hyperledger.besu.cli.options.unstable.DnsOptions; -import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions; -import org.hyperledger.besu.cli.options.unstable.EvmOptions; -import org.hyperledger.besu.cli.options.unstable.InProcessRpcOptions; -import org.hyperledger.besu.cli.options.unstable.IpcOptions; -import org.hyperledger.besu.cli.options.unstable.NatOptions; -import org.hyperledger.besu.cli.options.unstable.NativeLibraryOptions; -import org.hyperledger.besu.cli.options.unstable.NetworkingOptions; -import org.hyperledger.besu.cli.options.unstable.P2PTLSConfigOptions; -import org.hyperledger.besu.cli.options.unstable.PrivacyPluginOptions; -import org.hyperledger.besu.cli.options.unstable.RPCOptions; -import org.hyperledger.besu.cli.options.unstable.SynchronizerOptions; import org.hyperledger.besu.cli.presynctasks.PreSynchronizationTaskRunner; import org.hyperledger.besu.cli.presynctasks.PrivateDatabaseMigrationPreSyncTask; import org.hyperledger.besu.cli.subcommands.PasswordSubCommand; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java similarity index 99% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java index d6bc17026c..c5954f5063 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import static java.util.Arrays.asList; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/ChainPruningOptions.java similarity index 98% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/ChainPruningOptions.java index 0a59ef9b04..3f26b676ce 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/ChainPruningOptions.java @@ -12,9 +12,8 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; -import org.hyperledger.besu.cli.options.CLIOptions; import org.hyperledger.besu.ethereum.chain.ChainPrunerConfiguration; import org.hyperledger.besu.util.number.PositiveNumber; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/DnsOptions.java similarity index 96% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/DnsOptions.java index 9f9670e8e6..9a720bebbb 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/DnsOptions.java @@ -12,9 +12,8 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; -import org.hyperledger.besu.cli.options.CLIOptions; import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration; import org.hyperledger.besu.ethereum.p2p.peers.ImmutableEnodeDnsConfiguration; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCConfiguration.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCConfiguration.java similarity index 96% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCConfiguration.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCConfiguration.java index c0eb9d1be0..ec98204d3b 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCConfiguration.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCConfiguration.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCOptions.java similarity index 96% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCOptions.java index 1aa5b3d326..e660e6c821 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCOptions.java @@ -12,13 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_ENGINE_JSON_RPC_PORT; import org.hyperledger.besu.cli.DefaultCommandValues; import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty; -import org.hyperledger.besu.cli.options.CLIOptions; import org.hyperledger.besu.cli.util.CommandLineUtils; import java.nio.file.Path; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EthProtocolOptions.java similarity index 97% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/EthProtocolOptions.java index 1d5434ff02..a20403027d 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EthProtocolOptions.java @@ -12,10 +12,8 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; -import org.hyperledger.besu.cli.options.CLIOptions; -import org.hyperledger.besu.cli.options.OptionParser; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.util.number.PositiveNumber; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EthstatsOptions.java similarity index 96% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/EthstatsOptions.java index a6e939fdf0..08e8b49c52 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EthstatsOptions.java @@ -12,9 +12,8 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; -import org.hyperledger.besu.cli.options.CLIOptions; import org.hyperledger.besu.ethstats.util.EthStatsConnectOptions; import java.nio.file.Path; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EvmOptions.java similarity index 96% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/EvmOptions.java index 39d95324df..6a58d6830a 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EvmOptions.java @@ -12,9 +12,8 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; -import org.hyperledger.besu.cli.options.CLIOptions; import org.hyperledger.besu.evm.internal.EvmConfiguration; import java.util.List; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/GraphQlOptions.java similarity index 98% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/GraphQlOptions.java index 6aac24a6fb..643ca22e00 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/GraphQlOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import static java.util.Arrays.asList; import static org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_PORT; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/InProcessRpcOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/InProcessRpcOptions.java similarity index 96% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/InProcessRpcOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/InProcessRpcOptions.java index 9adeb37db7..278a55e187 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/InProcessRpcOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/InProcessRpcOptions.java @@ -12,12 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; import static org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration.DEFAULT_IN_PROCESS_RPC_APIS; import static org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration.DEFAULT_IN_PROCESS_RPC_ENABLED; -import org.hyperledger.besu.cli.options.CLIOptions; import org.hyperledger.besu.cli.util.CommandLineUtils; import org.hyperledger.besu.ethereum.api.jsonrpc.ImmutableInProcessRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/IpcOptions.java similarity index 98% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/IpcOptions.java index 19ba294193..689ac4e9b3 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/IpcOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/JsonRpcHttpOptions.java similarity index 99% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/JsonRpcHttpOptions.java index 7d08a6f9aa..c8c2c73344 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/JsonRpcHttpOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import static java.util.Arrays.asList; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_HOST; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java b/besu/src/main/java/org/hyperledger/besu/cli/options/LoggingLevelOption.java similarity index 97% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/LoggingLevelOption.java index 39b2a2482b..1a498fd196 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/LoggingLevelOption.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import java.util.Locale; import java.util.Set; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/MetricsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/MetricsOptions.java similarity index 99% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/MetricsOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/MetricsOptions.java index beba20e29b..1f777286bf 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/MetricsOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/MetricsOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import static com.google.common.base.Preconditions.checkState; import static java.util.stream.Collectors.toUnmodifiableSet; @@ -24,7 +24,6 @@ import static org.hyperledger.besu.metrics.MetricsProtocol.PROMETHEUS; import static org.hyperledger.besu.metrics.prometheus.MetricsConfiguration.DEFAULT_METRICS_PORT; import static org.hyperledger.besu.metrics.prometheus.MetricsConfiguration.DEFAULT_METRICS_PUSH_PORT; -import org.hyperledger.besu.cli.options.CLIOptions; import org.hyperledger.besu.cli.util.CommandLineUtils; import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl; import org.hyperledger.besu.metrics.MetricsProtocol; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NatOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NatOptions.java similarity index 97% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NatOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/NatOptions.java index 31716543d5..11e8051d0e 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NatOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NatOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; import static org.hyperledger.besu.nat.kubernetes.KubernetesNatManager.DEFAULT_BESU_SERVICE_NAME_FILTER; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NativeLibraryOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NativeLibraryOptions.java similarity index 98% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NativeLibraryOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/NativeLibraryOptions.java index ec7f043b8f..f3fc9c3ba4 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NativeLibraryOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NativeLibraryOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; import picocli.CommandLine; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NetworkingOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NetworkingOptions.java similarity index 96% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NetworkingOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/NetworkingOptions.java index aed7b079d8..dc001d0231 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NetworkingOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NetworkingOptions.java @@ -12,10 +12,8 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; -import org.hyperledger.besu.cli.options.CLIOptions; -import org.hyperledger.besu.cli.options.OptionParser; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import java.util.Arrays; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NodePrivateKeyFileOption.java similarity index 96% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/NodePrivateKeyFileOption.java index 107ced545d..781dcb06e8 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NodePrivateKeyFileOption.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PDiscoveryOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PDiscoveryOptions.java similarity index 98% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PDiscoveryOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/P2PDiscoveryOptions.java index a15be99dc7..798d246b52 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PDiscoveryOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PDiscoveryOptions.java @@ -12,12 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import org.hyperledger.besu.cli.DefaultCommandValues; import org.hyperledger.besu.cli.converter.PercentageConverter; import org.hyperledger.besu.cli.converter.SubnetInfoConverter; -import org.hyperledger.besu.cli.options.CLIOptions; import org.hyperledger.besu.cli.util.CommandLineUtils; import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/P2PTLSConfigOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PTLSConfigOptions.java similarity index 99% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/P2PTLSConfigOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/P2PTLSConfigOptions.java index 5939eb3d39..ee53a5e96f 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/P2PTLSConfigOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PTLSConfigOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; import static java.util.Arrays.asList; import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_KEYSTORE_TYPE; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/PermissionsOptions.java similarity index 99% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/PermissionsOptions.java index 4dc693d36e..b6c744c98f 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/PermissionsOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import org.hyperledger.besu.cli.DefaultCommandValues; import org.hyperledger.besu.datatypes.Address; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/PluginsConfigurationOptions.java similarity index 97% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/PluginsConfigurationOptions.java index 25893fff89..5a5a064608 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/PluginsConfigurationOptions.java @@ -12,14 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_CONTINUE_ON_PLUGIN_ERROR_OPTION_NAME; import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_EXTERNAL_ENABLED_OPTION_NAME; import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_OPTION_NAME; import org.hyperledger.besu.cli.converter.PluginInfoConverter; -import org.hyperledger.besu.cli.options.CLIOptions; import org.hyperledger.besu.cli.util.CommandLineUtils; import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; import org.hyperledger.besu.ethereum.core.plugins.PluginInfo; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/PrivacyPluginOptions.java similarity index 96% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/PrivacyPluginOptions.java index fe2f4df3fe..9a8c0348e8 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/PrivacyPluginOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; import static picocli.CommandLine.Option; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/RPCOptions.java similarity index 97% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/RPCOptions.java index 2dd11f428d..63759af1c6 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/RPCOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java similarity index 99% rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java index 40edeecc0d..d596d4183c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.VALID_APIS; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/SynchronizerOptions.java similarity index 99% rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java rename to besu/src/main/java/org/hyperledger/besu/cli/options/SynchronizerOptions.java index 816d9df00a..c7d20c17fb 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/SynchronizerOptions.java @@ -12,10 +12,8 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.unstable; +package org.hyperledger.besu.cli.options; -import org.hyperledger.besu.cli.options.CLIOptions; -import org.hyperledger.besu.cli.options.OptionParser; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.snapsync.ImmutableSnapSyncConfiguration; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java index 73916a936e..593fc6cd77 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java @@ -20,7 +20,7 @@ import static org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.COMMAND_N import org.hyperledger.besu.cli.BesuCommand; import org.hyperledger.besu.cli.DefaultCommandValues; -import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption; +import org.hyperledger.besu.cli.options.NodePrivateKeyFileOption; import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.AddressSubCommand; import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.ExportSubCommand; import org.hyperledger.besu.cli.util.VersionProvider; diff --git a/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java b/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java index e757fd62a2..ce4f00db73 100644 --- a/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java +++ b/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java @@ -20,8 +20,8 @@ import org.hyperledger.besu.chainexport.RlpBlockExporter; import org.hyperledger.besu.chainimport.JsonBlockImporter; import org.hyperledger.besu.chainimport.RlpBlockImporter; import org.hyperledger.besu.cli.BesuCommand; -import org.hyperledger.besu.cli.options.stable.P2PDiscoveryOptions; -import org.hyperledger.besu.cli.options.unstable.RPCOptions; +import org.hyperledger.besu.cli.options.P2PDiscoveryOptions; +import org.hyperledger.besu.cli.options.RPCOptions; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java index 39db58ee4d..f2f5fa53da 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.services; -import org.hyperledger.besu.cli.options.stable.JsonRpcHttpOptions; +import org.hyperledger.besu.cli.options.JsonRpcHttpOptions; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java index 5c7bf3ce88..7239659398 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java @@ -34,13 +34,13 @@ import org.hyperledger.besu.chainexport.RlpBlockExporter; import org.hyperledger.besu.chainimport.JsonBlockImporter; import org.hyperledger.besu.chainimport.RlpBlockImporter; import org.hyperledger.besu.cli.config.EthNetworkConfig; +import org.hyperledger.besu.cli.options.EthProtocolOptions; +import org.hyperledger.besu.cli.options.EthstatsOptions; import org.hyperledger.besu.cli.options.MiningOptions; +import org.hyperledger.besu.cli.options.NetworkingOptions; +import org.hyperledger.besu.cli.options.SynchronizerOptions; import org.hyperledger.besu.cli.options.TransactionPoolOptions; -import org.hyperledger.besu.cli.options.stable.EthstatsOptions; import org.hyperledger.besu.cli.options.storage.DataStorageOptions; -import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions; -import org.hyperledger.besu.cli.options.unstable.NetworkingOptions; -import org.hyperledger.besu.cli.options.unstable.SynchronizerOptions; import org.hyperledger.besu.components.BesuComponent; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.controller.BesuController; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java index 6f7aa637cd..33c91f2c03 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java @@ -18,7 +18,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verifyNoInteractions; -import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.junit.jupiter.api.Test; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/LoggingLevelOptionTest.java similarity index 97% rename from besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java rename to besu/src/test/java/org/hyperledger/besu/cli/options/LoggingLevelOptionTest.java index b1fb3217c2..78c0f694ad 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/LoggingLevelOptionTest.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.cli.options.stable; +package org.hyperledger.besu.cli.options; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java index cd541759ad..39e77cbad7 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.cli.options; -import org.hyperledger.besu.cli.options.stable.MetricsOptions; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl; import org.hyperledger.besu.metrics.StandardMetricCategory; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java index a645f28b54..191b1a8299 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java @@ -17,7 +17,6 @@ package org.hyperledger.besu.cli.options; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; -import org.hyperledger.besu.cli.options.unstable.NetworkingOptions; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import java.util.Arrays; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java index 0511279c19..0a257de6da 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.cli.options; -import org.hyperledger.besu.cli.options.unstable.SynchronizerOptions; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.snapsync.ImmutableSnapSyncConfiguration; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigDefaultValueProviderStrategyTest.java b/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigDefaultValueProviderStrategyTest.java index 50eadceb3b..30eb677e88 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigDefaultValueProviderStrategyTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigDefaultValueProviderStrategyTest.java @@ -25,7 +25,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.hyperledger.besu.cli.error.BesuParameterExceptionHandler; -import org.hyperledger.besu.cli.options.stable.LoggingLevelOption; +import org.hyperledger.besu.cli.options.LoggingLevelOption; import java.io.File; import java.io.IOException; From 1da0e9f232d568ec899615bd1e51a4b53d2a7cdd Mon Sep 17 00:00:00 2001 From: garyschulte Date: Mon, 4 Nov 2024 13:16:36 -0800 Subject: [PATCH 02/20] remove dangling retesteth references (#7856) Signed-off-by: garyschulte --- besu/build.gradle | 1 - build.gradle | 3 --- settings.gradle | 1 - 3 files changed, 5 deletions(-) diff --git a/besu/build.gradle b/besu/build.gradle index 41a4b11494..b6e506d9c1 100644 --- a/besu/build.gradle +++ b/besu/build.gradle @@ -49,7 +49,6 @@ dependencies { implementation project(':ethereum:eth') implementation project(':ethereum:p2p') implementation project(':ethereum:permissioning') - implementation project(':ethereum:retesteth') implementation project(':ethereum:rlp') implementation project(':ethereum:trie') implementation project(':ethereum:stratum') diff --git a/build.gradle b/build.gradle index 4fe80600c2..8b6982cd4a 100644 --- a/build.gradle +++ b/build.gradle @@ -417,9 +417,6 @@ configure(allprojects - project(':platform')) { '-org.hyperledger.besu.ethereum.permissioning.*,' + // referencetests module '-org.hyperledger.besu.ethereum.referencetests,' + - // retesteth module - '-org.hyperledger.besu.ethereum.retesteth.methods,' + - '-org.hyperledger.besu.ethereum.retesteth,' + //rlp module '-org.hyperledger.besu.ethereum.rlp,' + // stratum module diff --git a/settings.gradle b/settings.gradle index 2860c666d9..83363f70e4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -51,7 +51,6 @@ include 'ethereum:mock-p2p' include 'ethereum:p2p' include 'ethereum:permissioning' include 'ethereum:referencetests' -include 'ethereum:retesteth' include 'ethereum:rlp' include 'ethereum:stratum' include 'ethereum:ethstats' From d415b7db532a32123cb2c8cc14c6d71f6b988e60 Mon Sep 17 00:00:00 2001 From: garyschulte Date: Mon, 4 Nov 2024 15:05:16 -0800 Subject: [PATCH 03/20] feature: Add optional worldstate move flag to debug_setHead (#7821) * add optional worldstate move to debug_setHead * make state rolling occur incrementally so as not to overwhelm memory and resources Signed-off-by: garyschulte --- .../internal/methods/DebugSetHead.java | 123 ++++++++++- .../internal/methods/DebugSetHeadTest.java | 198 ++++++++++++++++++ 2 files changed, 310 insertions(+), 11 deletions(-) create mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHeadTest.java diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHead.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHead.java index 7958f8e759..c2210f8174 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHead.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHead.java @@ -21,22 +21,41 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; +import org.hyperledger.besu.ethereum.chain.MutableBlockchain; +import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedWorldStateProvider; import java.util.Optional; -public class DebugSetHead extends AbstractBlockParameterMethod { +import graphql.VisibleForTesting; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DebugSetHead extends AbstractBlockParameterOrBlockHashMethod { private final ProtocolContext protocolContext; + private static final Logger LOG = LoggerFactory.getLogger(DebugSetHead.class); + private static final int DEFAULT_MAX_TRIE_LOGS_TO_ROLL_AT_ONCE = 512; + + private final long maxTrieLogsToRollAtOnce; public DebugSetHead(final BlockchainQueries blockchain, final ProtocolContext protocolContext) { - super(blockchain); + this(blockchain, protocolContext, DEFAULT_MAX_TRIE_LOGS_TO_ROLL_AT_ONCE); + } + @VisibleForTesting + DebugSetHead( + final BlockchainQueries blockchain, + final ProtocolContext protocolContext, + final long maxTrieLogsToRollAtOnce) { + super(blockchain); this.protocolContext = protocolContext; + this.maxTrieLogsToRollAtOnce = Math.abs(maxTrieLogsToRollAtOnce); } @Override @@ -45,26 +64,108 @@ public class DebugSetHead extends AbstractBlockParameterMethod { } @Override - protected BlockParameter blockParameter(final JsonRpcRequestContext request) { + protected BlockParameterOrBlockHash blockParameterOrBlockHash( + final JsonRpcRequestContext requestContext) { try { - return request.getRequiredParameter(0, BlockParameter.class); + return requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class); } catch (JsonRpcParameterException e) { throw new InvalidJsonRpcParameters( - "Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e); + "Invalid block or block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e); } } @Override - protected Object resultByBlockNumber( - final JsonRpcRequestContext request, final long blockNumber) { - final Optional maybeBlockHash = getBlockchainQueries().getBlockHashByNumber(blockNumber); + protected Object resultByBlockHash(final JsonRpcRequestContext request, final Hash blockHash) { + var blockchainQueries = getBlockchainQueries(); + var blockchain = protocolContext.getBlockchain(); + Optional maybeBlockHeader = blockchainQueries.getBlockHeaderByHash(blockHash); + Optional maybeMoveWorldstate = shouldMoveWorldstate(request); - if (maybeBlockHash.isEmpty()) { + if (maybeBlockHeader.isEmpty()) { return new JsonRpcErrorResponse(request.getRequest().getId(), UNKNOWN_BLOCK); } - protocolContext.getBlockchain().rewindToBlock(maybeBlockHash.get()); + // Optionally move the worldstate to the specified blockhash, if it is present in the chain + if (maybeMoveWorldstate.orElse(Boolean.FALSE)) { + var archive = blockchainQueries.getWorldStateArchive(); + + // Only DiffBasedWorldState's need to be moved: + if (archive instanceof DiffBasedWorldStateProvider diffBasedArchive) { + if (rollIncrementally(maybeBlockHeader.get(), blockchain, diffBasedArchive)) { + return JsonRpcSuccessResponse.SUCCESS_RESULT; + } + } + } + + // If we are not rolling incrementally or if there was an error incrementally rolling, + // move the blockchain to the requested hash: + blockchain.rewindToBlock(maybeBlockHeader.get().getBlockHash()); return JsonRpcSuccessResponse.SUCCESS_RESULT; } + + private boolean rollIncrementally( + final BlockHeader target, + final MutableBlockchain blockchain, + final DiffBasedWorldStateProvider archive) { + + try { + if (archive.isWorldStateAvailable(target.getStateRoot(), target.getBlockHash())) { + // WARNING, this can be dangerous for a DiffBasedWorldstate if a concurrent + // process attempts to move or modify the head worldstate. + // Ensure no block processing is occuring when using this feature. + // No engine-api, block import, sync, mining or other rpc calls should be running. + + Optional currentHead = + archive + .getWorldStateKeyValueStorage() + .getWorldStateBlockHash() + .flatMap(blockchain::getBlockHeader); + + while (currentHead.isPresent() + && !target.getStateRoot().equals(currentHead.get().getStateRoot())) { + long delta = currentHead.get().getNumber() - target.getNumber(); + + if (maxTrieLogsToRollAtOnce < Math.abs(delta)) { + // do we need to move forward or backward? + long distanceToMove = (delta > 0) ? -maxTrieLogsToRollAtOnce : maxTrieLogsToRollAtOnce; + + // Add distanceToMove to the current block number to get the interim target header + var interimHead = + blockchain.getBlockHeader(currentHead.get().getNumber() + distanceToMove); + + interimHead.ifPresent( + it -> { + blockchain.rewindToBlock(it.getBlockHash()); + archive.getMutable(it.getStateRoot(), it.getBlockHash()); + LOG.info("incrementally rolled worldstate to {}", it.toLogString()); + }); + currentHead = interimHead; + + } else { + blockchain.rewindToBlock(target.getBlockHash()); + archive.getMutable(target.getStateRoot(), target.getBlockHash()); + currentHead = Optional.of(target); + LOG.info("finished rolling worldstate to {}", target.toLogString()); + } + } + } + + return true; + } catch (Exception ex) { + LOG.error("Failed to incrementally roll blockchain to " + target.toLogString(), ex); + return false; + } + } + + private Optional shouldMoveWorldstate(final JsonRpcRequestContext request) { + try { + return request.getOptionalParameter(1, Boolean.class); + } catch (JsonRpcParameterException e) { + throw new InvalidJsonRpcParameters( + "Invalid should move worldstate boolean parameter (index 1)", + RpcErrorType.INVALID_PARAMS, + e); + } + } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHeadTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHeadTest.java new file mode 100644 index 0000000000..8d552ee376 --- /dev/null +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHeadTest.java @@ -0,0 +1,198 @@ +/* + * Copyright contributors to Besu. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods; + +import static java.lang.Boolean.FALSE; +import static java.lang.Boolean.TRUE; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +import org.hyperledger.besu.crypto.Hash; +import org.hyperledger.besu.ethereum.ProtocolContext; +import org.hyperledger.besu.ethereum.api.jsonrpc.AbstractJsonRpcHttpServiceTest; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash; +import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; +import org.hyperledger.besu.ethereum.chain.Blockchain; +import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; + +import java.util.Optional; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.apache.tuweni.bytes.Bytes; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +/** + * This test only exercises bonsai worldstate since forest is essentially a no-op for moving the + * worldstate. + */ +public class DebugSetHeadTest extends AbstractJsonRpcHttpServiceTest { + + DebugSetHead debugSetHead; + Blockchain blockchain; + WorldStateArchive archive; + ProtocolContext protocolContext; + ProtocolSchedule protocolSchedule; + + @Override + @BeforeEach + public void setup() throws Exception { + setupBonsaiBlockchain(); + blockchain = blockchainSetupUtil.getBlockchain(); + protocolContext = blockchainSetupUtil.getProtocolContext(); + protocolSchedule = blockchainSetupUtil.getProtocolSchedule(); + ; + archive = blockchainSetupUtil.getWorldArchive(); + debugSetHead = + new DebugSetHead( + new BlockchainQueries( + protocolSchedule, blockchain, archive, MiningConfiguration.MINING_DISABLED), + protocolContext, + // a value of 2 here exercises all the state rolling code paths + 2); + startService(); + } + + @ParameterizedTest + @ValueSource( + strings = {"0x01", "0x4e9a67b663f9abe03e7e9fd5452c9497998337077122f44ee78a466f6a7358de"}) + public void assertOnlyChainHeadMovesWorldParameterAbsent(final String blockParam) { + var chainTip = blockchain.getChainHead().getBlockHeader(); + var blockOne = getBlockHeaderForHashOrNumber(blockParam).orElse(null); + + assertThat(blockOne).isNotNull(); + assertThat(blockOne).isNotEqualTo(chainTip); + + // move the head to param val, number or hash + debugSetHead.response(debugSetHead(blockParam, Optional.empty())); + + // get the new chainTip: + var newChainTip = blockchain.getChainHead().getBlockHeader(); + + // assert the chain moved, and the worldstate did not + assertThat(newChainTip).isEqualTo(blockOne); + assertThat(archive.getMutable().rootHash()).isEqualTo(chainTip.getStateRoot()); + } + + @ParameterizedTest + @ValueSource( + strings = { + "0x01", + "0x02", + "0x3d813a0ffc9cd04436e17e3e9c309f1e80df0407078e50355ce0d570b5424812", + "0x4e9a67b663f9abe03e7e9fd5452c9497998337077122f44ee78a466f6a7358de" + }) + public void assertOnlyChainHeadMoves(final String blockParam) { + var chainTip = blockchain.getChainHead().getBlockHeader(); + var blockOne = getBlockHeaderForHashOrNumber(blockParam).orElse(null); + + assertThat(blockOne).isNotNull(); + assertThat(blockOne).isNotEqualTo(chainTip); + + // move the head to param val, number or hash + debugSetHead.response(debugSetHead(blockParam, Optional.of(FALSE))); + + // get the new chainTip: + var newChainTip = blockchain.getChainHead().getBlockHeader(); + + // assert the chain moved, and the worldstate did not + assertThat(newChainTip).isEqualTo(blockOne); + assertThat(archive.getMutable().rootHash()).isEqualTo(chainTip.getStateRoot()); + } + + @ParameterizedTest + @ValueSource( + strings = { + "0x01", + "0x02", + "0x3d813a0ffc9cd04436e17e3e9c309f1e80df0407078e50355ce0d570b5424812", + "0x4e9a67b663f9abe03e7e9fd5452c9497998337077122f44ee78a466f6a7358de" + }) + public void assertBothChainHeadAndWorldStatByNumber(final String blockParam) { + var chainTip = blockchain.getChainHead().getBlockHeader(); + var blockOne = getBlockHeaderForHashOrNumber(blockParam).orElse(null); + + assertThat(blockOne).isNotNull(); + assertThat(blockOne).isNotEqualTo(chainTip); + + // move the head and worldstate to param val number or hash + debugSetHead.response(debugSetHead(blockParam, Optional.of(TRUE))); + + // get the new chainTip: + var newChainTip = blockchain.getChainHead().getBlockHeader(); + + // assert both the chain and worldstate moved to block one + assertThat(newChainTip).isEqualTo(blockOne); + assertThat(archive.getMutable().rootHash()).isEqualTo(blockOne.getStateRoot()); + } + + @Test + public void assertNotFound() { + var chainTip = blockchain.getChainHead().getBlockHeader(); + + // move the head to number just after chain head + var resp = + debugSetHead.response(debugSetHead("" + chainTip.getNumber() + 1, Optional.of(TRUE))); + assertThat(resp.getType()).isEqualTo(RpcResponseType.ERROR); + + // move the head to some arbitrary hash + var resp2 = + debugSetHead.response( + debugSetHead( + Hash.keccak256(Bytes.fromHexString("0xdeadbeef")).toHexString(), + Optional.of(TRUE))); + assertThat(resp2.getType()).isEqualTo(RpcResponseType.ERROR); + + // get the new chainTip: + var newChainTip = blockchain.getChainHead().getBlockHeader(); + + // assert neither the chain nor the worldstate moved + assertThat(newChainTip).isEqualTo(chainTip); + assertThat(archive.getMutable().rootHash()).isEqualTo(chainTip.getStateRoot()); + } + + private JsonRpcRequestContext debugSetHead( + final String numberOrHash, final Optional moveWorldState) { + if (moveWorldState.isPresent()) { + return new JsonRpcRequestContext( + new JsonRpcRequest( + "2.0", "debug_setHead", new Object[] {numberOrHash, moveWorldState.get()})); + } else { + return new JsonRpcRequestContext( + new JsonRpcRequest("2.0", "debug_setHead", new Object[] {numberOrHash})); + } + } + + private Optional getBlockHeaderForHashOrNumber(final String input) { + try { + var param = new BlockParameterOrBlockHash(input); + if (param.getHash().isPresent()) { + return blockchain.getBlockHeader(param.getHash().get()); + } else if (param.getNumber().isPresent()) { + return blockchain.getBlockHeader(param.getNumber().getAsLong()); + } + } catch (JsonProcessingException ignored) { + // meh + } + return Optional.empty(); + } +} From ef9d1ab38ed82e3eaca1166bdb97da2d06d813d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bojarski?= <54240434+letypequividelespoubelles@users.noreply.github.com> Date: Tue, 5 Nov 2024 00:47:44 +0100 Subject: [PATCH 04/20] fix(push): right pad if `push parameter + PC +1` exceeds code length (#7834) * fix(push): right pad if push parameter exceeds code length * test: add push operation padding tests * better perf rightPadding thnks to Ameziane Signed-off-by: F Bojarski Co-authored-by: Ameziane H. --- .../besu/evm/operation/PushOperation.java | 12 ++- .../besu/evm/operation/PushOperationTest.java | 83 +++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 evm/src/test/java/org/hyperledger/besu/evm/operation/PushOperationTest.java diff --git a/evm/src/main/java/org/hyperledger/besu/evm/operation/PushOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/PushOperation.java index 006956207b..0462fb9775 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/operation/PushOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/PushOperation.java @@ -68,13 +68,21 @@ public class PushOperation extends AbstractFixedCostOperation { */ public static OperationResult staticOperation( final MessageFrame frame, final byte[] code, final int pc, final int pushSize) { - int copyStart = pc + 1; + final int copyStart = pc + 1; Bytes push; if (code.length <= copyStart) { push = Bytes.EMPTY; } else { final int copyLength = Math.min(pushSize, code.length - pc - 1); - push = Bytes.wrap(code, copyStart, copyLength); + final int rightPad = pushSize - copyLength; + if (rightPad == 0) { + push = Bytes.wrap(code, copyStart, copyLength); + } else { + // Right Pad the push with 0s up to pushSize if greater than the copyLength + var bytecodeLocal = new byte[pushSize]; + System.arraycopy(code, copyStart, bytecodeLocal, 0, copyLength); + push = Bytes.wrap(bytecodeLocal); + } } frame.pushStackItem(push); frame.setPC(pc + pushSize); diff --git a/evm/src/test/java/org/hyperledger/besu/evm/operation/PushOperationTest.java b/evm/src/test/java/org/hyperledger/besu/evm/operation/PushOperationTest.java new file mode 100644 index 0000000000..d303cc27d8 --- /dev/null +++ b/evm/src/test/java/org/hyperledger/besu/evm/operation/PushOperationTest.java @@ -0,0 +1,83 @@ +/* + * Copyright ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.evm.operation; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.evm.operation.PushOperation.staticOperation; + +import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.evm.code.CodeV0; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.toy.ToyBlockValues; +import org.hyperledger.besu.evm.toy.ToyWorld; + +import org.apache.tuweni.bytes.Bytes; +import org.apache.tuweni.bytes.Bytes32; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class PushOperationTest { + + private static final byte[] byteCode = new byte[] {0x00, 0x01, 0x02, 0x03}; + private static final MessageFrame frame = + MessageFrame.builder() + .worldUpdater(new ToyWorld()) + .originator(Address.ZERO) + .gasPrice(Wei.ONE) + .blobGasPrice(Wei.ONE) + .blockValues(new ToyBlockValues()) + .miningBeneficiary(Address.ZERO) + .blockHashLookup((l) -> Hash.ZERO) + .type(MessageFrame.Type.MESSAGE_CALL) + .initialGas(1) + .address(Address.ZERO) + .contract(Address.ZERO) + .inputData(Bytes32.ZERO) + .sender(Address.ZERO) + .value(Wei.ZERO) + .apparentValue(Wei.ZERO) + .code(CodeV0.EMPTY_CODE) + .completer(messageFrame -> {}) + .build(); + ; + + @Test + void unpaddedPushDoesntReachEndCode() { + staticOperation(frame, byteCode, 0, byteCode.length - 2); + assertThat(frame.getStackItem(0).equals(Bytes.fromHexString("0x0102"))).isTrue(); + } + + @Test + void unpaddedPushUpReachesEndCode() { + staticOperation(frame, byteCode, 0, byteCode.length - 1); + assertThat(frame.getStackItem(0).equals(Bytes.fromHexString("0x010203"))).isTrue(); + } + + @Test + void paddedPush() { + staticOperation(frame, byteCode, 1, byteCode.length - 1); + assertThat(frame.getStackItem(0).equals(Bytes.fromHexString("0x020300"))).isTrue(); + } + + @Test + void oobPush() { + staticOperation(frame, byteCode, byteCode.length, byteCode.length - 1); + assertThat(frame.getStackItem(0).equals(Bytes.EMPTY)).isTrue(); + } +} From 2054e12071bf0b3e10c6bb79634672dcddd1bb94 Mon Sep 17 00:00:00 2001 From: Vaidik Date: Tue, 5 Nov 2024 21:01:07 +0530 Subject: [PATCH 05/20] nonce as integer for preloaded contracts (#7850) * fixes #7749 Signed-off-by: vaidikcode * tests Signed-off-by: vaidikcode * spotless format fix Signed-off-by: vaidikcode --------- Co-authored-by: Sally MacFarlane Co-authored-by: Fabio Di Fabio --- .../hyperledger/besu/config/GenesisReader.java | 4 +++- .../besu/config/GenesisReaderTest.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java b/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java index 6b42c3c2ed..4ee99f0bd8 100644 --- a/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java +++ b/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java @@ -80,7 +80,9 @@ interface GenesisReader { final var on = normalizeKeys((ObjectNode) entry.getValue()); return new GenesisAccount( Address.fromHexString(entry.getKey()), - JsonUtil.getString(on, "nonce").map(ParserUtils::parseUnsignedLong).orElse(0L), + JsonUtil.getValueAsString(on, "nonce") + .map(ParserUtils::parseUnsignedLong) + .orElse(0L), JsonUtil.getString(on, "balance") .map(ParserUtils::parseBalance) .orElse(Wei.ZERO), diff --git a/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java b/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java index f8327174a3..eab6dfac73 100644 --- a/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java +++ b/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java @@ -17,6 +17,7 @@ package org.hyperledger.besu.config; import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.config.GenesisReader.ALLOCATION_FIELD; import static org.hyperledger.besu.config.GenesisReader.CONFIG_FIELD; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; @@ -27,6 +28,7 @@ import java.nio.file.Path; import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -111,4 +113,17 @@ public class GenesisReaderTest { entry.put("balance", balance.toShortHexString()); return entry; } + + @Test + void testNonceHandlingAsStringAndInteger() { + ObjectNode accountNode = JsonNodeFactory.instance.objectNode(); + + accountNode.put("nonce", 10); + String nonceAsStringFromInt = JsonUtil.getValueAsString(accountNode, "nonce").orElse(""); + assertEquals("10", nonceAsStringFromInt, "Nonce should convert integer to string correctly"); + + accountNode.put("nonce", "20"); + String nonceAsStringDirect = JsonUtil.getValueAsString(accountNode, "nonce").orElse(""); + assertEquals("20", nonceAsStringDirect, "Nonce should keep string as string correctly"); + } } From d73e815126c4cd3e5d8c054700db3f38a1180c99 Mon Sep 17 00:00:00 2001 From: Justin Florentine Date: Tue, 5 Nov 2024 10:56:07 -0500 Subject: [PATCH 06/20] calling the wrong create() method (#7857) Signed-off-by: jflo --- .../hyperledger/besu/controller/CliqueBesuControllerBuilder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java index 19840fb73d..edb55a1126 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java @@ -132,6 +132,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder { genesisConfigOptions, forksSchedule, nodeKey, + privacyParameters, isRevertReasonEnabled, evmConfiguration, miningConfiguration, From a585f1f2f79d1398f5970ccb7cf29f18e321eb55 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Wed, 6 Nov 2024 07:04:54 +0100 Subject: [PATCH 07/20] Fully initialize MetricCategoryRegistry for acceptance tests (#7860) Signed-off-by: Fabio Di Fabio --- .../besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java index a76a3e6dcb..fc2a7d372e 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java @@ -494,6 +494,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { final RpcEndpointServiceImpl rpcEndpointServiceImpl, final BesuConfiguration commonPluginConfiguration, final PermissioningServiceImpl permissioningService, + final MetricsConfiguration metricsConfiguration, final MetricCategoryRegistryImpl metricCategoryRegistry, final MetricsSystem metricsSystem, final @Named("ExtraCLIOptions") List extraCLIOptions, @@ -512,6 +513,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { TransactionSimulationService.class, transactionSimulationServiceImpl); besuPluginContext.addService(BlockchainService.class, blockchainServiceImpl); besuPluginContext.addService(BesuConfiguration.class, commonPluginConfiguration); + metricCategoryRegistry.setMetricsConfiguration(metricsConfiguration); besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry); besuPluginContext.addService(MetricsSystem.class, metricsSystem); From 4099b3b32222de34754af7d2ffb0bf433434f4c7 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Wed, 6 Nov 2024 09:14:07 +0100 Subject: [PATCH 08/20] Add more subprojects to BOM (#7859) Signed-off-by: Fabio Di Fabio --- platform/build.gradle | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/platform/build.gradle b/platform/build.gradle index 5b02eb0bee..d614603f17 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -43,8 +43,14 @@ dependencies { api project(':acceptance-tests:dsl') api project(':besu') api project(':config') + api project(':consensus:clique') + api project(':consensus:common') + api project(':consensus:ibft') + api project(':consensus:merge') + api project(':consensus:qbft') api project(':crypto:algorithms') api project(':crypto:services') + api project(':datatypes') api project(':ethereum:api') api project(':ethereum:blockcreation') api project(':ethereum:core') @@ -53,9 +59,12 @@ dependencies { api project(':ethereum:permissioning') api project(':ethereum:referencetests') api project(':ethereum:rlp') + api project(':ethereum:trie') api project(':evm') - api project(':datatypes') + api project(':metrics:core') api project(':plugin-api') + api project(':testutil') + api project(':util') api 'com.github.ben-manes.caffeine:caffeine:3.1.8' From deb3fa2727c6924c60374c889031ccdff0028e7a Mon Sep 17 00:00:00 2001 From: Justin Florentine Date: Wed, 6 Nov 2024 14:55:57 -0500 Subject: [PATCH 09/20] adds action to manage stale issues (#7864) Signed-off-by: jflo --- .github/workflows/stale-issues.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/stale-issues.yml diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml new file mode 100644 index 0000000000..fe45d91b49 --- /dev/null +++ b/.github/workflows/stale-issues.yml @@ -0,0 +1,27 @@ +name: Close inactive issues +on: + schedule: + - cron: "30 1 * * *" + +jobs: + close-issues: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + contents: write + steps: + - uses: actions/stale@v5 + with: + days-before-issue-stale: 180 + days-before-issue-close: 14 + stale-issue-label: "stale" + stale-issue-message: "This issue is stale because it has been open for 6 months with no activity." + close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." + days-before-pr-stale: 30 + days-before-pr-close: 14 + stale-pr-message: "This pr is stale because it has been open for 30 days with no activity." + close-pr-message: "This pr was closed because it has been inactive for 14 days since being marked as stale." + remove-issue-stale-when-updated: true + remove-pr-stale-when-updated: true + repo-token: ${{ secrets.GITHUB_TOKEN }} From 3ebf50ea0ba75e8fc9fee285d4992285992f3442 Mon Sep 17 00:00:00 2001 From: wangjingcun Date: Fri, 8 Nov 2024 17:00:29 +0800 Subject: [PATCH 10/20] chore: fix some typos in comments (#7866) Signed-off-by: wangjingcun --- .../besu/tests/acceptance/plugins/TestMetricsPlugin.java | 2 +- .../rocksdb/segmented/RocksDBColumnarKeyValueStorageTest.java | 2 +- .../java/org/hyperledger/besu/testfuzz/javafuzz/FuzzTarget.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java index 7e1ac2ccde..af179c57cf 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java @@ -51,7 +51,7 @@ public class TestMetricsPlugin implements BesuPlugin { .createGauge( TestMetricCategory.TEST_METRIC_CATEGORY, "test_metric", - "Returns 1 on succes", + "Returns 1 on success", () -> 1.0); } diff --git a/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorageTest.java b/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorageTest.java index e28828c396..4800e82abc 100644 --- a/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorageTest.java +++ b/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorageTest.java @@ -264,7 +264,7 @@ public abstract class RocksDBColumnarKeyValueStorageTest extends AbstractKeyValu List.of()); store.close(); - // Create new db without ignoring experimental colum family will add column to db + // Create new db without ignoring experimental column family will add column to db store = createSegmentedStore( testPath, diff --git a/testfuzz/src/main/java/org/hyperledger/besu/testfuzz/javafuzz/FuzzTarget.java b/testfuzz/src/main/java/org/hyperledger/besu/testfuzz/javafuzz/FuzzTarget.java index 26f3522e11..bee6bca776 100644 --- a/testfuzz/src/main/java/org/hyperledger/besu/testfuzz/javafuzz/FuzzTarget.java +++ b/testfuzz/src/main/java/org/hyperledger/besu/testfuzz/javafuzz/FuzzTarget.java @@ -25,7 +25,7 @@ public interface FuzzTarget { /** * The target to fuzz * - * @param data data proviced by the fuzzer + * @param data data provided by the fuzzer */ void fuzz(byte[] data); } From e17ebc5e8d8e0f032c6871ad5fc4144524d190cb Mon Sep 17 00:00:00 2001 From: Bhanu Pulluri <59369753+pullurib@users.noreply.github.com> Date: Fri, 8 Nov 2024 05:08:11 -0500 Subject: [PATCH 11/20] Add TLS/mTLS options for websockets (#7854) * Fix incorrect duration for THREE_MINUTES from 1 minute to 3 minutes Signed-off-by: Bhanu Pulluri * Add options to enable TLS/mTLS for websocket connections Signed-off-by: Bhanu Pulluri * Revert an irrelevant change Signed-off-by: Bhanu Pulluri * Update tests, options and option dependencies Signed-off-by: Bhanu Pulluri * Fix CHANGELOG entry Signed-off-by: Bhanu Pulluri * Fix CHANGELOG entry Signed-off-by: Bhanu Pulluri --------- Signed-off-by: Bhanu Pulluri Co-authored-by: Bhanu Pulluri Co-authored-by: Fabio Di Fabio --- CHANGELOG.md | 1 + .../besu/cli/options/RpcWebsocketOptions.java | 133 +++++- .../src/test/resources/everything_config.toml | 13 + .../websocket/WebSocketConfiguration.java | 112 +++++ .../jsonrpc/websocket/WebSocketService.java | 72 ++- .../websocket/WebSocketServiceTLSTest.java | 444 ++++++++++++++++++ 6 files changed, 764 insertions(+), 11 deletions(-) create mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceTLSTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 41aea176de..b78adf6e06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Additions and Improvements - Fine tune already seen txs tracker when a tx is removed from the pool [#7755](https://github.com/hyperledger/besu/pull/7755) +- Support for enabling and configuring TLS/mTLS in WebSocket service. [#7854](https://github.com/hyperledger/besu/pull/7854) - Create and publish Besu BOM (Bill of Materials) [#7615](https://github.com/hyperledger/besu/pull/7615) - Update Java dependencies [#7786](https://github.com/hyperledger/besu/pull/7786) - Add a method to get all the transaction in the pool, to the `TransactionPoolService`, to easily access the transaction pool content from plugins [#7813](https://github.com/hyperledger/besu/pull/7813) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java index d596d4183c..2dde517ccc 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java @@ -120,6 +120,71 @@ public class RpcWebsocketOptions { arity = "1") private final File rpcWsAuthenticationPublicKeyFile = null; + @CommandLine.Option( + names = {"--rpc-ws-ssl-enabled"}, + description = "Enable SSL/TLS for the WebSocket RPC service") + private final Boolean isRpcWsSslEnabled = false; + + @CommandLine.Option( + names = {"--rpc-ws-ssl-keystore-file"}, + paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, + description = "Path to the keystore file for the WebSocket RPC service") + private String rpcWsKeyStoreFile = null; + + @CommandLine.Option( + names = {"--rpc-ws-ssl-keystore-password"}, + paramLabel = "", + description = "Password for the WebSocket RPC keystore file") + private String rpcWsKeyStorePassword = null; + + @CommandLine.Option( + names = {"--rpc-ws-ssl-key-file"}, + paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, + description = "Path to the PEM key file for the WebSocket RPC service") + private String rpcWsKeyFile = null; + + @CommandLine.Option( + names = {"--rpc-ws-ssl-cert-file"}, + paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, + description = "Path to the PEM cert file for the WebSocket RPC service") + private String rpcWsCertFile = null; + + @CommandLine.Option( + names = {"--rpc-ws-ssl-keystore-type"}, + paramLabel = "", + description = "Type of the WebSocket RPC keystore (JKS, PKCS12, PEM)") + private String rpcWsKeyStoreType = null; + + // For client authentication (mTLS) + @CommandLine.Option( + names = {"--rpc-ws-ssl-client-auth-enabled"}, + description = "Enable client authentication for the WebSocket RPC service") + private final Boolean isRpcWsClientAuthEnabled = false; + + @CommandLine.Option( + names = {"--rpc-ws-ssl-truststore-file"}, + paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, + description = "Path to the truststore file for the WebSocket RPC service") + private String rpcWsTrustStoreFile = null; + + @CommandLine.Option( + names = {"--rpc-ws-ssl-truststore-password"}, + paramLabel = "", + description = "Password for the WebSocket RPC truststore file") + private String rpcWsTrustStorePassword = null; + + @CommandLine.Option( + names = {"--rpc-ws-ssl-trustcert-file"}, + paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP, + description = "Path to the PEM trustcert file for the WebSocket RPC service") + private String rpcWsTrustCertFile = null; + + @CommandLine.Option( + names = {"--rpc-ws-ssl-truststore-type"}, + paramLabel = "", + description = "Type of the truststore (JKS, PKCS12, PEM)") + private String rpcWsTrustStoreType = null; + /** Default Constructor. */ public RpcWebsocketOptions() {} @@ -184,7 +249,61 @@ public class RpcWebsocketOptions { "--rpc-ws-authentication-enabled", "--rpc-ws-authentication-credentials-file", "--rpc-ws-authentication-public-key-file", - "--rpc-ws-authentication-jwt-algorithm")); + "--rpc-ws-authentication-jwt-algorithm", + "--rpc-ws-ssl-enabled")); + + CommandLineUtils.checkOptionDependencies( + logger, + commandLine, + "--rpc-ws-ssl-enabled", + !isRpcWsSslEnabled, + List.of( + "--rpc-ws-ssl-keystore-file", + "--rpc-ws-ssl-keystore-type", + "--rpc-ws-ssl-client-auth-enabled")); + + CommandLineUtils.checkOptionDependencies( + logger, + commandLine, + "--rpc-ws-ssl-client-auth-enabled", + !isRpcWsClientAuthEnabled, + List.of( + "--rpc-ws-ssl-truststore-file", + "--rpc-ws-ssl-truststore-type", + "--rpc-ws-ssl-trustcert-file")); + + if (isRpcWsSslEnabled) { + if ("PEM".equalsIgnoreCase(rpcWsKeyStoreType)) { + CommandLineUtils.checkOptionDependencies( + logger, + commandLine, + "--rpc-ws-ssl-key-file", + rpcWsKeyFile == null, + List.of("--rpc-ws-ssl-cert-file")); + CommandLineUtils.checkOptionDependencies( + logger, + commandLine, + "--rpc-ws-ssl-cert-file", + rpcWsCertFile == null, + List.of("--rpc-ws-ssl-key-file")); + } else { + CommandLineUtils.checkOptionDependencies( + logger, + commandLine, + "--rpc-ws-ssl-keystore-file", + rpcWsKeyStoreFile == null, + List.of("--rpc-ws-ssl-keystore-password")); + } + } + + if (isRpcWsClientAuthEnabled && !"PEM".equalsIgnoreCase(rpcWsTrustStoreType)) { + CommandLineUtils.checkOptionDependencies( + logger, + commandLine, + "--rpc-ws-ssl-truststore-file", + rpcWsTrustStoreFile == null, + List.of("--rpc-ws-ssl-truststore-password")); + } if (isRpcWsAuthenticationEnabled) { CommandLineUtils.checkOptionDependencies( @@ -222,6 +341,18 @@ public class RpcWebsocketOptions { webSocketConfiguration.setAuthenticationPublicKeyFile(rpcWsAuthenticationPublicKeyFile); webSocketConfiguration.setAuthenticationAlgorithm(rpcWebsocketsAuthenticationAlgorithm); webSocketConfiguration.setTimeoutSec(wsTimoutSec); + webSocketConfiguration.setSslEnabled(isRpcWsSslEnabled); + webSocketConfiguration.setKeyStorePath(rpcWsKeyStoreFile); + webSocketConfiguration.setKeyStorePassword(rpcWsKeyStorePassword); + webSocketConfiguration.setKeyStoreType(rpcWsKeyStoreType); + webSocketConfiguration.setClientAuthEnabled(isRpcWsClientAuthEnabled); + webSocketConfiguration.setTrustStorePath(rpcWsTrustStoreFile); + webSocketConfiguration.setTrustStorePassword(rpcWsTrustStorePassword); + webSocketConfiguration.setTrustStoreType(rpcWsTrustStoreType); + webSocketConfiguration.setKeyPath(rpcWsKeyFile); + webSocketConfiguration.setCertPath(rpcWsCertFile); + webSocketConfiguration.setTrustCertPath(rpcWsTrustCertFile); + return webSocketConfiguration; } diff --git a/besu/src/test/resources/everything_config.toml b/besu/src/test/resources/everything_config.toml index e89442f7f7..960b2b5772 100644 --- a/besu/src/test/resources/everything_config.toml +++ b/besu/src/test/resources/everything_config.toml @@ -120,6 +120,19 @@ rpc-ws-max-frame-size=65535 rpc-ws-authentication-enabled=false rpc-ws-authentication-credentials-file="none" rpc-ws-authentication-jwt-public-key-file="none" +rpc-ws-ssl-enabled=false +rpc-ws-ssl-keystore-file="none.pfx" +rpc-ws-ssl-keystore-password="none.passwd" +rpc-ws-ssl-keystore-type="none" +rpc-ws-ssl-client-auth-enabled=false +rpc-ws-ssl-truststore-file="none.pfx" +rpc-ws-ssl-truststore-password="none.passwd" +rpc-ws-ssl-truststore-type="none" +rpc-ws-ssl-key-file="none.pfx" +rpc-ws-ssl-cert-file="none.pfx" +rpc-ws-ssl-trustcert-file="none.pfx" + + # API api-gas-price-blocks=100 diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketConfiguration.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketConfiguration.java index e27f7f21ce..42905b96a7 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketConfiguration.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketConfiguration.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.Optional; import com.google.common.base.MoreObjects; @@ -49,6 +50,21 @@ public class WebSocketConfiguration { private int maxActiveConnections; private int maxFrameSize; + private boolean isSslEnabled = false; + private Optional keyStorePath = Optional.empty(); + private Optional keyStorePassword = Optional.empty(); + private Optional keyStoreType = Optional.of("JKS"); // Default to JKS + + private boolean clientAuthEnabled = false; + private Optional trustStorePath = Optional.empty(); + private Optional trustStorePassword = Optional.empty(); + private Optional trustStoreType = Optional.of("JKS"); // Default to JKS + + // For PEM format + private Optional keyPath = Optional.empty(); + private Optional certPath = Optional.empty(); + private Optional trustCertPath = Optional.empty(); + public static WebSocketConfiguration createDefault() { final WebSocketConfiguration config = new WebSocketConfiguration(); config.setEnabled(false); @@ -159,6 +175,102 @@ public class WebSocketConfiguration { this.timeoutSec = timeoutSec; } + public boolean isSslEnabled() { + return isSslEnabled; + } + + public void setSslEnabled(final boolean isSslEnabled) { + this.isSslEnabled = isSslEnabled; + } + + public Optional getKeyStorePath() { + return keyStorePath; + } + + public void setKeyStorePath(final String keyStorePath) { + this.keyStorePath = Optional.ofNullable(keyStorePath); + } + + public Optional getKeyStorePassword() { + return keyStorePassword; + } + + public void setKeyStorePassword(final String keyStorePassword) { + this.keyStorePassword = Optional.ofNullable(keyStorePassword); + } + + // Keystore Type + public Optional getKeyStoreType() { + return keyStoreType; + } + + public void setKeyStoreType(final String keyStoreType) { + this.keyStoreType = Optional.ofNullable(keyStoreType); + } + + // Key Path (for PEM) + public Optional getKeyPath() { + return keyPath; + } + + public void setKeyPath(final String keyPath) { + this.keyPath = Optional.ofNullable(keyPath); + } + + // Cert Path (for PEM) + public Optional getCertPath() { + return certPath; + } + + public void setCertPath(final String certPath) { + this.certPath = Optional.ofNullable(certPath); + } + + // Client Authentication Enabled + public boolean isClientAuthEnabled() { + return clientAuthEnabled; + } + + public void setClientAuthEnabled(final boolean clientAuthEnabled) { + this.clientAuthEnabled = clientAuthEnabled; + } + + // Truststore Path + public Optional getTrustStorePath() { + return trustStorePath; + } + + public void setTrustStorePath(final String trustStorePath) { + this.trustStorePath = Optional.ofNullable(trustStorePath); + } + + // Truststore Password + public Optional getTrustStorePassword() { + return trustStorePassword; + } + + public void setTrustStorePassword(final String trustStorePassword) { + this.trustStorePassword = Optional.ofNullable(trustStorePassword); + } + + // Truststore Type + public Optional getTrustStoreType() { + return trustStoreType; + } + + public void setTrustStoreType(final String trustStoreType) { + this.trustStoreType = Optional.ofNullable(trustStoreType); + } + + // Trust Cert Path (for PEM) + public Optional getTrustCertPath() { + return trustCertPath; + } + + public void setTrustCertPath(final String trustCertPath) { + this.trustCertPath = Optional.ofNullable(trustCertPath); + } + @Override public boolean equals(final Object o) { if (this == o) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java index 59742836ba..31c86b18d2 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java @@ -25,6 +25,7 @@ import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.plugin.services.MetricsSystem; import java.net.InetSocketAddress; +import java.util.Locale; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; @@ -34,6 +35,7 @@ import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.Vertx; import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.ClientAuth; import io.vertx.core.http.HttpConnection; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; @@ -41,6 +43,9 @@ import io.vertx.core.http.HttpServerRequest; import io.vertx.core.http.HttpServerResponse; import io.vertx.core.http.ServerWebSocket; import io.vertx.core.net.HostAndPort; +import io.vertx.core.net.JksOptions; +import io.vertx.core.net.PemKeyCertOptions; +import io.vertx.core.net.PemTrustOptions; import io.vertx.core.net.SocketAddress; import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; @@ -103,18 +108,65 @@ public class WebSocketService { "Starting Websocket service on {}:{}", configuration.getHost(), configuration.getPort()); final CompletableFuture resultFuture = new CompletableFuture<>(); + HttpServerOptions serverOptions = + new HttpServerOptions() + .setHost(configuration.getHost()) + .setPort(configuration.getPort()) + .setHandle100ContinueAutomatically(true) + .setCompressionSupported(true) + .addWebSocketSubProtocol("undefined") + .setMaxWebSocketFrameSize(configuration.getMaxFrameSize()) + .setMaxWebSocketMessageSize(configuration.getMaxFrameSize() * 4) + .setRegisterWebSocketWriteHandlers(true); + + // Check if SSL/TLS is enabled in the configuration + if (configuration.isSslEnabled()) { + serverOptions.setSsl(true); + + String keystorePath = configuration.getKeyStorePath().orElse(null); + String keystorePassword = configuration.getKeyStorePassword().orElse(null); + String keyPath = configuration.getKeyPath().orElse(null); + String certPath = configuration.getCertPath().orElse(null); + + String keystoreType = configuration.getKeyStoreType().orElse("JKS"); + + switch (keystoreType.toUpperCase(Locale.getDefault())) { + case "PEM": + serverOptions.setKeyCertOptions( + new PemKeyCertOptions().setKeyPath(keyPath).setCertPath(certPath)); + break; + case "JKS": + default: + serverOptions.setKeyCertOptions( + new JksOptions().setPath(keystorePath).setPassword(keystorePassword)); + break; + } + } + + // Set up truststore for client authentication (mTLS) + if (configuration.isClientAuthEnabled()) { + serverOptions.setClientAuth(ClientAuth.REQUIRED); + + String truststorePath = configuration.getTrustStorePath().orElse(null); + String truststorePassword = configuration.getTrustStorePassword().orElse(""); + String truststoreType = configuration.getTrustStoreType().orElse("JKS"); + String trustCertPath = configuration.getTrustCertPath().orElse(null); + + switch (truststoreType.toUpperCase(Locale.getDefault())) { + case "PEM": + serverOptions.setTrustOptions(new PemTrustOptions().addCertPath(trustCertPath)); + break; + case "JKS": + default: + serverOptions.setTrustOptions( + new JksOptions().setPath(truststorePath).setPassword(truststorePassword)); + break; + } + } + httpServer = vertx - .createHttpServer( - new HttpServerOptions() - .setHost(configuration.getHost()) - .setPort(configuration.getPort()) - .setHandle100ContinueAutomatically(true) - .setCompressionSupported(true) - .addWebSocketSubProtocol("undefined") - .setMaxWebSocketFrameSize(configuration.getMaxFrameSize()) - .setMaxWebSocketMessageSize(configuration.getMaxFrameSize() * 4) - .setRegisterWebSocketWriteHandlers(true)) + .createHttpServer(serverOptions) .webSocketHandler(websocketHandler()) .connectionHandler(connectionHandler()) .requestHandler(httpHandler()) diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceTLSTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceTLSTest.java new file mode 100644 index 0000000000..9a227dc432 --- /dev/null +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceTLSTest.java @@ -0,0 +1,444 @@ +/* + * Copyright contributors to Besu. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.ethereum.api.jsonrpc.websocket; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; + +import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions; +import org.hyperledger.besu.ethereum.api.jsonrpc.execution.BaseJsonRpcProcessor; +import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; +import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.WebSocketMethodsFactory; +import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.SubscriptionManager; +import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; +import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; + +import java.io.File; +import java.io.FileOutputStream; +import java.security.KeyStore; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import io.netty.handler.ssl.util.SelfSignedCertificate; +import io.vertx.core.Vertx; +import io.vertx.core.http.WebSocketClient; +import io.vertx.core.http.WebSocketClientOptions; +import io.vertx.core.net.JksOptions; +import io.vertx.core.net.PemTrustOptions; +import io.vertx.junit5.VertxExtension; +import io.vertx.junit5.VertxTestContext; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@ExtendWith(VertxExtension.class) +public class WebSocketServiceTLSTest { + + private Vertx vertx; + private WebSocketConfiguration config; + private WebSocketMessageHandler webSocketMessageHandlerSpy; + + @BeforeEach + public void setUp() { + vertx = Vertx.vertx(); + config = WebSocketConfiguration.createDefault(); + Map websocketMethods; + config.setPort(0); // Use ephemeral port + config.setHost("localhost"); + websocketMethods = + new WebSocketMethodsFactory( + new SubscriptionManager(new NoOpMetricsSystem()), new HashMap<>()) + .methods(); + webSocketMessageHandlerSpy = + spy( + new WebSocketMessageHandler( + vertx, + new JsonRpcExecutor(new BaseJsonRpcProcessor(), websocketMethods), + mock(EthScheduler.class), + TimeoutOptions.defaultOptions().getTimeoutSeconds())); + } + + @Test + public void shouldAcceptSecureWebSocketConnection(final VertxTestContext testContext) + throws Throwable { + // Generate a self-signed certificate + SelfSignedCertificate ssc = new SelfSignedCertificate(); + + // Create a temporary keystore file + File keystoreFile = File.createTempFile("keystore", ".jks"); + keystoreFile.deleteOnExit(); + + // Create a PKCS12 keystore and load the self-signed certificate + KeyStore keyStore = KeyStore.getInstance("JKS"); + keyStore.load(null, null); + keyStore.setKeyEntry( + "alias", + ssc.key(), + "password".toCharArray(), + new java.security.cert.Certificate[] {ssc.cert()}); + + // Save the keystore to the temporary file + try (FileOutputStream fos = new FileOutputStream(keystoreFile)) { + keyStore.store(fos, "password".toCharArray()); + } + + // Configure WebSocket with SSL enabled + config.setSslEnabled(true); + config.setKeyStorePath(keystoreFile.getAbsolutePath()); + config.setKeyStorePassword("password"); + config.setKeyStoreType("JKS"); + + // Create and start WebSocketService + WebSocketService webSocketService = + new WebSocketService(vertx, config, webSocketMessageHandlerSpy, new NoOpMetricsSystem()); + webSocketService.start().join(); + + // Get the actual port + int port = webSocketService.socketAddress().getPort(); + + // Create a temporary truststore file + File truststoreFile = File.createTempFile("truststore", ".jks"); + truststoreFile.deleteOnExit(); + + // Create a PKCS12 truststore and load the server's certificate + KeyStore trustStore = KeyStore.getInstance("JKS"); + trustStore.load(null, null); + trustStore.setCertificateEntry("alias", ssc.cert()); + + // Save the truststore to the temporary file + try (FileOutputStream fos = new FileOutputStream(truststoreFile)) { + trustStore.store(fos, "password".toCharArray()); + } + + // Configure the HTTP client with the truststore + WebSocketClientOptions clientOptions = + new WebSocketClientOptions() + .setSsl(true) + .setTrustOptions( + new JksOptions().setPath(truststoreFile.getAbsolutePath()).setPassword("password")) + .setVerifyHost(true); + + WebSocketClient webSocketClient = vertx.createWebSocketClient(clientOptions); + webSocketClient + .connect(port, "localhost", "/") + .onSuccess( + ws -> { + assertThat(ws.isSsl()).isTrue(); + ws.close(); + testContext.completeNow(); + }) + .onFailure(testContext::failNow); + + assertThat(testContext.awaitCompletion(5, TimeUnit.SECONDS)).isTrue(); + if (testContext.failed()) { + throw testContext.causeOfFailure(); + } + + // Stop the WebSocketService after the test + webSocketService.stop().join(); + } + + @Test + public void shouldAcceptSecureWebSocketConnectionPEM(final VertxTestContext testContext) + throws Throwable { + // Generate a self-signed certificate + SelfSignedCertificate ssc = new SelfSignedCertificate(); + + // Create temporary PEM files for the certificate and key + File certFile = File.createTempFile("cert", ".pem"); + certFile.deleteOnExit(); + File keyFile = File.createTempFile("key", ".pem"); + keyFile.deleteOnExit(); + + // Write the certificate and key to the PEM files + try (FileOutputStream certOut = new FileOutputStream(certFile); + FileOutputStream keyOut = new FileOutputStream(keyFile)) { + certOut.write("-----BEGIN CERTIFICATE-----\n".getBytes(UTF_8)); + certOut.write( + Base64.getMimeEncoder(64, "\n".getBytes(UTF_8)).encode(ssc.cert().getEncoded())); + certOut.write("\n-----END CERTIFICATE-----\n".getBytes(UTF_8)); + + keyOut.write("-----BEGIN PRIVATE KEY-----\n".getBytes(UTF_8)); + keyOut.write(Base64.getMimeEncoder(64, "\n".getBytes(UTF_8)).encode(ssc.key().getEncoded())); + keyOut.write("\n-----END PRIVATE KEY-----\n".getBytes(UTF_8)); + } + + // Configure WebSocket with SSL enabled using PEM files + config.setSslEnabled(true); + config.setKeyPath(keyFile.getAbsolutePath()); + config.setCertPath(certFile.getAbsolutePath()); + config.setKeyStoreType("PEM"); + + // Create and start WebSocketService + WebSocketService webSocketService = + new WebSocketService(vertx, config, webSocketMessageHandlerSpy, new NoOpMetricsSystem()); + webSocketService.start().join(); + + // Get the actual port + int port = webSocketService.socketAddress().getPort(); + + // Create a temporary PEM file for the trust store + File trustCertFile = File.createTempFile("trust-cert", ".pem"); + trustCertFile.deleteOnExit(); + + // Write the server's certificate to the PEM file + try (FileOutputStream trustCertOut = new FileOutputStream(trustCertFile)) { + trustCertOut.write("-----BEGIN CERTIFICATE-----\n".getBytes(UTF_8)); + trustCertOut.write( + Base64.getMimeEncoder(64, "\n".getBytes(UTF_8)).encode(ssc.cert().getEncoded())); + trustCertOut.write("\n-----END CERTIFICATE-----\n".getBytes(UTF_8)); + } + + // Configure the HTTP client with the trust store using PEM files + WebSocketClientOptions clientOptions = + new WebSocketClientOptions() + .setSsl(true) + .setTrustOptions(new PemTrustOptions().addCertPath(trustCertFile.getAbsolutePath())) + .setVerifyHost(true); + + WebSocketClient webSocketClient = vertx.createWebSocketClient(clientOptions); + webSocketClient + .connect(port, "localhost", "/") + .onSuccess( + ws -> { + assertThat(ws.isSsl()).isTrue(); + ws.close(); + testContext.completeNow(); + }) + .onFailure(testContext::failNow); + + assertThat(testContext.awaitCompletion(5, TimeUnit.SECONDS)).isTrue(); + if (testContext.failed()) { + throw testContext.causeOfFailure(); + } + + // Stop the WebSocketService after the test + webSocketService.stop().join(); + } + + @Test + public void shouldFailConnectionWithWrongCertificateInTrustStore( + final VertxTestContext testContext) throws Throwable { + // Generate a self-signed certificate for the server + SelfSignedCertificate serverCert = new SelfSignedCertificate(); + + // Create a temporary keystore file for the server + File keystoreFile = File.createTempFile("keystore", ".p12"); + keystoreFile.deleteOnExit(); + + // Create a PKCS12 keystore and load the server's self-signed certificate + KeyStore keyStore = KeyStore.getInstance("PKCS12"); + keyStore.load(null, null); + keyStore.setKeyEntry( + "alias", + serverCert.key(), + "password".toCharArray(), + new java.security.cert.Certificate[] {serverCert.cert()}); + + // Save the keystore to the temporary file + try (FileOutputStream fos = new FileOutputStream(keystoreFile)) { + keyStore.store(fos, "password".toCharArray()); + } + + // Configure WebSocket with SSL enabled + config.setSslEnabled(true); + config.setKeyStorePath(keystoreFile.getAbsolutePath()); + config.setKeyStorePassword("password"); + config.setKeyStoreType("PKCS12"); + + // Create and start WebSocketService + WebSocketService webSocketService = + new WebSocketService(vertx, config, webSocketMessageHandlerSpy, new NoOpMetricsSystem()); + webSocketService.start().join(); + + // Get the actual port + int port = webSocketService.socketAddress().getPort(); + + // Generate a different self-signed certificate for the trust store + SelfSignedCertificate wrongCert = new SelfSignedCertificate(); + + // Create a temporary truststore file + File truststoreFile = File.createTempFile("truststore", ".p12"); + truststoreFile.deleteOnExit(); + + // Create a PKCS12 truststore and load the wrong certificate + KeyStore trustStore = KeyStore.getInstance("PKCS12"); + trustStore.load(null, null); + trustStore.setCertificateEntry("alias", wrongCert.cert()); + + // Save the truststore to the temporary file + try (FileOutputStream fos = new FileOutputStream(truststoreFile)) { + trustStore.store(fos, "password".toCharArray()); + } + + // Configure the HTTP client with the truststore containing the wrong certificate + WebSocketClientOptions clientOptions = + new WebSocketClientOptions() + .setSsl(true) + .setTrustOptions( + new JksOptions().setPath(truststoreFile.getAbsolutePath()).setPassword("password")) + .setVerifyHost(true); + + WebSocketClient webSocketClient = vertx.createWebSocketClient(clientOptions); + webSocketClient + .connect(port, "localhost", "/") + .onSuccess( + ws -> { + testContext.failNow(new AssertionError("Connection should have been rejected")); + }) + .onFailure( + throwable -> { + assertThat(throwable).isInstanceOf(Exception.class); + testContext.completeNow(); + }); + + assertThat(testContext.awaitCompletion(5, TimeUnit.SECONDS)).isTrue(); + if (testContext.failed()) { + throw testContext.causeOfFailure(); + } + + // Stop the WebSocketService after the test + webSocketService.stop().join(); + } + + @Test + public void shouldAuthenticateClient(final VertxTestContext testContext) throws Throwable { + // Generate a self-signed certificate for the server + SelfSignedCertificate serverCert = new SelfSignedCertificate(); + + // Generate a self-signed certificate for the client + SelfSignedCertificate clientCert = new SelfSignedCertificate(); + + // Create a temporary keystore file for the server + File serverKeystoreFile = File.createTempFile("keystore", ".p12"); + serverKeystoreFile.deleteOnExit(); + + // Create a temporary truststore file for the server + File serverTruststoreFile = File.createTempFile("truststore", ".p12"); + serverTruststoreFile.deleteOnExit(); + + // Create a temporary keystore file for the client + File clientKeystoreFile = File.createTempFile("client-keystore", ".p12"); + clientKeystoreFile.deleteOnExit(); + + // Create a temporary truststore file for the client + File clientTruststoreFile = File.createTempFile("truststore", ".p12"); + clientTruststoreFile.deleteOnExit(); + + // Create a PKCS12 keystore and load the server's self-signed certificate + KeyStore serverKeyStore = KeyStore.getInstance("PKCS12"); + serverKeyStore.load(null, null); + serverKeyStore.setKeyEntry( + "alias", + serverCert.key(), + "password".toCharArray(), + new java.security.cert.Certificate[] {serverCert.cert()}); + + // Save the keystore to the temporary file + try (FileOutputStream fos = new FileOutputStream(serverKeystoreFile)) { + serverKeyStore.store(fos, "password".toCharArray()); + } + + // Create a PKCS12 truststore and load the client's self-signed certificate + KeyStore serverTrustStore = KeyStore.getInstance("PKCS12"); + serverTrustStore.load(null, null); + serverTrustStore.setCertificateEntry("alias", clientCert.cert()); + + // Save the truststore to the temporary file + try (FileOutputStream fos = new FileOutputStream(serverTruststoreFile)) { + serverTrustStore.store(fos, "password".toCharArray()); + } + + // Create a PKCS12 keystore and load the client's self-signed certificate + KeyStore clientKeyStore = KeyStore.getInstance("PKCS12"); + clientKeyStore.load(null, null); + clientKeyStore.setKeyEntry( + "alias", + clientCert.key(), + "password".toCharArray(), + new java.security.cert.Certificate[] {clientCert.cert()}); + + // Save the client keystore to the temporary file + try (FileOutputStream fos = new FileOutputStream(clientKeystoreFile)) { + clientKeyStore.store(fos, "password".toCharArray()); + } + + // Create a PKCS12 truststore and load the server's self-signed certificate + KeyStore clientTrustStore = KeyStore.getInstance("PKCS12"); + clientTrustStore.load(null, null); + clientTrustStore.setCertificateEntry("alias", serverCert.cert()); + + // Save the truststore to the temporary file + try (FileOutputStream fos = new FileOutputStream(clientTruststoreFile)) { + clientTrustStore.store(fos, "password".toCharArray()); + } + + // Configure WebSocket with SSL and client authentication enabled + config.setSslEnabled(true); + config.setKeyStorePath(serverKeystoreFile.getAbsolutePath()); + config.setKeyStorePassword("password"); + config.setKeyStoreType("PKCS12"); + config.setClientAuthEnabled(true); + config.setTrustStorePath(serverTruststoreFile.getAbsolutePath()); + config.setTrustStorePassword("password"); + config.setTrustStoreType("PKCS12"); + + // Create and start WebSocketService + WebSocketService webSocketService = + new WebSocketService(vertx, config, webSocketMessageHandlerSpy, new NoOpMetricsSystem()); + webSocketService.start().join(); + + // Get the actual port + int port = webSocketService.socketAddress().getPort(); + + // Configure the HTTP client with the client certificate + WebSocketClientOptions clientOptions = + new WebSocketClientOptions() + .setSsl(true) + .setKeyStoreOptions( + new JksOptions() + .setPath(clientKeystoreFile.getAbsolutePath()) + .setPassword("password")) + .setTrustOptions( + new JksOptions() + .setPath(clientTruststoreFile.getAbsolutePath()) + .setPassword("password")) + .setVerifyHost(true); + + WebSocketClient webSocketClient = vertx.createWebSocketClient(clientOptions); + webSocketClient + .connect(port, "localhost", "/") + .onSuccess( + ws -> { + assertThat(ws.isSsl()).isTrue(); + ws.close(); + testContext.completeNow(); + }) + .onFailure(testContext::failNow); + + assertThat(testContext.awaitCompletion(5, TimeUnit.SECONDS)).isTrue(); + if (testContext.failed()) { + throw testContext.causeOfFailure(); + } + + // Stop the WebSocketService after the test + webSocketService.stop().join(); + } +} From 62b2c500c4baeb02674cd5568cb3e02bcb26e8ec Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Fri, 8 Nov 2024 12:25:59 +0100 Subject: [PATCH 12/20] Fix missing registration of PeerTransactionTracker to dropped tx notifications (#7858) Signed-off-by: Fabio Di Fabio --- .../ethereum/eth/transactions/TransactionBroadcaster.java | 8 +++++++- .../besu/ethereum/eth/transactions/TransactionPool.java | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionBroadcaster.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionBroadcaster.java index c60c064c4c..35f438d419 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionBroadcaster.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionBroadcaster.java @@ -37,7 +37,8 @@ import com.google.common.annotations.VisibleForTesting; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TransactionBroadcaster implements TransactionBatchAddedListener { +public class TransactionBroadcaster + implements TransactionBatchAddedListener, PendingTransactionDroppedListener { private static final Logger LOG = LoggerFactory.getLogger(TransactionBroadcaster.class); private static final EnumSet ANNOUNCE_HASH_ONLY_TX_TYPES = EnumSet.of(BLOB); @@ -219,4 +220,9 @@ public class TransactionBroadcaster implements TransactionBatchAddedListener { destinationList.add(sourceList.remove(i)); } } + + @Override + public void onTransactionDropped(final Transaction transaction, final RemovalReason reason) { + transactionTracker.onTransactionDropped(transaction, reason); + } } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java index 19bcfe0b36..3acf49894a 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java @@ -139,6 +139,7 @@ public class TransactionPool implements BlockAddedObserver { subscribePendingTransactions(this::mapBlobsOnTransactionAdded); subscribeDroppedTransactions( (transaction, reason) -> unmapBlobsOnTransactionDropped(transaction)); + subscribeDroppedTransactions(transactionBroadcaster); } private void initLogForReplay() { From 62b8b4e1d87d07107085a037c1e99ad951b47a0e Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Fri, 8 Nov 2024 13:44:28 +0100 Subject: [PATCH 13/20] Make healing an action of the WorldStateArchive (#7862) Signed-off-by: Fabio Di Fabio --- .../controller/BesuControllerBuilder.java | 17 ++++++-- .../besu/ethereum/MainnetBlockValidator.java | 2 +- .../bonsai/BonsaiWorldStateProvider.java | 15 ++++++- .../trie/forest/ForestWorldStateArchive.java | 5 +++ .../worldstate/WorldStateArchive.java | 20 ++++++++++ .../core/InMemoryKeyValueStorageProvider.java | 5 ++- .../ethereum/core/WorldStateHealerHelper.java | 39 +++++++++++++++++++ .../bonsai/AbstractIsolationTests.java | 4 +- .../bonsai/BonsaiWorldStateProviderTest.java | 22 +++++++---- 9 files changed, 114 insertions(+), 15 deletions(-) create mode 100644 ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/WorldStateHealerHelper.java diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index 5eb5e1214d..a2e1a1b6c5 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -93,6 +93,7 @@ import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive; import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration; import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive.WorldStateHealer; import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator; @@ -113,6 +114,7 @@ import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.OptionalLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; import org.slf4j.Logger; @@ -589,9 +591,14 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides .map(BesuComponent::getCachedMerkleTrieLoader) .orElseGet(() -> new BonsaiCachedMerkleTrieLoader(metricsSystem)); + final var worldStateHealerSupplier = new AtomicReference(); + final WorldStateArchive worldStateArchive = createWorldStateArchive( - worldStateStorageCoordinator, blockchain, bonsaiCachedMerkleTrieLoader); + worldStateStorageCoordinator, + blockchain, + bonsaiCachedMerkleTrieLoader, + worldStateHealerSupplier::get); if (maybeStoredGenesisBlockHash.isEmpty()) { genesisState.writeStateTo(worldStateArchive.getMutable()); @@ -713,6 +720,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides ethProtocolManager, pivotBlockSelector); + worldStateHealerSupplier.set(synchronizer::healWorldState); + ethPeers.setTrailingPeerRequirementsSupplier(synchronizer::calculateTrailingPeerRequirements); if (syncConfig.getSyncMode() == SyncMode.SNAP @@ -1101,7 +1110,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides WorldStateArchive createWorldStateArchive( final WorldStateStorageCoordinator worldStateStorageCoordinator, final Blockchain blockchain, - final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader) { + final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader, + final Supplier worldStateHealerSupplier) { return switch (dataStorageConfiguration.getDataStorageFormat()) { case BONSAI -> { final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage = @@ -1116,7 +1126,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides .getMaxLayersToLoad()), bonsaiCachedMerkleTrieLoader, besuComponent.map(BesuComponent::getBesuPluginContext).orElse(null), - evmConfiguration); + evmConfiguration, + worldStateHealerSupplier); } case FOREST -> { final WorldStatePreimageStorage preimageStorage = diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java index b218982c09..39f5cb0f66 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java @@ -181,7 +181,7 @@ public class MainnetBlockValidator implements BlockValidator { Optional.of(new BlockProcessingOutputs(worldState, receipts, maybeRequests))); } } catch (MerkleTrieException ex) { - context.getSynchronizer().healWorldState(ex.getMaybeAddress(), ex.getLocation()); + context.getWorldStateArchive().heal(ex.getMaybeAddress(), ex.getLocation()); return new BlockProcessingResult(Optional.empty(), ex); } catch (StorageException ex) { var retval = new BlockProcessingResult(Optional.empty(), ex); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProvider.java index e4b7ea991f..96a56da6e2 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProvider.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProvider.java @@ -34,6 +34,7 @@ import java.util.HashSet; import java.util.Optional; import java.util.Set; import java.util.function.Function; +import java.util.function.Supplier; import com.google.common.annotations.VisibleForTesting; import org.apache.tuweni.bytes.Bytes; @@ -44,6 +45,7 @@ public class BonsaiWorldStateProvider extends DiffBasedWorldStateProvider { private static final Logger LOG = LoggerFactory.getLogger(BonsaiWorldStateProvider.class); private final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader; + private final Supplier worldStateHealerSupplier; public BonsaiWorldStateProvider( final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage, @@ -51,9 +53,11 @@ public class BonsaiWorldStateProvider extends DiffBasedWorldStateProvider { final Optional maxLayersToLoad, final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader, final BesuContext pluginContext, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final Supplier worldStateHealerSupplier) { super(worldStateKeyValueStorage, blockchain, maxLayersToLoad, pluginContext); this.bonsaiCachedMerkleTrieLoader = bonsaiCachedMerkleTrieLoader; + this.worldStateHealerSupplier = worldStateHealerSupplier; provideCachedWorldStorageManager( new BonsaiCachedWorldStorageManager( this, worldStateKeyValueStorage, this::cloneBonsaiWorldStateConfig)); @@ -69,9 +73,11 @@ public class BonsaiWorldStateProvider extends DiffBasedWorldStateProvider { final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage, final Blockchain blockchain, final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final Supplier worldStateHealerSupplier) { super(worldStateKeyValueStorage, blockchain, trieLogManager); this.bonsaiCachedMerkleTrieLoader = bonsaiCachedMerkleTrieLoader; + this.worldStateHealerSupplier = worldStateHealerSupplier; provideCachedWorldStorageManager(bonsaiCachedWorldStorageManager); loadPersistedState( new BonsaiWorldState( @@ -151,4 +157,9 @@ public class BonsaiWorldStateProvider extends DiffBasedWorldStateProvider { private DiffBasedWorldStateConfig cloneBonsaiWorldStateConfig() { return new DiffBasedWorldStateConfig(defaultWorldStateConfig); } + + @Override + public void heal(final Optional
maybeAccountToRepair, final Bytes location) { + worldStateHealerSupplier.get().heal(maybeAccountToRepair, location); + } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java index 1cdd079e15..800d2c9834 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java @@ -112,6 +112,11 @@ public class ForestWorldStateArchive implements WorldStateArchive { blockHeader.getStateRoot(), accountAddress, accountStorageKeys)); } + @Override + public void heal(final Optional
maybeAccountToRepair, final Bytes location) { + // no heal needed for Forest + } + @Override public void close() { // no op diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java index 23859ac396..9856a200b2 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java @@ -64,4 +64,24 @@ public interface WorldStateArchive extends Closeable { final Address accountAddress, final List accountStorageKeys, final Function, ? extends Optional> mapper); + + /** + * Heal the world state to fix inconsistency + * + * @param maybeAccountToRepair the optional account to repair + * @param location the location of the inconsistency + */ + void heal(Optional
maybeAccountToRepair, Bytes location); + + /** A world state healer */ + @FunctionalInterface + interface WorldStateHealer { + /** + * Heal the world state to fix inconsistency + * + * @param maybeAccountToRepair the optional account to repair + * @param location the location of the inconsistency + */ + void heal(Optional
maybeAccountToRepair, Bytes location); + } } diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java index 9bac925494..aa32ee2b05 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java @@ -14,6 +14,8 @@ */ package org.hyperledger.besu.ethereum.core; +import static org.hyperledger.besu.ethereum.core.WorldStateHealerHelper.throwingWorldStateHealerSupplier; + import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.DefaultBlockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; @@ -105,7 +107,8 @@ public class InMemoryKeyValueStorageProvider extends KeyValueStorageProvider { Optional.empty(), bonsaiCachedMerkleTrieLoader, null, - evmConfiguration); + evmConfiguration, + throwingWorldStateHealerSupplier()); } public static MutableWorldState createInMemoryWorldState() { diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/WorldStateHealerHelper.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/WorldStateHealerHelper.java new file mode 100644 index 0000000000..a94ce24793 --- /dev/null +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/WorldStateHealerHelper.java @@ -0,0 +1,39 @@ +/* + * Copyright contributors to Besu. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.hyperledger.besu.ethereum.core; + +import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive.WorldStateHealer; + +import java.util.Optional; +import java.util.function.Supplier; + +import org.apache.tuweni.bytes.Bytes; + +public class WorldStateHealerHelper { + + public static WorldStateHealer throwingHealer( + final Optional
maybeAccountToRepair, final Bytes location) { + throw new RuntimeException( + "World state needs to be healed: " + + maybeAccountToRepair.map(address -> "account to repair: " + address).orElse("") + + " location: " + + location.toHexString()); + } + + public static Supplier throwingWorldStateHealerSupplier() { + return () -> WorldStateHealerHelper::throwingHealer; + } +} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java index 999d33a5c5..cfb3094726 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.trie.diffbased.bonsai; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain; +import static org.hyperledger.besu.ethereum.core.WorldStateHealerHelper.throwingWorldStateHealerSupplier; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; @@ -167,7 +168,8 @@ public abstract class AbstractIsolationTests { Optional.of(16L), new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()), null, - EvmConfiguration.DEFAULT); + EvmConfiguration.DEFAULT, + throwingWorldStateHealerSupplier()); var ws = archive.getMutable(); genesisState.writeStateTo(ws); protocolContext = new ProtocolContext(blockchain, archive, null, new BadBlockManager()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProviderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProviderTest.java index 4ac99377ef..87cc16c23c 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProviderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProviderTest.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.trie.diffbased.bonsai; import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.ethereum.core.WorldStateHealerHelper.throwingWorldStateHealerSupplier; import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.BLOCKCHAIN; import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE; import static org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage.WORLD_BLOCK_HASH_KEY; @@ -111,7 +112,8 @@ class BonsaiWorldStateProviderTest { DataStorageConfiguration.DEFAULT_BONSAI_CONFIG), blockchain, new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()), - EvmConfiguration.DEFAULT); + EvmConfiguration.DEFAULT, + throwingWorldStateHealerSupplier()); assertThat(bonsaiWorldStateArchive.getMutable(chainHead, true)) .containsInstanceOf(BonsaiWorldState.class); @@ -129,7 +131,8 @@ class BonsaiWorldStateProviderTest { Optional.of(512L), new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()), null, - EvmConfiguration.DEFAULT); + EvmConfiguration.DEFAULT, + throwingWorldStateHealerSupplier()); final BlockHeader blockHeader = blockBuilder.number(0).buildHeader(); final BlockHeader chainHead = blockBuilder.number(512).buildHeader(); when(blockchain.getChainHeadHeader()).thenReturn(chainHead); @@ -150,7 +153,8 @@ class BonsaiWorldStateProviderTest { DataStorageConfiguration.DEFAULT_BONSAI_CONFIG), blockchain, new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()), - EvmConfiguration.DEFAULT); + EvmConfiguration.DEFAULT, + throwingWorldStateHealerSupplier()); final BlockHeader blockHeader = blockBuilder.number(0).buildHeader(); final BlockHeader chainHead = blockBuilder.number(511).buildHeader(); final BonsaiWorldState mockWorldState = mock(BonsaiWorldState.class); @@ -185,7 +189,8 @@ class BonsaiWorldStateProviderTest { worldStateKeyValueStorage, blockchain, new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()), - EvmConfiguration.DEFAULT)); + EvmConfiguration.DEFAULT, + throwingWorldStateHealerSupplier())); final BlockHeader blockHeader = blockBuilder.number(0).buildHeader(); when(blockchain.getBlockHeader(blockHeader.getHash())).thenReturn(Optional.of(blockHeader)); @@ -214,7 +219,8 @@ class BonsaiWorldStateProviderTest { worldStateKeyValueStorage, blockchain, new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()), - EvmConfiguration.DEFAULT)); + EvmConfiguration.DEFAULT, + throwingWorldStateHealerSupplier())); final BlockHeader blockHeader = blockBuilder.number(0).buildHeader(); @@ -254,7 +260,8 @@ class BonsaiWorldStateProviderTest { worldStateKeyValueStorage, blockchain, new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()), - EvmConfiguration.DEFAULT)); + EvmConfiguration.DEFAULT, + throwingWorldStateHealerSupplier())); // initial persisted state hash key when(blockchain.getBlockHeader(Hash.ZERO)).thenReturn(Optional.of(blockHeaderChainA)); @@ -297,7 +304,8 @@ class BonsaiWorldStateProviderTest { DataStorageConfiguration.DEFAULT_BONSAI_CONFIG), blockchain, new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()), - EvmConfiguration.DEFAULT)); + EvmConfiguration.DEFAULT, + throwingWorldStateHealerSupplier())); // initial persisted state hash key when(blockchain.getBlockHeader(Hash.ZERO)).thenReturn(Optional.of(blockHeaderChainA)); From 1c75afbab99646cc9c8c7a6207d4b8c886e25db5 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Fri, 8 Nov 2024 15:40:02 +0100 Subject: [PATCH 14/20] Remove the Synchronizer from ProtocolContext (#7863) Signed-off-by: Fabio Di Fabio --- .../controller/BesuControllerBuilder.java | 11 +++++----- .../blockcreation/MergeCoordinatorTest.java | 2 -- .../besu/ethereum/ProtocolContext.java | 20 ------------------- .../ethereum/core/BlockchainSetupUtil.java | 1 - .../ethereum/MainnetBlockValidatorTest.java | 2 -- .../eth/manager/snap/SnapProtocolManager.java | 7 +++++-- .../ethereum/eth/manager/snap/SnapServer.java | 6 ++++-- .../snap/SnapServerGetAccountRangeTest.java | 5 ++++- 8 files changed, 19 insertions(+), 35 deletions(-) diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index a2e1a1b6c5..9059d2209b 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -45,6 +45,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; +import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.SnapProtocol; @@ -732,11 +733,9 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides ethPeers.snapServerPeersNeeded(false); } - protocolContext.setSynchronizer(synchronizer); - final Optional maybeSnapProtocolManager = createSnapProtocolManager( - protocolContext, worldStateStorageCoordinator, ethPeers, snapMessages); + protocolContext, worldStateStorageCoordinator, ethPeers, snapMessages, synchronizer); final MiningCoordinator miningCoordinator = createMiningCoordinator( @@ -1097,14 +1096,16 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides final ProtocolContext protocolContext, final WorldStateStorageCoordinator worldStateStorageCoordinator, final EthPeers ethPeers, - final EthMessages snapMessages) { + final EthMessages snapMessages, + final Synchronizer synchronizer) { return Optional.of( new SnapProtocolManager( worldStateStorageCoordinator, syncConfig.getSnapSyncConfiguration(), ethPeers, snapMessages, - protocolContext)); + protocolContext, + synchronizer)); } WorldStateArchive createWorldStateArchive( diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java index 23a5ae16b1..90c4b6866e 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java @@ -59,7 +59,6 @@ import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.Unstable; import org.hyperledger.besu.ethereum.core.MiningConfiguration; -import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; @@ -190,7 +189,6 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { protocolContext = new ProtocolContext(blockchain, worldStateArchive, mergeContext, badBlockManager); - protocolContext.setSynchronizer(mock(Synchronizer.class)); var mutable = worldStateArchive.getMutable(); genesisState.writeStateTo(mutable); mutable.persist(null); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java index 4ca40bc0a9..53197ea9c5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java @@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; @@ -32,7 +31,6 @@ public class ProtocolContext { private final WorldStateArchive worldStateArchive; private final BadBlockManager badBlockManager; private final ConsensusContext consensusContext; - private Synchronizer synchronizer; /** * Constructs a new ProtocolContext with the given blockchain, world state archive, consensus @@ -78,24 +76,6 @@ public class ProtocolContext { badBlockManager); } - /** - * Gets the synchronizer of the protocol context. - * - * @return the synchronizer of the protocol context - */ - public Synchronizer getSynchronizer() { - return synchronizer; - } - - /** - * Sets the synchronizer of the protocol context. - * - * @param synchronizer the synchronizer to set - */ - public void setSynchronizer(final Synchronizer synchronizer) { - this.synchronizer = synchronizer; - } - /** * Gets the blockchain of the protocol context. * diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java index 57f1158585..b7608bb5de 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java @@ -194,7 +194,6 @@ public class BlockchainSetupUtil { genesisState.writeStateTo(worldArchive.getMutable()); final ProtocolContext protocolContext = protocolContextProvider.get(blockchain, worldArchive); - protocolContext.setSynchronizer(new DummySynchronizer()); final Path blocksPath = Path.of(chainResources.getBlocksURL().toURI()); final List blocks = new ArrayList<>(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java index 013adae51e..255ea77839 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java @@ -31,7 +31,6 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.mainnet.BlockBodyValidator; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.BlockProcessor; @@ -91,7 +90,6 @@ public class MainnetBlockValidatorTest { when(protocolContext.getBlockchain()).thenReturn(blockchain); when(protocolContext.getWorldStateArchive()).thenReturn(worldStateArchive); - when(protocolContext.getSynchronizer()).thenReturn(mock(Synchronizer.class)); when(worldStateArchive.getMutable(any(BlockHeader.class), anyBoolean())) .thenReturn(Optional.of(worldState)); when(worldStateArchive.getMutable(any(Hash.class), any(Hash.class))) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapProtocolManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapProtocolManager.java index ce639a7a9a..2e49eba353 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapProtocolManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapProtocolManager.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.eth.manager.snap; import org.hyperledger.besu.ethereum.ProtocolContext; +import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.SnapProtocol; import org.hyperledger.besu.ethereum.eth.manager.EthMessage; import org.hyperledger.besu.ethereum.eth.manager.EthMessages; @@ -53,11 +54,13 @@ public class SnapProtocolManager implements ProtocolManager { final SnapSyncConfiguration snapConfig, final EthPeers ethPeers, final EthMessages snapMessages, - final ProtocolContext protocolContext) { + final ProtocolContext protocolContext, + final Synchronizer synchronizer) { this.ethPeers = ethPeers; this.snapMessages = snapMessages; this.supportedCapabilities = calculateCapabilities(); - new SnapServer(snapConfig, snapMessages, worldStateStorageCoordinator, protocolContext); + new SnapServer( + snapConfig, snapMessages, worldStateStorageCoordinator, protocolContext, synchronizer); } private List calculateCapabilities() { diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServer.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServer.java index 56c3ae0a4a..35cc63cde8 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServer.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServer.java @@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.eth.manager.snap; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.ProtocolContext; +import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.manager.EthMessages; import org.hyperledger.besu.ethereum.eth.messages.snap.AccountRangeMessage; import org.hyperledger.besu.ethereum.eth.messages.snap.ByteCodesMessage; @@ -98,7 +99,8 @@ class SnapServer implements BesuEvents.InitialSyncCompletionListener { final SnapSyncConfiguration snapConfig, final EthMessages snapMessages, final WorldStateStorageCoordinator worldStateStorageCoordinator, - final ProtocolContext protocolContext) { + final ProtocolContext protocolContext, + final Synchronizer synchronizer) { this.snapServerEnabled = Optional.ofNullable(snapConfig) .map(SnapSyncConfiguration::isSnapServerEnabled) @@ -110,7 +112,7 @@ class SnapServer implements BesuEvents.InitialSyncCompletionListener { // subscribe to initial sync completed events to start/stop snap server, // not saving the listenerId since we never need to unsubscribe. - protocolContext.getSynchronizer().subscribeInitialSync(this); + synchronizer.subscribeInitialSync(this); } /** diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServerGetAccountRangeTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServerGetAccountRangeTest.java index 6d8180c8c0..eb97419967 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServerGetAccountRangeTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServerGetAccountRangeTest.java @@ -15,10 +15,12 @@ package org.hyperledger.besu.ethereum.eth.manager.snap; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.mockito.Mockito.mock; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; +import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.manager.EthMessages; import org.hyperledger.besu.ethereum.eth.messages.snap.AccountRangeMessage; import org.hyperledger.besu.ethereum.eth.messages.snap.GetAccountRangeMessage; @@ -70,7 +72,8 @@ public class SnapServerGetAccountRangeTest { snapSyncConfiguration, new EthMessages(), worldStateStorageCoordinator, - protocolContext) + protocolContext, + mock(Synchronizer.class)) .start(); initAccounts(); } From 1895d44415f4cb8db97a0804bb2002b2a1c4d4a8 Mon Sep 17 00:00:00 2001 From: Dmitry <98899785+mdqst@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:03:43 +0300 Subject: [PATCH 15/20] Typo Update trace_rpc_apis.md (#7868) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "ope.ex.mem" should be "op.ex.mem" — The abbreviation for "opcode execution" should be "op" rather than "ope." Corrected. Signed-off-by: Dmitry <98899785+mdqst@users.noreply.github.com> Co-authored-by: Sally MacFarlane --- docs/trace_rpc_apis.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/trace_rpc_apis.md b/docs/trace_rpc_apis.md index e8db0bcbc5..7f04d497a7 100644 --- a/docs/trace_rpc_apis.md +++ b/docs/trace_rpc_apis.md @@ -16,7 +16,7 @@ implementations of Besu might track gas refunds separately. ### Returned Memory from Calls -In the `vmTrace` `ope.ex.mem` fields Besu only reports actual data returned +In the `vmTrace` `op.ex.mem` fields Besu only reports actual data returned from a `RETURN` opcode. Other implementations return the contents of the reserved output space for the call operations. Note two major differences: From c15afb915bdb2fa53e41807c8794b80151e9c5d3 Mon Sep 17 00:00:00 2001 From: amsmota Date: Wed, 13 Nov 2024 08:50:56 +0000 Subject: [PATCH 16/20] control jemalloc reporting and loading (#7424) * Implementing Issue #7047 - Optionally load jemalloc Signed-off-by: Antonio Mota * Implementing Issue #7047 - Optionally load jemalloc Signed-off-by: Antonio Mota * Implementing Issue #7047 - Optionally load jemalloc: fixes after review Signed-off-by: Antonio Mota * Implementing Issue #7047 - Optionally load jemalloc: added entry to CHANGELOG Signed-off-by: Antonio Mota * Changes after review Signed-off-by: Antonio Mota * Added env var check in unix script Signed-off-by: Antonio Mota * Improved code and script, build and tested Signed-off-by: amsmota * Improved code and script, build and tested Signed-off-by: amsmota --------- Signed-off-by: Antonio Mota Signed-off-by: amsmota --- CHANGELOG.md | 1 + .../cli/ConfigurationOverviewBuilder.java | 14 +++++++---- besu/src/main/scripts/unixStartScript.txt | 24 +++++++++---------- .../hyperledger/besu/cli/BesuCommandTest.java | 12 ++++++---- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b78adf6e06..7b02f81270 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,7 @@ This release version has been deprecated release due to CI bug - Remove long-deprecated `perm*whitelist*` methods [#7401](https://github.com/hyperledger/besu/pull/7401) ### Additions and Improvements +- Allow optional loading of `jemalloc` (if installed) by setting the environment variable `BESU_USING_JEMALLOC` to true/false. It that env is not set at all it will behave as if it is set to `true` - Expose set finalized/safe block in plugin api BlockchainService. These method can be used by plugins to set finalized/safe block for a PoA network (such as QBFT, IBFT and Clique).[#7382](https://github.com/hyperledger/besu/pull/7382) - In process RPC service [#7395](https://github.com/hyperledger/besu/pull/7395) - Added support for tracing private transactions using `priv_traceTransaction` API. [#6161](https://github.com/hyperledger/besu/pull/6161) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java index b3dfa2a054..a7b43d0d9e 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -433,14 +433,18 @@ public class ConfigurationOverviewBuilder { private void detectJemalloc(final List lines) { Optional.ofNullable(Objects.isNull(environment) ? null : environment.get("BESU_USING_JEMALLOC")) .ifPresentOrElse( - t -> { + jemallocEnabled -> { try { - final String version = PlatformDetector.getJemalloc(); - lines.add("jemalloc: " + version); + if (Boolean.parseBoolean(jemallocEnabled)) { + final String version = PlatformDetector.getJemalloc(); + lines.add("jemalloc: " + version); + } else { + logger.warn( + "besu_using_jemalloc is present but is not set to true, jemalloc library not loaded"); + } } catch (final Throwable throwable) { logger.warn( - "BESU_USING_JEMALLOC is present but we failed to load jemalloc library to get the version", - throwable); + "besu_using_jemalloc is present but we failed to load jemalloc library to get the version"); } }, () -> { diff --git a/besu/src/main/scripts/unixStartScript.txt b/besu/src/main/scripts/unixStartScript.txt index 3302b9c2fe..9e5c5a300b 100644 --- a/besu/src/main/scripts/unixStartScript.txt +++ b/besu/src/main/scripts/unixStartScript.txt @@ -182,19 +182,19 @@ APP_ARGS=`save "\$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- \$DEFAULT_JVM_OPTS \$JAVA_OPTS \$${optsEnvironmentVar} <% if ( appNameSystemProperty ) { %>"\"-D${appNameSystemProperty}=\$APP_BASE_NAME\"" <% } %>-classpath "\"\$CLASSPATH\"" <% if ( mainClassName.startsWith('--module ') ) { %>--module-path "\"\$MODULE_PATH\"" <% } %>${mainClassName} "\$APP_ARGS" -unset BESU_USING_JEMALLOC if [ "\$darwin" = "false" -a "\$msys" = "false" ]; then - # check if jemalloc is available - TEST_JEMALLOC=\$(LD_PRELOAD=libjemalloc.so sh -c true 2>&1) - - # if jemalloc is available the output is empty, otherwise the output has an error line - if [ -z "\$TEST_JEMALLOC" ]; then - export LD_PRELOAD=libjemalloc.so - export BESU_USING_JEMALLOC=true - else - # jemalloc not available, as fallback limit malloc to 2 arenas - export MALLOC_ARENA_MAX=2 - fi + if [ "\$BESU_USING_JEMALLOC" != "FALSE" -a "\$BESU_USING_JEMALLOC" != "false" ]; then + # check if jemalloc is available + TEST_JEMALLOC=\$(LD_PRELOAD=libjemalloc.so sh -c true 2>&1) + + # if jemalloc is available the output is empty, otherwise the output has an error line + if [ -z "\$TEST_JEMALLOC" ]; then + export LD_PRELOAD=libjemalloc.so + else + # jemalloc not available, as fallback limit malloc to 2 arenas + export MALLOC_ARENA_MAX=2 + fi + fi fi exec "\$JAVACMD" "\$@" 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 ea06f406ed..eb789478b9 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -37,6 +37,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.contains; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNotNull; +import static org.mockito.Mockito.argThat; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -2412,13 +2413,16 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void logsWarningWhenFailToLoadJemalloc() { assumeTrue(PlatformDetector.getOSType().equals("linux")); - setEnvironmentVariable("BESU_USING_JEMALLOC", "true"); + setEnvironmentVariable("BESU_USING_JEMALLOC", "false"); parseCommand(); verify(mockLogger) .warn( - eq( - "BESU_USING_JEMALLOC is present but we failed to load jemalloc library to get the version"), - any(Throwable.class)); + argThat( + arg -> + arg.equals( + "besu_using_jemalloc is present but is not set to true, jemalloc library not loaded") + || arg.equals( + "besu_using_jemalloc is present but we failed to load jemalloc library to get the version"))); } @Test From f156a17d3fb207a348533967b18f56ab96b4dbba Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Thu, 14 Nov 2024 04:58:05 +0100 Subject: [PATCH 17/20] Fix registration of RocksDB metrics categories (#7879) Signed-off-by: Fabio Di Fabio --- .../besu/cli/options/MetricsOptionsTest.java | 24 +++++++++++++++++++ .../metrics/MetricCategoryRegistryImpl.java | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java index 39e77cbad7..f68a87643b 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java @@ -14,12 +14,18 @@ */ package org.hyperledger.besu.cli.options; +import static org.assertj.core.api.Assertions.assertThat; + import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl; import org.hyperledger.besu.metrics.StandardMetricCategory; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; +import java.util.EnumSet; +import java.util.stream.Collectors; + import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; @@ -64,4 +70,22 @@ public class MetricsOptionsTest protected String[] getNonOptionFields() { return new String[] {"metricCategoryRegistry"}; } + + @Test + public void enableRocksDbCategories() { + final var rocksDbMetricsCategories = + EnumSet.of( + BesuMetricCategory.KVSTORE_ROCKSDB, + BesuMetricCategory.KVSTORE_ROCKSDB_STATS, + BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB, + BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB_STATS); + + internalTestSuccess( + metricsConfBuilder -> { + assertThat(metricsConfBuilder.build().getMetricCategories()) + .containsExactlyInAnyOrderElementsOf(rocksDbMetricsCategories); + }, + "--metrics-categories", + rocksDbMetricsCategories.stream().map(Enum::name).collect(Collectors.joining(","))); + } } diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricCategoryRegistryImpl.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricCategoryRegistryImpl.java index 6596268acb..43feef12ac 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricCategoryRegistryImpl.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricCategoryRegistryImpl.java @@ -40,7 +40,8 @@ public class MetricCategoryRegistryImpl implements MetricCategoryRegistry { * @param categoryEnum the category enum */ public & MetricCategory> void addCategories(final Class categoryEnum) { - EnumSet.allOf(categoryEnum).forEach(this::addMetricCategory); + EnumSet.allOf(categoryEnum) + .forEach(category -> metricCategories.put(category.name(), category)); } /** From e548cdc487789ae2e38fc15daab7b6fdf9fb1480 Mon Sep 17 00:00:00 2001 From: Gabriel-Trintinalia Date: Thu, 14 Nov 2024 15:44:40 +1100 Subject: [PATCH 18/20] MAINTAINERS - Add Matilda Clerke (#7829) Signed-off-by: Gabriel-Trintinalia --- MAINTAINERS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS.md b/MAINTAINERS.md index afb82b6fc5..6c17df8823 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -22,6 +22,7 @@ | Luis Pinto | lu-pinto | lu-pinto | | Lucas Saldanha | lucassaldanha | lucassaldanha | | Sally MacFarlane | macfarla | macfarla | +| Matilda Clerke | Matilda-Clerke | MatildaClerke | | Karim Taam | matkt | matkt | | Matthew Whitehead| matthew1001 | matthew.whitehead | | Meredith Baxter | mbaxter | mbaxter | From 40b27a15d2c4ee2f4f8442dbcc6da2c0d9a9c051 Mon Sep 17 00:00:00 2001 From: Matt Whitehead Date: Thu, 14 Nov 2024 14:45:34 +0700 Subject: [PATCH 19/20] Upgrade netty to 4.1.115 (latest version) to resolve CVE (#7878) * Upgrade netty to 4.1.115 (latest version) to resolve CVE Signed-off-by: Matthew Whitehead * Update changelog Signed-off-by: Matthew Whitehead --------- Signed-off-by: Matthew Whitehead --- CHANGELOG.md | 1 + gradle/verification-metadata.xml | 297 +++++++++++++++++++++++++++++++ platform/build.gradle | 2 +- 3 files changed, 299 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b02f81270..a0a53280fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ ### Bug fixes - Fix registering new metric categories from plugins [#7825](https://github.com/hyperledger/besu/pull/7825) +- Fix CVE-2024-47535 [7878](https://github.com/hyperledger/besu/pull/7878) ## 24.10.0 diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index d4407855f0..5c143f63a6 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -1932,6 +1932,14 @@ + + + + + + + + @@ -1942,6 +1950,11 @@ + + + + + @@ -1955,6 +1968,14 @@ + + + + + + + + @@ -1963,6 +1984,14 @@ + + + + + + + + @@ -1971,6 +2000,14 @@ + + + + + + + + @@ -1979,6 +2016,14 @@ + + + + + + + + @@ -1992,6 +2037,14 @@ + + + + + + + + @@ -2005,6 +2058,14 @@ + + + + + + + + @@ -2013,6 +2074,14 @@ + + + + + + + + @@ -2021,6 +2090,14 @@ + + + + + + + + @@ -2029,6 +2106,14 @@ + + + + + + + + @@ -2037,6 +2122,14 @@ + + + + + + + + @@ -2045,6 +2138,14 @@ + + + + + + + + @@ -2053,6 +2154,14 @@ + + + + + + + + @@ -2061,6 +2170,14 @@ + + + + + + + + @@ -2074,6 +2191,14 @@ + + + + + + + + @@ -2087,6 +2212,14 @@ + + + + + + + + @@ -2100,6 +2233,14 @@ + + + + + + + + @@ -2108,6 +2249,14 @@ + + + + + + + + @@ -2118,6 +2267,11 @@ + + + + + @@ -2131,6 +2285,14 @@ + + + + + + + + @@ -2144,6 +2306,14 @@ + + + + + + + + @@ -2152,6 +2322,14 @@ + + + + + + + + @@ -2163,6 +2341,17 @@ + + + + + + + + + + + @@ -2176,6 +2365,14 @@ + + + + + + + + @@ -2184,11 +2381,24 @@ + + + + + + + + + + + + + @@ -2202,6 +2412,14 @@ + + + + + + + + @@ -2210,6 +2428,14 @@ + + + + + + + + @@ -2218,6 +2444,14 @@ + + + + + + + + @@ -2240,6 +2474,23 @@ + + + + + + + + + + + + + + + + + @@ -2259,6 +2510,20 @@ + + + + + + + + + + + + + + @@ -2272,6 +2537,14 @@ + + + + + + + + @@ -2280,6 +2553,14 @@ + + + + + + + + @@ -2288,6 +2569,14 @@ + + + + + + + + @@ -2296,6 +2585,14 @@ + + + + + + + + diff --git a/platform/build.gradle b/platform/build.gradle index d614603f17..dad2d8e1a0 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -28,7 +28,7 @@ javaPlatform { dependencies { api platform('com.fasterxml.jackson:jackson-bom:2.18.0') api platform('io.grpc:grpc-bom:1.68.0') - api platform('io.netty:netty-bom:4.1.114.Final') + api platform('io.netty:netty-bom:4.1.115.Final') api platform('io.opentelemetry:opentelemetry-bom:1.43.0') api platform('io.prometheus:simpleclient_bom:0.16.0') api platform('io.vertx:vertx-stack-depchain:4.5.10') From 37ea0282de17f393531a6ee7be2dbfe92d0910ac Mon Sep 17 00:00:00 2001 From: Dmitry <98899785+mdqst@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:33:06 +0300 Subject: [PATCH 20/20] Typo Update Private-Txns-Migration.md (#7870) The phrase "private transaction created using v1.3.4" should be in the plural form: "private transactions created using v1.3.4". Corrected. Signed-off-by: Dmitry <98899785+mdqst@users.noreply.github.com> Co-authored-by: Sally MacFarlane --- docs/Private-Txns-Migration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Private-Txns-Migration.md b/docs/Private-Txns-Migration.md index 0ae06dae3c..042e83c8dd 100644 --- a/docs/Private-Txns-Migration.md +++ b/docs/Private-Txns-Migration.md @@ -12,7 +12,7 @@ state storage when upgrading to v1.4. It is not possible to upgrade to v1.4 with ## Private transactions created using v1.3.4 or earlier A critical issue for privacy users with private transactions created using Hyperledger Besu v1.3.4 -or earlier has been identified. If you have a network with private transaction created using v1.3.4 +or earlier has been identified. If you have a network with private transactions created using v1.3.4 or earlier, please read the following and take the appropriate steps: https://wiki.hyperledger.org/display/BESU/Critical+Issue+for+Privacy+Users @@ -41,4 +41,4 @@ your Besu database from backup and restart the migration process. ## Migration support If you have a long running network with a large volume of private transactions and/or would like to discuss -the migration process with us before upgrading, contact us at support@pegasys.tech \ No newline at end of file +the migration process with us before upgrading, contact us at support@pegasys.tech