mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-09 13:58:02 -05:00
Merge branch 'main' into zkbesu
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
This commit is contained in:
20
.github/ISSUE_TEMPLATE/release-checklist.md
vendored
20
.github/ISSUE_TEMPLATE/release-checklist.md
vendored
@@ -11,11 +11,16 @@ assignees: ''
|
|||||||
- [ ] Update changelog if necessary, and merge a PR for it to main
|
- [ ] Update changelog if necessary, and merge a PR for it to main
|
||||||
- [ ] Notify maintainers about updating changelog for in-flight PRs
|
- [ ] 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: 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`
|
- [ ] 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
|
- [ ] git tag 24.4.0-RC2
|
||||||
- [ ] Consensys staff start burn-in using the proposed release <version-RCX> tag
|
- [ ] git push upstream 24.4.0-RC2
|
||||||
- [ ] Sign off burn-in; convey burn-in results in #besu-release in Discord
|
- [ ] 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 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:
|
- [ ] Using the FULL RELEASE tag, create a release in github to trigger the workflows. Once published:
|
||||||
- this is now public and notifies subscribed users
|
- this is now public and notifies subscribed users
|
||||||
@@ -24,8 +29,9 @@ assignees: ''
|
|||||||
- publishes the docker `latest` tag variants
|
- publishes the docker `latest` tag variants
|
||||||
- [ ] Check binary SHAs are correct on the release page
|
- [ ] Check binary SHAs are correct on the release page
|
||||||
- [ ] Check "Container Verify" GitHub workflow has run successfully
|
- [ ] 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
|
- [ ] Create besu-docs release - https://github.com/hyperledger/besu-docs/releases/new
|
||||||
- Copy release notes from besu
|
- 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
|
- 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
|
- [ ] Social announcements
|
||||||
|
|||||||
@@ -17,12 +17,15 @@
|
|||||||
- In process RPC service [#7395](https://github.com/hyperledger/besu/pull/7395)
|
- 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)
|
- 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)
|
- 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
|
### Bug fixes
|
||||||
- Correct entrypoint in Docker evmtool [#7430](https://github.com/hyperledger/besu/pull/7430)
|
- 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 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 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
|
## 24.7.1
|
||||||
|
|
||||||
|
|||||||
@@ -432,7 +432,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
|
|||||||
besuPluginContext.addService(PermissioningService.class, permissioningService);
|
besuPluginContext.addService(PermissioningService.class, permissioningService);
|
||||||
besuPluginContext.addService(PrivacyPluginService.class, new PrivacyPluginServiceImpl());
|
besuPluginContext.addService(PrivacyPluginService.class, new PrivacyPluginServiceImpl());
|
||||||
|
|
||||||
besuPluginContext.registerPlugins(new PluginConfiguration(pluginsPath));
|
besuPluginContext.registerPlugins(
|
||||||
|
new PluginConfiguration.Builder().pluginsDir(pluginsPath).build());
|
||||||
|
|
||||||
// register built-in plugins
|
// register built-in plugins
|
||||||
new RocksDBPlugin().register(besuPluginContext);
|
new RocksDBPlugin().register(besuPluginContext);
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ public class BesuPluginContextImplTest {
|
|||||||
@Test
|
@Test
|
||||||
public void verifyEverythingGoesSmoothly() {
|
public void verifyEverythingGoesSmoothly() {
|
||||||
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
||||||
contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY));
|
contextImpl.registerPlugins(
|
||||||
|
PluginConfiguration.builder().pluginsDir(DEFAULT_PLUGIN_DIRECTORY).build());
|
||||||
assertThat(contextImpl.getRegisteredPlugins()).isNotEmpty();
|
assertThat(contextImpl.getRegisteredPlugins()).isNotEmpty();
|
||||||
|
|
||||||
final Optional<TestPicoCLIPlugin> testPluginOptional =
|
final Optional<TestPicoCLIPlugin> testPluginOptional =
|
||||||
@@ -86,7 +87,8 @@ public class BesuPluginContextImplTest {
|
|||||||
System.setProperty("testPicoCLIPlugin.testOption", "FAILREGISTER");
|
System.setProperty("testPicoCLIPlugin.testOption", "FAILREGISTER");
|
||||||
|
|
||||||
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
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);
|
assertThat(contextImpl.getRegisteredPlugins()).isNotInstanceOfAny(TestPicoCLIPlugin.class);
|
||||||
|
|
||||||
contextImpl.beforeExternalServices();
|
contextImpl.beforeExternalServices();
|
||||||
@@ -104,7 +106,8 @@ public class BesuPluginContextImplTest {
|
|||||||
System.setProperty("testPicoCLIPlugin.testOption", "FAILSTART");
|
System.setProperty("testPicoCLIPlugin.testOption", "FAILSTART");
|
||||||
|
|
||||||
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
||||||
contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY));
|
contextImpl.registerPlugins(
|
||||||
|
PluginConfiguration.builder().pluginsDir(DEFAULT_PLUGIN_DIRECTORY).build());
|
||||||
assertThat(contextImpl.getRegisteredPlugins())
|
assertThat(contextImpl.getRegisteredPlugins())
|
||||||
.extracting("class")
|
.extracting("class")
|
||||||
.contains(TestPicoCLIPlugin.class);
|
.contains(TestPicoCLIPlugin.class);
|
||||||
@@ -129,7 +132,8 @@ public class BesuPluginContextImplTest {
|
|||||||
System.setProperty("testPicoCLIPlugin.testOption", "FAILSTOP");
|
System.setProperty("testPicoCLIPlugin.testOption", "FAILSTOP");
|
||||||
|
|
||||||
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
||||||
contextImpl.registerPlugins(new PluginConfiguration(DEFAULT_PLUGIN_DIRECTORY));
|
contextImpl.registerPlugins(
|
||||||
|
PluginConfiguration.builder().pluginsDir(DEFAULT_PLUGIN_DIRECTORY).build());
|
||||||
assertThat(contextImpl.getRegisteredPlugins())
|
assertThat(contextImpl.getRegisteredPlugins())
|
||||||
.extracting("class")
|
.extracting("class")
|
||||||
.contains(TestPicoCLIPlugin.class);
|
.contains(TestPicoCLIPlugin.class);
|
||||||
@@ -151,7 +155,9 @@ public class BesuPluginContextImplTest {
|
|||||||
@Test
|
@Test
|
||||||
public void lifecycleExceptions() throws Throwable {
|
public void lifecycleExceptions() throws Throwable {
|
||||||
final ThrowableAssert.ThrowingCallable registerPlugins =
|
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::startPlugins);
|
||||||
assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::stopPlugins);
|
assertThatExceptionOfType(IllegalStateException.class).isThrownBy(contextImpl::stopPlugins);
|
||||||
@@ -173,7 +179,8 @@ public class BesuPluginContextImplTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldRegisterAllPluginsWhenNoPluginsOption() {
|
public void shouldRegisterAllPluginsWhenNoPluginsOption() {
|
||||||
final PluginConfiguration config = createConfigurationForAllPlugins();
|
final PluginConfiguration config =
|
||||||
|
PluginConfiguration.builder().pluginsDir(DEFAULT_PLUGIN_DIRECTORY).build();
|
||||||
|
|
||||||
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
||||||
contextImpl.registerPlugins(config);
|
contextImpl.registerPlugins(config);
|
||||||
@@ -227,12 +234,33 @@ public class BesuPluginContextImplTest {
|
|||||||
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
assertThat(contextImpl.getRegisteredPlugins()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PluginConfiguration createConfigurationForAllPlugins() {
|
@Test
|
||||||
return new PluginConfiguration(null, DEFAULT_PLUGIN_DIRECTORY);
|
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) {
|
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(
|
private Optional<TestPicoCLIPlugin> findTestPlugin(
|
||||||
|
|||||||
@@ -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.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.JsonRpcConfiguration.DEFAULT_ENGINE_JSON_RPC_PORT;
|
||||||
import static org.hyperledger.besu.ethereum.api.jsonrpc.authentication.EngineAuthService.EPHEMERAL_JWT_FILE;
|
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 static org.hyperledger.besu.nat.kubernetes.KubernetesNatManager.DEFAULT_BESU_SERVICE_NAME_FILTER;
|
||||||
|
|
||||||
import org.hyperledger.besu.BesuInfo;
|
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.GraphQlOptions;
|
||||||
import org.hyperledger.besu.cli.options.stable.JsonRpcHttpOptions;
|
import org.hyperledger.besu.cli.options.stable.JsonRpcHttpOptions;
|
||||||
import org.hyperledger.besu.cli.options.stable.LoggingLevelOption;
|
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.NodePrivateKeyFileOption;
|
||||||
import org.hyperledger.besu.cli.options.stable.P2PTLSConfigOptions;
|
import org.hyperledger.besu.cli.options.stable.P2PTLSConfigOptions;
|
||||||
import org.hyperledger.besu.cli.options.stable.PermissionsOptions;
|
import org.hyperledger.besu.cli.options.stable.PermissionsOptions;
|
||||||
@@ -314,7 +311,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
final MiningOptions miningOptions = MiningOptions.create();
|
final MiningOptions miningOptions = MiningOptions.create();
|
||||||
|
|
||||||
private final RunnerBuilder runnerBuilder;
|
private final RunnerBuilder runnerBuilder;
|
||||||
private final BesuController.Builder controllerBuilderFactory;
|
private final BesuController.Builder controllerBuilder;
|
||||||
private final BesuPluginContextImpl besuPluginContext;
|
private final BesuPluginContextImpl besuPluginContext;
|
||||||
private final StorageServiceImpl storageService;
|
private final StorageServiceImpl storageService;
|
||||||
private final SecurityModuleServiceImpl securityModuleService;
|
private final SecurityModuleServiceImpl securityModuleService;
|
||||||
@@ -375,7 +372,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
|
|
||||||
@Option(
|
@Option(
|
||||||
names = {"--genesis-state-hash-cache-enabled"},
|
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;
|
private final Boolean genesisStateHashCacheEnabled = false;
|
||||||
|
|
||||||
@Option(
|
@Option(
|
||||||
@@ -745,81 +743,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
@CommandLine.ArgGroup(validate = false, heading = "@|bold Metrics Options|@%n")
|
@CommandLine.ArgGroup(validate = false, heading = "@|bold Metrics Options|@%n")
|
||||||
MetricsOptionGroup metricsOptionGroup = new MetricsOptionGroup();
|
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(
|
@Option(
|
||||||
names = {"--host-allowlist"},
|
names = {"--host-allowlist"},
|
||||||
paramLabel = "<hostname>[,<hostname>...]... or * or all",
|
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 jsonBlockImporterFactory instance of {@code Function<BesuController, JsonBlockImporter>}
|
||||||
* @param rlpBlockExporterFactory instance of {@code Function<Blockchain, RlpBlockExporter>}
|
* @param rlpBlockExporterFactory instance of {@code Function<Blockchain, RlpBlockExporter>}
|
||||||
* @param runnerBuilder instance of RunnerBuilder
|
* @param runnerBuilder instance of RunnerBuilder
|
||||||
* @param controllerBuilderFactory instance of BesuController.Builder
|
* @param controllerBuilder instance of BesuController.Builder
|
||||||
* @param besuPluginContext instance of BesuPluginContextImpl
|
* @param besuPluginContext instance of BesuPluginContextImpl
|
||||||
* @param environment Environment variables map
|
* @param environment Environment variables map
|
||||||
*/
|
*/
|
||||||
@@ -971,7 +894,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
|
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
|
||||||
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
|
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
|
||||||
final RunnerBuilder runnerBuilder,
|
final RunnerBuilder runnerBuilder,
|
||||||
final BesuController.Builder controllerBuilderFactory,
|
final BesuController.Builder controllerBuilder,
|
||||||
final BesuPluginContextImpl besuPluginContext,
|
final BesuPluginContextImpl besuPluginContext,
|
||||||
final Map<String, String> environment) {
|
final Map<String, String> environment) {
|
||||||
this(
|
this(
|
||||||
@@ -980,7 +903,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
jsonBlockImporterFactory,
|
jsonBlockImporterFactory,
|
||||||
rlpBlockExporterFactory,
|
rlpBlockExporterFactory,
|
||||||
runnerBuilder,
|
runnerBuilder,
|
||||||
controllerBuilderFactory,
|
controllerBuilder,
|
||||||
besuPluginContext,
|
besuPluginContext,
|
||||||
environment,
|
environment,
|
||||||
new StorageServiceImpl(),
|
new StorageServiceImpl(),
|
||||||
@@ -1002,7 +925,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
* @param jsonBlockImporterFactory instance of {@code Function<BesuController, JsonBlockImporter>}
|
* @param jsonBlockImporterFactory instance of {@code Function<BesuController, JsonBlockImporter>}
|
||||||
* @param rlpBlockExporterFactory instance of {@code Function<Blockchain, RlpBlockExporter>}
|
* @param rlpBlockExporterFactory instance of {@code Function<Blockchain, RlpBlockExporter>}
|
||||||
* @param runnerBuilder instance of RunnerBuilder
|
* @param runnerBuilder instance of RunnerBuilder
|
||||||
* @param controllerBuilderFactory instance of BesuController.Builder
|
* @param controllerBuilder instance of BesuController.Builder
|
||||||
* @param besuPluginContext instance of BesuPluginContextImpl
|
* @param besuPluginContext instance of BesuPluginContextImpl
|
||||||
* @param environment Environment variables map
|
* @param environment Environment variables map
|
||||||
* @param storageService instance of StorageServiceImpl
|
* @param storageService instance of StorageServiceImpl
|
||||||
@@ -1022,7 +945,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
|
final Function<BesuController, JsonBlockImporter> jsonBlockImporterFactory,
|
||||||
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
|
final Function<Blockchain, RlpBlockExporter> rlpBlockExporterFactory,
|
||||||
final RunnerBuilder runnerBuilder,
|
final RunnerBuilder runnerBuilder,
|
||||||
final BesuController.Builder controllerBuilderFactory,
|
final BesuController.Builder controllerBuilder,
|
||||||
final BesuPluginContextImpl besuPluginContext,
|
final BesuPluginContextImpl besuPluginContext,
|
||||||
final Map<String, String> environment,
|
final Map<String, String> environment,
|
||||||
final StorageServiceImpl storageService,
|
final StorageServiceImpl storageService,
|
||||||
@@ -1040,7 +963,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
this.rlpBlockExporterFactory = rlpBlockExporterFactory;
|
this.rlpBlockExporterFactory = rlpBlockExporterFactory;
|
||||||
this.jsonBlockImporterFactory = jsonBlockImporterFactory;
|
this.jsonBlockImporterFactory = jsonBlockImporterFactory;
|
||||||
this.runnerBuilder = runnerBuilder;
|
this.runnerBuilder = runnerBuilder;
|
||||||
this.controllerBuilderFactory = controllerBuilderFactory;
|
this.controllerBuilder = controllerBuilder;
|
||||||
this.besuPluginContext = besuPluginContext;
|
this.besuPluginContext = besuPluginContext;
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.storageService = storageService;
|
this.storageService = storageService;
|
||||||
@@ -1199,7 +1122,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
runner.startExternalServices();
|
runner.startExternalServices();
|
||||||
|
|
||||||
startPlugins(runner);
|
startPlugins(runner);
|
||||||
validatePluginOptions();
|
validatePrivacyPluginOptions();
|
||||||
setReleaseMetrics();
|
setReleaseMetrics();
|
||||||
preSynchronization();
|
preSynchronization();
|
||||||
|
|
||||||
@@ -1424,7 +1347,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
besuPluginContext.startPlugins();
|
besuPluginContext.startPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validatePluginOptions() {
|
private void validatePrivacyPluginOptions() {
|
||||||
// plugins do not 'wire up' until start has been called
|
// plugins do not 'wire up' until start has been called
|
||||||
// consequently you can only do some configuration checks
|
// consequently you can only do some configuration checks
|
||||||
// after start has been called on plugins
|
// after start has been called on plugins
|
||||||
@@ -1503,7 +1426,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
|
|
||||||
private void configureNativeLibs() {
|
private void configureNativeLibs() {
|
||||||
if (unstableNativeLibraryOptions.getNativeAltbn128()
|
if (unstableNativeLibraryOptions.getNativeAltbn128()
|
||||||
&& AbstractAltBnPrecompiledContract.isNative()) {
|
&& AbstractAltBnPrecompiledContract.maybeEnableNative()) {
|
||||||
logger.info("Using the native implementation of alt bn128");
|
logger.info("Using the native implementation of alt bn128");
|
||||||
} else {
|
} else {
|
||||||
AbstractAltBnPrecompiledContract.disableNative();
|
AbstractAltBnPrecompiledContract.disableNative();
|
||||||
@@ -1519,7 +1442,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (unstableNativeLibraryOptions.getNativeSecp()
|
if (unstableNativeLibraryOptions.getNativeSecp()
|
||||||
&& SignatureAlgorithmFactory.getInstance().isNative()) {
|
&& SignatureAlgorithmFactory.getInstance().maybeEnableNative()) {
|
||||||
logger.info("Using the native implementation of the signature algorithm");
|
logger.info("Using the native implementation of the signature algorithm");
|
||||||
} else {
|
} else {
|
||||||
SignatureAlgorithmFactory.getInstance().disableNative();
|
SignatureAlgorithmFactory.getInstance().disableNative();
|
||||||
@@ -1568,6 +1491,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
validateGraphQlOptions();
|
validateGraphQlOptions();
|
||||||
validateApiOptions();
|
validateApiOptions();
|
||||||
validateConsensusSyncCompatibilityOptions();
|
validateConsensusSyncCompatibilityOptions();
|
||||||
|
validatePluginOptions();
|
||||||
p2pTLSConfigOptions.checkP2PTLSOptionsDependencies(logger, commandLine);
|
p2pTLSConfigOptions.checkP2PTLSOptionsDependencies(logger, commandLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1588,6 +1512,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validatePluginOptions() {
|
||||||
|
pluginsConfigurationOptions.validate(commandLine);
|
||||||
|
}
|
||||||
|
|
||||||
private void validateApiOptions() {
|
private void validateApiOptions() {
|
||||||
apiConfigurationOptions.validate(commandLine, logger);
|
apiConfigurationOptions.validate(commandLine, logger);
|
||||||
}
|
}
|
||||||
@@ -1910,7 +1838,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
.withMiningParameters(miningParametersSupplier.get())
|
.withMiningParameters(miningParametersSupplier.get())
|
||||||
.withJsonRpcHttpOptions(jsonRpcHttpOptions);
|
.withJsonRpcHttpOptions(jsonRpcHttpOptions);
|
||||||
final KeyValueStorageProvider storageProvider = keyValueStorageProvider(keyValueStorageName);
|
final KeyValueStorageProvider storageProvider = keyValueStorageProvider(keyValueStorageName);
|
||||||
return controllerBuilderFactory
|
return controllerBuilder
|
||||||
.fromEthNetworkConfig(updateNetworkConfig(network), getDefaultSyncModeIfNotSet())
|
.fromEthNetworkConfig(updateNetworkConfig(network), getDefaultSyncModeIfNotSet())
|
||||||
.synchronizerConfiguration(buildSyncConfig())
|
.synchronizerConfiguration(buildSyncConfig())
|
||||||
.ethProtocolConfiguration(unstableEthProtocolOptions.toDomainObject())
|
.ethProtocolConfiguration(unstableEthProtocolOptions.toDomainObject())
|
||||||
@@ -1986,7 +1914,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
* @return instance of MetricsConfiguration.
|
* @return instance of MetricsConfiguration.
|
||||||
*/
|
*/
|
||||||
public MetricsConfiguration metricsConfiguration() {
|
public MetricsConfiguration metricsConfiguration() {
|
||||||
if (metricsOptionGroup.isMetricsEnabled && metricsOptionGroup.isMetricsPushEnabled) {
|
if (metricsOptionGroup.getMetricsEnabled() && metricsOptionGroup.getMetricsPushEnabled()) {
|
||||||
throw new ParameterException(
|
throw new ParameterException(
|
||||||
this.commandLine,
|
this.commandLine,
|
||||||
"--metrics-enabled option and --metrics-push-enabled option can't be used at the same "
|
"--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,
|
logger,
|
||||||
commandLine,
|
commandLine,
|
||||||
"--metrics-enabled",
|
"--metrics-enabled",
|
||||||
!metricsOptionGroup.isMetricsEnabled,
|
!metricsOptionGroup.getMetricsEnabled(),
|
||||||
asList("--metrics-host", "--metrics-port"));
|
asList("--metrics-host", "--metrics-port"));
|
||||||
|
|
||||||
CommandLineUtils.checkOptionDependencies(
|
CommandLineUtils.checkOptionDependencies(
|
||||||
logger,
|
logger,
|
||||||
commandLine,
|
commandLine,
|
||||||
"--metrics-push-enabled",
|
"--metrics-push-enabled",
|
||||||
!metricsOptionGroup.isMetricsPushEnabled,
|
!metricsOptionGroup.getMetricsPushEnabled(),
|
||||||
asList(
|
asList(
|
||||||
"--metrics-push-host",
|
"--metrics-push-host",
|
||||||
"--metrics-push-port",
|
"--metrics-push-port",
|
||||||
@@ -2013,23 +1941,23 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
|
|
||||||
return unstableMetricsCLIOptions
|
return unstableMetricsCLIOptions
|
||||||
.toDomainObject()
|
.toDomainObject()
|
||||||
.enabled(metricsOptionGroup.isMetricsEnabled)
|
.enabled(metricsOptionGroup.getMetricsEnabled())
|
||||||
.host(
|
.host(
|
||||||
Strings.isNullOrEmpty(metricsOptionGroup.metricsHost)
|
Strings.isNullOrEmpty(metricsOptionGroup.getMetricsHost())
|
||||||
? p2PDiscoveryOptionGroup.autoDiscoverDefaultIP().getHostAddress()
|
? p2PDiscoveryOptionGroup.autoDiscoverDefaultIP().getHostAddress()
|
||||||
: metricsOptionGroup.metricsHost)
|
: metricsOptionGroup.getMetricsHost())
|
||||||
.port(metricsOptionGroup.metricsPort)
|
.port(metricsOptionGroup.getMetricsPort())
|
||||||
.protocol(metricsOptionGroup.metricsProtocol)
|
.protocol(metricsOptionGroup.getMetricsProtocol())
|
||||||
.metricCategories(metricsOptionGroup.metricCategories)
|
.metricCategories(metricsOptionGroup.getMetricCategories())
|
||||||
.pushEnabled(metricsOptionGroup.isMetricsPushEnabled)
|
.pushEnabled(metricsOptionGroup.getMetricsPushEnabled())
|
||||||
.pushHost(
|
.pushHost(
|
||||||
Strings.isNullOrEmpty(metricsOptionGroup.metricsPushHost)
|
Strings.isNullOrEmpty(metricsOptionGroup.getMetricsPushHost())
|
||||||
? p2PDiscoveryOptionGroup.autoDiscoverDefaultIP().getHostAddress()
|
? p2PDiscoveryOptionGroup.autoDiscoverDefaultIP().getHostAddress()
|
||||||
: metricsOptionGroup.metricsPushHost)
|
: metricsOptionGroup.getMetricsPushHost())
|
||||||
.pushPort(metricsOptionGroup.metricsPushPort)
|
.pushPort(metricsOptionGroup.getMetricsPushPort())
|
||||||
.pushInterval(metricsOptionGroup.metricsPushInterval)
|
.pushInterval(metricsOptionGroup.getMetricsPushInterval())
|
||||||
.hostsAllowlist(hostsAllowlist)
|
.hostsAllowlist(hostsAllowlist)
|
||||||
.prometheusJob(metricsOptionGroup.metricsPrometheusJob)
|
.prometheusJob(metricsOptionGroup.getMetricsPrometheusJob())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2661,7 +2589,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
effectivePorts, rpcWebsocketOptions.getRpcWsPort(), rpcWebsocketOptions.isRpcWsEnabled());
|
effectivePorts, rpcWebsocketOptions.getRpcWsPort(), rpcWebsocketOptions.isRpcWsEnabled());
|
||||||
addPortIfEnabled(effectivePorts, engineRPCOptionGroup.engineRpcPort, isEngineApiEnabled());
|
addPortIfEnabled(effectivePorts, engineRPCOptionGroup.engineRpcPort, isEngineApiEnabled());
|
||||||
addPortIfEnabled(
|
addPortIfEnabled(
|
||||||
effectivePorts, metricsOptionGroup.metricsPort, metricsOptionGroup.isMetricsEnabled);
|
effectivePorts,
|
||||||
|
metricsOptionGroup.getMetricsPort(),
|
||||||
|
metricsOptionGroup.getMetricsEnabled());
|
||||||
addPortIfEnabled(
|
addPortIfEnabled(
|
||||||
effectivePorts,
|
effectivePorts,
|
||||||
miningParametersSupplier.get().getStratumPort(),
|
miningParametersSupplier.get().getStratumPort(),
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ public interface DefaultCommandValues {
|
|||||||
/** The constant DEFAULT_PLUGINS_OPTION_NAME. */
|
/** The constant DEFAULT_PLUGINS_OPTION_NAME. */
|
||||||
String DEFAULT_PLUGINS_OPTION_NAME = "--plugins";
|
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.
|
* Gets default besu data path.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class ApiConfigurationOptions {
|
|||||||
@CommandLine.Option(
|
@CommandLine.Option(
|
||||||
names = {"--rpc-max-trace-filter-range"},
|
names = {"--rpc-max-trace-filter-range"},
|
||||||
description =
|
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;
|
private final Long maxTraceFilterRange = 1000L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.cli.options.stable;
|
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 static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_OPTION_NAME;
|
||||||
|
|
||||||
import org.hyperledger.besu.cli.converter.PluginInfoConverter;
|
import org.hyperledger.besu.cli.converter.PluginInfoConverter;
|
||||||
@@ -28,6 +29,15 @@ import picocli.CommandLine;
|
|||||||
|
|
||||||
/** The Plugins Options options. */
|
/** The Plugins Options options. */
|
||||||
public class PluginsConfigurationOptions implements CLIOptions<PluginConfiguration> {
|
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(
|
@CommandLine.Option(
|
||||||
names = {DEFAULT_PLUGINS_OPTION_NAME},
|
names = {DEFAULT_PLUGINS_OPTION_NAME},
|
||||||
description = "Comma-separated list of plugin names",
|
description = "Comma-separated list of plugin names",
|
||||||
@@ -42,7 +52,24 @@ public class PluginsConfigurationOptions implements CLIOptions<PluginConfigurati
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginConfiguration toDomainObject() {
|
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
|
@Override
|
||||||
@@ -61,6 +88,13 @@ public class PluginsConfigurationOptions implements CLIOptions<PluginConfigurati
|
|||||||
CommandLineUtils.getOptionValueOrDefault(
|
CommandLineUtils.getOptionValueOrDefault(
|
||||||
commandLine, DEFAULT_PLUGINS_OPTION_NAME, new PluginInfoConverter());
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,20 +132,25 @@ public class BesuPluginContextImpl implements BesuContext, PluginVersionsProvide
|
|||||||
"Besu plugins have already been registered. Cannot register additional plugins.");
|
"Besu plugins have already been registered. Cannot register additional plugins.");
|
||||||
state = Lifecycle.REGISTERING;
|
state = Lifecycle.REGISTERING;
|
||||||
|
|
||||||
detectedPlugins = detectPlugins(config);
|
if (config.isExternalPluginsEnabled()) {
|
||||||
if (!config.getRequestedPlugins().isEmpty()) {
|
detectedPlugins = detectPlugins(config);
|
||||||
// Register only the plugins that were explicitly requested and validated
|
|
||||||
requestedPlugins = config.getRequestedPlugins();
|
|
||||||
|
|
||||||
// Match and validate the requested plugins against the detected plugins
|
if (config.getRequestedPlugins().isEmpty()) {
|
||||||
List<BesuPlugin> registeringPlugins =
|
// If no plugins were specified, register all detected plugins
|
||||||
matchAndValidateRequestedPlugins(requestedPlugins, detectedPlugins);
|
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);
|
registerPlugins(registeringPlugins);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// If no plugins were specified, register all detected plugins
|
LOG.debug("External plugins are disabled. Skipping plugins registration.");
|
||||||
registerPlugins(detectedPlugins);
|
|
||||||
}
|
}
|
||||||
|
state = Lifecycle.REGISTERED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<BesuPlugin> matchAndValidateRequestedPlugins(
|
private List<BesuPlugin> matchAndValidateRequestedPlugins(
|
||||||
@@ -182,7 +187,6 @@ public class BesuPluginContextImpl implements BesuContext, PluginVersionsProvide
|
|||||||
registeredPlugins.add(plugin);
|
registeredPlugins.add(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state = Lifecycle.REGISTERED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean registerPlugin(final BesuPlugin plugin) {
|
private boolean registerPlugin(final BesuPlugin plugin) {
|
||||||
|
|||||||
@@ -2503,4 +2503,16 @@ public class BesuCommandTest extends CommandTestAbstract {
|
|||||||
assertThat(commandOutput.toString(UTF_8)).isEmpty();
|
assertThat(commandOutput.toString(UTF_8)).isEmpty();
|
||||||
assertThat(commandErrorOutput.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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -242,3 +242,7 @@ Xp2p-tls-clienthello-sni=false
|
|||||||
|
|
||||||
#contracts
|
#contracts
|
||||||
Xevm-jumpdest-cache-weight-kb=32000
|
Xevm-jumpdest-cache-weight-kb=32000
|
||||||
|
|
||||||
|
# plugins
|
||||||
|
Xplugins-external-enabled=true
|
||||||
|
plugins=["none"]
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
package org.hyperledger.besu.consensus.merge;
|
package org.hyperledger.besu.consensus.merge;
|
||||||
|
|
||||||
import org.hyperledger.besu.config.GenesisConfigOptions;
|
import org.hyperledger.besu.config.GenesisConfigOptions;
|
||||||
|
import org.hyperledger.besu.datatypes.HardforkId;
|
||||||
import org.hyperledger.besu.ethereum.ProtocolContext;
|
import org.hyperledger.besu.ethereum.ProtocolContext;
|
||||||
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
|
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
|
||||||
import org.hyperledger.besu.ethereum.core.BlockHeader;
|
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.MiningParameters;
|
||||||
import org.hyperledger.besu.ethereum.core.PermissionTransactionFilter;
|
import org.hyperledger.besu.ethereum.core.PermissionTransactionFilter;
|
||||||
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
|
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.MainnetProtocolSchedule;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
||||||
|
|||||||
@@ -397,7 +397,9 @@ public abstract class AbstractSECP256 implements SignatureAlgorithm {
|
|||||||
final Bytes32 dataHash, final SECPSignature signature) {
|
final Bytes32 dataHash, final SECPSignature signature) {
|
||||||
final BigInteger publicKeyBI =
|
final BigInteger publicKeyBI =
|
||||||
recoverFromSignature(signature.getRecId(), signature.getR(), signature.getS(), dataHash);
|
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
|
@Override
|
||||||
|
|||||||
@@ -44,9 +44,10 @@ public class Blake2bfMessageDigest extends BCMessageDigest implements Cloneable
|
|||||||
/**
|
/**
|
||||||
* Implementation of the `F` compression function of the Blake2b cryptographic hash function.
|
* 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
|
* <p>Optimized for 64-bit platforms
|
||||||
*/
|
*/
|
||||||
@@ -93,12 +94,7 @@ public class Blake2bfMessageDigest extends BCMessageDigest implements Cloneable
|
|||||||
private static boolean useNative;
|
private static boolean useNative;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
maybeEnableNative();
|
||||||
useNative = LibBlake2bf.ENABLED;
|
|
||||||
} catch (UnsatisfiedLinkError ule) {
|
|
||||||
LOG.info("blake2bf native precompile not available: {}", ule.getMessage());
|
|
||||||
useNative = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Instantiates a new Blake2bf digest. */
|
/** Instantiates a new Blake2bf digest. */
|
||||||
@@ -130,6 +126,21 @@ public class Blake2bfMessageDigest extends BCMessageDigest implements Cloneable
|
|||||||
return cloned;
|
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. */
|
/** Disable native. */
|
||||||
public static void disableNative() {
|
public static void disableNative() {
|
||||||
useNative = false;
|
useNative = false;
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public class SECP256K1 extends AbstractSECP256 {
|
|||||||
*
|
*
|
||||||
* @return true if the native library was enabled.
|
* @return true if the native library was enabled.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean maybeEnableNative() {
|
public boolean maybeEnableNative() {
|
||||||
try {
|
try {
|
||||||
useNative = LibSecp256k1.CONTEXT != null;
|
useNative = LibSecp256k1.CONTEXT != null;
|
||||||
|
|||||||
@@ -61,6 +61,22 @@ public class SECP256R1 extends AbstractSECP256 {
|
|||||||
return useNative;
|
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)
|
* SECP256R1 is using the non-deterministic implementation of K calculation (standard)
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ public interface SignatureAlgorithm {
|
|||||||
/** Disable native. */
|
/** Disable native. */
|
||||||
void disableNative();
|
void disableNative();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to enable the native library.
|
||||||
|
*
|
||||||
|
* @return true if the native library was enabled
|
||||||
|
*/
|
||||||
|
boolean maybeEnableNative();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is native enabled.
|
* Is native enabled.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public class SECP256R1Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void recoverPublicKeyFromSignature() {
|
void recoverPublicKeyFromSignature() {
|
||||||
final SECPPrivateKey privateKey =
|
final SECPPrivateKey privateKey =
|
||||||
secp256R1.createPrivateKey(
|
secp256R1.createPrivateKey(
|
||||||
new BigInteger("c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4", 16));
|
new BigInteger("c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4", 16));
|
||||||
@@ -139,20 +139,20 @@ public class SECP256R1Test {
|
|||||||
|
|
||||||
final SECPPublicKey recoveredPublicKey =
|
final SECPPublicKey recoveredPublicKey =
|
||||||
secp256R1.recoverPublicKeyFromSignature(dataHash, signature).get();
|
secp256R1.recoverPublicKeyFromSignature(dataHash, signature).get();
|
||||||
assertThat(recoveredPublicKey.toString()).isEqualTo(keyPair.getPublicKey().toString());
|
assertThat(recoveredPublicKey).hasToString(keyPair.getPublicKey().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void signatureGenerationVerificationAndPubKeyRecovery() {
|
void signatureGenerationVerificationAndPubKeyRecovery() {
|
||||||
signTestVectors.forEach(
|
signTestVectors.forEach(
|
||||||
signTestVector -> {
|
signTestVector -> {
|
||||||
final SECPPrivateKey privateKey =
|
final SECPPrivateKey privateKey =
|
||||||
secp256R1.createPrivateKey(new BigInteger(signTestVector.getPrivateKey(), 16));
|
secp256R1.createPrivateKey(new BigInteger(signTestVector.privateKey(), 16));
|
||||||
final BigInteger publicKeyBigInt = new BigInteger(signTestVector.getPublicKey(), 16);
|
final BigInteger publicKeyBigInt = new BigInteger(signTestVector.publicKey(), 16);
|
||||||
final SECPPublicKey publicKey = secp256R1.createPublicKey(publicKeyBigInt);
|
final SECPPublicKey publicKey = secp256R1.createPublicKey(publicKeyBigInt);
|
||||||
final KeyPair keyPair = secp256R1.createKeyPair(privateKey);
|
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);
|
final SECPSignature signature = secp256R1.sign(dataHash, keyPair);
|
||||||
assertThat(secp256R1.verify(dataHash, signature, publicKey)).isTrue();
|
assertThat(secp256R1.verify(dataHash, signature, publicKey)).isTrue();
|
||||||
@@ -165,44 +165,22 @@ public class SECP256R1Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invalidFileThrowsInvalidKeyPairException() throws Exception {
|
void invalidFileThrowsInvalidKeyPairException() throws Exception {
|
||||||
final File tempFile = Files.createTempFile(suiteName(), ".keypair").toFile();
|
final File tempFile = Files.createTempFile(suiteName(), ".keypair").toFile();
|
||||||
tempFile.deleteOnExit();
|
tempFile.deleteOnExit();
|
||||||
Files.write(tempFile.toPath(), "not valid".getBytes(UTF_8));
|
Files.writeString(tempFile.toPath(), "not valid");
|
||||||
assertThatThrownBy(() -> KeyPairUtil.load(tempFile))
|
assertThatThrownBy(() -> KeyPairUtil.load(tempFile))
|
||||||
.isInstanceOf(IllegalArgumentException.class);
|
.isInstanceOf(IllegalArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invalidMultiLineFileThrowsInvalidIdException() throws Exception {
|
void invalidMultiLineFileThrowsInvalidIdException() throws Exception {
|
||||||
final File tempFile = Files.createTempFile(suiteName(), ".keypair").toFile();
|
final File tempFile = Files.createTempFile(suiteName(), ".keypair").toFile();
|
||||||
tempFile.deleteOnExit();
|
tempFile.deleteOnExit();
|
||||||
Files.write(tempFile.toPath(), "not\n\nvalid".getBytes(UTF_8));
|
Files.writeString(tempFile.toPath(), "not\n\nvalid");
|
||||||
assertThatThrownBy(() -> KeyPairUtil.load(tempFile))
|
assertThatThrownBy(() -> KeyPairUtil.load(tempFile))
|
||||||
.isInstanceOf(IllegalArgumentException.class);
|
.isInstanceOf(IllegalArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SignTestVector {
|
private record SignTestVector(String privateKey, String publicKey, String data) {}
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -437,7 +437,7 @@ public class EthGetBlockByNumberIntegrationTest {
|
|||||||
|
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessage("Missing required json rpc parameter at index 1");
|
.hasMessage("Invalid is transaction complete parameter (index 1)");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -177,9 +177,7 @@ public enum RpcMethod {
|
|||||||
PERM_GET_NODES_WHITELIST("perm_getNodesWhitelist"),
|
PERM_GET_NODES_WHITELIST("perm_getNodesWhitelist"),
|
||||||
PERM_GET_NODES_ALLOWLIST("perm_getNodesAllowlist"),
|
PERM_GET_NODES_ALLOWLIST("perm_getNodesAllowlist"),
|
||||||
PERM_RELOAD_PERMISSIONS_FROM_FILE("perm_reloadPermissionsFromFile"),
|
PERM_RELOAD_PERMISSIONS_FROM_FILE("perm_reloadPermissionsFromFile"),
|
||||||
PERM_REMOVE_ACCOUNTS_FROM_WHITELIST("perm_removeAccountsFromWhitelist"),
|
|
||||||
PERM_REMOVE_ACCOUNTS_FROM_ALLOWLIST("perm_removeAccountsFromAllowlist"),
|
PERM_REMOVE_ACCOUNTS_FROM_ALLOWLIST("perm_removeAccountsFromAllowlist"),
|
||||||
PERM_REMOVE_NODES_FROM_WHITELIST("perm_removeNodesFromWhitelist"),
|
|
||||||
PERM_REMOVE_NODES_FROM_ALLOWLIST("perm_removeNodesFromAllowlist"),
|
PERM_REMOVE_NODES_FROM_ALLOWLIST("perm_removeNodesFromAllowlist"),
|
||||||
RPC_MODULES("rpc_modules"),
|
RPC_MODULES("rpc_modules"),
|
||||||
TRACE_BLOCK("trace_block"),
|
TRACE_BLOCK("trace_block"),
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ public class TracedJsonRpcProcessor implements JsonRpcProcessor {
|
|||||||
case INVALID_DEPOSIT_REQUEST_PARAMS:
|
case INVALID_DEPOSIT_REQUEST_PARAMS:
|
||||||
case INVALID_ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_PARAMS:
|
case INVALID_ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_PARAMS:
|
||||||
case INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS:
|
case INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS:
|
||||||
case INVALID_ENGINE_PAYLOAD_ATTRIBUTES_PARAMS:
|
case INVALID_ENGINE_FORKCHOICE_UPDATED_PAYLOAD_ATTRIBUTES:
|
||||||
case INVALID_ENGINE_PAYLOAD_PARAMS:
|
case INVALID_ENGINE_NEW_PAYLOAD_PARAMS:
|
||||||
case INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS:
|
case INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS:
|
||||||
case INVALID_ENODE_PARAMS:
|
case INVALID_ENODE_PARAMS:
|
||||||
case INVALID_EXCESS_BLOB_GAS_PARAMS:
|
case INVALID_EXCESS_BLOB_GAS_PARAMS:
|
||||||
|
|||||||
@@ -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.exception.InvalidJsonRpcRequestException;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
|
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.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -51,7 +52,8 @@ public class JsonRpcRequest {
|
|||||||
this.method = method;
|
this.method = method;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
if (method == null) {
|
if (method == null) {
|
||||||
throw new InvalidJsonRpcRequestException("Field 'method' is required");
|
throw new InvalidJsonRpcRequestException(
|
||||||
|
"Field 'method' is required", RpcErrorType.INVALID_METHOD_PARAMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal;
|
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.exception.InvalidJsonRpcRequestException;
|
||||||
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -34,7 +35,7 @@ public class JsonRpcRequestId {
|
|||||||
@JsonCreator
|
@JsonCreator
|
||||||
public JsonRpcRequestId(final Object id) {
|
public JsonRpcRequestId(final Object id) {
|
||||||
if (isRequestTypeInvalid(id)) {
|
if (isRequestTypeInvalid(id)) {
|
||||||
throw new InvalidJsonRpcRequestException("Invalid id");
|
throw new InvalidJsonRpcRequestException("Invalid id", RpcErrorType.INVALID_ID_PARAMS);
|
||||||
}
|
}
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,13 +44,24 @@ public class AdminChangeLogLevel implements JsonRpcMethod {
|
|||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
try {
|
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)) {
|
if (!VALID_PARAMS.contains(logLevel)) {
|
||||||
return new JsonRpcErrorResponse(
|
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(
|
optionalLogFilters.ifPresentOrElse(
|
||||||
logFilters ->
|
logFilters ->
|
||||||
Arrays.stream(logFilters).forEach(logFilter -> setLogLevel(logFilter, logLevel)),
|
Arrays.stream(logFilters).forEach(logFilter -> setLogLevel(logFilter, logLevel)),
|
||||||
@@ -58,7 +69,7 @@ public class AdminChangeLogLevel implements JsonRpcMethod {
|
|||||||
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
|
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
|
||||||
} catch (InvalidJsonRpcParameters invalidJsonRpcParameters) {
|
} catch (InvalidJsonRpcParameters invalidJsonRpcParameters) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), invalidJsonRpcParameters.getRpcErrorType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
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.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.JsonRpcErrorResponse;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
|
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) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
if (requestContext.getRequest().getParamLength() != 1) {
|
if (requestContext.getRequest().getParamLength() != 1) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final String enodeString = requestContext.getRequiredParameter(0, String.class);
|
final String enodeString = requestContext.getRequiredParameter(0, String.class);
|
||||||
return performOperation(requestContext.getRequest().getId(), enodeString);
|
return performOperation(requestContext.getRequest().getId(), enodeString);
|
||||||
} catch (final InvalidJsonRpcParameters e) {
|
|
||||||
return new JsonRpcErrorResponse(
|
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
if (e.getMessage()
|
if (e.getMessage()
|
||||||
.endsWith(
|
.endsWith(
|
||||||
@@ -69,6 +65,9 @@ public abstract class AdminModifyPeer implements JsonRpcMethod {
|
|||||||
} catch (final P2PDisabledException e) {
|
} catch (final P2PDisabledException e) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
|
requestContext.getRequest().getId(), RpcErrorType.P2P_DISABLED);
|
||||||
|
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||||
|
return new JsonRpcErrorResponse(
|
||||||
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_ENODE_PARAMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,13 @@ public class DebugAccountRange implements JsonRpcMethod {
|
|||||||
throw new InvalidJsonRpcParameters(
|
throw new InvalidJsonRpcParameters(
|
||||||
"Invalid address hash parameter (index 2)", RpcErrorType.INVALID_ADDRESS_HASH_PARAMS, e);
|
"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);
|
final Optional<Hash> blockHashOptional = hashFromParameter(blockParameterOrBlockHash);
|
||||||
if (blockHashOptional.isEmpty()) {
|
if (blockHashOptional.isEmpty()) {
|
||||||
|
|||||||
@@ -85,8 +85,13 @@ public class DebugStorageRangeAt implements JsonRpcMethod {
|
|||||||
throw new InvalidJsonRpcParameters(
|
throw new InvalidJsonRpcParameters(
|
||||||
"Invalid account address parameter (index 2)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
|
"Invalid account address parameter (index 2)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
|
||||||
}
|
}
|
||||||
final Hash startKey =
|
final Hash startKey;
|
||||||
Hash.fromHexStringLenient(requestContext.getRequiredParameter(3, String.class));
|
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 int limit = requestContext.getRequiredParameter(4, Integer.class);
|
||||||
|
|
||||||
final Optional<Hash> blockHashOptional = hashFromParameter(blockParameterOrBlockHash);
|
final Optional<Hash> blockHashOptional = hashFromParameter(blockParameterOrBlockHash);
|
||||||
|
|||||||
@@ -93,6 +93,13 @@ public class EthGetBlockByHash implements JsonRpcMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCompleteTransactions(final JsonRpcRequestContext requestContext) {
|
private boolean isCompleteTransactions(final JsonRpcRequestContext requestContext) {
|
||||||
return requestContext.getRequiredParameter(1, Boolean.class);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,13 @@ public class EthGetBlockByNumber extends AbstractBlockParameterMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCompleteTransactions(final JsonRpcRequestContext request) {
|
private boolean isCompleteTransactions(final JsonRpcRequestContext request) {
|
||||||
return request.getRequiredParameter(1, Boolean.class);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
|||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
|
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.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.filter.FilterManager;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
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.JsonRpcResponse;
|
||||||
@@ -43,7 +44,13 @@ public class EthGetFilterChanges implements JsonRpcMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
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);
|
final List<Hash> blockHashes = filterManager.blockChanges(filterId);
|
||||||
if (blockHashes != null) {
|
if (blockHashes != null) {
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.filter.FilterManager;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
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.JsonRpcResponse;
|
||||||
@@ -41,7 +42,13 @@ public class EthGetFilterLogs implements JsonRpcMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
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);
|
final List<LogWithMetadata> logs = filterManager.logs(filterId);
|
||||||
if (logs != null) {
|
if (logs != null) {
|
||||||
|
|||||||
@@ -52,12 +52,18 @@ public class EthGetLogs implements JsonRpcMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
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();
|
LOG.atTrace().setMessage("eth_getLogs FilterParameter: {}").addArgument(filter).log();
|
||||||
|
|
||||||
if (!filter.isValid()) {
|
if (!filter.isValid()) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_FILTER_PARAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
final AtomicReference<Exception> ex = new AtomicReference<>();
|
final AtomicReference<Exception> ex = new AtomicReference<>();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class EthGetTransactionByHash implements JsonRpcMethod {
|
|||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
if (requestContext.getRequest().getParamLength() != 1) {
|
if (requestContext.getRequest().getParamLength() != 1) {
|
||||||
return new JsonRpcErrorResponse(
|
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 Hash hash = requestContext.getRequiredParameter(0, Hash.class);
|
||||||
final JsonRpcSuccessResponse jsonRpcSuccessResponse =
|
final JsonRpcSuccessResponse jsonRpcSuccessResponse =
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.filter.FilterManager;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||||
@@ -38,11 +39,17 @@ public class EthNewFilter implements JsonRpcMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
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()) {
|
if (!filter.isValid()) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_FILTER_PARAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String logFilterId =
|
final String logFilterId =
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class EthSendRawTransaction implements JsonRpcMethod {
|
|||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
if (requestContext.getRequest().getParamLength() != 1) {
|
if (requestContext.getRequest().getParamLength() != 1) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||||
}
|
}
|
||||||
final String rawTransaction = requestContext.getRequiredParameter(0, String.class);
|
final String rawTransaction = requestContext.getRequiredParameter(0, String.class);
|
||||||
|
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.JsonRpcResponse;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
|
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.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
|
||||||
|
|
||||||
import org.apache.tuweni.bytes.Bytes;
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
@@ -37,7 +39,13 @@ public class EthSubmitHashRate implements JsonRpcMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
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);
|
final String id = requestContext.getRequiredParameter(1, String.class);
|
||||||
return new JsonRpcSuccessResponse(
|
return new JsonRpcSuccessResponse(
|
||||||
requestContext.getRequest().getId(),
|
requestContext.getRequest().getId(),
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
|
|||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
|
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.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.JsonRpcErrorResponse;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
|
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.JsonRpcSuccessResponse;
|
||||||
@@ -49,12 +50,23 @@ public class EthSubmitWork implements JsonRpcMethod {
|
|||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
final Optional<PoWSolverInputs> solver = miner.getWorkDefinition();
|
final Optional<PoWSolverInputs> solver = miner.getWorkDefinition();
|
||||||
if (solver.isPresent()) {
|
if (solver.isPresent()) {
|
||||||
final PoWSolution solution =
|
long nonce;
|
||||||
new PoWSolution(
|
try {
|
||||||
Bytes.fromHexString(requestContext.getRequiredParameter(0, String.class)).getLong(0),
|
nonce =
|
||||||
requestContext.getRequiredParameter(2, Hash.class),
|
Bytes.fromHexString(requestContext.getRequiredParameter(0, String.class)).getLong(0);
|
||||||
null,
|
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||||
Bytes.fromHexString(requestContext.getRequiredParameter(1, String.class)));
|
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);
|
final boolean result = miner.submitWork(solution);
|
||||||
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result);
|
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.filter.FilterManager;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
|
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.JsonRpcSuccessResponse;
|
||||||
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
|
||||||
|
|
||||||
public class EthUninstallFilter implements JsonRpcMethod {
|
public class EthUninstallFilter implements JsonRpcMethod {
|
||||||
|
|
||||||
@@ -35,7 +37,13 @@ public class EthUninstallFilter implements JsonRpcMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
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(
|
return new JsonRpcSuccessResponse(
|
||||||
requestContext.getRequest().getId(), filterManager.uninstallFilter(filterId));
|
requestContext.getRequest().getId(), filterManager.uninstallFilter(filterId));
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ public class JsonCallParameterUtil {
|
|||||||
&& (callParams.getMaxFeePerGas().isPresent()
|
&& (callParams.getMaxFeePerGas().isPresent()
|
||||||
|| callParams.getMaxPriorityFeePerGas().isPresent())) {
|
|| callParams.getMaxPriorityFeePerGas().isPresent())) {
|
||||||
throw new InvalidJsonRpcParameters(
|
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;
|
return callParams;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.JsonRpcErrorResponse;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
|
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.JsonRpcSuccessResponse;
|
||||||
@@ -56,9 +55,9 @@ public class PluginsReloadConfiguration implements JsonRpcMethod {
|
|||||||
}
|
}
|
||||||
reloadPluginConfig(namedPlugins.get(pluginName));
|
reloadPluginConfig(namedPlugins.get(pluginName));
|
||||||
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
|
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
|
||||||
} catch (InvalidJsonRpcParameters invalidJsonRpcParameters) {
|
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVAlID_PLUGIN_NAME_PARAMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class TraceCallMany extends TraceCall implements JsonRpcMethod {
|
|||||||
|
|
||||||
if (requestContext.getRequest().getParamLength() != 2) {
|
if (requestContext.getRequest().getParamLength() != 2) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
final TraceCallManyParameter[] transactionsAndTraceTypeParameters;
|
final TraceCallManyParameter[] transactionsAndTraceTypeParameters;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import static org.hyperledger.besu.services.pipeline.PipelineBuilder.createPipel
|
|||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
|
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.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.BlockParameter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
|
||||||
@@ -86,8 +87,13 @@ public class TraceFilter extends TraceBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
final FilterParameter filterParameter =
|
final FilterParameter filterParameter;
|
||||||
requestContext.getRequiredParameter(0, FilterParameter.class);
|
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 fromBlock = resolveBlockNumber(filterParameter.getFromBlock());
|
||||||
final long toBlock = resolveBlockNumber(filterParameter.getToBlock());
|
final long toBlock = resolveBlockNumber(filterParameter.getToBlock());
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class TraceGet extends AbstractTraceByHash implements JsonRpcMethod {
|
|||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
if (requestContext.getRequest().getParamLength() != 2) {
|
if (requestContext.getRequest().getParamLength() != 2) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Hash transactionHash = requestContext.getRequiredParameter(0, Hash.class);
|
final Hash transactionHash = requestContext.getRequiredParameter(0, Hash.class);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class TraceRawTransaction extends AbstractTraceByBlock implements JsonRpc
|
|||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
if (requestContext.getRequest().getParamLength() != 2) {
|
if (requestContext.getRequest().getParamLength() != 2) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
final var rawTransaction = requestContext.getRequiredParameter(0, String.class);
|
final var rawTransaction = requestContext.getRequiredParameter(0, String.class);
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.parameters.PendingTransactionsParams;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
|
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.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.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;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transaction.pool.PendingTransactionFilter.Filter;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transaction.pool.PendingTransactionFilter.Filter;
|
||||||
@@ -54,11 +56,19 @@ public class TxPoolBesuPendingTransactions implements JsonRpcMethod {
|
|||||||
transactionPool.getPendingTransactions();
|
transactionPool.getPendingTransactions();
|
||||||
final Integer limit =
|
final Integer limit =
|
||||||
requestContext.getOptionalParameter(0, Integer.class).orElse(pendingTransactions.size());
|
requestContext.getOptionalParameter(0, Integer.class).orElse(pendingTransactions.size());
|
||||||
final List<Filter> filters =
|
final List<Filter> filters;
|
||||||
requestContext
|
try {
|
||||||
.getOptionalParameter(1, PendingTransactionsParams.class)
|
filters =
|
||||||
.map(PendingTransactionsParams::filters)
|
requestContext
|
||||||
.orElse(Collections.emptyList());
|
.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 =
|
final Collection<Transaction> pendingTransactionsFiltered =
|
||||||
pendingTransactionFilter.reduce(pendingTransactions, filters, limit);
|
pendingTransactionFilter.reduce(pendingTransactions, filters, limit);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class Web3Sha3 implements JsonRpcMethod {
|
|||||||
if (requestContext.getRequest().getParamLength() != 1) {
|
if (requestContext.getRequest().getParamLength() != 1) {
|
||||||
// Do we want custom messages for each different type of invalid params?
|
// Do we want custom messages for each different type of invalid params?
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String data;
|
final String data;
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
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.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.SYNCING;
|
||||||
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
|
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.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;
|
||||||
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator.ForkchoiceResult;
|
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.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.ProtocolContext;
|
import org.hyperledger.besu.ethereum.ProtocolContext;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.methods.ExecutionEngineJsonRpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineForkchoiceUpdatedParameter;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EngineForkchoiceUpdatedParameter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadAttributesParameter;
|
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 Object requestId = requestContext.getRequest().getId();
|
||||||
|
|
||||||
final EngineForkchoiceUpdatedParameter forkChoice =
|
final EngineForkchoiceUpdatedParameter forkChoice;
|
||||||
requestContext.getRequiredParameter(0, EngineForkchoiceUpdatedParameter.class);
|
try {
|
||||||
final Optional<EnginePayloadAttributesParameter> maybePayloadAttributes =
|
forkChoice = requestContext.getRequiredParameter(0, EngineForkchoiceUpdatedParameter.class);
|
||||||
requestContext.getOptionalParameter(1, EnginePayloadAttributesParameter.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);
|
LOG.debug("Forkchoice parameters {}", forkChoice);
|
||||||
mergeContext
|
mergeContext
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator
|
|||||||
import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier;
|
import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier;
|
||||||
import org.hyperledger.besu.ethereum.ProtocolContext;
|
import org.hyperledger.besu.ethereum.ProtocolContext;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.methods.ExecutionEngineJsonRpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
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.JsonRpcResponse;
|
||||||
@@ -68,7 +69,13 @@ public abstract class AbstractEngineGetPayload extends ExecutionEngineJsonRpcMet
|
|||||||
public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) {
|
public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) {
|
||||||
engineCallListener.executionEngineCalled();
|
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);
|
mergeMiningCoordinator.finalizeProposalById(payloadId);
|
||||||
final Optional<PayloadWrapper> maybePayload = mergeContext.get().retrievePayloadById(payloadId);
|
final Optional<PayloadWrapper> maybePayload = mergeContext.get().retrievePayloadById(payloadId);
|
||||||
if (maybePayload.isPresent()) {
|
if (maybePayload.isPresent()) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.hyperledger.besu.datatypes.Wei;
|
|||||||
import org.hyperledger.besu.ethereum.BlockProcessingResult;
|
import org.hyperledger.besu.ethereum.BlockProcessingResult;
|
||||||
import org.hyperledger.besu.ethereum.ProtocolContext;
|
import org.hyperledger.besu.ethereum.ProtocolContext;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.methods.ExecutionEngineJsonRpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter;
|
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) {
|
public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) {
|
||||||
engineCallListener.executionEngineCalled();
|
engineCallListener.executionEngineCalled();
|
||||||
|
|
||||||
final EnginePayloadParameter blockParam =
|
final EnginePayloadParameter blockParam;
|
||||||
requestContext.getRequiredParameter(0, EnginePayloadParameter.class);
|
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 =
|
final Optional<List<String>> maybeVersionedHashParam =
|
||||||
requestContext.getOptionalList(1, String.class);
|
requestContext.getOptionalList(1, String.class);
|
||||||
|
|
||||||
final Object reqId = requestContext.getRequest().getId();
|
final Object reqId = requestContext.getRequest().getId();
|
||||||
|
|
||||||
Optional<String> maybeParentBeaconBlockRootParam =
|
Optional<String> maybeParentBeaconBlockRootParam;
|
||||||
requestContext.getOptionalParameter(2, String.class);
|
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 =
|
final Optional<Bytes32> maybeParentBeaconBlockRoot =
|
||||||
maybeParentBeaconBlockRootParam.map(Bytes32::fromHexString);
|
maybeParentBeaconBlockRootParam.map(Bytes32::fromHexString);
|
||||||
|
|
||||||
@@ -486,7 +501,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
|
|||||||
if (maybeParentHeader.isPresent()) {
|
if (maybeParentHeader.isPresent()) {
|
||||||
if (!validateExcessBlobGas(header, maybeParentHeader.get(), protocolSpec)) {
|
if (!validateExcessBlobGas(header, maybeParentHeader.get(), protocolSpec)) {
|
||||||
return ValidationResult.invalid(
|
return ValidationResult.invalid(
|
||||||
RpcErrorType.INVALID_PARAMS,
|
RpcErrorType.INVALID_EXCESS_BLOB_GAS_PARAMS,
|
||||||
"Payload excessBlobGas does not match calculated excessBlobGas");
|
"Payload excessBlobGas does not match calculated excessBlobGas");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
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.consensus.merge.blockcreation.MergeMiningCoordinator;
|
||||||
import org.hyperledger.besu.ethereum.ProtocolContext;
|
import org.hyperledger.besu.ethereum.ProtocolContext;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
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.PayloadWrapper;
|
||||||
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
|
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
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.PayloadWrapper;
|
||||||
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
|
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
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.PayloadWrapper;
|
||||||
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
|
import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
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.consensus.merge.blockcreation.MergeMiningCoordinator;
|
||||||
import org.hyperledger.besu.datatypes.VersionedHash;
|
import org.hyperledger.besu.datatypes.VersionedHash;
|
||||||
@@ -64,7 +64,7 @@ public class EngineNewPayloadV2 extends AbstractEngineNewPayload {
|
|||||||
}
|
}
|
||||||
if (payloadParameter.getExcessBlobGas() != null) {
|
if (payloadParameter.getExcessBlobGas() != null) {
|
||||||
return ValidationResult.invalid(
|
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();
|
return ValidationResult.valid();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
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.consensus.merge.blockcreation.MergeMiningCoordinator;
|
||||||
import org.hyperledger.besu.ethereum.ProtocolContext;
|
import org.hyperledger.besu.ethereum.ProtocolContext;
|
||||||
@@ -60,13 +60,15 @@ public class EngineNewPayloadV3 extends AbstractEngineNewPayload {
|
|||||||
return ValidationResult.invalid(
|
return ValidationResult.invalid(
|
||||||
RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field");
|
RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field");
|
||||||
} else if (payloadParameter.getExcessBlobGas() == null) {
|
} 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()) {
|
} else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) {
|
||||||
return ValidationResult.invalid(
|
return ValidationResult.invalid(
|
||||||
RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field");
|
RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field");
|
||||||
} else if (maybeBeaconBlockRootParam.isEmpty()) {
|
} else if (maybeBeaconBlockRootParam.isEmpty()) {
|
||||||
return ValidationResult.invalid(
|
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 {
|
} else {
|
||||||
return ValidationResult.valid();
|
return ValidationResult.valid();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
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.consensus.merge.blockcreation.MergeMiningCoordinator;
|
||||||
import org.hyperledger.besu.ethereum.ProtocolContext;
|
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");
|
RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field");
|
||||||
} else if (payloadParameter.getExcessBlobGas() == null) {
|
} else if (payloadParameter.getExcessBlobGas() == null) {
|
||||||
return ValidationResult.invalid(
|
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()) {
|
} else if (maybeVersionedHashParam == null || maybeVersionedHashParam.isEmpty()) {
|
||||||
return ValidationResult.invalid(
|
return ValidationResult.invalid(
|
||||||
RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field");
|
RpcErrorType.INVALID_PARAMS, "Missing versioned hashes field");
|
||||||
} else if (maybeBeaconBlockRootParam.isEmpty()) {
|
} else if (maybeBeaconBlockRootParam.isEmpty()) {
|
||||||
return ValidationResult.invalid(
|
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) {
|
} else if (payloadParameter.getDepositRequests() == null) {
|
||||||
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing deposit field");
|
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing deposit field");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier;
|
|||||||
import org.hyperledger.besu.ethereum.ProtocolContext;
|
import org.hyperledger.besu.ethereum.ProtocolContext;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
|
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.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.methods.ExecutionEngineJsonRpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePreparePayloadParameter;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePreparePayloadParameter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
|
||||||
@@ -58,17 +59,25 @@ public class EnginePreparePayloadDebug extends ExecutionEngineJsonRpcMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) {
|
||||||
final EnginePreparePayloadParameter enginePreparePayloadParameter =
|
final EnginePreparePayloadParameter enginePreparePayloadParameter;
|
||||||
requestContext
|
try {
|
||||||
.getOptionalParameter(0, EnginePreparePayloadParameter.class)
|
enginePreparePayloadParameter =
|
||||||
.orElse(
|
requestContext
|
||||||
new EnginePreparePayloadParameter(
|
.getOptionalParameter(0, EnginePreparePayloadParameter.class)
|
||||||
Optional.empty(),
|
.orElse(
|
||||||
Optional.empty(),
|
new EnginePreparePayloadParameter(
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
Optional.empty()));
|
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();
|
final var requestId = requestContext.getRequest().getId();
|
||||||
|
|
||||||
@@ -81,7 +90,10 @@ public class EnginePreparePayloadDebug extends ExecutionEngineJsonRpcMethod {
|
|||||||
payloadIdentifier ->
|
payloadIdentifier ->
|
||||||
new JsonRpcSuccessResponse(
|
new JsonRpcSuccessResponse(
|
||||||
requestId, new EnginePreparePayloadResult(VALID, payloadIdentifier)))
|
requestId, new EnginePreparePayloadResult(VALID, payloadIdentifier)))
|
||||||
.orElseGet(() -> new JsonRpcErrorResponse(requestId, RpcErrorType.INVALID_PARAMS));
|
.orElseGet(
|
||||||
|
() ->
|
||||||
|
new JsonRpcErrorResponse(
|
||||||
|
requestId, RpcErrorType.INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
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.api.jsonrpc.internal.response.RpcErrorType;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.HardforkId;
|
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
|
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|||||||
@@ -60,10 +60,12 @@ public class MinerSetExtraData implements JsonRpcMethod {
|
|||||||
.addArgument(() -> new String(extraData.toArray(), StandardCharsets.UTF_8))
|
.addArgument(() -> new String(extraData.toArray(), StandardCharsets.UTF_8))
|
||||||
.log();
|
.log();
|
||||||
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
|
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
|
||||||
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
|
} catch (Exception invalidJsonRpcParameters) { // TODO:replace with "IllegalArgumentException |
|
||||||
|
// JsonRpcParameter.JsonRpcParameterException"
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(),
|
requestContext.getRequest().getId(),
|
||||||
new JsonRpcError(RpcErrorType.INVALID_PARAMS, invalidJsonRpcParameters.getMessage()));
|
new JsonRpcError(
|
||||||
|
RpcErrorType.INVALID_EXTRA_DATA_PARAMS, invalidJsonRpcParameters.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner;
|
|||||||
import org.hyperledger.besu.datatypes.Wei;
|
import org.hyperledger.besu.datatypes.Wei;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
|
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.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.methods.JsonRpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||||
@@ -53,7 +54,13 @@ public class MinerSetMinGasPrice implements JsonRpcMethod {
|
|||||||
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
|
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(),
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ public class MinerSetMinPriorityFee implements JsonRpcMethod {
|
|||||||
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
|
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(),
|
requestContext.getRequest().getId(),
|
||||||
new JsonRpcError(RpcErrorType.INVALID_PARAMS, invalidJsonRpcParameters.getMessage()));
|
new JsonRpcError(
|
||||||
|
RpcErrorType.INVALID_MIN_PRIORITY_FEE_PARAMS, invalidJsonRpcParameters.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.methods.JsonRpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||||
@@ -46,8 +47,13 @@ public class PermAddNodesToAllowlist implements JsonRpcMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
final StringListParameter enodeListParam =
|
final StringListParameter enodeListParam;
|
||||||
requestContext.getRequiredParameter(0, StringListParameter.class);
|
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 {
|
try {
|
||||||
if (nodeAllowlistPermissioningController.isPresent()) {
|
if (nodeAllowlistPermissioningController.isPresent()) {
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.methods.JsonRpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||||
@@ -46,8 +47,13 @@ public class PermRemoveNodesFromAllowlist implements JsonRpcMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
final StringListParameter enodeListParam =
|
final StringListParameter enodeListParam;
|
||||||
requestContext.getRequiredParameter(0, StringListParameter.class);
|
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 {
|
try {
|
||||||
if (nodeAllowlistPermissioningController.isPresent()) {
|
if (nodeAllowlistPermissioningController.isPresent()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -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 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.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.PendingTransactionFilter.Filter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transaction.pool.Predicate;
|
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) {
|
private Optional<Filter> getFilter(final String key, final Map<String, String> map) {
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
if (map.size() > 1) {
|
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()) {
|
} else if (!map.isEmpty()) {
|
||||||
final Map.Entry<String, String> foundEntry = map.entrySet().stream().findFirst().get();
|
final Map.Entry<String, String> foundEntry = map.entrySet().stream().findFirst().get();
|
||||||
final Predicate predicate =
|
final Predicate predicate =
|
||||||
@@ -87,17 +89,22 @@ public class PendingTransactionsParams {
|
|||||||
.orElseThrow(
|
.orElseThrow(
|
||||||
() ->
|
() ->
|
||||||
new InvalidJsonRpcParameters(
|
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);
|
final Filter filter = new Filter(key, foundEntry.getValue(), predicate);
|
||||||
if (key.equals(FROM_FIELD) && !predicate.equals(EQ)) {
|
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)) {
|
} else if (key.equals(TO_FIELD) && !predicate.equals(EQ) && !predicate.equals(ACTION)) {
|
||||||
throw new InvalidJsonRpcParameters(
|
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)) {
|
} else if (!key.equals(TO_FIELD) && predicate.equals(ACTION)) {
|
||||||
throw new InvalidJsonRpcParameters(
|
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);
|
return Optional.of(filter);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.filter.FilterManager;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||||
@@ -52,7 +53,13 @@ public class PrivGetFilterChanges implements JsonRpcMethod {
|
|||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
final String privacyGroupId = requestContext.getRequiredParameter(0, String.class);
|
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) {
|
if (privacyController instanceof MultiTenancyPrivacyController) {
|
||||||
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(requestContext, privacyGroupId);
|
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(requestContext, privacyGroupId);
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.filter.FilterManager;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
|
||||||
@@ -52,7 +53,13 @@ public class PrivGetFilterLogs implements JsonRpcMethod {
|
|||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext request) {
|
public JsonRpcResponse response(final JsonRpcRequestContext request) {
|
||||||
final String privacyGroupId = request.getRequiredParameter(0, String.class);
|
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) {
|
if (privacyController instanceof MultiTenancyPrivacyController) {
|
||||||
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(request, privacyGroupId);
|
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(request, privacyGroupId);
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.filter.FilterManager;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
|
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.JsonRpcResponse;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
|
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.MultiTenancyPrivacyController;
|
||||||
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
|
import org.hyperledger.besu.ethereum.privacy.PrivacyController;
|
||||||
|
|
||||||
@@ -46,7 +48,13 @@ public class PrivUninstallFilter implements JsonRpcMethod {
|
|||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext request) {
|
public JsonRpcResponse response(final JsonRpcRequestContext request) {
|
||||||
final String privacyGroupId = request.getRequiredParameter(0, String.class);
|
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) {
|
if (privacyController instanceof MultiTenancyPrivacyController) {
|
||||||
checkIfPrivacyGroupMatchesAuthenticatedEnclaveKey(request, privacyGroupId);
|
checkIfPrivacyGroupMatchesAuthenticatedEnclaveKey(request, privacyGroupId);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class PrivGetEeaTransactionCount implements JsonRpcMethod {
|
|||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
if (requestContext.getRequest().getParamLength() != 3) {
|
if (requestContext.getRequest().getParamLength() != 3) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Address address;
|
final Address address;
|
||||||
|
|||||||
@@ -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.datatypes.Hash;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
|
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.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.methods.JsonRpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider;
|
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider;
|
||||||
@@ -62,11 +63,17 @@ public class PrivGetLogs implements JsonRpcMethod {
|
|||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
final String privacyGroupId = requestContext.getRequiredParameter(0, String.class);
|
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()) {
|
if (!filter.isValid()) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_FILTER_PARAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<LogWithMetadata> matchingLogs =
|
final List<LogWithMetadata> matchingLogs =
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class PrivGetTransactionCount implements JsonRpcMethod {
|
|||||||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
|
||||||
if (requestContext.getRequest().getParamLength() != 2) {
|
if (requestContext.getRequest().getParamLength() != 2) {
|
||||||
return new JsonRpcErrorResponse(
|
return new JsonRpcErrorResponse(
|
||||||
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
|
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Address address;
|
final Address address;
|
||||||
|
|||||||
@@ -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.RpcMethod;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
|
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.filter.FilterManager;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
|
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.parameters.FilterParameter;
|
||||||
@@ -50,7 +51,13 @@ public class PrivNewFilter implements JsonRpcMethod {
|
|||||||
@Override
|
@Override
|
||||||
public JsonRpcResponse response(final JsonRpcRequestContext request) {
|
public JsonRpcResponse response(final JsonRpcRequestContext request) {
|
||||||
final String privacyGroupId = request.getRequiredParameter(0, String.class);
|
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());
|
final String privacyUserId = privacyIdProvider.getPrivacyUserId(request.getUser());
|
||||||
|
|
||||||
if (privacyController instanceof MultiTenancyPrivacyController) {
|
if (privacyController instanceof MultiTenancyPrivacyController) {
|
||||||
@@ -60,7 +67,8 @@ public class PrivNewFilter implements JsonRpcMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!filter.isValid()) {
|
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 =
|
final String logFilterId =
|
||||||
|
|||||||
@@ -47,14 +47,15 @@ public enum RpcErrorType implements RpcMethodError {
|
|||||||
INVALID_CREATE_PRIVACY_GROUP_PARAMS(
|
INVALID_CREATE_PRIVACY_GROUP_PARAMS(
|
||||||
INVALID_PARAMS_ERROR_CODE, "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_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_DEPOSIT_REQUEST_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid deposit request"),
|
||||||
INVALID_ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_PARAMS(
|
INVALID_ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_PARAMS(
|
||||||
INVALID_PARAMS_ERROR_CODE, "Invalid engine exchange transition configuration params"),
|
INVALID_PARAMS_ERROR_CODE, "Invalid engine exchange transition configuration params"),
|
||||||
INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS(
|
INVALID_ENGINE_FORKCHOICE_UPDATED_PARAMS(
|
||||||
INVALID_PARAMS_ERROR_CODE, "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_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_ENGINE_PREPARE_PAYLOAD_PARAMS(
|
||||||
INVALID_PARAMS_ERROR_CODE, "Invalid engine prepare payload parameter"),
|
INVALID_PARAMS_ERROR_CODE, "Invalid engine prepare payload parameter"),
|
||||||
INVALID_ENODE_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid enode params"),
|
INVALID_ENODE_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid enode params"),
|
||||||
|
|||||||
@@ -24,10 +24,13 @@ public class NetworkResult {
|
|||||||
|
|
||||||
private final String localAddress;
|
private final String localAddress;
|
||||||
private final String remoteAddress;
|
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.localAddress = removeTrailingSlash(localAddress.toString());
|
||||||
this.remoteAddress = removeTrailingSlash(remoteAddress.toString());
|
this.remoteAddress = removeTrailingSlash(remoteAddress.toString());
|
||||||
|
this.inbound = inbound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonGetter(value = "localAddress")
|
@JsonGetter(value = "localAddress")
|
||||||
@@ -40,6 +43,11 @@ public class NetworkResult {
|
|||||||
return remoteAddress;
|
return remoteAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonGetter(value = "inbound")
|
||||||
|
public boolean isInbound() {
|
||||||
|
return inbound;
|
||||||
|
}
|
||||||
|
|
||||||
private String removeTrailingSlash(final String address) {
|
private String removeTrailingSlash(final String address) {
|
||||||
if (address != null && address.startsWith("/")) {
|
if (address != null && address.startsWith("/")) {
|
||||||
return address.substring(1);
|
return address.substring(1);
|
||||||
|
|||||||
@@ -45,7 +45,11 @@ public interface PeerResult {
|
|||||||
.map(Capability::toString)
|
.map(Capability::toString)
|
||||||
.map(TextNode::new)
|
.map(TextNode::new)
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.network(new NetworkResult(connection.getLocalAddress(), connection.getRemoteAddress()))
|
.network(
|
||||||
|
new NetworkResult(
|
||||||
|
connection.getLocalAddress(),
|
||||||
|
connection.getRemoteAddress(),
|
||||||
|
connection.inboundInitiated()))
|
||||||
.port(Quantity.create(peerInfo.getPort()))
|
.port(Quantity.create(peerInfo.getPort()))
|
||||||
.id(peerInfo.getNodeId().toString())
|
.id(peerInfo.getNodeId().toString())
|
||||||
.protocols(Map.of(peer.getProtocolName(), ProtocolsResult.fromEthPeer(peer)))
|
.protocols(Map.of(peer.getProtocolName(), ProtocolsResult.fromEthPeer(peer)))
|
||||||
|
|||||||
@@ -15,8 +15,10 @@
|
|||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request;
|
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.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.FilterParameter;
|
||||||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter;
|
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 org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.WebSocketRpcRequest;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -70,7 +72,13 @@ public class SubscriptionRequestMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SubscribeRequest parseLogsRequest(final WebSocketRpcRequest request) {
|
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(
|
return new SubscribeRequest(
|
||||||
SubscriptionType.LOGS, filterParameter, null, request.getConnectionId());
|
SubscriptionType.LOGS, filterParameter, null, request.getConnectionId());
|
||||||
}
|
}
|
||||||
@@ -101,8 +109,14 @@ public class SubscriptionRequestMapper {
|
|||||||
switch (subscriptionType) {
|
switch (subscriptionType) {
|
||||||
case LOGS:
|
case LOGS:
|
||||||
{
|
{
|
||||||
final FilterParameter filterParameter =
|
final FilterParameter filterParameter;
|
||||||
jsonRpcRequestContext.getRequiredParameter(2, FilterParameter.class);
|
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(
|
return new PrivateSubscribeRequest(
|
||||||
SubscriptionType.LOGS,
|
SubscriptionType.LOGS,
|
||||||
filterParameter,
|
filterParameter,
|
||||||
|
|||||||
@@ -784,7 +784,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
|
|||||||
assertThat(resp.code()).isEqualTo(200);
|
assertThat(resp.code()).isEqualTo(200);
|
||||||
// Check general format of result
|
// Check general format of result
|
||||||
final JsonObject json = new JsonObject(resp.body().string());
|
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(
|
testHelper.assertValidJsonRpcError(
|
||||||
json, id, expectedError.getCode(), expectedError.getMessage());
|
json, id, expectedError.getCode(), expectedError.getMessage());
|
||||||
}
|
}
|
||||||
@@ -854,7 +854,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
|
|||||||
assertThat(resp.code()).isEqualTo(200);
|
assertThat(resp.code()).isEqualTo(200);
|
||||||
// Check general format of result
|
// Check general format of result
|
||||||
final JsonObject json = new JsonObject(resp.body().string());
|
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(
|
testHelper.assertValidJsonRpcError(
|
||||||
json, id, expectedError.getCode(), expectedError.getMessage());
|
json, id, expectedError.getCode(), expectedError.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class PluginJsonRpcMethodTest extends JsonRpcHttpServiceTestBase {
|
|||||||
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) {
|
try (final Response resp = client.newCall(buildPostRequest(body)).execute()) {
|
||||||
assertThat(resp.code()).isEqualTo(200);
|
assertThat(resp.code()).isEqualTo(200);
|
||||||
final JsonObject json = new JsonObject(resp.body().string());
|
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(
|
testHelper.assertValidJsonRpcError(
|
||||||
json, 1, expectedError.getCode(), expectedError.getMessage());
|
json, 1, expectedError.getCode(), expectedError.getMessage());
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,8 @@ public class PluginJsonRpcMethodTest extends JsonRpcHttpServiceTestBase {
|
|||||||
private static Object echoPluginRpcMethod(final PluginRpcRequest request) {
|
private static Object echoPluginRpcMethod(final PluginRpcRequest request) {
|
||||||
final var params = request.getParams();
|
final var params = request.getParams();
|
||||||
if (params.length == 0) {
|
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];
|
final var input = params[0];
|
||||||
if (input.toString().isBlank()) {
|
if (input.toString().isBlank()) {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class AdminAddPeerTest {
|
|||||||
final JsonRpcRequestContext request =
|
final JsonRpcRequestContext request =
|
||||||
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_addPeer", new String[] {}));
|
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_addPeer", new String[] {}));
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ public class AdminAddPeerTest {
|
|||||||
final JsonRpcRequestContext request =
|
final JsonRpcRequestContext request =
|
||||||
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_addPeer", null));
|
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_addPeer", null));
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ public class AdminAddPeerTest {
|
|||||||
final JsonRpcRequestContext request =
|
final JsonRpcRequestContext request =
|
||||||
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_addPeer", new String[] {null}));
|
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_addPeer", new String[] {null}));
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ public class AdminAddPeerTest {
|
|||||||
new JsonRpcRequest("2.0", "admin_addPeer", new String[] {validEnode, validEnode}));
|
new JsonRpcRequest("2.0", "admin_addPeer", new String[] {validEnode, validEnode}));
|
||||||
|
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,8 @@ public class AdminChangeLogLevelTest {
|
|||||||
new JsonRpcRequestContext(
|
new JsonRpcRequestContext(
|
||||||
new JsonRpcRequest("2.0", "admin_changeLogLevel", new Object[] {null}));
|
new JsonRpcRequest("2.0", "admin_changeLogLevel", new Object[] {null}));
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = adminChangeLogLevel.response(request);
|
||||||
assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse);
|
assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse);
|
||||||
@@ -129,7 +130,8 @@ public class AdminChangeLogLevelTest {
|
|||||||
new JsonRpcRequestContext(
|
new JsonRpcRequestContext(
|
||||||
new JsonRpcRequest("2.0", "admin_changeLogLevel", new String[] {"INVALID"}));
|
new JsonRpcRequest("2.0", "admin_changeLogLevel", new String[] {"INVALID"}));
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = adminChangeLogLevel.response(request);
|
||||||
assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse);
|
assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse);
|
||||||
@@ -141,7 +143,8 @@ public class AdminChangeLogLevelTest {
|
|||||||
new JsonRpcRequestContext(
|
new JsonRpcRequestContext(
|
||||||
new JsonRpcRequest("2.0", "admin_changeLogLevel", new Object[] {"DEBUG", "INVALID"}));
|
new JsonRpcRequest("2.0", "admin_changeLogLevel", new Object[] {"DEBUG", "INVALID"}));
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = adminChangeLogLevel.response(request);
|
||||||
assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse);
|
assertThat(actualResponse).usingRecursiveComparison().isEqualTo(expectedResponse);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class AdminRemovePeerTest {
|
|||||||
final JsonRpcRequestContext request =
|
final JsonRpcRequestContext request =
|
||||||
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_removePeer", new String[] {}));
|
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_removePeer", new String[] {}));
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ public class AdminRemovePeerTest {
|
|||||||
final JsonRpcRequestContext request =
|
final JsonRpcRequestContext request =
|
||||||
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_removePeer", null));
|
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "admin_removePeer", null));
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ public class AdminRemovePeerTest {
|
|||||||
new JsonRpcRequestContext(
|
new JsonRpcRequestContext(
|
||||||
new JsonRpcRequest("2.0", "admin_removePeer", new String[] {null}));
|
new JsonRpcRequest("2.0", "admin_removePeer", new String[] {null}));
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ public class AdminRemovePeerTest {
|
|||||||
new JsonRpcRequest("2.0", "admin_removePeer", new String[] {validEnode, validEnode}));
|
new JsonRpcRequest("2.0", "admin_removePeer", new String[] {validEnode, validEnode}));
|
||||||
|
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class EthGetBlockByHashTest {
|
|||||||
public void exceptionWhenNoBoolSupplied() {
|
public void exceptionWhenNoBoolSupplied() {
|
||||||
assertThatThrownBy(() -> method.response(requestWithParams(ZERO_HASH)))
|
assertThatThrownBy(() -> method.response(requestWithParams(ZERO_HASH)))
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessage("Missing required json rpc parameter at index 1");
|
.hasMessage("Invalid is complete transaction parameter (index 1)");
|
||||||
verifyNoMoreInteractions(blockchainQueries);
|
verifyNoMoreInteractions(blockchainQueries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,8 +85,7 @@ public class EthGetBlockByHashTest {
|
|||||||
public void exceptionWhenBoolParamInvalid() {
|
public void exceptionWhenBoolParamInvalid() {
|
||||||
assertThatThrownBy(() -> method.response(requestWithParams(ZERO_HASH, "maybe")))
|
assertThatThrownBy(() -> method.response(requestWithParams(ZERO_HASH, "maybe")))
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessage(
|
.hasMessage("Invalid is complete transaction parameter (index 1)");
|
||||||
"Invalid json rpc parameter at index 1. Supplied value was: 'maybe' of type: 'java.lang.String' - expected type: 'java.lang.Boolean'");
|
|
||||||
verifyNoMoreInteractions(blockchainQueries);
|
verifyNoMoreInteractions(blockchainQueries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class EthGetBlockByNumberTest {
|
|||||||
public void exceptionWhenNoBoolSupplied() {
|
public void exceptionWhenNoBoolSupplied() {
|
||||||
assertThatThrownBy(() -> method.response(requestWithParams("0")))
|
assertThatThrownBy(() -> method.response(requestWithParams("0")))
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessage("Missing required json rpc parameter at index 1");
|
.hasMessage("Invalid is transaction complete parameter (index 1)");
|
||||||
verifyNoMoreInteractions(blockchainQueries);
|
verifyNoMoreInteractions(blockchainQueries);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,8 +137,7 @@ public class EthGetBlockByNumberTest {
|
|||||||
public void exceptionWhenBoolParamInvalid() {
|
public void exceptionWhenBoolParamInvalid() {
|
||||||
assertThatThrownBy(() -> method.response(requestWithParams("0", "maybe")))
|
assertThatThrownBy(() -> method.response(requestWithParams("0", "maybe")))
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessage(
|
.hasMessage("Invalid is transaction complete parameter (index 1)");
|
||||||
"Invalid json rpc parameter at index 1. Supplied value was: 'maybe' of type: 'java.lang.String' - expected type: 'java.lang.Boolean'");
|
|
||||||
verifyNoMoreInteractions(blockchainQueries);
|
verifyNoMoreInteractions(blockchainQueries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,9 +69,8 @@ public class EthGetFilterChangesTest {
|
|||||||
|
|
||||||
final Throwable thrown = catchThrowable(() -> method.response(request));
|
final Throwable thrown = catchThrowable(() -> method.response(request));
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
.hasNoCause()
|
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessage("Missing required json rpc parameter at index 0");
|
.hasMessage("Invalid filter ID parameter (index 0)");
|
||||||
|
|
||||||
verifyNoInteractions(filterManager);
|
verifyNoInteractions(filterManager);
|
||||||
}
|
}
|
||||||
@@ -83,7 +82,7 @@ public class EthGetFilterChangesTest {
|
|||||||
final Throwable thrown = catchThrowable(() -> method.response(request));
|
final Throwable thrown = catchThrowable(() -> method.response(request));
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessage("Missing required json rpc parameter at index 0");
|
.hasMessage("Invalid filter ID parameter (index 0)");
|
||||||
|
|
||||||
verifyNoInteractions(filterManager);
|
verifyNoInteractions(filterManager);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class EthGetFilterLogsTest {
|
|||||||
final Throwable thrown = catchThrowable(() -> method.response(request));
|
final Throwable thrown = catchThrowable(() -> method.response(request));
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessage("Missing required json rpc parameter at index 0");
|
.hasMessage("Invalid filter ID parameter (index 0)");
|
||||||
|
|
||||||
verifyNoInteractions(filterManager);
|
verifyNoInteractions(filterManager);
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ public class EthGetFilterLogsTest {
|
|||||||
final Throwable thrown = catchThrowable(() -> method.response(request));
|
final Throwable thrown = catchThrowable(() -> method.response(request));
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessage("Missing required json rpc parameter at index 0");
|
.hasMessage("Invalid filter ID parameter (index 0)");
|
||||||
|
|
||||||
verifyNoInteractions(filterManager);
|
verifyNoInteractions(filterManager);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class EthGetLogsTest {
|
|||||||
final Throwable thrown = catchThrowable(() -> method.response(request));
|
final Throwable thrown = catchThrowable(() -> method.response(request));
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessage("Missing required json rpc parameter at index 0");
|
.hasMessage("Invalid filter parameter (index 0)");
|
||||||
|
|
||||||
verifyNoInteractions(blockchainQueries);
|
verifyNoInteractions(blockchainQueries);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class EthGetTransactionByHashTest {
|
|||||||
final JsonRpcRequestContext context = new JsonRpcRequestContext(request);
|
final JsonRpcRequestContext context = new JsonRpcRequestContext(request);
|
||||||
|
|
||||||
final JsonRpcErrorResponse expectedResponse =
|
final JsonRpcErrorResponse expectedResponse =
|
||||||
new JsonRpcErrorResponse(request.getId(), RpcErrorType.INVALID_PARAMS);
|
new JsonRpcErrorResponse(request.getId(), RpcErrorType.INVALID_PARAM_COUNT);
|
||||||
|
|
||||||
final JsonRpcResponse actualResponse = method.response(context);
|
final JsonRpcResponse actualResponse = method.response(context);
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public class EthNewFilterTest {
|
|||||||
final JsonRpcRequestContext request = ethNewFilter(invalidFilter);
|
final JsonRpcRequestContext request = ethNewFilter(invalidFilter);
|
||||||
|
|
||||||
final JsonRpcResponse expectedResponse =
|
final JsonRpcResponse expectedResponse =
|
||||||
new JsonRpcErrorResponse(null, RpcErrorType.INVALID_PARAMS);
|
new JsonRpcErrorResponse(null, RpcErrorType.INVALID_FILTER_PARAMS);
|
||||||
|
|
||||||
final JsonRpcResponse response = method.response(request);
|
final JsonRpcResponse response = method.response(request);
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class EthSendRawTransactionTest {
|
|||||||
new JsonRpcRequest("2.0", "eth_sendRawTransaction", new String[] {}));
|
new JsonRpcRequest("2.0", "eth_sendRawTransaction", new String[] {}));
|
||||||
|
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ public class EthSendRawTransactionTest {
|
|||||||
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "eth_sendRawTransaction", null));
|
new JsonRpcRequestContext(new JsonRpcRequest("2.0", "eth_sendRawTransaction", null));
|
||||||
|
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public class EthSendRawTransactionTest {
|
|||||||
new JsonRpcRequest("2.0", "eth_sendRawTransaction", new String[] {null}));
|
new JsonRpcRequest("2.0", "eth_sendRawTransaction", new String[] {null}));
|
||||||
|
|
||||||
final JsonRpcResponse expectedResponse =
|
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);
|
final JsonRpcResponse actualResponse = method.response(request);
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class TxPoolBesuPendingTransactionsTest {
|
|||||||
|
|
||||||
assertThatThrownBy(() -> method.response(request))
|
assertThatThrownBy(() -> method.response(request))
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessageContaining("Unknown field expected one of `eq`, `gt`, `lt`, `action`");
|
.hasMessageContaining("Invalid pending transactions parameter (index 1)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -229,7 +229,7 @@ public class TxPoolBesuPendingTransactionsTest {
|
|||||||
|
|
||||||
assertThatThrownBy(() -> method.response(request))
|
assertThatThrownBy(() -> method.response(request))
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessageContaining("Only one operator per filter type allowed");
|
.hasMessageContaining("Invalid pending transactions parameter (index 1)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -256,7 +256,7 @@ public class TxPoolBesuPendingTransactionsTest {
|
|||||||
|
|
||||||
assertThatThrownBy(() -> method.response(request))
|
assertThatThrownBy(() -> method.response(request))
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.isInstanceOf(InvalidJsonRpcParameters.class)
|
||||||
.hasMessageContaining("The `from` filter only supports the `eq` operator");
|
.hasMessageContaining("Invalid pending transactions parameter (index 1)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -283,7 +283,7 @@ public class TxPoolBesuPendingTransactionsTest {
|
|||||||
|
|
||||||
assertThatThrownBy(() -> method.response(request))
|
assertThatThrownBy(() -> method.response(request))
|
||||||
.isInstanceOf(InvalidJsonRpcParameters.class)
|
.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() {
|
private Set<PendingTransaction> getTransactionPool() {
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public class Web3Sha3Test {
|
|||||||
"2", "web3_sha3", new Object[] {"0x68656c6c6f20776f726c64", "{encode:'hex'}"}));
|
"2", "web3_sha3", new Object[] {"0x68656c6c6f20776f726c64", "{encode:'hex'}"}));
|
||||||
|
|
||||||
final JsonRpcResponse expected =
|
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);
|
final JsonRpcResponse actual = method.response(request);
|
||||||
|
|
||||||
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
|
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
|
||||||
@@ -135,7 +135,7 @@ public class Web3Sha3Test {
|
|||||||
new JsonRpcRequestContext(new JsonRpcRequest("2", "web3_sha3", new Object[] {}));
|
new JsonRpcRequestContext(new JsonRpcRequest("2", "web3_sha3", new Object[] {}));
|
||||||
|
|
||||||
final JsonRpcResponse expected =
|
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);
|
final JsonRpcResponse actual = method.response(request);
|
||||||
|
|
||||||
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
|
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
|||||||
|
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
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.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.SYNCING;
|
||||||
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
|
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.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|||||||
@@ -14,12 +14,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
|
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 static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.EXPERIMENTAL_EIPS;
|
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.EXPERIMENTAL_EIPS;
|
||||||
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.LONDON;
|
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.LONDON;
|
||||||
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.PARIS;
|
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.PARIS;
|
||||||
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.PRAGUE;
|
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.PRAGUE;
|
||||||
import static org.hyperledger.besu.ethereum.mainnet.HardforkId.MainnetHardforkId.SHANGHAI;
|
import static org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId.SHANGHAI;
|
||||||
import static org.mockito.Mockito.lenient;
|
import static org.mockito.Mockito.lenient;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class EngineNewPayloadV2Test extends AbstractEngineNewPayloadTest {
|
|||||||
|
|
||||||
final JsonRpcError jsonRpcError = fromErrorResp(resp);
|
final JsonRpcError jsonRpcError = fromErrorResp(resp);
|
||||||
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
|
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();
|
verify(engineCallListener, times(1)).executionEngineCalled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test {
|
|||||||
|
|
||||||
final JsonRpcError jsonRpcError = fromErrorResp(resp);
|
final JsonRpcError jsonRpcError = fromErrorResp(resp);
|
||||||
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
|
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();
|
verify(engineCallListener, times(1)).executionEngineCalled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class MinerSetExtraDataTest {
|
|||||||
new JsonRpcErrorResponse(
|
new JsonRpcErrorResponse(
|
||||||
request.getRequest().getId(),
|
request.getRequest().getId(),
|
||||||
new JsonRpcError(
|
new JsonRpcError(
|
||||||
RpcErrorType.INVALID_PARAMS,
|
RpcErrorType.INVALID_EXTRA_DATA_PARAMS,
|
||||||
"Illegal character 'n' found at index 0 in hex binary representation"));
|
"Illegal character 'n' found at index 0 in hex binary representation"));
|
||||||
|
|
||||||
final JsonRpcResponse actual = method.response(request);
|
final JsonRpcResponse actual = method.response(request);
|
||||||
@@ -100,7 +100,7 @@ public class MinerSetExtraDataTest {
|
|||||||
new JsonRpcErrorResponse(
|
new JsonRpcErrorResponse(
|
||||||
request.getRequest().getId(),
|
request.getRequest().getId(),
|
||||||
new JsonRpcError(
|
new JsonRpcError(
|
||||||
RpcErrorType.INVALID_PARAMS,
|
RpcErrorType.INVALID_EXTRA_DATA_PARAMS,
|
||||||
"Hex value is too large: expected at most 32 bytes but got 37"));
|
"Hex value is too large: expected at most 32 bytes but got 37"));
|
||||||
|
|
||||||
final JsonRpcResponse actual = method.response(request);
|
final JsonRpcResponse actual = method.response(request);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class MinerSetMinGasPriceTest {
|
|||||||
new JsonRpcErrorResponse(
|
new JsonRpcErrorResponse(
|
||||||
request.getRequest().getId(),
|
request.getRequest().getId(),
|
||||||
new JsonRpcError(
|
new JsonRpcError(
|
||||||
RpcErrorType.INVALID_PARAMS,
|
RpcErrorType.INVALID_MIN_GAS_PRICE_PARAMS,
|
||||||
"Illegal character '-' found at index 0 in hex binary representation"));
|
"Illegal character '-' found at index 0 in hex binary representation"));
|
||||||
|
|
||||||
final JsonRpcResponse actual = method.response(request);
|
final JsonRpcResponse actual = method.response(request);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class MinerSetMinPriorityFeeTest {
|
|||||||
new JsonRpcErrorResponse(
|
new JsonRpcErrorResponse(
|
||||||
request.getRequest().getId(),
|
request.getRequest().getId(),
|
||||||
new JsonRpcError(
|
new JsonRpcError(
|
||||||
RpcErrorType.INVALID_PARAMS,
|
RpcErrorType.INVALID_MIN_PRIORITY_FEE_PARAMS,
|
||||||
"Hex value is too large: expected at most 32 bytes but got 33"));
|
"Hex value is too large: expected at most 32 bytes but got 33"));
|
||||||
|
|
||||||
final JsonRpcResponse actual = method.response(request);
|
final JsonRpcResponse actual = method.response(request);
|
||||||
@@ -65,7 +65,8 @@ public class MinerSetMinPriorityFeeTest {
|
|||||||
new JsonRpcErrorResponse(
|
new JsonRpcErrorResponse(
|
||||||
request.getRequest().getId(),
|
request.getRequest().getId(),
|
||||||
new JsonRpcError(
|
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);
|
final JsonRpcResponse actual = method.response(request);
|
||||||
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
|
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user