Merge branch 'main' into zkbesu

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
This commit is contained in:
Gabriel-Trintinalia
2024-08-16 16:44:07 +10:00
152 changed files with 1834 additions and 825 deletions

View File

@@ -11,11 +11,16 @@ assignees: ''
- [ ] Update changelog if necessary, and merge a PR for it to main
- [ ] Notify maintainers about updating changelog for in-flight PRs
- [ ] Optional: for hotfixes, create a release branch and cherry-pick, e.g. `release-<version>-hotfix`
- [ ] Optional: create a PR into main from the hotfix branch to see the CI checks pass
- [ ] Optional: for hotfixes, create a PR into main from the hotfix branch to see the CI checks pass
- [ ] On the appropriate branch/commit, create a calver tag for the release candidate, format example: `24.4.0-RC2`
- [ ] Sign-off with team; confirm tag is correct in #besu-release in Discord
- [ ] Consensys staff start burn-in using the proposed release <version-RCX> tag
- [ ] Sign off burn-in; convey burn-in results in #besu-release in Discord
- [ ] git tag 24.4.0-RC2
- [ ] git push upstream 24.4.0-RC2
- [ ] Sign-off with team; announce the tag in #besu-release in Discord
- [ ] Targeting this tag for the burn-in: https://github.com/hyperledger/besu/releases/tag/24.4.0-RC2
- [ ] Consensys staff start burn-in using this tag
- [ ] Seek sign off for burn-in
- [ ] Pass? Go ahead and complete the release process
- [ ] Fail? Put a message in #besu-release in Discord indicating the release will be aborted because it failed burn-in
- [ ] Using the same git sha, create a calver tag for the FULL RELEASE, example format `24.4.0`
- [ ] Using the FULL RELEASE tag, create a release in github to trigger the workflows. Once published:
- this is now public and notifies subscribed users
@@ -24,8 +29,9 @@ assignees: ''
- publishes the docker `latest` tag variants
- [ ] Check binary SHAs are correct on the release page
- [ ] Check "Container Verify" GitHub workflow has run successfully
- [ ] Create homebrew release - run https://github.com/hyperledger/homebrew-besu/actions/workflows/update-version.yml
- [ ] Create besu-docs release - https://github.com/hyperledger/besu-docs/releases/new
- Copy release notes from besu
- If publishing the release in github doesn't automatically trigger this workflow, then manually run https://github.com/hyperledger/besu-docs/actions/workflows/update-version.yml
- [ ] Create homebrew release - run GHA workflow directly https://github.com/hyperledger/homebrew-besu/actions/workflows/update-version.yml
- [ ] Delete the burn-in nodes (unless required for further analysis eg performance)
- [ ] Social announcements

View File

