mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-08 21:38:15 -05:00
Merge branch 'main' into zkbesu
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -402,9 +402,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
|
||||
|
||||
@@ -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<Hash> maybeBlockHash = getBlockchainQueries().getBlockHashByNumber(blockNumber);
|
||||
protected Object resultByBlockHash(final JsonRpcRequestContext request, final Hash blockHash) {
|
||||
var blockchainQueries = getBlockchainQueries();
|
||||
var blockchain = protocolContext.getBlockchain();
|
||||
Optional<BlockHeader> maybeBlockHeader = blockchainQueries.getBlockHeaderByHash(blockHash);
|
||||
Optional<Boolean> 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<BlockHeader> 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<Boolean> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Boolean> 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<BlockHeader> 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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user