@@ -17,12 +17,15 @@
- 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)
- Wrap WorldUpdater into EVMWorldupdater [#7434](https://github.com/hyperledger/besu/pull/7434)
- Bump besu-native to 0.9.4 [#7456](https://github.com/hyperledger/besu/pull/7456)
- Add 'inbound' field to admin_peers JSON-RPC Call [#7461](https://github.com/hyperledger/besu/pull/7461)
### Bug fixes
- Correct entrypoint in Docker evmtool [#7430](https://github.com/hyperledger/besu/pull/7430)
- Fix protocol schedule check for devnets [#7429](https://github.com/hyperledger/besu/pull/7429)
- Fix behaviour when starting in a pre-merge network [#7431](https://github.com/hyperledger/besu/pull/7431)
- Fix tracing in precompiled contracts when halting for out of gas [#7318](https://github.com/hyperledger/besu/issues/7318)
## 24.7.1

View File

@@ -432,7 +432,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
besuPluginContext.addService(PermissioningService.class, permissioningService);
besuPluginContext.addService(PrivacyPluginService.class, new PrivacyPluginServiceImpl());
besuPluginContext.registerPlugins(new PluginConfiguration(pluginsPath));
besuPluginContext.registerPlugins(
new PluginConfiguration.Builder().pluginsDir(pluginsPath).build());
// register built-in plugins
new RocksDBPlugin().register(besuPluginContext);

View File

@@ -64,7 +64,8 @@ public class BesuPluginContextImplTest {
@Test
public void verifyEverythingGoesSmoothly() {
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY));
contextImpl.registerPlugins(
PluginConfiguration.builder().pluginsDir(DEFAULT_PLUGIN_DIRECTORY).build());
assertThat(contextImpl.getRegisteredPlugins()).isNotEmpty();
final Optional<TestPicoCLIPlugin> testPluginOptional =
@@ -86,7 +87,8 @@ public class BesuPluginContextImplTest {
System.setProperty("testPicoCLIPlugin.testOption", "FAILREGISTER");
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY));
contextImpl.registerPlugins(
PluginConfiguration.builder().pluginsDir(DEFAULT_PLUGIN_DIRECTORY).build());
assertThat(contextImpl.getRegisteredPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class);
contextImpl.beforeExternalServices();
@@ -104,7 +106,8 @@ public class BesuPluginContextImplTest {
System.setProperty("testPicoCLIPlugin.testOption", "FAILSTART");
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY));
contextImpl.registerPlugins(
PluginConfiguration.builder().pluginsDir(DEFAULT_PLUGIN_DIRECTORY).build());
assertThat(contextImpl.getRegisteredPlugins())
.extracting("class")
.contains(TestPicoCLIPlugin.class);
@@ -129,7 +132,8 @@ public class BesuPluginContextImplTest {
System.setProperty("testPicoCLIPlugin.testOption", "FAILSTOP");
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY));
contextImpl.registerPlugins(
PluginConfiguration.builder().pluginsDir(DEFAULT_PLUGIN_DIRECTORY).build());
assertThat(contextImpl.getRegisteredPlugins())
.extracting("class")
.contains(TestPicoCLIPlugin.class);
@@ -151,7 +155,9 @@ public class BesuPluginContextImplTest {
@Test
public void lifecycleExceptions() throws Throwable {
final ThrowableAssert.ThrowingCallable registerPlugins =
() -> contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY));
() ->
contextImpl.registerPlugins(
PluginConfiguration.builder().pluginsDir(DEFAULT_PLUGIN_DIRECTORY).build());
assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::startPlugins);
assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::stopPlugins);
@@ -173,7 +179,8 @@ public class BesuPluginContextImplTest {
@Test
public void shouldRegisterAllPluginsWhenNoPluginsOption() {
final PluginConfiguration config = createConfigurationForAllPlugins();
final PluginConfiguration config =
PluginConfiguration.builder().pluginsDir(DEFAULT_PLUGIN_DIRECTORY).build();
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
contextImpl.registerPlugins(config);
@@ -227,12 +234,33 @@ public class BesuPluginContextImplTest {
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
}
private PluginConfiguration createConfigurationForAllPlugins() {
return new PluginConfiguration(null, DEFAULT_PLUGIN_DIRECTORY);
@Test
void shouldNotRegisterAnyPluginsIfExternalPluginsDisabled() {
PluginConfiguration config =
PluginConfiguration.builder()
.pluginsDir(DEFAULT_PLUGIN_DIRECTORY)
.externalPluginsEnabled(false)
.build();
contextImpl.registerPlugins(config);
assertThat(contextImpl.getRegisteredPlugins().isEmpty()).isTrue();
}
@Test
void shouldRegisterPluginsIfExternalPluginsEnabled() {
PluginConfiguration config =
PluginConfiguration.builder()
.pluginsDir(DEFAULT_PLUGIN_DIRECTORY)
.externalPluginsEnabled(true)
.build();
contextImpl.registerPlugins(config);
assertThat(contextImpl.getRegisteredPlugins().isEmpty()).isFalse();
}
private PluginConfiguration createConfigurationForSpecificPlugin(final String pluginName) {
return new PluginConfiguration(List.of(new PluginInfo(pluginName)), DEFAULT_PLUGIN_DIRECTORY);
return PluginConfiguration.builder()
.requestedPlugins(List.of(new PluginInfo(pluginName)))
.pluginsDir(DEFAULT_PLUGIN_DIRECTORY)
.build();
}
private Optional<TestPicoCLIPlugin> findTestPlugin(

View File

@@ -25,10 +25,6 @@ import static org.hyperledger.besu.cli.util.CommandLineUtils.isOptionSet;
import static org.hyperledger.besu.controller.BesuController.DATABASE_PATH;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_ENGINE_JSON_RPC_PORT;
import static org.hyperledger.besu.ethereum.api.jsonrpc.authentication.EngineAuthService.EPHEMERAL_JWT_FILE;
import static org.hyperledger.besu.metrics.BesuMetricCategory.DEFAULT_METRIC_CATEGORIES;
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 static org.hyperledger.besu.nat.kubernetes.KubernetesNatManager.DEFAULT_BESU_SERVICE_NAME_FILTER;
import org.hyperledger.besu.BesuInfo;
@@ -54,6 +50,7 @@ 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.MetricsOptionGroup;
import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption;
import org.hyperledger.besu.cli.options.stable.P2PTLSConfigOptions;
import org.hyperledger.besu.cli.options.stable.PermissionsOptions;
@@ -314,7 +311,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
final MiningOptions miningOptions = MiningOptions.create();
private final RunnerBuilder runnerBuilder;
private final BesuController.Builder controllerBuilderFactory;
private final BesuController.Builder controllerBuilder;
private final BesuPluginContextImpl besuPluginContext;
private final StorageServiceImpl storageService;
private final SecurityModuleServiceImpl securityModuleService;
@@ -375,7 +372,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
@Option(
names = {"--genesis-state-hash-cache-enabled"},
description = "Use genesis state hash from data on startup if specified")
description =
"Use genesis state hash from data on startup if specified (default: ${DEFAULT-VALUE})")
private final Boolean genesisStateHashCacheEnabled = false;
@Option(
@@ -745,81 +743,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
@CommandLine.ArgGroup(validate = false, heading = "@|bold Metrics Options|@%n")
MetricsOptionGroup metricsOptionGroup = new MetricsOptionGroup();
static class MetricsOptionGroup {
@Option(
names = {"--metrics-enabled"},
description = "Set to start the metrics exporter (default: ${DEFAULT-VALUE})")
private final Boolean isMetricsEnabled = false;
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@Option(
names = {"--metrics-protocol"},
description =
"Metrics protocol, one of PROMETHEUS, OPENTELEMETRY or NONE. (default: ${DEFAULT-VALUE})")
private MetricsProtocol metricsProtocol = PROMETHEUS;
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@Option(
names = {"--metrics-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for the metrics exporter to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private String metricsHost;
@Option(
names = {"--metrics-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for the metrics exporter to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer metricsPort = DEFAULT_METRICS_PORT;
@Option(
names = {"--metrics-category", "--metrics-categories"},
paramLabel = "<category name>",
split = ",",
arity = "1..*",
description =
"Comma separated list of categories to track metrics for (default: ${DEFAULT-VALUE})")
private final Set<MetricCategory> metricCategories = DEFAULT_METRIC_CATEGORIES;
@Option(
names = {"--metrics-push-enabled"},
description = "Enable the metrics push gateway integration (default: ${DEFAULT-VALUE})")
private final Boolean isMetricsPushEnabled = false;
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@Option(
names = {"--metrics-push-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description =
"Host of the Prometheus Push Gateway for push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private String metricsPushHost;
@Option(
names = {"--metrics-push-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description =
"Port of the Prometheus Push Gateway for push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer metricsPushPort = DEFAULT_METRICS_PUSH_PORT;
@Option(
names = {"--metrics-push-interval"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description =
"Interval in seconds to push metrics when in push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer metricsPushInterval = 15;
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@Option(
names = {"--metrics-push-prometheus-job"},
description = "Job name to use when in push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private String metricsPrometheusJob = "besu-client";
}
@Option(
names = {"--host-allowlist"},
paramLabel = "<hostname>[,<hostname>...]... or * or all",
@@ -961,7 +884,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
* @param jsonBlockImporterFactory instance of {@code Function<BesuController, JsonBlockImporter>}
* @param rlpBlockExporterFactory instance of {@code Function<Blockchain, RlpBlockExporter>}
* @param runnerBuilder instance of RunnerBuilder
* @param controllerBuilderFactory instance of BesuController.Builder
* @param controllerBuilder instance of BesuController.Builder
* @param besuPluginContext instance of BesuPluginContextImpl
* @param environment Environment variables map
*/
@@ -971,7 +894,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
final RunnerBuilder runnerBuilder,
final BesuController.Builder controllerBuilderFactory,
final BesuController.Builder controllerBuilder,
final BesuPluginContextImpl besuPluginContext,
final Map<String, String> environment) {
this(
@@ -980,7 +903,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
jsonBlockImporterFactory,
rlpBlockExporterFactory,
runnerBuilder,
controllerBuilderFactory,
controllerBuilder,
besuPluginContext,
environment,
new StorageServiceImpl(),
@@ -1002,7 +925,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
* @param jsonBlockImporterFactory instance of {@code Function<BesuController, JsonBlockImporter>}
* @param rlpBlockExporterFactory instance of {@code Function<Blockchain, RlpBlockExporter>}
* @param runnerBuilder instance of RunnerBuilder
* @param controllerBuilderFactory instance of BesuController.Builder
* @param controllerBuilder instance of BesuController.Builder
* @param besuPluginContext instance of BesuPluginContextImpl
* @param environment Environment variables map
* @param storageService instance of StorageServiceImpl
@@ -1022,7 +945,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
final RunnerBuilder runnerBuilder,
final BesuController.Builder controllerBuilderFactory,
final BesuController.Builder controllerBuilder,
final BesuPluginContextImpl besuPluginContext,
final Map<String, String> environment,
final StorageServiceImpl storageService,
@@ -1040,7 +963,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
this.rlpBlockExporterFactory = rlpBlockExporterFactory;
this.jsonBlockImporterFactory = jsonBlockImporterFactory;
this.runnerBuilder = runnerBuilder;
this.controllerBuilderFactory = controllerBuilderFactory;
this.controllerBuilder = controllerBuilder;
this.besuPluginContext = besuPluginContext;
this.environment = environment;
this.storageService = storageService;
@@ -1199,7 +1122,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
runner.startExternalServices();
startPlugins(runner);
validatePluginOptions();
validatePrivacyPluginOptions();
setReleaseMetrics();
preSynchronization();
@@ -1424,7 +1347,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
besuPluginContext.startPlugins();
}
private void validatePluginOptions() {
private void validatePrivacyPluginOptions() {
// plugins do not 'wire up' until start has been called
// consequently you can only do some configuration checks
// after start has been called on plugins
@@ -1503,7 +1426,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private void configureNativeLibs() {
if (unstableNativeLibraryOptions.getNativeAltbn128()
&& AbstractAltBnPrecompiledContract.isNative()) {
&& AbstractAltBnPrecompiledContract.maybeEnableNative()) {
logger.info("Using the native implementation of alt bn128");
} else {
AbstractAltBnPrecompiledContract.disableNative();
@@ -1519,7 +1442,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
if (unstableNativeLibraryOptions.getNativeSecp()
&& SignatureAlgorithmFactory.getInstance().isNative()) {
&& SignatureAlgorithmFactory.getInstance().maybeEnableNative()) {
logger.info("Using the native implementation of the signature algorithm");
} else {
SignatureAlgorithmFactory.getInstance().disableNative();
@@ -1568,6 +1491,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
validateGraphQlOptions();
validateApiOptions();
validateConsensusSyncCompatibilityOptions();
validatePluginOptions();
p2pTLSConfigOptions.checkP2PTLSOptionsDependencies(logger, commandLine);
}
@@ -1588,6 +1512,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
}
private void validatePluginOptions() {
pluginsConfigurationOptions.validate(commandLine);
}
private void validateApiOptions() {
apiConfigurationOptions.validate(commandLine, logger);
}
@@ -1910,7 +1838,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.withMiningParameters(miningParametersSupplier.get())
.withJsonRpcHttpOptions(jsonRpcHttpOptions);
final KeyValueStorageProvider storageProvider = keyValueStorageProvider(keyValueStorageName);
return controllerBuilderFactory
return controllerBuilder
.fromEthNetworkConfig(updateNetworkConfig(network), getDefaultSyncModeIfNotSet())
.synchronizerConfiguration(buildSyncConfig())
.ethProtocolConfiguration(unstableEthProtocolOptions.toDomainObject())
@@ -1986,7 +1914,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
* @return instance of MetricsConfiguration.
*/
public MetricsConfiguration metricsConfiguration() {
if (metricsOptionGroup.isMetricsEnabled && metricsOptionGroup.isMetricsPushEnabled) {
if (metricsOptionGroup.getMetricsEnabled() && metricsOptionGroup.getMetricsPushEnabled()) {
throw new ParameterException(
this.commandLine,
"--metrics-enabled option and --metrics-push-enabled option can't be used at the same "
@@ -1997,14 +1925,14 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
logger,
commandLine,
"--metrics-enabled",
!metricsOptionGroup.isMetricsEnabled,
!metricsOptionGroup.getMetricsEnabled(),
asList("--metrics-host", "--metrics-port"));
CommandLineUtils.checkOptionDependencies(
logger,
commandLine,
"--metrics-push-enabled",
!metricsOptionGroup.isMetricsPushEnabled,
!metricsOptionGroup.getMetricsPushEnabled(),
asList(
"--metrics-push-host",
"--metrics-push-port",
@@ -2013,23 +1941,23 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return unstableMetricsCLIOptions
.toDomainObject()
.enabled(metricsOptionGroup.isMetricsEnabled)
.enabled(metricsOptionGroup.getMetricsEnabled())
.host(
Strings.isNullOrEmpty(metricsOptionGroup.metricsHost)
Strings.isNullOrEmpty(metricsOptionGroup.getMetricsHost())
? p2PDiscoveryOptionGroup.autoDiscoverDefaultIP().getHostAddress()
: metricsOptionGroup.metricsHost)
.port(metricsOptionGroup.metricsPort)
.protocol(metricsOptionGroup.metricsProtocol)
.metricCategories(metricsOptionGroup.metricCategories)
.pushEnabled(metricsOptionGroup.isMetricsPushEnabled)
: metricsOptionGroup.getMetricsHost())
.port(metricsOptionGroup.getMetricsPort())
.protocol(metricsOptionGroup.getMetricsProtocol())
.metricCategories(metricsOptionGroup.getMetricCategories())
.pushEnabled(metricsOptionGroup.getMetricsPushEnabled())
.pushHost(
Strings.isNullOrEmpty(metricsOptionGroup.metricsPushHost)
Strings.isNullOrEmpty(metricsOptionGroup.getMetricsPushHost())
? p2PDiscoveryOptionGroup.autoDiscoverDefaultIP().getHostAddress()
: metricsOptionGroup.metricsPushHost)
.pushPort(metricsOptionGroup.metricsPushPort)
.pushInterval(metricsOptionGroup.metricsPushInterval)
: metricsOptionGroup.getMetricsPushHost())
.pushPort(metricsOptionGroup.getMetricsPushPort())
.pushInterval(metricsOptionGroup.getMetricsPushInterval())
.hostsAllowlist(hostsAllowlist)
.prometheusJob(metricsOptionGroup.metricsPrometheusJob)
.prometheusJob(metricsOptionGroup.getMetricsPrometheusJob())
.build();
}
@@ -2661,7 +2589,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
effectivePorts, rpcWebsocketOptions.getRpcWsPort(), rpcWebsocketOptions.isRpcWsEnabled());
addPortIfEnabled(effectivePorts, engineRPCOptionGroup.engineRpcPort, isEngineApiEnabled());
addPortIfEnabled(
effectivePorts, metricsOptionGroup.metricsPort, metricsOptionGroup.isMetricsEnabled);
effectivePorts,
metricsOptionGroup.getMetricsPort(),
metricsOptionGroup.getMetricsEnabled());
addPortIfEnabled(
effectivePorts,
miningParametersSupplier.get().getStratumPort(),

View File

@@ -128,6 +128,9 @@ public interface DefaultCommandValues {
/** The constant DEFAULT_PLUGINS_OPTION_NAME. */
String DEFAULT_PLUGINS_OPTION_NAME = "--plugins";
/** The constant DEFAULT_PLUGINS_EXTERNAL_ENABLED_OPTION_NAME. */
String DEFAULT_PLUGINS_EXTERNAL_ENABLED_OPTION_NAME = "--Xplugins-external-enabled";
/**
* Gets default besu data path.
*

View File

@@ -85,7 +85,7 @@ public class ApiConfigurationOptions {
@CommandLine.Option(
names = {"--rpc-max-trace-filter-range"},
description =
"Specifies the maximum number of blocks for the trace_filter method. Must be >=0. 0 specifies no limit (default: $DEFAULT-VALUE)")
"Specifies the maximum number of blocks for the trace_filter method. Must be >=0. 0 specifies no limit (default: ${DEFAULT-VALUE})")
private final Long maxTraceFilterRange = 1000L;
/**

View File

@@ -0,0 +1,197 @@
/*
* Copyright contributors to Hyperledger 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.cli.options.stable;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_HOST_FORMAT_HELP;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_INTEGER_FORMAT_HELP;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_PORT_FORMAT_HELP;
import static org.hyperledger.besu.metrics.BesuMetricCategory.DEFAULT_METRIC_CATEGORIES;
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.metrics.MetricsProtocol;
import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
import java.util.Set;
import picocli.CommandLine;
/** Command line options for configuring metrics. */
public class MetricsOptionGroup {
@CommandLine.Option(
names = {"--metrics-enabled"},
description = "Set to start the metrics exporter (default: ${DEFAULT-VALUE})")
private final Boolean isMetricsEnabled = false;
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@CommandLine.Option(
names = {"--metrics-protocol"},
description =
"Metrics protocol, one of PROMETHEUS, OPENTELEMETRY or NONE. (default: ${DEFAULT-VALUE})")
private MetricsProtocol metricsProtocol = PROMETHEUS;
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@CommandLine.Option(
names = {"--metrics-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host for the metrics exporter to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private String metricsHost;
@CommandLine.Option(
names = {"--metrics-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port for the metrics exporter to listen on (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer metricsPort = DEFAULT_METRICS_PORT;
@CommandLine.Option(
names = {"--metrics-category", "--metrics-categories"},
paramLabel = "<category name>",
split = ",",
arity = "1..*",
description =
"Comma separated list of categories to track metrics for (default: ${DEFAULT-VALUE})")
private final Set<MetricCategory> metricCategories = DEFAULT_METRIC_CATEGORIES;
@CommandLine.Option(
names = {"--metrics-push-enabled"},
description = "Enable the metrics push gateway integration (default: ${DEFAULT-VALUE})")
private final Boolean isMetricsPushEnabled = false;
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@CommandLine.Option(
names = {"--metrics-push-host"},
paramLabel = MANDATORY_HOST_FORMAT_HELP,
description = "Host of the Prometheus Push Gateway for push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private String metricsPushHost;
@CommandLine.Option(
names = {"--metrics-push-port"},
paramLabel = MANDATORY_PORT_FORMAT_HELP,
description = "Port of the Prometheus Push Gateway for push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer metricsPushPort = DEFAULT_METRICS_PUSH_PORT;
@CommandLine.Option(
names = {"--metrics-push-interval"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description =
"Interval in seconds to push metrics when in push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private final Integer metricsPushInterval = 15;
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
@CommandLine.Option(
names = {"--metrics-push-prometheus-job"},
description = "Job name to use when in push mode (default: ${DEFAULT-VALUE})",
arity = "1")
private String metricsPrometheusJob = "besu-client";
/** Returns a newly created {@link MetricsOptionGroup} with default values. */
public MetricsOptionGroup() {}
/**
* Returns whether metrics are enabled.
*
* @return true if metrics are enabled, otherwise false
*/
public Boolean getMetricsEnabled() {
return isMetricsEnabled;
}
/**
* Returns the metrics protocol.
*
* @return the metrics protocol
*/
public MetricsProtocol getMetricsProtocol() {
return metricsProtocol;
}
/**
* Returns the metrics host.
*
* @return the metrics host
*/
public String getMetricsHost() {
return metricsHost;
}
/**
* Returns the metrics port.
*
* @return the metrics port
*/
public Integer getMetricsPort() {
return metricsPort;
}
/**
* Returns the metric categories.
*
* @return the metric categories
*/
public Set<MetricCategory> getMetricCategories() {
return metricCategories;
}
/**
* Returns whether metrics push is enabled.
*
* @return true if metrics push is enabled, otherwise false
*/
public Boolean getMetricsPushEnabled() {
return isMetricsPushEnabled;
}
/**
* Returns the metrics push host.
*
* @return the metrics push host
*/
public String getMetricsPushHost() {
return metricsPushHost;
}
/**
* Returns the metrics push port.
*
* @return the metrics push port
*/
public Integer getMetricsPushPort() {
return metricsPushPort;
}
/**
* Returns the metrics push interval.
*
* @return the metrics push interval
*/
public Integer getMetricsPushInterval() {
return metricsPushInterval;
}
/**
* Returns the metrics prometheus job.
*
* @return the metrics prometheus job
*/
public String getMetricsPrometheusJob() {
return metricsPrometheusJob;
}
}

View File

@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.cli.options.stable;
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;
@@ -28,6 +29,15 @@ import picocli.CommandLine;
/** The Plugins Options options. */
public class PluginsConfigurationOptions implements CLIOptions<PluginConfiguration> {
@CommandLine.Option(
names = {DEFAULT_PLUGINS_EXTERNAL_ENABLED_OPTION_NAME},
description = "Enables external plugins (default: ${DEFAULT-VALUE})",
hidden = true,
defaultValue = "true",
arity = "1")
private Boolean externalPluginsEnabled = true;
@CommandLine.Option(
names = {DEFAULT_PLUGINS_OPTION_NAME},
description = "Comma-separated list of plugin names",
@@ -42,7 +52,24 @@ public class PluginsConfigurationOptions implements CLIOptions<PluginConfigurati
@Override
public PluginConfiguration toDomainObject() {
return new PluginConfiguration(plugins);
return new PluginConfiguration.Builder()
.externalPluginsEnabled(externalPluginsEnabled)
.requestedPlugins(plugins)
.build();
}
/**
* Validate that there are no inconsistencies in the specified options.
*
* @param commandLine the full commandLine to check all the options specified by the user
*/
public void validate(final CommandLine commandLine) {
String errorMessage =
String.format(
"%s option can only be used when %s is true",
DEFAULT_PLUGINS_OPTION_NAME, DEFAULT_PLUGINS_EXTERNAL_ENABLED_OPTION_NAME);
CommandLineUtils.failIfOptionDoesntMeetRequirement(
commandLine, errorMessage, externalPluginsEnabled, List.of(DEFAULT_PLUGINS_OPTION_NAME));
}
@Override
@@ -61,6 +88,13 @@ public class PluginsConfigurationOptions implements CLIOptions<PluginConfigurati
CommandLineUtils.getOptionValueOrDefault(
commandLine, DEFAULT_PLUGINS_OPTION_NAME, new PluginInfoConverter());
return new PluginConfiguration(plugins);
boolean externalPluginsEnabled =
CommandLineUtils.getOptionValueOrDefault(
commandLine, DEFAULT_PLUGINS_EXTERNAL_ENABLED_OPTION_NAME, Boolean::parseBoolean);
return new PluginConfiguration.Builder()
.requestedPlugins(plugins)
.externalPluginsEnabled(externalPluginsEnabled)
.build();
}
}

View File

@@ -132,20 +132,25 @@ public class BesuPluginContextImpl implements BesuContext, PluginVersionsProvide
"Besu plugins have already been registered. Cannot register additional plugins.");
state = Lifecycle.REGISTERING;
if (config.isExternalPluginsEnabled()) {
detectedPlugins = detectPlugins(config);
if (!config.getRequestedPlugins().isEmpty()) {
if (config.getRequestedPlugins().isEmpty()) {
// If no plugins were specified, register all detected plugins
registerPlugins(detectedPlugins);
} else {
// Register only the plugins that were explicitly requested and validated
requestedPlugins = config.getRequestedPlugins();
// Match and validate the requested plugins against the detected plugins
List<BesuPlugin> registeringPlugins =
matchAndValidateRequestedPlugins(requestedPlugins, detectedPlugins);
registerPlugins(registeringPlugins);
} else {
// If no plugins were specified, register all detected plugins
registerPlugins(detectedPlugins);
}
} else {
LOG.debug("External plugins are disabled. Skipping plugins registration.");
}
state = Lifecycle.REGISTERED;
}
private List<BesuPlugin> matchAndValidateRequestedPlugins(
@@ -182,7 +187,6 @@ public class BesuPluginContextImpl implements BesuContext, PluginVersionsProvide
registeredPlugins.add(plugin);
}
}
state = Lifecycle.REGISTERED;
}
private boolean registerPlugin(final BesuPlugin plugin) {

View File

@@ -2503,4 +2503,16 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Test
void helpOutputShouldDisplayCorrectDefaultValues() {
parseCommand("--help");
final String commandOutputString = commandOutput.toString(UTF_8);
final String errorOutputString = commandErrorOutput.toString(UTF_8);
assertThat(commandOutputString).doesNotContain("$DEFAULT-VALUE");
assertThat(errorOutputString).isEmpty();
}
}

View File

@@ -0,0 +1,118 @@
/*
* Copyright contributors to Hyperledger 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.cli;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
public class PluginsOptionsTest extends CommandTestAbstract {
@Captor protected ArgumentCaptor<PluginConfiguration> pluginConfigurationArgumentCaptor;
@Test
public void shouldParsePluginOptionForSinglePlugin() {
parseCommand("--plugins", "pluginA");
verify(mockBesuPluginContext).registerPlugins(pluginConfigurationArgumentCaptor.capture());
assertThat(pluginConfigurationArgumentCaptor.getValue().getRequestedPlugins())
.isEqualTo(List.of("pluginA"));
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Test
public void shouldParsePluginOptionForMultiplePlugins() {
parseCommand("--plugins", "pluginA,pluginB");
verify(mockBesuPluginContext).registerPlugins(pluginConfigurationArgumentCaptor.capture());
assertThat(pluginConfigurationArgumentCaptor.getValue().getRequestedPlugins())
.isEqualTo(List.of("pluginA", "pluginB"));
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Test
public void shouldNotUsePluginOptionWhenNoPluginsSpecified() {
parseCommand();
verify(mockBesuPluginContext).registerPlugins(pluginConfigurationArgumentCaptor.capture());
assertThat(pluginConfigurationArgumentCaptor.getValue().getRequestedPlugins())
.isEqualTo(List.of());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Test
public void shouldNotParseAnyPluginsWhenPluginOptionIsEmpty() {
parseCommand("--plugins", "");
verify(mockBesuPluginContext).registerPlugins(pluginConfigurationArgumentCaptor.capture());
assertThat(pluginConfigurationArgumentCaptor.getValue().getRequestedPlugins())
.isEqualTo(List.of());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Test
public void shouldParsePluginsExternalEnabledOptionWhenFalse() {
parseCommand("--Xplugins-external-enabled=false");
verify(mockBesuPluginContext).registerPlugins(pluginConfigurationArgumentCaptor.capture());
assertThat(pluginConfigurationArgumentCaptor.getValue().isExternalPluginsEnabled())
.isEqualTo(false);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Test
public void shouldParsePluginsExternalEnabledOptionWhenTrue() {
parseCommand("--Xplugins-external-enabled=true");
verify(mockBesuPluginContext).registerPlugins(pluginConfigurationArgumentCaptor.capture());
assertThat(pluginConfigurationArgumentCaptor.getValue().isExternalPluginsEnabled())
.isEqualTo(true);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Test
public void shouldEnablePluginsExternalByDefault() {
parseCommand();
verify(mockBesuPluginContext).registerPlugins(pluginConfigurationArgumentCaptor.capture());
assertThat(pluginConfigurationArgumentCaptor.getValue().isExternalPluginsEnabled())
.isEqualTo(true);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Test
public void shouldFailWhenPluginsIsDisabledAndPluginsExplicitlyRequested() {
parseCommand("--Xplugins-external-enabled=false", "--plugins", "pluginA");
verify(mockBesuPluginContext).registerPlugins(pluginConfigurationArgumentCaptor.capture());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains("--plugins option can only be used when --Xplugins-external-enabled is true");
}
}

View File

@@ -242,3 +242,7 @@ Xp2p-tls-clienthello-sni=false
#contracts
Xevm-jumpdest-cache-weight-kb=32000
# plugins
Xplugins-external-enabled=true
plugins=["none"]

View File

@@ -15,6 +15,7 @@
package org.hyperledger.besu.consensus.merge;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.datatypes.HardforkId;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@@ -22,7 +23,6 @@ import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PermissionTransactionFilter;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.mainnet.HardforkId;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;

View File

@@ -397,7 +397,9 @@ public abstract class AbstractSECP256 implements SignatureAlgorithm {
final Bytes32 dataHash, final SECPSignature signature) {
final BigInteger publicKeyBI =
recoverFromSignature(signature.getRecId(), signature.getR(), signature.getS(), dataHash);
return Optional.of(SECPPublicKey.create(publicKeyBI, ALGORITHM));
return publicKeyBI == null
? Optional.empty()
: Optional.of(SECPPublicKey.create(publicKeyBI, ALGORITHM));
}
@Override

View File

@@ -44,9 +44,10 @@ public class Blake2bfMessageDigest extends BCMessageDigest implements Cloneable
/**
* Implementation of the `F` compression function of the Blake2b cryptographic hash function.
*
* <p>RFC - https://tools.ietf.org/html/rfc7693
* <p>RFC - <a href="https://tools.ietf.org/html/rfc7693">...</a>
*
* <p>Adapted from - https://github.com/keep-network/blake2b/blob/master/compression/f.go
* <p>Adapted from - <a
* href="https://github.com/keep-network/blake2b/blob/master/compression/f.go">...</a>
*
* <p>Optimized for 64-bit platforms
*/
@@ -93,12 +94,7 @@ public class Blake2bfMessageDigest extends BCMessageDigest implements Cloneable
private static boolean useNative;
static {
try {
useNative = LibBlake2bf.ENABLED;
} catch (UnsatisfiedLinkError ule) {
LOG.info("blake2bf native precompile not available: {}", ule.getMessage());
useNative = false;
}
maybeEnableNative();
}
/** Instantiates a new Blake2bf digest. */
@@ -130,6 +126,21 @@ public class Blake2bfMessageDigest extends BCMessageDigest implements Cloneable
return cloned;
}
/**
* Attempt to enable the native libreary
*
* @return true if the native library was successfully enabled.
*/
public static boolean maybeEnableNative() {
try {
useNative = LibBlake2bf.ENABLED;
} catch (UnsatisfiedLinkError | NoClassDefFoundError e) {
LOG.info("blake2bf native precompile not available: {}", e.getMessage());
useNative = false;
}
return useNative;
}
/** Disable native. */
public static void disableNative() {
useNative = false;

View File

@@ -72,6 +72,7 @@ public class SECP256K1 extends AbstractSECP256 {
*
* @return true if the native library was enabled.
*/
@Override
public boolean maybeEnableNative() {
try {
useNative = LibSecp256k1.CONTEXT != null;

View File

@@ -61,6 +61,22 @@ public class SECP256R1 extends AbstractSECP256 {
return useNative;
}
/**
* Attempt to enable the native library for secp256r1
*
* @return true if the native library was enabled.
*/
@Override
public boolean maybeEnableNative() {
try {
useNative = BesuNativeEC.INSTANCE != null;
} catch (UnsatisfiedLinkError | NoClassDefFoundError e) {
LOG.info("Native secp256r1 not available - {}", e.getMessage());
useNative = false;
}
return useNative;
}
/**
* SECP256R1 is using the non-deterministic implementation of K calculation (standard)
*

View File

@@ -31,6 +31,13 @@ public interface SignatureAlgorithm {
/** Disable native. */
void disableNative();
/**
* Attempt to enable the native library.
*
* @return true if the native library was enabled
*/
boolean maybeEnableNative();
/**
* Is native enabled.
*

View File

@@ -127,7 +127,7 @@ public class SECP256R1Test {
}
@Test
public void recoverPublicKeyFromSignature() {
void recoverPublicKeyFromSignature() {
final SECPPrivateKey privateKey =
secp256R1.createPrivateKey(
new BigInteger("c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4", 16));
@@ -139,20 +139,20 @@ public class SECP256R1Test {
final SECPPublicKey recoveredPublicKey =
secp256R1.recoverPublicKeyFromSignature(dataHash, signature).get();
assertThat(recoveredPublicKey.toString()).isEqualTo(keyPair.getPublicKey().toString());
assertThat(recoveredPublicKey).hasToString(keyPair.getPublicKey().toString());
}
@Test
public void signatureGenerationVerificationAndPubKeyRecovery() {
void signatureGenerationVerificationAndPubKeyRecovery() {
signTestVectors.forEach(
signTestVector -> {
final SECPPrivateKey privateKey =
secp256R1.createPrivateKey(new BigInteger(signTestVector.getPrivateKey(), 16));
final BigInteger publicKeyBigInt = new BigInteger(signTestVector.getPublicKey(), 16);
secp256R1.createPrivateKey(new BigInteger(signTestVector.privateKey(), 16));
final BigInteger publicKeyBigInt = new BigInteger(signTestVector.publicKey(), 16);
final SECPPublicKey publicKey = secp256R1.createPublicKey(publicKeyBigInt);
final KeyPair keyPair = secp256R1.createKeyPair(privateKey);
final Bytes32 dataHash = keccak256(Bytes.wrap(signTestVector.getData().getBytes(UTF_8)));
final Bytes32 dataHash = keccak256(Bytes.wrap(signTestVector.data().getBytes(UTF_8)));
final SECPSignature signature = secp256R1.sign(dataHash, keyPair);
assertThat(secp256R1.verify(dataHash, signature, publicKey)).isTrue();
@@ -165,44 +165,22 @@ public class SECP256R1Test {
}
@Test
public void invalidFileThrowsInvalidKeyPairException() throws Exception {
void invalidFileThrowsInvalidKeyPairException() throws Exception {
final File tempFile = Files.createTempFile(suiteName(), ".keypair").toFile();
tempFile.deleteOnExit();
Files.write(tempFile.toPath(), "not valid".getBytes(UTF_8));
Files.writeString(tempFile.toPath(), "not valid");
assertThatThrownBy(() -> KeyPairUtil.load(tempFile))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
public void invalidMultiLineFileThrowsInvalidIdException() throws Exception {
void invalidMultiLineFileThrowsInvalidIdException() throws Exception {
final File tempFile = Files.createTempFile(suiteName(), ".keypair").toFile();
tempFile.deleteOnExit();
Files.write(tempFile.toPath(), "not\n\nvalid".getBytes(UTF_8));
Files.writeString(tempFile.toPath(), "not\n\nvalid");
assertThatThrownBy(() -> KeyPairUtil.load(tempFile))
.isInstanceOf(IllegalArgumentException.class);
}
private static class SignTestVector {
private final String privateKey;
private final String publicKey;
private final String data;
public SignTestVector(final String privateKey, final String publicKey, final String data) {
this.privateKey = privateKey;
this.publicKey = publicKey;
this.data = data;
}
public String getPrivateKey() {
return privateKey;
}
public String getPublicKey() {
return publicKey;
}
public String getData() {
return data;
}
}
private record SignTestVector(String privateKey, String publicKey, String data) {}
}

View File

@@ -0,0 +1,188 @@
/*
* Copyright contributors to Hyperledger 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.datatypes;
/** Description and metadata for a hard fork */
public interface HardforkId {
/**
* The name of the hard fork.
*
* @return the name for the fork
*/
String name();
/**
* Has the fork been finalized? i.e., could the definition change in future versions of Besu?
*
* @return true if the specification is finalized.
*/
boolean finalized();
/**
* A brief description of the hard fork, suitable for human consumption
*
* @return the description of the fork.
*/
String description();
/** List of all Ethereum Mainnet hardforks, including future and developmental forks. */
enum MainnetHardforkId implements HardforkId {
/** Frontier fork. */
FRONTIER(true, "Frontier"),
/** Homestead fork. */
HOMESTEAD(true, "Homestead"),
/** DAO Fork fork. */
DAO_FORK(true, "DAO Fork"),
/** Tangerine Whistle fork. */
TANGERINE_WHISTLE(true, "Tangerine Whistle"),
/** Spurious Dragon fork. */
SPURIOUS_DRAGON(true, "Spurious Dragon"),
/** Byzantium fork. */
BYZANTIUM(true, "Byzantium"),
/** Constantinople fork. */
CONSTANTINOPLE(true, "Constantinople"),
/** Petersburg fork. */
PETERSBURG(true, "Petersburg"),
/** Istanbul fork. */
ISTANBUL(true, "Istanbul"),
/** Muir Glacier fork. */
MUIR_GLACIER(true, "Muir Glacier"),
/** Berlin fork. */
BERLIN(true, "Berlin"),
/** London fork. */
LONDON(true, "London"),
/** Arrow Glacier fork. */
ARROW_GLACIER(true, "Arrow Glacier"),
/** Gray Glacier fork. */
GRAY_GLACIER(true, "Gray Glacier"),
/** Paris fork. */
PARIS(true, "Paris"),
/** Shanghai fork. */
SHANGHAI(true, "Shanghai"),
/** Cancun fork. */
CANCUN(true, "Cancun"),
/** Cancun + EOF fork. */
CANCUN_EOF(false, "Cancun + EOF"),
/** Prague fork. */
PRAGUE(false, "Prague"),
/** Prague + EOF fork. */
PRAGUE_EOF(false, "Prague + EOF"),
/** Osaka fork. */
OSAKA(false, "Osaka"),
/** Amsterdam fork. */
AMSTERDAM(false, "Amsterdam"),
/** Bogota fork. */
BOGOTA(false, "Bogota"),
/** Polis fork. (from the greek form of an earlier incarnation of the city of Istanbul. */
POLIS(false, "Polis"),
/** Bangkok fork. */
BANGKOK(false, "Bangkok"),
/** Development fork, for accepted and unscheduled EIPs. */
FUTURE_EIPS(false, "Development, for accepted and unscheduled EIPs"),
/** Developmental fork, for experimental EIPs. */
EXPERIMENTAL_EIPS(false, "Developmental, for experimental EIPs");
final boolean finalized;
final String description;
MainnetHardforkId(final boolean finalized, final String description) {
this.finalized = finalized;
this.description = description;
}
@Override
public boolean finalized() {
return finalized;
}
@Override
public String description() {
return description;
}
}
/** List of all Ethereum Classic hard forks. */
enum ClassicHardforkId implements HardforkId {
/** Frontier fork. */
FRONTIER(true, "Frontier"),
/** Homestead fork. */
HOMESTEAD(true, "Homestead"),
/** Classic Tangerine Whistle fork. */
CLASSIC_TANGERINE_WHISTLE(true, "Classic Tangerine Whistle"),
/** Die Hard fork. */
DIE_HARD(true, "Die Hard"),
/** Gotham fork. */
GOTHAM(true, "Gotham"),
/** Defuse Difficulty Bomb fork. */
DEFUSE_DIFFICULTY_BOMB(true, "Defuse Difficulty Bomb"),
/** Atlantis fork. */
ATLANTIS(true, "Atlantis"),
/** Agharta fork. */
AGHARTA(true, "Agharta"),
/** Phoenix fork. */
PHOENIX(true, "Phoenix"),
/** Thanos fork. */
THANOS(true, "Thanos"),
/** Magneto fork. */
MAGNETO(true, "Magneto"),
/** Mystique fork. */
MYSTIQUE(true, "Mystique"),
/** Spiral fork. */
SPIRAL(true, "Spiral");
final boolean finalized;
final String description;
ClassicHardforkId(final boolean finalized, final String description) {
this.finalized = finalized;
this.description = description;
}
@Override
public boolean finalized() {
return finalized;
}
@Override
public String description() {
return description;
}
}
/** List of all Linea hard forks. */
enum LineaHardforkId implements HardforkId {
/** opcodes changes fork. */
OP_CODES_CHANGES(false, "Linea");
final boolean finalized;
final String description;
LineaHardforkId(final boolean finalized, final String description) {
this.finalized = finalized;
this.description = description;
}
@Override
public boolean finalized() {
return finalized;
}
@Override
public String description() {
return description;
}
}
}

View File

@@ -437,7 +437,7 @@ public class EthGetBlockByNumberIntegrationTest {
assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 1");
.hasMessage("Invalid is transaction complete parameter (index 1)");
}
/**

View File

@@ -177,9 +177,7 @@ public enum RpcMethod {
PERM_GET_NODES_WHITELIST("perm_getNodesWhitelist"),
PERM_GET_NODES_ALLOWLIST("perm_getNodesAllowlist"),
PERM_RELOAD_PERMISSIONS_FROM_FILE("perm_reloadPermissionsFromFile"),
PERM_REMOVE_ACCOUNTS_FROM_WHITELIST("perm_removeAccountsFromWhitelist"),
PERM_REMOVE_ACCOUNTS_FROM_ALLOWLIST("perm_removeAccountsFromAllowlist"),
PERM_REMOVE_NODES_FROM_WHITELIST("perm_removeNodesFromWhitelist"),
PERM_REMOVE_NODES_FROM_ALLOWLIST("perm_removeNodesFromAllowlist"),
RPC_MODULES("rpc_modules"),
TRACE_BLOCK("trace_block"),

View File

@@ -74,8 +74,8 @@ public class TracedJsonRpcProcessor implements JsonRpcProcessor {
case INVALID_DEPOSIT_REQUEST_PARAMS:
case INVALID_ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_PARAMS:
case INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS:
case INVALID_ENGINE_PAYLOAD_ATTRIBUTES_PARAMS:
case INVALID_ENGINE_PAYLOAD_PARAMS:
case INVALID_ENGINE_FORKCHOICE_UPDATED_PAYLOAD_ATTRIBUTES:
case INVALID_ENGINE_NEW_PAYLOAD_PARAMS:
case INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS:
case INVALID_ENODE_PARAMS:
case INVALID_EXCESS_BLOB_GAS_PARAMS:

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.util.Arrays;
import java.util.List;
@@ -51,7 +52,8 @@ public class JsonRpcRequest {
this.method = method;
this.params = params;
if (method == null) {
throw new InvalidJsonRpcRequestException("Field 'method' is required");
throw new InvalidJsonRpcRequestException(
"Field 'method' is required", RpcErrorType.INVALID_METHOD_PARAMS);
}
}

View File

@@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import java.math.BigInteger;
import java.util.Objects;
@@ -34,7 +35,7 @@ public class JsonRpcRequestId {
@JsonCreator
public JsonRpcRequestId(final Object id) {
if (isRequestTypeInvalid(id)) {
throw new InvalidJsonRpcRequestException("Invalid id");
throw new InvalidJsonRpcRequestException("Invalid id", RpcErrorType.INVALID_ID_PARAMS);
}
this.id = id;
}

View File

@@ -44,13 +44,24 @@ public class AdminChangeLogLevel implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
try {
final String logLevel = requestContext.getRequiredParameter(0, String.class);
final String logLevel;
try {
logLevel = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid log level parameter (index 0)", RpcErrorType.INVALID_LOG_LEVEL_PARAMS, e);
}
if (!VALID_PARAMS.contains(logLevel)) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_LOG_LEVEL_PARAMS);
}
final Optional<String[]> optionalLogFilters;
try {
optionalLogFilters = requestContext.getOptionalParameter(1, String[].class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid log filter parameters (index 1)", RpcErrorType.INVALID_LOG_FILTER_PARAMS, e);
}
final Optional<String[]> optionalLogFilters =
requestContext.getOptionalParameter(1, String[].class);
optionalLogFilters.ifPresentOrElse(
logFilters ->
Arrays.stream(logFilters).forEach(logFilter -> setLogLevel(logFilter, logLevel)),
@@ -58,7 +69,7 @@ public class AdminChangeLogLevel implements JsonRpcMethod {
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
} catch (InvalidJsonRpcParameters invalidJsonRpcParameters) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), invalidJsonRpcParameters.getRpcErrorType());
}
}

View File

@@ -15,7 +15,6 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
@@ -40,14 +39,11 @@ public abstract class AdminModifyPeer implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 1) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
}
try {
final String enodeString = requestContext.getRequiredParameter(0, String.class);
return performOperation(requestContext.getRequest().getId(), enodeString);
} catch (final InvalidJsonRpcParameters e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
} catch (final IllegalArgumentException e) {
if (e.getMessage()
.endsWith(
@@ -69,6 +65,9 @@ public abstract class AdminModifyPeer implements JsonRpcMethod {
} catch (final P2PDisabledException e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_ENODE_PARAMS);
}
}

View File

@@ -75,7 +75,13 @@ public class DebugAccountRange implements JsonRpcMethod {
throw new InvalidJsonRpcParameters(
"Invalid address hash parameter (index 2)", RpcErrorType.INVALID_ADDRESS_HASH_PARAMS, e);
}
final int maxResults = requestContext.getRequiredParameter(3, Integer.TYPE);
final int maxResults;
try {
maxResults = requestContext.getRequiredParameter(3, Integer.TYPE);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid max results parameter (index 3)", RpcErrorType.INVALID_MAX_RESULTS_PARAMS, e);
}
final Optional<Hash> blockHashOptional = hashFromParameter(blockParameterOrBlockHash);
if (blockHashOptional.isEmpty()) {

View File

@@ -85,8 +85,13 @@ public class DebugStorageRangeAt implements JsonRpcMethod {
throw new InvalidJsonRpcParameters(
"Invalid account address parameter (index 2)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
final Hash startKey =
Hash.fromHexStringLenient(requestContext.getRequiredParameter(3, String.class));
final Hash startKey;
try {
startKey = Hash.fromHexStringLenient(requestContext.getRequiredParameter(3, String.class));
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid data start hash parameter (index 3)", RpcErrorType.INVALID_DATA_HASH_PARAMS, e);
}
final int limit = requestContext.getRequiredParameter(4, Integer.class);
final Optional<Hash> blockHashOptional = hashFromParameter(blockParameterOrBlockHash);

View File

@@ -93,6 +93,13 @@ public class EthGetBlockByHash implements JsonRpcMethod {
}
private boolean isCompleteTransactions(final JsonRpcRequestContext requestContext) {
try {
return requestContext.getRequiredParameter(1, Boolean.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid is complete transaction parameter (index 1)",
RpcErrorType.INVALID_IS_TRANSACTION_COMPLETE_PARAMS,
e);
}
}
}

View File

@@ -124,6 +124,13 @@ public class EthGetBlockByNumber extends AbstractBlockParameterMethod {
}
private boolean isCompleteTransactions(final JsonRpcRequestContext request) {
try {
return request.getRequiredParameter(1, Boolean.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid is transaction complete parameter (index 1)",
RpcErrorType.INVALID_IS_TRANSACTION_COMPLETE_PARAMS,
e);
}
}
}

View File

@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.datatypes.Hash;
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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@@ -43,7 +44,13 @@ public class EthGetFilterChanges implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String filterId = requestContext.getRequiredParameter(0, String.class);
final String filterId;
try {
filterId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter ID parameter (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
final List<Hash> blockHashes = filterManager.blockChanges(filterId);
if (blockHashes != null) {

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@@ -41,7 +42,13 @@ public class EthGetFilterLogs implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String filterId = requestContext.getRequiredParameter(0, String.class);
final String filterId;
try {
filterId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter ID parameter (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
final List<LogWithMetadata> logs = filterManager.logs(filterId);
if (logs != null) {

View File

@@ -52,12 +52,18 @@ public class EthGetLogs implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final FilterParameter filter = requestContext.getRequiredParameter(0, FilterParameter.class);
final FilterParameter filter;
try {
filter = requestContext.getRequiredParameter(0, FilterParameter.class);
} catch (Exception e) {
throw new InvalidJsonRpcParameters(
"Invalid filter parameter (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
LOG.atTrace().setMessage("eth_getLogs FilterParameter: {}").addArgument(filter).log();
if (!filter.isValid()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_FILTER_PARAMS);
}
final AtomicReference<Exception> ex = new AtomicReference<>();

View File

@@ -48,7 +48,7 @@ public class EthGetTransactionByHash implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 1) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
}
final Hash hash = requestContext.getRequiredParameter(0, Hash.class);
final JsonRpcSuccessResponse jsonRpcSuccessResponse =

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@@ -38,11 +39,17 @@ public class EthNewFilter implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final FilterParameter filter = requestContext.getRequiredParameter(0, FilterParameter.class);
final FilterParameter filter;
try {
filter = requestContext.getRequiredParameter(0, FilterParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter paramters (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
if (!filter.isValid()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_FILTER_PARAMS);
}
final String logFilterId =

View File

@@ -66,7 +66,7 @@ public class EthSendRawTransaction implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 1) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
}
final String rawTransaction = requestContext.getRequiredParameter(0, String.class);

View File

@@ -16,8 +16,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.response.JsonRpcResponse;
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.blockcreation.MiningCoordinator;
import org.apache.tuweni.bytes.Bytes;
@@ -37,7 +39,13 @@ public class EthSubmitHashRate implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String hashRate = requestContext.getRequiredParameter(0, String.class);
final String hashRate;
try {
hashRate = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) {
throw new InvalidJsonRpcParameters(
"Invalid hash rate parameter (index 0)", RpcErrorType.INVALID_HASH_RATE_PARAMS, e);
}
final String id = requestContext.getRequiredParameter(1, String.class);
return new JsonRpcSuccessResponse(
requestContext.getRequest().getId(),

View File

@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.datatypes.Hash;
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.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@@ -49,12 +50,23 @@ public class EthSubmitWork implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final Optional<PoWSolverInputs> solver = miner.getWorkDefinition();
if (solver.isPresent()) {
final PoWSolution solution =
new PoWSolution(
Bytes.fromHexString(requestContext.getRequiredParameter(0, String.class)).getLong(0),
requestContext.getRequiredParameter(2, Hash.class),
null,
Bytes.fromHexString(requestContext.getRequiredParameter(1, String.class)));
long nonce;
try {
nonce =
Bytes.fromHexString(requestContext.getRequiredParameter(0, String.class)).getLong(0);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid nonce parameter (index 0)", RpcErrorType.INVALID_NONCE_PARAMS, e);
}
Hash mixHash;
try {
mixHash = requestContext.getRequiredParameter(2, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid mix hash parameter (index 2)", RpcErrorType.INVALID_MIX_HASH_PARAMS, e);
}
Bytes powHash = Bytes.fromHexString(requestContext.getRequiredParameter(1, String.class));
final PoWSolution solution = new PoWSolution(nonce, mixHash, null, powHash);
final boolean result = miner.submitWork(solution);
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result);
} else {

View File

@@ -16,9 +16,11 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
public class EthUninstallFilter implements JsonRpcMethod {
@@ -35,7 +37,13 @@ public class EthUninstallFilter implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String filterId = requestContext.getRequiredParameter(0, String.class);
final String filterId;
try {
filterId = requestContext.getRequiredParameter(0, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter ID parameter (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
return new JsonRpcSuccessResponse(
requestContext.getRequest().getId(), filterManager.uninstallFilter(filterId));

View File

@@ -36,7 +36,8 @@ public class JsonCallParameterUtil {
&& (callParams.getMaxFeePerGas().isPresent()
|| callParams.getMaxPriorityFeePerGas().isPresent())) {
throw new InvalidJsonRpcParameters(
"gasPrice cannot be used with maxFeePerGas or maxPriorityFeePerGas");
"gasPrice cannot be used with maxFeePerGas or maxPriorityFeePerGas",
RpcErrorType.INVALID_GAS_PRICE_PARAMS);
}
return callParams;
}

View File

@@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@@ -56,9 +55,9 @@ public class PluginsReloadConfiguration implements JsonRpcMethod {
}
reloadPluginConfig(namedPlugins.get(pluginName));
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
} catch (InvalidJsonRpcParameters invalidJsonRpcParameters) {
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVAlID_PLUGIN_NAME_PARAMS);
}
}

View File

@@ -81,7 +81,7 @@ public class TraceCallMany extends TraceCall implements JsonRpcMethod {
if (requestContext.getRequest().getParamLength() != 2) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
}
final TraceCallManyParameter[] transactionsAndTraceTypeParameters;

View File

@@ -19,6 +19,7 @@ import static org.hyperledger.besu.services.pipeline.PipelineBuilder.createPipel
import org.hyperledger.besu.datatypes.Address;
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.FilterParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
@@ -86,8 +87,13 @@ public class TraceFilter extends TraceBlock {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final FilterParameter filterParameter =
requestContext.getRequiredParameter(0, FilterParameter.class);
final FilterParameter filterParameter;
try {
filterParameter = requestContext.getRequiredParameter(0, FilterParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter parameter (index 0)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
final long fromBlock = resolveBlockNumber(filterParameter.getFromBlock());
final long toBlock = resolveBlockNumber(filterParameter.getToBlock());

View File

@@ -51,7 +51,7 @@ public class TraceGet extends AbstractTraceByHash implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 2) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
}
final Hash transactionHash = requestContext.getRequiredParameter(0, Hash.class);

View File

@@ -67,7 +67,7 @@ public class TraceRawTransaction extends AbstractTraceByBlock implements JsonRpc
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 2) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
}
final var rawTransaction = requestContext.getRequiredParameter(0, String.class);

View File

@@ -16,9 +16,11 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
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.PendingTransactionsParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
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.jsonrpc.internal.results.TransactionPendingResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transaction.pool.PendingTransactionFilter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transaction.pool.PendingTransactionFilter.Filter;
@@ -54,11 +56,19 @@ public class TxPoolBesuPendingTransactions implements JsonRpcMethod {
transactionPool.getPendingTransactions();
final Integer limit =
requestContext.getOptionalParameter(0, Integer.class).orElse(pendingTransactions.size());
final List<Filter> filters =
final List<Filter> filters;
try {
filters =
requestContext
.getOptionalParameter(1, PendingTransactionsParams.class)
.map(PendingTransactionsParams::filters)
.orElse(Collections.emptyList());
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid pending transactions parameter (index 1)",
RpcErrorType.INVALID_PENDING_TRANSACTIONS_PARAMS,
e);
}
final Collection<Transaction> pendingTransactionsFiltered =
pendingTransactionFilter.reduce(pendingTransactions, filters, limit);

View File

@@ -39,7 +39,7 @@ public class Web3Sha3 implements JsonRpcMethod {
if (requestContext.getRequest().getParamLength() != 1) {
// Do we want custom messages for each different type of invalid params?
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
}
final String data;

View File

@@ -15,11 +15,11 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static java.util.stream.Collectors.toList;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.CANCUN;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.WithdrawalsValidatorProvider.getWithdrawalsValidator;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.CANCUN;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator.ForkchoiceResult;
@@ -27,6 +27,7 @@ import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ProtocolContext;
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.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineForkchoiceUpdatedParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadAttributesParameter;
@@ -80,10 +81,25 @@ public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJso
final Object requestId = requestContext.getRequest().getId();
final EngineForkchoiceUpdatedParameter forkChoice =
requestContext.getRequiredParameter(0, EngineForkchoiceUpdatedParameter.class);
final Optional<EnginePayloadAttributesParameter> maybePayloadAttributes =
final EngineForkchoiceUpdatedParameter forkChoice;
try {
forkChoice = requestContext.getRequiredParameter(0, EngineForkchoiceUpdatedParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid engine forkchoice updated parameter (index 0)",
RpcErrorType.INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS,
e);
}
final Optional<EnginePayloadAttributesParameter> maybePayloadAttributes;
try {
maybePayloadAttributes =
requestContext.getOptionalParameter(1, EnginePayloadAttributesParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid engine payload attributes parameter (index 1)",
RpcErrorType.INVALID_ENGINE_FORKCHOICE_UPDATED_PAYLOAD_ATTRIBUTES,
e);
}
LOG.debug("Forkchoice parameters {}", forkChoice);
mergeContext

View File

@@ -19,6 +19,7 @@ import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator
import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier;
import org.hyperledger.besu.ethereum.ProtocolContext;
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.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@@ -68,7 +69,13 @@ public abstract class AbstractEngineGetPayload extends ExecutionEngineJsonRpcMet
public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) {
engineCallListener.executionEngineCalled();
final PayloadIdentifier payloadId = request.getRequiredParameter(0, PayloadIdentifier.class);
final PayloadIdentifier payloadId;
try {
payloadId = request.getRequiredParameter(0, PayloadIdentifier.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid payload ID parameter (index 0)", RpcErrorType.INVALID_PAYLOAD_ID_PARAMS, e);
}
mergeMiningCoordinator.finalizeProposalById(payloadId);
final Optional<PayloadWrapper> maybePayload = mergeContext.get().retrievePayloadById(payloadId);
if (maybePayload.isPresent()) {

View File

@@ -35,6 +35,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.BlockProcessingResult;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter;
@@ -107,16 +108,30 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) {
engineCallListener.executionEngineCalled();
final EnginePayloadParameter blockParam =
requestContext.getRequiredParameter(0, EnginePayloadParameter.class);
final EnginePayloadParameter blockParam;
try {
blockParam = requestContext.getRequiredParameter(0, EnginePayloadParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcRequestException(
"Invalid engine payload parameter (index 0)",
RpcErrorType.INVALID_ENGINE_NEW_PAYLOAD_PARAMS,
e);
}
final Optional<List<String>> maybeVersionedHashParam =
requestContext.getOptionalList(1, String.class);
final Object reqId = requestContext.getRequest().getId();
Optional<String> maybeParentBeaconBlockRootParam =
requestContext.getOptionalParameter(2, String.class);
Optional<String> maybeParentBeaconBlockRootParam;
try {
maybeParentBeaconBlockRootParam = requestContext.getOptionalParameter(2, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcRequestException(
"Invalid parent beacon block root parameters (index 2)",
RpcErrorType.INVALID_PARENT_BEACON_BLOCK_ROOT_PARAMS,
e);
}
final Optional<Bytes32> maybeParentBeaconBlockRoot =
maybeParentBeaconBlockRootParam.map(Bytes32::fromHexString);
@@ -486,7 +501,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
if (maybeParentHeader.isPresent()) {
if (!validateExcessBlobGas(header, maybeParentHeader.get(), protocolSpec)) {
return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS,
RpcErrorType.INVALID_EXCESS_BLOB_GAS_PARAMS,
"Payload excessBlobGas does not match calculated excessBlobGas");
}
}

View File

@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.CANCUN;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.CANCUN;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
import org.hyperledger.besu.ethereum.ProtocolContext;

View File

@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.CANCUN;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.CANCUN;
import org.hyperledger.besu.consensus.merge.PayloadWrapper;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;

View File

@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.CANCUN;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.CANCUN;
import org.hyperledger.besu.consensus.merge.PayloadWrapper;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;

View File

@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.PRAGUE;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.PRAGUE;
import org.hyperledger.besu.consensus.merge.PayloadWrapper;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;

View File

@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.CANCUN;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.CANCUN;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
import org.hyperledger.besu.datatypes.VersionedHash;
@@ -64,7 +64,7 @@ public class EngineNewPayloadV2 extends AbstractEngineNewPayload {
}
if (payloadParameter.getExcessBlobGas() != null) {
return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "non-null ExcessBlobGas pre-cancun");
RpcErrorType.INVALID_EXCESS_BLOB_GAS_PARAMS, "Missing excess blob gas field");
}
return ValidationResult.valid();
}

View File

@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.CANCUN;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.CANCUN;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
import org.hyperledger.besu.ethereum.ProtocolContext;
@@ -60,13 +60,15 @@ public class EngineNewPayloadV3 extends AbstractEngineNewPayload {
return ValidationResult.invalid(
RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field");
} else if (payloadParameter.getExcessBlobGas() == null) {
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing blob gas fields");
return ValidationResult.invalid(
RpcErrorType.INVALID_EXCESS_BLOB_GAS_PARAMS, "Missing excess blob gas field");
} else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) {
return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field");
} else if (maybeBeaconBlockRootParam.isEmpty()) {
return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "Missing parent beacon block root field");
RpcErrorType.INVALID_PARENT_BEACON_BLOCK_ROOT_PARAMS,
"Missing parent beacon block root field");
} else {
return ValidationResult.valid();
}

View File

@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.PRAGUE;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.PRAGUE;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
import org.hyperledger.besu.ethereum.ProtocolContext;
@@ -61,13 +61,14 @@ public class EngineNewPayloadV4 extends AbstractEngineNewPayload {
RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field");
} else if (payloadParameter.getExcessBlobGas() == null) {
return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "non-null ExcessBlobGas pre-cancun");
RpcErrorType.INVALID_EXCESS_BLOB_GAS_PARAMS, "Missing excess blob gas field");
} else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) {
return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field");
} else if (maybeBeaconBlockRootParam.isEmpty()) {
return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "Missing parent beacon block root field");
RpcErrorType.INVALID_PARENT_BEACON_BLOCK_ROOT_PARAMS,
"Missing parent beacon block root field");
} else if (payloadParameter.getDepositRequests() == null) {
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing deposit field");
} else {

View File

@@ -23,6 +23,7 @@ import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier;
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.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePreparePayloadParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
@@ -58,7 +59,9 @@ public class EnginePreparePayloadDebug extends ExecutionEngineJsonRpcMethod {
@Override
public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) {
final EnginePreparePayloadParameter enginePreparePayloadParameter =
final EnginePreparePayloadParameter enginePreparePayloadParameter;
try {
enginePreparePayloadParameter =
requestContext
.getOptionalParameter(0, EnginePreparePayloadParameter.class)
.orElse(
@@ -69,6 +72,12 @@ public class EnginePreparePayloadDebug extends ExecutionEngineJsonRpcMethod {
Optional.empty(),
Optional.empty(),
Optional.empty()));
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid engine prepare payload parameter (index 0)",
RpcErrorType.INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS,
e);
}
final var requestId = requestContext.getRequest().getId();
@@ -81,7 +90,10 @@ public class EnginePreparePayloadDebug extends ExecutionEngineJsonRpcMethod {
payloadIdentifier ->
new JsonRpcSuccessResponse(
requestId, new EnginePreparePayloadResult(VALID, payloadIdentifier)))
.orElseGet(() -> new JsonRpcErrorResponse(requestId, RpcErrorType.INVALID_PARAMS));
.orElseGet(
() ->
new JsonRpcErrorResponse(
requestId, RpcErrorType.INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS));
}
@VisibleForTesting

View File

@@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import org.hyperledger.besu.datatypes.HardforkId;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.mainnet.HardforkId;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import java.util.Optional;

View File

@@ -60,10 +60,12 @@ public class MinerSetExtraData implements JsonRpcMethod {
.addArgument(() -> new String(extraData.toArray(), StandardCharsets.UTF_8))
.log();
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
} catch (Exception invalidJsonRpcParameters) { // TODO:replace with "IllegalArgumentException |
// JsonRpcParameter.JsonRpcParameterException"
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
new JsonRpcError(RpcErrorType.INVALID_PARAMS, invalidJsonRpcParameters.getMessage()));
new JsonRpcError(
RpcErrorType.INVALID_EXTRA_DATA_PARAMS, invalidJsonRpcParameters.getMessage()));
}
}
}

View File

@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner;
import org.hyperledger.besu.datatypes.Wei;
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.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@@ -53,7 +54,13 @@ public class MinerSetMinGasPrice implements JsonRpcMethod {
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
new JsonRpcError(RpcErrorType.INVALID_PARAMS, invalidJsonRpcParameters.getMessage()));
new JsonRpcError(
RpcErrorType.INVALID_MIN_GAS_PRICE_PARAMS, invalidJsonRpcParameters.getMessage()));
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid min gas price parameter (index 0)",
RpcErrorType.INVALID_MIN_GAS_PRICE_PARAMS,
e);
}
}
}

View File

@@ -54,7 +54,8 @@ public class MinerSetMinPriorityFee implements JsonRpcMethod {
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
new JsonRpcError(RpcErrorType.INVALID_PARAMS, invalidJsonRpcParameters.getMessage()));
new JsonRpcError(
RpcErrorType.INVALID_MIN_PRIORITY_FEE_PARAMS, invalidJsonRpcParameters.getMessage()));
}
}
}

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning
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.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@@ -46,8 +47,13 @@ public class PermAddNodesToAllowlist implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final StringListParameter enodeListParam =
requestContext.getRequiredParameter(0, StringListParameter.class);
final StringListParameter enodeListParam;
try {
enodeListParam = requestContext.getRequiredParameter(0, StringListParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid enode list parameter (index 0)", RpcErrorType.INVALID_ENODE_PARAMS, e);
}
try {
if (nodeAllowlistPermissioningController.isPresent()) {

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning
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.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@@ -46,8 +47,13 @@ public class PermRemoveNodesFromAllowlist implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final StringListParameter enodeListParam =
requestContext.getRequiredParameter(0, StringListParameter.class);
final StringListParameter enodeListParam;
try {
enodeListParam = requestContext.getRequiredParameter(0, StringListParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid enode list parameter (index 0)", RpcErrorType.INVALID_ENODE_PARAMS, e);
}
try {
if (nodeAllowlistPermissioningController.isPresent()) {
try {

View File

@@ -24,6 +24,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transac
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transaction.pool.Predicate.EQ;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transaction.pool.PendingTransactionFilter.Filter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transaction.pool.Predicate;
@@ -79,7 +80,8 @@ public class PendingTransactionsParams {
private Optional<Filter> getFilter(final String key, final Map<String, String> map) {
if (map != null) {
if (map.size() > 1) {
throw new InvalidJsonRpcParameters("Only one operator per filter type allowed");
throw new InvalidJsonRpcParameters(
"Only one operator per filter type allowed", RpcErrorType.INVALID_FILTER_PARAMS);
} else if (!map.isEmpty()) {
final Map.Entry<String, String> foundEntry = map.entrySet().stream().findFirst().get();
final Predicate predicate =
@@ -87,17 +89,22 @@ public class PendingTransactionsParams {
.orElseThrow(
() ->
new InvalidJsonRpcParameters(
"Unknown field expected one of `eq`, `gt`, `lt`, `action`"));
"Unknown field expected one of `eq`, `gt`, `lt`, `action`",
RpcErrorType.INVALID_FILTER_PARAMS));
final Filter filter = new Filter(key, foundEntry.getValue(), predicate);
if (key.equals(FROM_FIELD) && !predicate.equals(EQ)) {
throw new InvalidJsonRpcParameters("The `from` filter only supports the `eq` operator");
throw new InvalidJsonRpcParameters(
"The `from` filter only supports the `eq` operator",
RpcErrorType.INVALID_FILTER_PARAMS);
} else if (key.equals(TO_FIELD) && !predicate.equals(EQ) && !predicate.equals(ACTION)) {
throw new InvalidJsonRpcParameters(
"The `to` filter only supports the `eq` or `action` operator");
"The `to` filter only supports the `eq` or `action` operator",
RpcErrorType.INVALID_FILTER_PARAMS);
} else if (!key.equals(TO_FIELD) && predicate.equals(ACTION)) {
throw new InvalidJsonRpcParameters(
"The operator `action` is only supported by the `to` filter");
"The operator `action` is only supported by the `to` filter",
RpcErrorType.INVALID_FILTER_PARAMS);
}
return Optional.of(filter);
}

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods;
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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@@ -52,7 +53,13 @@ public class PrivGetFilterChanges implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String privacyGroupId = requestContext.getRequiredParameter(0, String.class);
final String filterId = requestContext.getRequiredParameter(1, String.class);
final String filterId;
try {
filterId = requestContext.getRequiredParameter(1, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter ID parameter (index 1)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
if (privacyController instanceof MultiTenancyPrivacyController) {
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(requestContext, privacyGroupId);

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods;
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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@@ -52,7 +53,13 @@ public class PrivGetFilterLogs implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext request) {
final String privacyGroupId = request.getRequiredParameter(0, String.class);
final String filterId = request.getRequiredParameter(1, String.class);
final String filterId;
try {
filterId = request.getRequiredParameter(1, String.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter ID parameter (index 1)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
if (privacyController instanceof MultiTenancyPrivacyController) {
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(request, privacyGroupId);

View File

@@ -16,10 +16,12 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods;
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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
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.privacy.MultiTenancyPrivacyController;
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
@@ -46,7 +48,13 @@ public class PrivUninstallFilter implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext request) {
final String privacyGroupId = request.getRequiredParameter(0, String.class);
final String filterId = request.getRequiredParameter(1, String.class);
final String filterId;
try {
filterId = request.getRequiredParameter(1, String.class);
} catch (Exception e) {
throw new InvalidJsonRpcParameters(
"Invalid filter ID paramter (index 1)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
if (privacyController instanceof MultiTenancyPrivacyController) {
checkIfPrivacyGroupMatchesAuthenticatedEnclaveKey(request, privacyGroupId);

View File

@@ -63,7 +63,7 @@ public class PrivGetEeaTransactionCount implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 3) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
}
final Address address;

View File

@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv;
import org.hyperledger.besu.datatypes.Hash;
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.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider;
@@ -62,11 +63,17 @@ public class PrivGetLogs implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final String privacyGroupId = requestContext.getRequiredParameter(0, String.class);
final FilterParameter filter = requestContext.getRequiredParameter(1, FilterParameter.class);
final FilterParameter filter;
try {
filter = requestContext.getRequiredParameter(1, FilterParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter parameter (index 1)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
if (!filter.isValid()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_FILTER_PARAMS);
}
final List<LogWithMetadata> matchingLogs =

View File

@@ -54,7 +54,7 @@ public class PrivGetTransactionCount implements JsonRpcMethod {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (requestContext.getRequest().getParamLength() != 2) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
}
final Address address;

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv;
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.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
@@ -50,7 +51,13 @@ public class PrivNewFilter implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext request) {
final String privacyGroupId = request.getRequiredParameter(0, String.class);
final FilterParameter filter = request.getRequiredParameter(1, FilterParameter.class);
final FilterParameter filter;
try {
filter = request.getRequiredParameter(1, FilterParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter parameter (index 1)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
final String privacyUserId = privacyIdProvider.getPrivacyUserId(request.getUser());
if (privacyController instanceof MultiTenancyPrivacyController) {
@@ -60,7 +67,8 @@ public class PrivNewFilter implements JsonRpcMethod {
}
if (!filter.isValid()) {
return new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
return new JsonRpcErrorResponse(
request.getRequest().getId(), RpcErrorType.INVALID_FILTER_PARAMS);
}
final String logFilterId =

View File

@@ -47,14 +47,15 @@ public enum RpcErrorType implements RpcMethodError {
INVALID_CREATE_PRIVACY_GROUP_PARAMS(
INVALID_PARAMS_ERROR_CODE, "Invalid create privacy group params"),
INVALID_DATA_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid data params"),
INVALID_DATA_HASH_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid data hash params"),
INVALID_DEPOSIT_REQUEST_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid deposit request"),
INVALID_ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_PARAMS(
INVALID_PARAMS_ERROR_CODE, "Invalid engine exchange transition configuration params"),
INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS(
INVALID_PARAMS_ERROR_CODE, "Invalid engine forkchoice updated params"),
INVALID_ENGINE_PAYLOAD_ATTRIBUTES_PARAMS(
INVALID_ENGINE_FORKCHOICE_UPDATED_PAYLOAD_ATTRIBUTES(
INVALID_PARAMS_ERROR_CODE, "Invalid engine payload attributes parameter"),
INVALID_ENGINE_PAYLOAD_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid engine payload parameter"),
INVALID_ENGINE_NEW_PAYLOAD_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid engine payload parameter"),
INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS(
INVALID_PARAMS_ERROR_CODE, "Invalid engine prepare payload parameter"),
INVALID_ENODE_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid enode params"),

View File

@@ -24,10 +24,13 @@ public class NetworkResult {
private final String localAddress;
private final String remoteAddress;
private final boolean inbound;
public NetworkResult(final SocketAddress localAddress, final SocketAddress remoteAddress) {
public NetworkResult(
final SocketAddress localAddress, final SocketAddress remoteAddress, final boolean inbound) {
this.localAddress = removeTrailingSlash(localAddress.toString());
this.remoteAddress = removeTrailingSlash(remoteAddress.toString());
this.inbound = inbound;
}
@JsonGetter(value = "localAddress")
@@ -40,6 +43,11 @@ public class NetworkResult {
return remoteAddress;
}
@JsonGetter(value = "inbound")
public boolean isInbound() {
return inbound;
}
private String removeTrailingSlash(final String address) {
if (address != null && address.startsWith("/")) {
return address.substring(1);

View File

@@ -45,7 +45,11 @@ public interface PeerResult {
.map(Capability::toString)
.map(TextNode::new)
.collect(Collectors.toList()))
.network(new NetworkResult(connection.getLocalAddress(), connection.getRemoteAddress()))
.network(
new NetworkResult(
connection.getLocalAddress(),
connection.getRemoteAddress(),
connection.inboundInitiated()))
.port(Quantity.create(peerInfo.getPort()))
.id(peerInfo.getNodeId().toString())
.protocols(Map.of(peer.getProtocolName(), ProtocolsResult.fromEthPeer(peer)))

View File

@@ -15,8 +15,10 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request;
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.FilterParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.WebSocketRpcRequest;
import java.util.Optional;
@@ -70,7 +72,13 @@ public class SubscriptionRequestMapper {
}
private SubscribeRequest parseLogsRequest(final WebSocketRpcRequest request) {
final FilterParameter filterParameter = request.getRequiredParameter(1, FilterParameter.class);
final FilterParameter filterParameter;
try {
filterParameter = request.getRequiredParameter(1, FilterParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter parameters (index 1)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
return new SubscribeRequest(
SubscriptionType.LOGS, filterParameter, null, request.getConnectionId());
}
@@ -101,8 +109,14 @@ public class SubscriptionRequestMapper {
switch (subscriptionType) {
case LOGS:
{
final FilterParameter filterParameter =
final FilterParameter filterParameter;
try {
filterParameter =
jsonRpcRequestContext.getRequiredParameter(2, FilterParameter.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid filter parameter (index 2)", RpcErrorType.INVALID_FILTER_PARAMS, e);
}
return new PrivateSubscribeRequest(
SubscriptionType.LOGS,
filterParameter,

View File

@@ -784,7 +784,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
assertThat(resp.code()).isEqualTo(200);
// Check general format of result
final JsonObject json = new JsonObject(resp.body().string());
final RpcErrorType expectedError = RpcErrorType.INVALID_PARAMS;
final RpcErrorType expectedError = RpcErrorType.INVALID_IS_TRANSACTION_COMPLETE_PARAMS;
testHelper.assertValidJsonRpcError(
json, id, expectedError.getCode(), expectedError.getMessage());
}
@@ -854,7 +854,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
assertThat(resp.code()).isEqualTo(200);
// Check general format of result
final JsonObject json = new JsonObject(resp.body().string());
final RpcErrorType expectedError = RpcErrorType.INVALID_PARAMS;
final RpcErrorType expectedError = RpcErrorType.INVALID_IS_TRANSACTION_COMPLETE_PARAMS;
testHelper.assertValidJsonRpcError(
json, id, expectedError.getCode(), expectedError.getMessage());
}

View File

@@ -104,7 +104,7 @@ public class PluginJsonRpcMethodTest extends JsonRpcHttpServiceTestBase {
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) {
assertThat(resp.code()).isEqualTo(200);
final JsonObject json = new JsonObject(resp.body().string());
final JsonRpcError expectedError = new JsonRpcError(RpcErrorType.INVALID_PARAMS);
final JsonRpcError expectedError = new JsonRpcError(RpcErrorType.INVALID_PARAM_COUNT);
testHelper.assertValidJsonRpcError(
json, 1, expectedError.getCode(), expectedError.getMessage());
}
@@ -173,7 +173,8 @@ public class PluginJsonRpcMethodTest extends JsonRpcHttpServiceTestBase {
private static Object echoPluginRpcMethod(final PluginRpcRequest request) {
final var params = request.getParams();
if (params.length == 0) {
throw new InvalidJsonRpcParameters("parameter is mandatory");
throw new InvalidJsonRpcParameters(
"parameter is mandatory", RpcErrorType.INVALID_PARAM_COUNT);
}
final var input = params[0];
if (input.toString().isBlank()) {

View File

@@ -102,7 +102,7 @@ public class AdminAddPeerTest {
final JsonRpcRequestContext request =
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_addPeer", new String[] {}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);
@@ -114,7 +114,7 @@ public class AdminAddPeerTest {
final JsonRpcRequestContext request =
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_addPeer", null));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);
@@ -126,7 +126,7 @@ public class AdminAddPeerTest {
final JsonRpcRequestContext request =
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_addPeer", new String[] {null}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);
@@ -221,7 +221,7 @@ public class AdminAddPeerTest {
new JsonRpcRequest("2.0", "admin_addPeer", new String[] {validEnode, validEnode}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);

View File

@@ -117,7 +117,8 @@ public class AdminChangeLogLevelTest {
new JsonRpcRequestContext(
new JsonRpcRequest("2.0", "admin_changeLogLevel", new Object[] {null}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(
request.getRequest().getId(), RpcErrorType.INVALID_LOG_LEVEL_PARAMS);
final JsonRpcResponse actualResponse = adminChangeLogLevel.response(request);
assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse);
@@ -129,7 +130,8 @@ public class AdminChangeLogLevelTest {
new JsonRpcRequestContext(
new JsonRpcRequest("2.0", "admin_changeLogLevel", new String[] {"INVALID"}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(
request.getRequest().getId(), RpcErrorType.INVALID_LOG_LEVEL_PARAMS);
final JsonRpcResponse actualResponse = adminChangeLogLevel.response(request);
assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse);
@@ -141,7 +143,8 @@ public class AdminChangeLogLevelTest {
new JsonRpcRequestContext(
new JsonRpcRequest("2.0", "admin_changeLogLevel", new Object[] {"DEBUG", "INVALID"}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(
request.getRequest().getId(), RpcErrorType.INVALID_LOG_FILTER_PARAMS);
final JsonRpcResponse actualResponse = adminChangeLogLevel.response(request);
assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse);

View File

@@ -102,7 +102,7 @@ public class AdminRemovePeerTest {
final JsonRpcRequestContext request =
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_removePeer", new String[] {}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);
@@ -114,7 +114,7 @@ public class AdminRemovePeerTest {
final JsonRpcRequestContext request =
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_removePeer", null));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);
@@ -127,7 +127,7 @@ public class AdminRemovePeerTest {
new JsonRpcRequestContext(
new JsonRpcRequest("2.0", "admin_removePeer", new String[] {null}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);
@@ -222,7 +222,7 @@ public class AdminRemovePeerTest {
new JsonRpcRequest("2.0", "admin_removePeer", new String[] {validEnode, validEnode}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);

View File

@@ -69,7 +69,7 @@ public class EthGetBlockByHashTest {
public void exceptionWhenNoBoolSupplied() {
assertThatThrownBy(() -> method.response(requestWithParams(ZERO_HASH)))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 1");
.hasMessage("Invalid is complete transaction parameter (index 1)");
verifyNoMoreInteractions(blockchainQueries);
}
@@ -85,8 +85,7 @@ public class EthGetBlockByHashTest {
public void exceptionWhenBoolParamInvalid() {
assertThatThrownBy(() -> method.response(requestWithParams(ZERO_HASH, "maybe")))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage(
"Invalid json rpc parameter at index 1. Supplied value was: 'maybe' of type: 'java.lang.String' - expected type: 'java.lang.Boolean'");
.hasMessage("Invalid is complete transaction parameter (index 1)");
verifyNoMoreInteractions(blockchainQueries);
}

View File

@@ -121,7 +121,7 @@ public class EthGetBlockByNumberTest {
public void exceptionWhenNoBoolSupplied() {
assertThatThrownBy(() -> method.response(requestWithParams("0")))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 1");
.hasMessage("Invalid is transaction complete parameter (index 1)");
verifyNoMoreInteractions(blockchainQueries);
}
@@ -137,8 +137,7 @@ public class EthGetBlockByNumberTest {
public void exceptionWhenBoolParamInvalid() {
assertThatThrownBy(() -> method.response(requestWithParams("0", "maybe")))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage(
"Invalid json rpc parameter at index 1. Supplied value was: 'maybe' of type: 'java.lang.String' - expected type: 'java.lang.Boolean'");
.hasMessage("Invalid is transaction complete parameter (index 1)");
verifyNoMoreInteractions(blockchainQueries);
}

View File

@@ -69,9 +69,8 @@ public class EthGetFilterChangesTest {
final Throwable thrown = catchThrowable(() -> method.response(request));
assertThat(thrown)
.hasNoCause()
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid filter ID parameter (index 0)");
verifyNoInteractions(filterManager);
}
@@ -83,7 +82,7 @@ public class EthGetFilterChangesTest {
final Throwable thrown = catchThrowable(() -> method.response(request));
assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid filter ID parameter (index 0)");
verifyNoInteractions(filterManager);
}

View File

@@ -70,7 +70,7 @@ public class EthGetFilterLogsTest {
final Throwable thrown = catchThrowable(() -> method.response(request));
assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid filter ID parameter (index 0)");
verifyNoInteractions(filterManager);
}
@@ -82,7 +82,7 @@ public class EthGetFilterLogsTest {
final Throwable thrown = catchThrowable(() -> method.response(request));
assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid filter ID parameter (index 0)");
verifyNoInteractions(filterManager);
}

View File

@@ -73,7 +73,7 @@ public class EthGetLogsTest {
final Throwable thrown = catchThrowable(() -> method.response(request));
assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid filter parameter (index 0)");
verifyNoInteractions(blockchainQueries);
}

View File

@@ -77,7 +77,7 @@ class EthGetTransactionByHashTest {
final JsonRpcRequestContext context = new JsonRpcRequestContext(request);
final JsonRpcErrorResponse expectedResponse =
new JsonRpcErrorResponse(request.getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(context);

View File

@@ -182,7 +182,7 @@ public class EthNewFilterTest {
final JsonRpcRequestContext request = ethNewFilter(invalidFilter);
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(null, RpcErrorType.INVALID_FILTER_PARAMS);
final JsonRpcResponse response = method.response(request);

View File

@@ -57,7 +57,7 @@ public class EthSendRawTransactionTest {
new JsonRpcRequest("2.0", "eth_sendRawTransaction", new String[] {}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);
@@ -70,7 +70,7 @@ public class EthSendRawTransactionTest {
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "eth_sendRawTransaction", null));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);
@@ -84,7 +84,7 @@ public class EthSendRawTransactionTest {
new JsonRpcRequest("2.0", "eth_sendRawTransaction", new String[] {null}));
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actualResponse = method.response(request);

View File

@@ -201,7 +201,7 @@ public class TxPoolBesuPendingTransactionsTest {
assertThatThrownBy(() -> method.response(request))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessageContaining("Unknown field expected one of `eq`, `gt`, `lt`, `action`");
.hasMessageContaining("Invalid pending transactions parameter (index 1)");
}
@Test
@@ -229,7 +229,7 @@ public class TxPoolBesuPendingTransactionsTest {
assertThatThrownBy(() -> method.response(request))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessageContaining("Only one operator per filter type allowed");
.hasMessageContaining("Invalid pending transactions parameter (index 1)");
}
@Test
@@ -256,7 +256,7 @@ public class TxPoolBesuPendingTransactionsTest {
assertThatThrownBy(() -> method.response(request))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessageContaining("The `from` filter only supports the `eq` operator");
.hasMessageContaining("Invalid pending transactions parameter (index 1)");
}
@Test
@@ -283,7 +283,7 @@ public class TxPoolBesuPendingTransactionsTest {
assertThatThrownBy(() -> method.response(request))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessageContaining("The `to` filter only supports the `eq` or `action` operator");
.hasMessageContaining("Invalid pending transactions parameter (index 1)");
}
private Set<PendingTransaction> getTransactionPool() {

View File

@@ -123,7 +123,7 @@ public class Web3Sha3Test {
"2", "web3_sha3", new Object[] {"0x68656c6c6f20776f726c64", "{encode:'hex'}"}));
final JsonRpcResponse expected =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actual = method.response(request);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
@@ -135,7 +135,7 @@ public class Web3Sha3Test {
new JsonRpcRequestContext(new JsonRpcRequest("2", "web3_sha3", new Object[] {}));
final JsonRpcResponse expected =
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
new JsonRpcErrorResponse(request.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
final JsonRpcResponse actual = method.response(request);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);

View File

@@ -16,10 +16,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static java.util.Collections.emptyList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.CANCUN;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.CANCUN;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.mock;

View File

@@ -14,12 +14,12 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.CANCUN;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.EXPERIMENTAL_EIPS;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.LONDON;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.PARIS;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.PRAGUE;
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.SHANGHAI;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.CANCUN;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.EXPERIMENTAL_EIPS;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.LONDON;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.PARIS;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.PRAGUE;
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.SHANGHAI;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;

View File

@@ -170,7 +170,7 @@ public class EngineNewPayloadV2Test extends AbstractEngineNewPayloadTest {
final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
assertThat(jsonRpcError.getData()).isEqualTo("non-null ExcessBlobGas pre-cancun");
assertThat(jsonRpcError.getData()).isEqualTo("Missing excess blob gas field");
verify(engineCallListener, times(1)).executionEngineCalled();
}

View File

@@ -219,7 +219,7 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test {
final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
assertThat(jsonRpcError.getData()).isEqualTo("Missing blob gas fields");
assertThat(jsonRpcError.getData()).isEqualTo("Missing excess blob gas field");
verify(engineCallListener, times(1)).executionEngineCalled();
}

View File

@@ -83,7 +83,7 @@ public class MinerSetExtraDataTest {
new JsonRpcErrorResponse(
request.getRequest().getId(),
new JsonRpcError(
RpcErrorType.INVALID_PARAMS,
RpcErrorType.INVALID_EXTRA_DATA_PARAMS,
"Illegal character 'n' found at index 0 in hex binary representation"));
final JsonRpcResponse actual = method.response(request);
@@ -100,7 +100,7 @@ public class MinerSetExtraDataTest {
new JsonRpcErrorResponse(
request.getRequest().getId(),
new JsonRpcError(
RpcErrorType.INVALID_PARAMS,
RpcErrorType.INVALID_EXTRA_DATA_PARAMS,
"Hex value is too large: expected at most 32 bytes but got 37"));
final JsonRpcResponse actual = method.response(request);

View File

@@ -48,7 +48,7 @@ public class MinerSetMinGasPriceTest {
new JsonRpcErrorResponse(
request.getRequest().getId(),
new JsonRpcError(
RpcErrorType.INVALID_PARAMS,
RpcErrorType.INVALID_MIN_GAS_PRICE_PARAMS,
"Illegal character '-' found at index 0 in hex binary representation"));
final JsonRpcResponse actual = method.response(request);

View File

@@ -49,7 +49,7 @@ public class MinerSetMinPriorityFeeTest {
new JsonRpcErrorResponse(
request.getRequest().getId(),
new JsonRpcError(
RpcErrorType.INVALID_PARAMS,
RpcErrorType.INVALID_MIN_PRIORITY_FEE_PARAMS,
"Hex value is too large: expected at most 32 bytes but got 33"));
final JsonRpcResponse actual = method.response(request);
@@ -65,7 +65,8 @@ public class MinerSetMinPriorityFeeTest {
new JsonRpcErrorResponse(
request.getRequest().getId(),
new JsonRpcError(
RpcErrorType.INVALID_PARAMS, "Missing required json rpc parameter at index 0"));
RpcErrorType.INVALID_MIN_PRIORITY_FEE_PARAMS,
"Missing required json rpc parameter at index 0"));
final JsonRpcResponse actual = method.response(request);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
}

Some files were not shown because too many files have changed in this diff Show More