diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md
new file mode 100644
index 0000000000..7b88a84379
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug-report.md
@@ -0,0 +1,50 @@
+---
+name: Bug Report
+about: necessary information to help us resolve the issue
+title: ''
+labels: 'bug'
+assignees: ''
+
+---
+
+
+
+
+
+
+
+
+
+### Steps to Reproduce
+1. [Step 1]
+2. [Step 2]
+3. [Step ...]
+
+**Expected behavior:** [What you expect to happen]
+
+**Actual behavior:** [What actually happens]
+
+**Frequency:** [What percentage of the time does it occur?]
+
+### Logs
+Please post relevant logs from Besu (and the consensus client, if running proof of stake) from before and after the issue.
+
+### Versions (Add all that apply)
+* Software version: [`besu --version`]
+* Java version: [`java -version`]
+* OS Name & Version: [`cat /etc/*release`]
+* Kernel Version: [`uname -a`]
+* Virtual Machine software & version: [`vmware -v`]
+* Docker Version: [`docker version`]
+* Cloud VM, type, size: [Amazon Web Services I3-large]
+* Consensus Client & Version if using Proof of Stake: [e.g. Teku, Lighthouse, Prysm, Nimbus, Lodestar]
+
+### Smart contract information (If you're reporting an issue arising from deploying or calling a smart contract, please supply related information)
+* Solidity version [`solc --version`]
+* Repo with minimal set of deployable/reproducible contract code - please provide a link
+* Please include specifics on how you are deploying/calling the contract
+* Have you reproduced the issue on other eth clients
+
+### Additional Information (Add any of the following or anything else that may be relevant)
+* Besu setup info - genesis file, config options
+* System info - memory, CPU
diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md
new file mode 100644
index 0000000000..73ebe5f060
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature-request.md
@@ -0,0 +1,45 @@
+---
+name: Feature Request
+about: suggesting new or altered functionality
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+
+
+
+
+
+
+### Description
+As an [Actor], I want [feature] so that [why].
+
+### Acceptance Criteria
+* [Criteria 1]
+* [Criteria 2]
+* [Criteria 3...]
+
+### Logs (if a change in behavior)
+Please post relevant logs from Besu (and the consensus client, if running proof of stake) illustrating behavior to be altered
+
+### Versions (Add all that apply)
+* Software version: [`besu --version`]
+* Java version: [`java -version`]
+* OS Name & Version: [`cat /etc/*release`]
+* Kernel Version: [`uname -a`]
+* Virtual Machine software & version: [`vmware -v`]
+* Docker Version: [`docker version`]
+* Cloud VM, type, size: [Amazon Web Services I3-large]
+* Consensus Client & Version if using Proof of Stake: [e.g. Teku, Lighthouse, Prysm, Nimbus, Lodestar]
+
+### Smart contract information (If you're reporting an issue arising from deploying or calling a smart contract, please supply related information)
+* Solidity version [`solc --version`]
+* Repo with minimal set of deployable/reproducible contract code - please provide a link
+* Please include specifics on how you are deploying/calling the contract
+* Have you reproduced the issue on other eth clients
+
+### Additional Information (Add any of the following or anything else that may be relevant)
+* Besu setup info - genesis file, config options
+* System info - memory, CPU
diff --git a/.github/issue_template.md b/.github/issue_template.md
index 54acf4c196..7fe82b4f07 100644
--- a/.github/issue_template.md
+++ b/.github/issue_template.md
@@ -2,30 +2,10 @@
-
-
-
+
-### Description
-As an [Actor], I want [feature] so that [why].
-### Acceptance Criteria
-* [Criteria 1]
-
-### Steps to Reproduce (Bug)
-1. [Step 1]
-2. [Step 2]
-3. [Step ...]
-
-**Expected behavior:** [What you expect to happen]
-
-**Actual behavior:** [What actually happens]
-
-**Frequency:** [What percentage of the time does it occur?]
-
-### Logs (if a bug)
-Please post relevant logs from Besu (and the consensus client, if running proof of stake) from before and after the issue.
### Versions (Add all that apply)
* Software version: [`besu --version`]
diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml
new file mode 100644
index 0000000000..fe45d91b49
--- /dev/null
+++ b/.github/workflows/stale-issues.yml
@@ -0,0 +1,27 @@
+name: Close inactive issues
+on:
+ schedule:
+ - cron: "30 1 * * *"
+
+jobs:
+ close-issues:
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ pull-requests: write
+ contents: write
+ steps:
+ - uses: actions/stale@v5
+ with:
+ days-before-issue-stale: 180
+ days-before-issue-close: 14
+ stale-issue-label: "stale"
+ stale-issue-message: "This issue is stale because it has been open for 6 months with no activity."
+ close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
+ days-before-pr-stale: 30
+ days-before-pr-close: 14
+ stale-pr-message: "This pr is stale because it has been open for 30 days with no activity."
+ close-pr-message: "This pr was closed because it has been inactive for 14 days since being marked as stale."
+ remove-issue-stale-when-updated: true
+ remove-pr-stale-when-updated: true
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8bfb4ebd3e..5472920ef5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,19 +1,35 @@
# Changelog
## [Unreleased]
-- Added isLabelsObserved to LabelledGauge in plugin-api. Default implementation returns false.
### Breaking Changes
+- Removed Retesteth rpc service and commands [#7833](https://github.com/hyperledger/besu/pull/7783)
### Upcoming Breaking Changes
+- Plugin API will be deprecating the BesuContext interface to be replaced with the ServiceManager interface.
+- `MetricSystem::createLabelledGauge` is deprecated and will be removed in a future release, replace it with `MetricSystem::createLabelledSuppliedGauge`
+- k8s (KUBERNETES) Nat method is now deprecated and will be removed in a future release
+- `--host-whitelist` has been deprecated in favor of `--host-allowlist` since 2020 and will be removed in a future release
+- Sunsetting features - for more context on the reasoning behind the deprecation of these features, including alternative options, read [this blog post](https://www.lfdecentralizedtrust.org/blog/sunsetting-tessera-and-simplifying-hyperledger-besu)
+ - Tessera privacy
+ - Smart-contract-based permissioning
+ - Proof of Work consensus
+ - Fast Sync
### Additions and Improvements
- Fine tune already seen txs tracker when a tx is removed from the pool [#7755](https://github.com/hyperledger/besu/pull/7755)
+- Support for enabling and configuring TLS/mTLS in WebSocket service. [#7854](https://github.com/hyperledger/besu/pull/7854)
- Create and publish Besu BOM (Bill of Materials) [#7615](https://github.com/hyperledger/besu/pull/7615)
- Update Java dependencies [#7786](https://github.com/hyperledger/besu/pull/7786)
- Add a method to get all the transaction in the pool, to the `TransactionPoolService`, to easily access the transaction pool content from plugins [#7813](https://github.com/hyperledger/besu/pull/7813)
+- Upgrade RocksDB JNI library from version 8.3.2 to 9.7.3 [#7817](https://github.com/hyperledger/besu/pull/7817)
+- Add a method to check if a metric category is enabled to the plugin API [#7832](https://github.com/hyperledger/besu/pull/7832)
+- Add a new metric collector for counters which get their value from suppliers [#7894](https://github.com/hyperledger/besu/pull/7894)
+- Add account and state overrides to `eth_call` [#7801](https://github.com/hyperledger/besu/pull/7801) and `eth_estimateGas` [#7890](https://github.com/hyperledger/besu/pull/7890)
### Bug fixes
+- Fix registering new metric categories from plugins [#7825](https://github.com/hyperledger/besu/pull/7825)
+- Fix CVE-2024-47535 [7878](https://github.com/hyperledger/besu/pull/7878)
## 24.10.0
@@ -99,6 +115,7 @@ This release version has been deprecated release due to CI bug
- Remove long-deprecated `perm*whitelist*` methods [#7401](https://github.com/hyperledger/besu/pull/7401)
### Additions and Improvements
+- Allow optional loading of `jemalloc` (if installed) by setting the environment variable `BESU_USING_JEMALLOC` to true/false. It that env is not set at all it will behave as if it is set to `true`
- Expose set finalized/safe block in plugin api BlockchainService. These method can be used by plugins to set finalized/safe block for a PoA network (such as QBFT, IBFT and Clique).[#7382](https://github.com/hyperledger/besu/pull/7382)
- In process RPC service [#7395](https://github.com/hyperledger/besu/pull/7395)
- Added support for tracing private transactions using `priv_traceTransaction` API. [#6161](https://github.com/hyperledger/besu/pull/6161)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c2d6c57d25..c13ea67852 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,7 +8,7 @@ Welcome to the Besu repository! The following links are a set of guidelines for
Having the following accounts is necessary for contributing code/issues to Besu.
* If you want to contribute code, you can make a [github account here](https://github.com).
* If you want to raise an issue, do so [in the issues tab](https://github.com/hyperledger/besu/issues).
-* To ask questions or chat with us, join our [Discord](https://discord.gg/hyperledger)
+* To ask questions or chat with us, join our [Discord](https://discord.com/invite/hyperledger)
* To edit pages in our wiki, you'll need a [Linux Foundation (LF) account].
### Useful contributing links
diff --git a/DCO.md b/DCO.md
index 4bf56cb80a..48227cadcd 100644
--- a/DCO.md
+++ b/DCO.md
@@ -5,4 +5,4 @@ As per section 13.a of the [Hyperledger Charter](https://www.hyperledger.org/abo
The sign off needs to be using your legal name, not a pseudonym. Git has a built-in mechanism to allow this with the `-s` or `--signoff` argument to `git commit` command, providing your `user.name` and `user.email` have been setup correctly.
-If you have any questions, you can reach us on Besu chat; first, [join the Discord server](https://discord.gg/hyperledger/) then [join the Besu channel](https://discord.com/channels/905194001349627914/938504958909747250).
+If you have any questions, you can reach us on Besu chat; first, [join the Discord server](https://discord.com/invite/hyperledger) then [join the Besu channel](https://discord.com/channels/905194001349627914/938504958909747250).
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
index ae6720632a..6c17df8823 100644
--- a/MAINTAINERS.md
+++ b/MAINTAINERS.md
@@ -22,6 +22,7 @@
| Luis Pinto | lu-pinto | lu-pinto |
| Lucas Saldanha | lucassaldanha | lucassaldanha |
| Sally MacFarlane | macfarla | macfarla |
+| Matilda Clerke | Matilda-Clerke | MatildaClerke |
| Karim Taam | matkt | matkt |
| Matthew Whitehead| matthew1001 | matthew.whitehead |
| Meredith Baxter | mbaxter | mbaxter |
@@ -84,7 +85,7 @@ The following steps must occur for a contributor to be "upgraded" as a maintaine
- The proposed maintainer accepts the nomination and expresses a willingness
to be a long-term (more than 6 month) committer by adding a comment in the proposal PR.
- The PR will be communicated in all appropriate communication channels
- including at least [besu-contributors channel on Discord](https://discord.gg/hyperledger),
+ including at least [besu-contributors channel on Discord](https://discord.com/invite/hyperledger),
the [mailing list](https://lists.hyperledger.org/g/besu)
and any maintainer/community call.
- Approval by at least 3 current maintainers within two weeks of the proposal or
diff --git a/README.md b/README.md
index 7139df8580..8f5f51a726 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
[![Documentation](https://img.shields.io/github/actions/workflow/status/hyperledger/besu-docs/publish-main-docs.yml?branch=main&label=docs)](https://github.com/hyperledger/besu-docs/actions/workflows/publish-main-docs.yml)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3174/badge)](https://bestpractices.coreinfrastructure.org/projects/3174)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/hyperledger/besu/blob/main/LICENSE)
- [![Discord](https://img.shields.io/discord/905194001349627914?logo=Hyperledger&style=plastic)](https://discord.gg/hyperledger)
+ [![Discord](https://img.shields.io/discord/905194001349627914?logo=Hyperledger&style=plastic)](https://discord.com/invite/hyperledger)
[![Twitter Follow](https://img.shields.io/twitter/follow/HyperledgerBesu)](https://twitter.com/HyperledgerBesu)
[Download](https://github.com/hyperledger/besu/releases)
@@ -67,5 +67,5 @@ and YourKit YouMonitor.
[Besu Issues]: https://github.com/hyperledger/besu/issues
[Besu User Documentation]: https://besu.hyperledger.org
-[Besu channel on Discord]: https://discord.gg/hyperledger
+[Besu channel on Discord]: https://discord.com/invite/hyperledger
[Contributing Guidelines]: CONTRIBUTING.md
diff --git a/SUPPORT.md b/SUPPORT.md
index 9e4a7b7b42..97715857cb 100644
--- a/SUPPORT.md
+++ b/SUPPORT.md
@@ -20,5 +20,5 @@ Having Github, Discord, and Linux Foundation accounts is necessary for obtaining
[Besu User Documentation]: https://besu.hyperledger.org
-[Besu channel on Discord]: https://discord.gg/hyperledger
+[Besu channel on Discord]: https://discord.com/invite/hyperledger
[Contributing Guidelines]: CONTRIBUTING.md
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
index 21ca45070b..76e18812b0 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
@@ -27,7 +27,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
@@ -101,7 +101,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private final boolean revertReasonEnabled;
private final String name;
- private MiningParameters miningParameters;
+ private MiningConfiguration miningConfiguration;
private TransactionPoolConfiguration txPoolConfiguration;
private final List runCommand;
private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT;
@@ -139,7 +139,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
public BesuNode(
final String name,
final Optional dataPath,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final TransactionPoolConfiguration txPoolConfiguration,
final JsonRpcConfiguration jsonRpcConfiguration,
final Optional engineRpcConfiguration,
@@ -191,7 +191,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
},
() -> this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory));
this.name = name;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
this.txPoolConfiguration = txPoolConfiguration;
this.jsonRpcConfiguration = jsonRpcConfiguration;
this.engineRpcConfiguration = engineRpcConfiguration;
@@ -678,12 +678,12 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
this.bootnodes.addAll(bootnodes);
}
- public MiningParameters getMiningParameters() {
- return miningParameters;
+ public MiningConfiguration getMiningParameters() {
+ return miningConfiguration;
}
- public void setMiningParameters(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public void setMiningParameters(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
}
public TransactionPoolConfiguration getTransactionPoolConfiguration() {
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
index 75307d9520..ee865a8142 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
@@ -17,9 +17,9 @@ package org.hyperledger.besu.tests.acceptance.dsl.node;
import static com.google.common.base.Preconditions.checkState;
import static java.nio.charset.StandardCharsets.UTF_8;
+import org.hyperledger.besu.cli.options.NetworkingOptions;
import org.hyperledger.besu.cli.options.TransactionPoolOptions;
import org.hyperledger.besu.cli.options.storage.DataStorageOptions;
-import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration;
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
index 42c0df73c7..9effaff4d4 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
@@ -36,8 +36,8 @@ import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;
import org.hyperledger.besu.ethereum.chain.Blockchain;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginInfo;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
@@ -57,6 +57,7 @@ import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl;
import org.hyperledger.besu.metrics.MetricsSystemModule;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
+import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.plugin.data.EnodeURL;
import org.hyperledger.besu.plugin.services.BesuConfiguration;
@@ -73,17 +74,21 @@ import org.hyperledger.besu.plugin.services.TransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.plugin.services.TransactionSimulationService;
import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry;
+import org.hyperledger.besu.plugin.services.mining.MiningService;
import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBPlugin;
+import org.hyperledger.besu.plugin.services.transactionpool.TransactionPoolService;
import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuEventsImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.BlockchainServiceImpl;
+import org.hyperledger.besu.services.MiningServiceImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PicoCLIOptionsImpl;
import org.hyperledger.besu.services.PrivacyPluginServiceImpl;
import org.hyperledger.besu.services.RpcEndpointServiceImpl;
import org.hyperledger.besu.services.SecurityModuleServiceImpl;
import org.hyperledger.besu.services.StorageServiceImpl;
+import org.hyperledger.besu.services.TransactionPoolServiceImpl;
import org.hyperledger.besu.services.TransactionPoolValidatorServiceImpl;
import org.hyperledger.besu.services.TransactionSelectionServiceImpl;
import org.hyperledger.besu.services.TransactionSimulationServiceImpl;
@@ -214,6 +219,11 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
besuController.getTransactionPool(),
besuController.getSyncState(),
besuController.getProtocolContext().getBadBlockManager()));
+ besuPluginContext.addService(
+ TransactionPoolService.class,
+ new TransactionPoolServiceImpl(besuController.getTransactionPool()));
+ besuPluginContext.addService(
+ MiningService.class, new MiningServiceImpl(besuController.getMiningCoordinator()));
component.rpcEndpointService().init(runner.getInProcessRpcMethods());
@@ -326,7 +336,9 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
@Singleton
BlockchainServiceImpl provideBlockchainService(final BesuController besuController) {
BlockchainServiceImpl retval = new BlockchainServiceImpl();
- retval.init(besuController.getProtocolContext(), besuController.getProtocolSchedule());
+ retval.init(
+ besuController.getProtocolContext().getBlockchain(),
+ besuController.getProtocolSchedule());
return retval;
}
@@ -406,9 +418,18 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
}
}
+ @Module
+ public static class ThreadBesuNodeRunnerModule {
+ @Provides
+ @Singleton
+ public ThreadBesuNodeRunner provideThreadBesuNodeRunner() {
+ return new ThreadBesuNodeRunner();
+ }
+ }
+
@Module
@SuppressWarnings("CloseableProvides")
- static class BesuControllerModule {
+ public static class BesuControllerModule {
@Provides
@Singleton
public SynchronizerConfiguration provideSynchronizationConfiguration() {
@@ -438,7 +459,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
final BesuControllerBuilder builder,
final MetricsSystem metricsSystem,
final KeyValueStorageProvider storageProvider,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
builder
.synchronizerConfiguration(synchronizerConfiguration)
@@ -451,7 +472,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
.evmConfiguration(EvmConfiguration.DEFAULT)
.maxPeers(25)
.maxRemotelyInitiatedPeers(15)
- .miningParameters(miningParameters)
+ .miningParameters(miningConfiguration)
.randomPeerPriority(false)
.besuComponent(null);
return builder.build();
@@ -484,6 +505,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
final RpcEndpointServiceImpl rpcEndpointServiceImpl,
final BesuConfiguration commonPluginConfiguration,
final PermissioningServiceImpl permissioningService,
+ final MetricsConfiguration metricsConfiguration,
final MetricCategoryRegistryImpl metricCategoryRegistry,
final MetricsSystem metricsSystem,
final @Named("ExtraCLIOptions") List extraCLIOptions,
@@ -502,6 +524,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
TransactionSimulationService.class, transactionSimulationServiceImpl);
besuPluginContext.addService(BlockchainService.class, blockchainServiceImpl);
besuPluginContext.addService(BesuConfiguration.class, commonPluginConfiguration);
+ metricCategoryRegistry.setMetricsConfiguration(metricsConfiguration);
besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry);
besuPluginContext.addService(MetricsSystem.class, metricsSystem);
@@ -554,11 +577,11 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
}
@Provides
- public MiningParameters provideMiningParameters(
+ public MiningConfiguration provideMiningParameters(
final TransactionSelectionServiceImpl transactionSelectionServiceImpl,
final BesuNode node) {
final var miningParameters =
- ImmutableMiningParameters.builder()
+ ImmutableMiningConfiguration.builder()
.from(node.getMiningParameters())
.transactionSelectionService(transactionSelectionServiceImpl)
.build();
@@ -569,17 +592,26 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
@Provides
@Inject
BesuConfiguration provideBesuConfiguration(
- final Path dataDir, final MiningParameters miningParameters, final BesuNode node) {
+ final Path dataDir, final MiningConfiguration miningConfiguration, final BesuNode node) {
final BesuConfigurationImpl commonPluginConfiguration = new BesuConfigurationImpl();
commonPluginConfiguration.init(
dataDir, dataDir.resolve(DATABASE_PATH), node.getDataStorageConfiguration());
- commonPluginConfiguration.withMiningParameters(miningParameters);
+ commonPluginConfiguration.withMiningParameters(miningConfiguration);
return commonPluginConfiguration;
}
}
@Module
- static class MockBesuCommandModule {
+ public static class ObservableMetricsSystemModule {
+ @Provides
+ @Singleton
+ public ObservableMetricsSystem provideObservableMetricsSystem() {
+ return new NoOpMetricsSystem();
+ }
+ }
+
+ @Module
+ public static class MockBesuCommandModule {
@Provides
BesuCommand provideBesuCommand(final BesuPluginContextImpl pluginContext) {
@@ -610,6 +642,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
modules = {
ThreadBesuNodeRunner.BesuControllerModule.class,
ThreadBesuNodeRunner.MockBesuCommandModule.class,
+ ThreadBesuNodeRunner.ObservableMetricsSystemModule.class,
+ ThreadBesuNodeRunnerModule.class,
BonsaiCachedMerkleTrieLoaderModule.class,
MetricsSystemModule.class,
ThreadBesuNodeRunner.BesuNodeProviderModule.class,
@@ -625,5 +659,9 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
RpcEndpointServiceImpl rpcEndpointService();
BlockchainServiceImpl blockchainService();
+
+ ObservableMetricsSystem getObservableMetricsSystem();
+
+ ThreadBesuNodeRunner getThreadBesuNodeRunner();
}
}
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
index ba69e4ddd7..5840f1e4f1 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
@@ -21,7 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
@@ -40,7 +40,7 @@ public class BesuNodeConfiguration {
private final String name;
private final Optional dataPath;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
private final TransactionPoolConfiguration transactionPoolConfiguration;
private final JsonRpcConfiguration jsonRpcConfiguration;
private final Optional engineRpcConfiguration;
@@ -78,7 +78,7 @@ public class BesuNodeConfiguration {
BesuNodeConfiguration(
final String name,
final Optional dataPath,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final TransactionPoolConfiguration transactionPoolConfiguration,
final JsonRpcConfiguration jsonRpcConfiguration,
final Optional engineRpcConfiguration,
@@ -113,7 +113,7 @@ public class BesuNodeConfiguration {
final boolean strictTxReplayProtectionEnabled,
final Map environment) {
this.name = name;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
this.transactionPoolConfiguration = transactionPoolConfiguration;
this.jsonRpcConfiguration = jsonRpcConfiguration;
this.engineRpcConfiguration = engineRpcConfiguration;
@@ -154,8 +154,8 @@ public class BesuNodeConfiguration {
return name;
}
- public MiningParameters getMiningParameters() {
- return miningParameters;
+ public MiningConfiguration getMiningParameters() {
+ return miningConfiguration;
}
public TransactionPoolConfiguration getTransactionPoolConfiguration() {
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
index ead01ce97d..9b000f56f1 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
@@ -33,9 +33,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.api.tls.FileBasedPasswordProvider;
import org.hyperledger.besu.ethereum.core.AddressHelpers;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
@@ -61,8 +61,8 @@ public class BesuNodeConfigurationBuilder {
private String name;
private Optional dataPath = Optional.empty();
- private MiningParameters miningParameters =
- ImmutableMiningParameters.builder()
+ private MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build())
.build();
@@ -125,13 +125,14 @@ public class BesuNodeConfigurationBuilder {
}
public BesuNodeConfigurationBuilder miningEnabled(final boolean enabled) {
- this.miningParameters = miningParameters.setMiningEnabled(enabled);
+ this.miningConfiguration = miningConfiguration.setMiningEnabled(enabled);
this.jsonRpcConfiguration.addRpcApi(RpcApis.MINER.name());
return this;
}
- public BesuNodeConfigurationBuilder miningConfiguration(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public BesuNodeConfigurationBuilder miningConfiguration(
+ final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
this.jsonRpcConfiguration.addRpcApi(RpcApis.MINER.name());
return this;
}
@@ -527,7 +528,7 @@ public class BesuNodeConfigurationBuilder {
return new BesuNodeConfiguration(
name,
dataPath,
- miningParameters,
+ miningConfiguration,
transactionPoolConfiguration,
jsonRpcConfiguration,
Optional.of(engineRpcConfiguration),
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java
index d9bde19b1e..ec048ea0d3 100644
--- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java
@@ -16,8 +16,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import static java.nio.charset.StandardCharsets.UTF_8;
-import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
+import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import java.io.File;
@@ -39,7 +39,7 @@ public class BadCLIOptionsPlugin implements BesuPlugin {
private File callbackDir;
@Override
- public void register(final BesuContext context) {
+ public void register(final ServiceManager context) {
LOG.info("Registering BadCliOptionsPlugin");
callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins"));
writeStatus("init");
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java
index 44e728010c..7a4a17cf71 100644
--- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java
@@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.tests.acceptance.plugins;
-import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
+import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.data.BlockHeader;
import org.hyperledger.besu.plugin.data.PropagatedBlockContext;
import org.hyperledger.besu.plugin.services.BesuEvents;
@@ -35,14 +35,14 @@ import org.slf4j.LoggerFactory;
public class TestBesuEventsPlugin implements BesuPlugin {
private static final Logger LOG = LoggerFactory.getLogger(TestBesuEventsPlugin.class);
- private BesuContext context;
+ private ServiceManager context;
private Optional subscriptionId;
private final AtomicInteger blockCounter = new AtomicInteger();
private File callbackDir;
@Override
- public void register(final BesuContext context) {
+ public void register(final ServiceManager context) {
this.context = context;
LOG.info("Registered");
callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins"));
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBlockchainServiceFinalizedPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBlockchainServiceFinalizedPlugin.java
index a61b80ab8e..4984e7a00e 100644
--- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBlockchainServiceFinalizedPlugin.java
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBlockchainServiceFinalizedPlugin.java
@@ -17,8 +17,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
-import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
+import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.data.BlockContext;
import org.hyperledger.besu.plugin.services.BlockchainService;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
@@ -40,11 +40,11 @@ public class TestBlockchainServiceFinalizedPlugin implements BesuPlugin {
private static final String RPC_METHOD_SAFE_BLOCK = "updateSafeBlockV1";
@Override
- public void register(final BesuContext besuContext) {
+ public void register(final ServiceManager serviceManager) {
LOG.trace("Registering plugin ...");
final RpcEndpointService rpcEndpointService =
- besuContext
+ serviceManager
.getService(RpcEndpointService.class)
.orElseThrow(
() ->
@@ -52,7 +52,7 @@ public class TestBlockchainServiceFinalizedPlugin implements BesuPlugin {
"Failed to obtain RpcEndpointService from the BesuContext."));
final BlockchainService blockchainService =
- besuContext
+ serviceManager
.getService(BlockchainService.class)
.orElseThrow(
() ->
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestInProcessRpcServicePlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestInProcessRpcServicePlugin.java
index 3ebced0df9..adbc1a3579 100644
--- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestInProcessRpcServicePlugin.java
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestInProcessRpcServicePlugin.java
@@ -15,8 +15,8 @@
package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.datatypes.Wei;
-import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
+import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.rpc.RpcResponseType;
@@ -36,7 +36,7 @@ public class TestInProcessRpcServicePlugin implements BesuPlugin {
long minGasPrice = -1;
@Override
- public void register(final BesuContext context) {
+ public void register(final ServiceManager context) {
final PicoCLIOptions cmdlineOptions =
context
.getService(PicoCLIOptions.class)
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java
new file mode 100644
index 0000000000..9400fb4bcc
--- /dev/null
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright contributors to Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.tests.acceptance.plugins;
+
+import org.hyperledger.besu.plugin.BesuPlugin;
+import org.hyperledger.besu.plugin.ServiceManager;
+import org.hyperledger.besu.plugin.services.MetricsSystem;
+import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
+import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry;
+
+import java.util.Locale;
+import java.util.Optional;
+
+import com.google.auto.service.AutoService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@AutoService(BesuPlugin.class)
+public class TestMetricsPlugin implements BesuPlugin {
+ private static final Logger LOG = LoggerFactory.getLogger(TestMetricsPlugin.class);
+ private ServiceManager serviceManager;
+
+ @Override
+ public void register(final ServiceManager context) {
+ LOG.info("Registering TestMetricsPlugin");
+ serviceManager = context;
+ context
+ .getService(MetricCategoryRegistry.class)
+ .orElseThrow()
+ .addMetricCategory(TestMetricCategory.TEST_METRIC_CATEGORY);
+ }
+
+ @Override
+ public void start() {
+ LOG.info("Starting TestMetricsPlugin");
+ serviceManager
+ .getService(MetricsSystem.class)
+ .orElseThrow()
+ .createGauge(
+ TestMetricCategory.TEST_METRIC_CATEGORY,
+ "test_metric",
+ "Returns 1 on success",
+ () -> 1.0);
+ }
+
+ @Override
+ public void stop() {
+ LOG.info("Stopping TestMetricsPlugin");
+ }
+
+ public enum TestMetricCategory implements MetricCategory {
+ TEST_METRIC_CATEGORY;
+
+ @Override
+ public String getName() {
+ return name().toLowerCase(Locale.ROOT);
+ }
+
+ @Override
+ public Optional getApplicationPrefix() {
+ return Optional.of("plugin_test_");
+ }
+ }
+}
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java
index 44afeeadaa..c2503ed811 100644
--- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java
@@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.tests.acceptance.plugins;
-import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
+import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PermissioningService;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
@@ -40,7 +40,7 @@ public class TestPermissioningPlugin implements BesuPlugin {
PermissioningService service;
@Override
- public void register(final BesuContext context) {
+ public void register(final ServiceManager context) {
context.getService(PicoCLIOptions.class).orElseThrow().addPicoCLIOptions("permissioning", this);
service = context.getService(PermissioningService.class).orElseThrow();
}
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPicoCLIPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPicoCLIPlugin.java
index 375fbd490e..bb83ba676d 100644
--- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPicoCLIPlugin.java
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPicoCLIPlugin.java
@@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.tests.acceptance.plugins;
-import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
+import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import java.io.File;
@@ -57,7 +57,7 @@ public class TestPicoCLIPlugin implements BesuPlugin {
private File callbackDir;
@Override
- public void register(final BesuContext context) {
+ public void register(final ServiceManager context) {
LOG.info("Registering. Test Option is '{}'", testOption);
state = "registering";
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPrivacyServicePlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPrivacyServicePlugin.java
index 4cdd35e8dc..698653f356 100644
--- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPrivacyServicePlugin.java
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPrivacyServicePlugin.java
@@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.tests.acceptance.plugins;
-import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
+import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.PrivacyPluginService;
import org.hyperledger.besu.tests.acceptance.plugins.privacy.TestPrivacyGroupGenesisProvider;
@@ -32,7 +32,7 @@ public class TestPrivacyServicePlugin implements BesuPlugin {
private static final Logger LOG = LoggerFactory.getLogger(TestPrivacyServicePlugin.class);
PrivacyPluginService pluginService;
- BesuContext context;
+ ServiceManager context;
TestPrivacyGroupGenesisProvider privacyGroupGenesisProvider =
new TestPrivacyGroupGenesisProvider();
@@ -40,7 +40,7 @@ public class TestPrivacyServicePlugin implements BesuPlugin {
new TestSigningPrivateMarkerTransactionFactory();
@Override
- public void register(final BesuContext context) {
+ public void register(final ServiceManager context) {
this.context = context;
context
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java
index 67980373ea..75d72473bf 100644
--- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java
@@ -16,8 +16,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import static com.google.common.base.Preconditions.checkArgument;
-import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
+import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.rpc.PluginRpcRequest;
@@ -51,7 +51,7 @@ public class TestRpcEndpointServicePlugin implements BesuPlugin {
}
@Override
- public void register(final BesuContext context) {
+ public void register(final ServiceManager context) {
context
.getService(RpcEndpointService.class)
.ifPresent(
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java
index c375946c98..c4044fc432 100644
--- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java
@@ -28,6 +28,7 @@ import org.apache.tuweni.bytes.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Deprecated(since = "24.11.0")
public class TestPrivacyPluginPayloadProvider implements PrivacyPluginPayloadProvider {
private static final Logger LOG = LoggerFactory.getLogger(TestPrivacyPluginPayloadProvider.class);
private String prefix;
diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle
index fdc7735452..b6c388172e 100644
--- a/acceptance-tests/tests/build.gradle
+++ b/acceptance-tests/tests/build.gradle
@@ -31,6 +31,7 @@ dependencies {
api 'org.slf4j:slf4j-api'
implementation project(':crypto:algorithms')
+ implementation project(':ethereum:eth')
testImplementation project(':acceptance-tests:dsl')
testImplementation project(':acceptance-tests:test-plugins')
@@ -42,6 +43,7 @@ dependencies {
testImplementation project(':ethereum:api')
testImplementation project(':ethereum:core')
testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')
+ testImplementation project(':ethereum:eth')
testImplementation project(':ethereum:p2p')
testImplementation project(':ethereum:permissioning')
testImplementation project(':ethereum:rlp')
@@ -78,6 +80,8 @@ dependencies {
testImplementation 'org.web3j:besu'
testImplementation 'org.web3j:core'
testImplementation 'org.wiremock:wiremock'
+ testImplementation 'com.google.dagger:dagger'
+ testAnnotationProcessor 'com.google.dagger:dagger-compiler'
testImplementation project(path: ':acceptance-tests:tests:shanghai')
}
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java
index 1e741a5cc6..177987aaaf 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java
@@ -17,9 +17,9 @@ package org.hyperledger.besu.tests.acceptance.bft;
import org.hyperledger.besu.config.JsonUtil;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.AddressHelpers;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.account.Account;
import org.hyperledger.besu.tests.acceptance.dsl.blockchain.Amount;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
@@ -62,8 +62,8 @@ public class BftMiningAcceptanceTest extends ParameterizedBftTestBase {
final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception {
setUp(testName, nodeFactory);
final BesuNode minerNode = nodeFactory.createNode(besu, "miner1");
- final MiningParameters zeroGasMiningParams =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration zeroGasMiningParams =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/MetricsPluginTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/MetricsPluginTest.java
new file mode 100644
index 0000000000..7559200720
--- /dev/null
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/MetricsPluginTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright contributors to Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.tests.acceptance.plugins;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.hyperledger.besu.tests.acceptance.plugins.TestMetricsPlugin.TestMetricCategory.TEST_METRIC_CATEGORY;
+
+import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
+import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
+import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class MetricsPluginTest extends AcceptanceTestBase {
+ private BesuNode node;
+ private MetricsConfiguration metricsConfiguration;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ metricsConfiguration =
+ MetricsConfiguration.builder()
+ .enabled(true)
+ .port(0)
+ .metricCategories(Set.of(TEST_METRIC_CATEGORY))
+ .build();
+ node =
+ besu.create(
+ new BesuNodeConfigurationBuilder()
+ .name("node1")
+ .plugins(List.of("testPlugins"))
+ .metricsConfiguration(metricsConfiguration)
+ .build());
+
+ cluster.start(node);
+ }
+
+ @Test
+ public void metricCategoryAdded() throws IOException, InterruptedException {
+ final var httpClient = HttpClient.newHttpClient();
+ final var req = HttpRequest.newBuilder(URI.create(node.metricsHttpUrl().get())).build();
+ final var resp = httpClient.send(req, HttpResponse.BodyHandlers.ofLines());
+ assertThat(resp.statusCode()).isEqualTo(200);
+ final var foundMetric =
+ resp.body()
+ .filter(
+ line -> line.startsWith(TEST_METRIC_CATEGORY.getApplicationPrefix().orElseThrow()))
+ .findFirst()
+ .orElseThrow();
+ assertThat(foundMetric).endsWith("1.0");
+ }
+}
diff --git a/besu/build.gradle b/besu/build.gradle
index 41a4b11494..b6e506d9c1 100644
--- a/besu/build.gradle
+++ b/besu/build.gradle
@@ -49,7 +49,6 @@ dependencies {
implementation project(':ethereum:eth')
implementation project(':ethereum:p2p')
implementation project(':ethereum:permissioning')
- implementation project(':ethereum:retesteth')
implementation project(':ethereum:rlp')
implementation project(':ethereum:trie')
implementation project(':ethereum:stratum')
diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
index 96eef547fe..06dca6c6f0 100644
--- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
@@ -23,7 +23,7 @@ import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIV
import org.hyperledger.besu.cli.config.EthNetworkConfig;
import org.hyperledger.besu.cli.config.NetworkName;
-import org.hyperledger.besu.cli.options.stable.EthstatsOptions;
+import org.hyperledger.besu.cli.options.EthstatsOptions;
import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.ethereum.ProtocolContext;
@@ -70,7 +70,7 @@ import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
@@ -773,7 +773,7 @@ public class RunnerBuilder {
final TransactionPool transactionPool = besuController.getTransactionPool();
final MiningCoordinator miningCoordinator = besuController.getMiningCoordinator();
- final MiningParameters miningParameters = besuController.getMiningParameters();
+ final MiningConfiguration miningConfiguration = besuController.getMiningParameters();
final BlockchainQueries blockchainQueries =
new BlockchainQueries(
@@ -783,7 +783,7 @@ public class RunnerBuilder {
Optional.of(dataDir.resolve(CACHE_PATH)),
Optional.of(besuController.getProtocolManager().ethContext().getScheduler()),
apiConfiguration,
- miningParameters);
+ miningConfiguration);
final PrivacyParameters privacyParameters = besuController.getPrivacyParameters();
@@ -802,7 +802,7 @@ public class RunnerBuilder {
Optional stratumServer = Optional.empty();
- if (miningParameters.isStratumMiningEnabled()) {
+ if (miningConfiguration.isStratumMiningEnabled()) {
if (!(miningCoordinator instanceof PoWMiningCoordinator powMiningCoordinator)) {
throw new IllegalArgumentException(
"Stratum mining requires the network option(--network) to be set to CLASSIC. Stratum server requires a PoWMiningCoordinator not "
@@ -813,9 +813,9 @@ public class RunnerBuilder {
new StratumServer(
vertx,
powMiningCoordinator,
- miningParameters.getStratumPort(),
- miningParameters.getStratumNetworkInterface(),
- miningParameters.getUnstable().getStratumExtranonce(),
+ miningConfiguration.getStratumPort(),
+ miningConfiguration.getStratumNetworkInterface(),
+ miningConfiguration.getUnstable().getStratumExtranonce(),
metricsSystem));
miningCoordinator.addEthHashObserver(stratumServer.get());
LOG.debug("added ethash observer: {}", stratumServer.get());
@@ -849,7 +849,7 @@ public class RunnerBuilder {
blockchainQueries,
synchronizer,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
@@ -896,7 +896,7 @@ public class RunnerBuilder {
blockchainQueries,
synchronizer,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
@@ -989,7 +989,7 @@ public class RunnerBuilder {
blockchainQueries,
synchronizer,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
@@ -1070,7 +1070,7 @@ public class RunnerBuilder {
blockchainQueries,
synchronizer,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
@@ -1111,7 +1111,7 @@ public class RunnerBuilder {
blockchainQueries,
synchronizer,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
@@ -1273,7 +1273,7 @@ public class RunnerBuilder {
final BlockchainQueries blockchainQueries,
final Synchronizer synchronizer,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final MiningCoordinator miningCoordinator,
final ObservableMetricsSystem metricsSystem,
final Set supportedCapabilities,
@@ -1308,7 +1308,7 @@ public class RunnerBuilder {
protocolContext,
filterManager,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
index 886e3d6838..1a842acc58 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
@@ -37,45 +37,43 @@ import org.hyperledger.besu.chainimport.RlpBlockImporter;
import org.hyperledger.besu.cli.config.EthNetworkConfig;
import org.hyperledger.besu.cli.config.NetworkName;
import org.hyperledger.besu.cli.config.ProfilesCompletionCandidates;
-import org.hyperledger.besu.cli.converter.MetricCategoryConverter;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
import org.hyperledger.besu.cli.error.BesuExecutionExceptionHandler;
import org.hyperledger.besu.cli.error.BesuParameterExceptionHandler;
+import org.hyperledger.besu.cli.options.ApiConfigurationOptions;
+import org.hyperledger.besu.cli.options.ChainPruningOptions;
+import org.hyperledger.besu.cli.options.DnsOptions;
+import org.hyperledger.besu.cli.options.EngineRPCConfiguration;
+import org.hyperledger.besu.cli.options.EngineRPCOptions;
+import org.hyperledger.besu.cli.options.EthProtocolOptions;
+import org.hyperledger.besu.cli.options.EthstatsOptions;
+import org.hyperledger.besu.cli.options.EvmOptions;
+import org.hyperledger.besu.cli.options.GraphQlOptions;
+import org.hyperledger.besu.cli.options.InProcessRpcOptions;
+import org.hyperledger.besu.cli.options.IpcOptions;
+import org.hyperledger.besu.cli.options.JsonRpcHttpOptions;
+import org.hyperledger.besu.cli.options.LoggingLevelOption;
+import org.hyperledger.besu.cli.options.MetricsOptions;
import org.hyperledger.besu.cli.options.MiningOptions;
+import org.hyperledger.besu.cli.options.NatOptions;
+import org.hyperledger.besu.cli.options.NativeLibraryOptions;
+import org.hyperledger.besu.cli.options.NetworkingOptions;
+import org.hyperledger.besu.cli.options.NodePrivateKeyFileOption;
+import org.hyperledger.besu.cli.options.P2PDiscoveryOptions;
+import org.hyperledger.besu.cli.options.P2PTLSConfigOptions;
+import org.hyperledger.besu.cli.options.PermissionsOptions;
+import org.hyperledger.besu.cli.options.PluginsConfigurationOptions;
+import org.hyperledger.besu.cli.options.PrivacyPluginOptions;
+import org.hyperledger.besu.cli.options.RPCOptions;
+import org.hyperledger.besu.cli.options.RpcWebsocketOptions;
+import org.hyperledger.besu.cli.options.SynchronizerOptions;
import org.hyperledger.besu.cli.options.TransactionPoolOptions;
-import org.hyperledger.besu.cli.options.stable.ApiConfigurationOptions;
-import org.hyperledger.besu.cli.options.stable.EngineRPCConfiguration;
-import org.hyperledger.besu.cli.options.stable.EngineRPCOptions;
-import org.hyperledger.besu.cli.options.stable.EthstatsOptions;
-import org.hyperledger.besu.cli.options.stable.GraphQlOptions;
-import org.hyperledger.besu.cli.options.stable.JsonRpcHttpOptions;
-import org.hyperledger.besu.cli.options.stable.LoggingLevelOption;
-import org.hyperledger.besu.cli.options.stable.MetricsOptions;
-import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption;
-import org.hyperledger.besu.cli.options.stable.P2PDiscoveryOptions;
-import org.hyperledger.besu.cli.options.stable.PermissionsOptions;
-import org.hyperledger.besu.cli.options.stable.PluginsConfigurationOptions;
-import org.hyperledger.besu.cli.options.stable.RpcWebsocketOptions;
import org.hyperledger.besu.cli.options.storage.DataStorageOptions;
import org.hyperledger.besu.cli.options.storage.DiffBasedSubStorageOptions;
-import org.hyperledger.besu.cli.options.unstable.ChainPruningOptions;
-import org.hyperledger.besu.cli.options.unstable.DnsOptions;
-import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
-import org.hyperledger.besu.cli.options.unstable.EvmOptions;
-import org.hyperledger.besu.cli.options.unstable.InProcessRpcOptions;
-import org.hyperledger.besu.cli.options.unstable.IpcOptions;
-import org.hyperledger.besu.cli.options.unstable.NatOptions;
-import org.hyperledger.besu.cli.options.unstable.NativeLibraryOptions;
-import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
-import org.hyperledger.besu.cli.options.unstable.P2PTLSConfigOptions;
-import org.hyperledger.besu.cli.options.unstable.PrivacyPluginOptions;
-import org.hyperledger.besu.cli.options.unstable.RPCOptions;
-import org.hyperledger.besu.cli.options.unstable.SynchronizerOptions;
import org.hyperledger.besu.cli.presynctasks.PreSynchronizationTaskRunner;
import org.hyperledger.besu.cli.presynctasks.PrivateDatabaseMigrationPreSyncTask;
import org.hyperledger.besu.cli.subcommands.PasswordSubCommand;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand;
-import org.hyperledger.besu.cli.subcommands.RetestethSubCommand;
import org.hyperledger.besu.cli.subcommands.TxParseSubCommand;
import org.hyperledger.besu.cli.subcommands.ValidateConfigSubCommand;
import org.hyperledger.besu.cli.subcommands.blocks.BlocksSubCommand;
@@ -115,7 +113,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.Blockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MiningParametersMetrics;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.VersionMetadata;
@@ -170,8 +168,8 @@ import org.hyperledger.besu.plugin.services.TransactionPoolValidatorService;
import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.plugin.services.TransactionSimulationService;
import org.hyperledger.besu.plugin.services.exception.StorageException;
-import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry;
+import org.hyperledger.besu.plugin.services.mining.MiningService;
import org.hyperledger.besu.plugin.services.p2p.P2PService;
import org.hyperledger.besu.plugin.services.rlp.RlpConverterService;
import org.hyperledger.besu.plugin.services.securitymodule.SecurityModule;
@@ -184,6 +182,7 @@ import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuEventsImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.BlockchainServiceImpl;
+import org.hyperledger.besu.services.MiningServiceImpl;
import org.hyperledger.besu.services.P2PServiceImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PicoCLIOptionsImpl;
@@ -332,7 +331,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final Map environment;
private final MetricCategoryRegistryImpl metricCategoryRegistry =
new MetricCategoryRegistryImpl();
- private final MetricCategoryConverter metricCategoryConverter = new MetricCategoryConverter();
private final PreSynchronizationTaskRunner preSynchronizationTaskRunner =
new PreSynchronizationTaskRunner();
@@ -342,7 +340,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
Suppliers.memoize(this::readGenesisConfigFile);
private final Supplier genesisConfigOptionsSupplier =
Suppliers.memoize(this::readGenesisConfigOptions);
- private final Supplier miningParametersSupplier =
+ private final Supplier miningParametersSupplier =
Suppliers.memoize(this::getMiningParameters);
private RocksDBPlugin rocksDBPlugin;
@@ -509,77 +507,95 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
@CommandLine.ArgGroup(validate = false, heading = "@|bold In-Process RPC Options|@%n")
InProcessRpcOptions inProcessRpcOptions = InProcessRpcOptions.create();
+ private static final String PRIVACY_DEPRECATION_PREFIX =
+ "Deprecated. Tessera-based privacy is deprecated. See CHANGELOG for alternative options. ";
+
// Privacy Options Group
- @CommandLine.ArgGroup(validate = false, heading = "@|bold Privacy Options|@%n")
+ @CommandLine.ArgGroup(validate = false, heading = "@|bold (Deprecated) Privacy Options |@%n")
PrivacyOptionGroup privacyOptionGroup = new PrivacyOptionGroup();
static class PrivacyOptionGroup {
@Option(
names = {"--privacy-tls-enabled"},
paramLabel = MANDATORY_FILE_FORMAT_HELP,
- description = "Enable TLS for connecting to privacy enclave (default: ${DEFAULT-VALUE})")
+ description =
+ PRIVACY_DEPRECATION_PREFIX
+ + "Enable TLS for connecting to privacy enclave (default: ${DEFAULT-VALUE})")
private final Boolean isPrivacyTlsEnabled = false;
@Option(
names = "--privacy-tls-keystore-file",
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description =
- "Path to a PKCS#12 formatted keystore; used to enable TLS on inbound connections.")
+ PRIVACY_DEPRECATION_PREFIX
+ + "Path to a PKCS#12 formatted keystore; used to enable TLS on inbound connections.")
private final Path privacyKeyStoreFile = null;
@Option(
names = "--privacy-tls-keystore-password-file",
paramLabel = MANDATORY_FILE_FORMAT_HELP,
- description = "Path to a file containing the password used to decrypt the keystore.")
+ description =
+ PRIVACY_DEPRECATION_PREFIX
+ + "Path to a file containing the password used to decrypt the keystore.")
private final Path privacyKeyStorePasswordFile = null;
@Option(
names = "--privacy-tls-known-enclave-file",
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description =
- "Path to a file containing the fingerprints of the authorized privacy enclave.")
+ PRIVACY_DEPRECATION_PREFIX
+ + "Path to a file containing the fingerprints of the authorized privacy enclave.")
private final Path privacyTlsKnownEnclaveFile = null;
@Option(
names = {"--privacy-enabled"},
- description = "Enable private transactions (default: ${DEFAULT-VALUE})")
+ description =
+ PRIVACY_DEPRECATION_PREFIX + "Enable private transactions (default: ${DEFAULT-VALUE})")
private final Boolean isPrivacyEnabled = false;
@Option(
names = {"--privacy-multi-tenancy-enabled"},
- description = "Enable multi-tenant private transactions (default: ${DEFAULT-VALUE})")
+ description =
+ PRIVACY_DEPRECATION_PREFIX
+ + "Enable multi-tenant private transactions (default: ${DEFAULT-VALUE})")
private final Boolean isPrivacyMultiTenancyEnabled = false;
@Option(
names = {"--privacy-url"},
- description = "The URL on which the enclave is running")
+ description = PRIVACY_DEPRECATION_PREFIX + "The URL on which the enclave is running")
private final URI privacyUrl = PrivacyParameters.DEFAULT_ENCLAVE_URL;
@Option(
names = {"--privacy-public-key-file"},
- description = "The enclave's public key file")
+ description = PRIVACY_DEPRECATION_PREFIX + "The enclave's public key file")
private final File privacyPublicKeyFile = null;
@Option(
names = {"--privacy-marker-transaction-signing-key-file"},
description =
- "The name of a file containing the private key used to sign privacy marker transactions. If unset, each will be signed with a random key.")
+ PRIVACY_DEPRECATION_PREFIX
+ + "The name of a file containing the private key used to sign privacy marker transactions. If unset, each will be signed with a random key.")
private final Path privateMarkerTransactionSigningKeyPath = null;
@Option(
names = {"--privacy-enable-database-migration"},
- description = "Enable private database metadata migration (default: ${DEFAULT-VALUE})")
+ description =
+ PRIVACY_DEPRECATION_PREFIX
+ + "Enable private database metadata migration (default: ${DEFAULT-VALUE})")
private final Boolean migratePrivateDatabase = false;
@Option(
names = {"--privacy-flexible-groups-enabled"},
- description = "Enable flexible privacy groups (default: ${DEFAULT-VALUE})")
+ description =
+ PRIVACY_DEPRECATION_PREFIX
+ + "Enable flexible privacy groups (default: ${DEFAULT-VALUE})")
private final Boolean isFlexiblePrivacyGroupsEnabled = false;
@Option(
names = {"--privacy-nonce-always-increments"},
description =
- "Enable private nonce "
+ PRIVACY_DEPRECATION_PREFIX
+ + "Enable private nonce "
+ "incrementation even if the transaction didn't succeeded (default: ${DEFAULT-VALUE})")
private final Boolean isPrivateNonceAlwaysIncrementsEnabled = false;
}
@@ -1108,7 +1124,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
PublicKeySubCommand.COMMAND_NAME, new PublicKeySubCommand(commandLine.getOut()));
commandLine.addSubcommand(
PasswordSubCommand.COMMAND_NAME, new PasswordSubCommand(commandLine.getOut()));
- commandLine.addSubcommand(RetestethSubCommand.COMMAND_NAME, new RetestethSubCommand());
commandLine.addSubcommand(
RLPSubCommand.COMMAND_NAME, new RLPSubCommand(commandLine.getOut(), in));
commandLine.addSubcommand(
@@ -1136,10 +1151,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
commandLine.registerConverter(Hash.class, Hash::fromHexString);
commandLine.registerConverter(Optional.class, Optional::of);
commandLine.registerConverter(Double.class, Double::parseDouble);
-
- metricCategoryConverter.addCategories(BesuMetricCategory.class);
- metricCategoryConverter.addCategories(StandardMetricCategory.class);
- commandLine.registerConverter(MetricCategory.class, metricCategoryConverter);
}
private void handleStableOptions() {
@@ -1174,6 +1185,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
besuPluginContext.addService(PicoCLIOptions.class, new PicoCLIOptionsImpl(commandLine));
besuPluginContext.addService(SecurityModuleService.class, securityModuleService);
besuPluginContext.addService(StorageService.class, storageService);
+
+ metricCategoryRegistry.addCategories(BesuMetricCategory.class);
+ metricCategoryRegistry.addCategories(StandardMetricCategory.class);
besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry);
besuPluginContext.addService(PermissioningService.class, permissioningService);
besuPluginContext.addService(PrivacyPluginService.class, privacyPluginService);
@@ -1191,10 +1205,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
rocksDBPlugin.register(besuPluginContext);
new InMemoryStoragePlugin().register(besuPluginContext);
- metricCategoryRegistry
- .getMetricCategories()
- .forEach(metricCategoryConverter::addRegistryCategory);
-
// register default security module
securityModuleService.register(
DEFAULT_SECURITY_MODULE, Suppliers.memoize(this::defaultSecurityModule));
@@ -1243,7 +1253,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private void startPlugins(final Runner runner) {
blockchainServiceImpl.init(
- besuController.getProtocolContext(), besuController.getProtocolSchedule());
+ besuController.getProtocolContext().getBlockchain(), besuController.getProtocolSchedule());
transactionSimulationServiceImpl.init(
besuController.getProtocolContext().getBlockchain(),
new TransactionSimulator(
@@ -1293,6 +1303,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
miningParametersSupplier.get()),
besuController.getProtocolSchedule()));
+ besuPluginContext.addService(
+ MiningService.class, new MiningServiceImpl(besuController.getMiningCoordinator()));
+
besuController.getAdditionalPluginServices().appendPluginServices(besuPluginContext);
besuPluginContext.startPlugins();
}
@@ -1303,6 +1316,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
// after start has been called on plugins
if (Boolean.TRUE.equals(privacyOptionGroup.isPrivacyEnabled)) {
+ logger.warn(
+ "--Xprivacy-plugin-enabled and related options are " + PRIVACY_DEPRECATION_PREFIX);
if (privacyOptionGroup.privateMarkerTransactionSigningKeyPath != null
&& privacyPluginService != null
@@ -1342,7 +1357,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private void setReleaseMetrics() {
besuComponent
.getMetricsSystem()
- .createLabelledGauge(
+ .createLabelledSuppliedGauge(
StandardMetricCategory.PROCESS, "release", "Release information", "version")
.labels(() -> 1, BesuInfo.version());
}
@@ -1891,6 +1906,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
"--metrics-push-interval",
"--metrics-push-prometheus-job"));
+ metricsOptions.setMetricCategoryRegistry(metricCategoryRegistry);
+
+ metricsOptions.validate(commandLine);
+
final MetricsConfiguration.Builder metricsConfigurationBuilder =
metricsOptions.toDomainObject();
metricsConfigurationBuilder
@@ -1903,7 +1922,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
? p2PDiscoveryOptions.autoDiscoverDefaultIP().getHostAddress()
: metricsOptions.getMetricsPushHost())
.hostsAllowlist(hostsAllowlist);
- return metricsConfigurationBuilder.build();
+ final var metricsConfiguration = metricsConfigurationBuilder.build();
+ metricCategoryRegistry.setMetricsConfiguration(metricsConfiguration);
+ return metricsConfiguration;
}
private PrivacyParameters privacyParameters() {
@@ -1926,6 +1947,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
final PrivacyParameters.Builder privacyParametersBuilder = new PrivacyParameters.Builder();
if (Boolean.TRUE.equals(privacyOptionGroup.isPrivacyEnabled)) {
+ logger.warn("--privacy-enabled and related options are " + PRIVACY_DEPRECATION_PREFIX);
final String errorSuffix = "cannot be enabled with privacy.";
if (syncMode == SyncMode.FAST) {
throw new ParameterException(commandLine, String.format("%s %s", "Fast sync", errorSuffix));
@@ -2121,7 +2143,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return txPoolConfBuilder.build();
}
- private MiningParameters getMiningParameters() {
+ private MiningConfiguration getMiningParameters() {
miningOptions.setTransactionSelectionService(transactionSelectionServiceImpl);
final var miningParameters = miningOptions.toDomainObject();
getGenesisBlockPeriodSeconds(genesisConfigOptionsSupplier.get())
@@ -2173,8 +2195,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return dataStorageConfiguration;
}
- private void initMiningParametersMetrics(final MiningParameters miningParameters) {
- new MiningParametersMetrics(getMetricsSystem(), miningParameters);
+ private void initMiningParametersMetrics(final MiningConfiguration miningConfiguration) {
+ new MiningParametersMetrics(getMetricsSystem(), miningConfiguration);
}
private OptionalInt getGenesisBlockPeriodSeconds(
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java
index b3dfa2a054..a7b43d0d9e 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java
@@ -433,14 +433,18 @@ public class ConfigurationOverviewBuilder {
private void detectJemalloc(final List lines) {
Optional.ofNullable(Objects.isNull(environment) ? null : environment.get("BESU_USING_JEMALLOC"))
.ifPresentOrElse(
- t -> {
+ jemallocEnabled -> {
try {
- final String version = PlatformDetector.getJemalloc();
- lines.add("jemalloc: " + version);
+ if (Boolean.parseBoolean(jemallocEnabled)) {
+ final String version = PlatformDetector.getJemalloc();
+ lines.add("jemalloc: " + version);
+ } else {
+ logger.warn(
+ "besu_using_jemalloc is present but is not set to true, jemalloc library not loaded");
+ }
} catch (final Throwable throwable) {
logger.warn(
- "BESU_USING_JEMALLOC is present but we failed to load jemalloc library to get the version",
- throwable);
+ "besu_using_jemalloc is present but we failed to load jemalloc library to get the version");
}
},
() -> {
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java
deleted file mode 100644
index 339da86b2d..0000000000
--- a/besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright ConsenSys AG.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package org.hyperledger.besu.cli.converter;
-
-import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import com.google.common.annotations.VisibleForTesting;
-import picocli.CommandLine;
-
-/** The Metric category converter for CLI options. */
-public class MetricCategoryConverter implements CommandLine.ITypeConverter {
-
- private final Map metricCategories = new HashMap<>();
-
- /** Default Constructor. */
- public MetricCategoryConverter() {}
-
- @Override
- public MetricCategory convert(final String value) {
- final MetricCategory category = metricCategories.get(value);
- if (category == null) {
- throw new IllegalArgumentException("Unknown category: " + value);
- }
- return category;
- }
-
- /**
- * Add Metrics categories.
- *
- * @param the type parameter
- * @param categoryEnum the category enum
- */
- public & MetricCategory> void addCategories(final Class categoryEnum) {
- EnumSet.allOf(categoryEnum)
- .forEach(category -> metricCategories.put(category.name(), category));
- }
-
- /**
- * Add registry category.
- *
- * @param metricCategory the metric category
- */
- public void addRegistryCategory(final MetricCategory metricCategory) {
- metricCategories.put(metricCategory.getName().toUpperCase(Locale.ROOT), metricCategory);
- }
-
- /**
- * Gets metric categories.
- *
- * @return the metric categories
- */
- @VisibleForTesting
- Map getMetricCategories() {
- return metricCategories;
- }
-}
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java
similarity index 99%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java
index d6bc17026c..c5954f5063 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/ChainPruningOptions.java
similarity index 98%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/ChainPruningOptions.java
index 0a59ef9b04..3f26b676ce 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/ChainPruningOptions.java
@@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethereum.chain.ChainPrunerConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/DnsOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/DnsOptions.java
index 9f9670e8e6..9a720bebbb 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/DnsOptions.java
@@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.ImmutableEnodeDnsConfiguration;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCConfiguration.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCConfiguration.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCConfiguration.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCConfiguration.java
index c0eb9d1be0..ec98204d3b 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCConfiguration.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCConfiguration.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCOptions.java
index 1aa5b3d326..e660e6c821 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCOptions.java
@@ -12,13 +12,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_ENGINE_JSON_RPC_PORT;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import java.nio.file.Path;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EthProtocolOptions.java
similarity index 97%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/EthProtocolOptions.java
index 1d5434ff02..a20403027d 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EthProtocolOptions.java
@@ -12,10 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
-import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EthstatsOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/EthstatsOptions.java
index a6e939fdf0..08e8b49c52 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EthstatsOptions.java
@@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethstats.util.EthStatsConnectOptions;
import java.nio.file.Path;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EvmOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/EvmOptions.java
index 39d95324df..6a58d6830a 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EvmOptions.java
@@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.util.List;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/GraphQlOptions.java
similarity index 98%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/GraphQlOptions.java
index 6aac24a6fb..643ca22e00 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/GraphQlOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
import static org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_PORT;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/InProcessRpcOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/InProcessRpcOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/InProcessRpcOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/InProcessRpcOptions.java
index 9adeb37db7..278a55e187 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/InProcessRpcOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/InProcessRpcOptions.java
@@ -12,12 +12,11 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration.DEFAULT_IN_PROCESS_RPC_APIS;
import static org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration.DEFAULT_IN_PROCESS_RPC_ENABLED;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.api.jsonrpc.ImmutableInProcessRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/IpcOptions.java
similarity index 98%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/IpcOptions.java
index 19ba294193..689ac4e9b3 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/IpcOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/JsonRpcHttpOptions.java
similarity index 99%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/JsonRpcHttpOptions.java
index 7d08a6f9aa..c8c2c73344 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/JsonRpcHttpOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_HOST;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java b/besu/src/main/java/org/hyperledger/besu/cli/options/LoggingLevelOption.java
similarity index 97%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/LoggingLevelOption.java
index 39b2a2482b..1a498fd196 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/LoggingLevelOption.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import java.util.Locale;
import java.util.Set;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/MetricsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/MetricsOptions.java
similarity index 83%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/MetricsOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/MetricsOptions.java
index 4906cf538e..1f777286bf 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/MetricsOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/MetricsOptions.java
@@ -12,8 +12,10 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.stream.Collectors.toUnmodifiableSet;
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;
@@ -22,8 +24,8 @@ import static org.hyperledger.besu.metrics.MetricsProtocol.PROMETHEUS;
import static org.hyperledger.besu.metrics.prometheus.MetricsConfiguration.DEFAULT_METRICS_PORT;
import static org.hyperledger.besu.metrics.prometheus.MetricsConfiguration.DEFAULT_METRICS_PUSH_PORT;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
+import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl;
import org.hyperledger.besu.metrics.MetricsProtocol;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
@@ -36,6 +38,7 @@ import picocli.CommandLine;
/** Command line options for configuring metrics. */
// TODO: implement CLIOption
public class MetricsOptions implements CLIOptions {
+ private MetricCategoryRegistryImpl metricCategoryRegistry;
/**
* Returns a MetricsConfiguration.Builder because fields are often overridden from other domains,
@@ -77,7 +80,10 @@ public class MetricsOptions implements CLIOptions
metricsOptions.metricsHost = config.getHost();
metricsOptions.metricsPort = config.getPort();
metricsOptions.metricsProtocol = config.getProtocol();
- metricsOptions.metricCategories = config.getMetricCategories();
+ metricsOptions.metricCategories =
+ config.getMetricCategories().stream()
+ .map(MetricCategory::getName)
+ .collect(toUnmodifiableSet());
metricsOptions.metricsPrometheusJob = config.getPrometheusJob();
metricsOptions.isMetricsPushEnabled = config.isPushEnabled();
metricsOptions.metricsPushHost = config.getPushHost();
@@ -126,7 +132,8 @@ public class MetricsOptions implements CLIOptions
arity = "1..*",
description =
"Comma separated list of categories to track metrics for (default: ${DEFAULT-VALUE})")
- private Set metricCategories = DEFAULT_METRIC_CATEGORIES;
+ private Set metricCategories =
+ DEFAULT_METRIC_CATEGORIES.stream().map(MetricCategory::getName).collect(toUnmodifiableSet());
@CommandLine.Option(
names = {"--metrics-push-enabled"},
@@ -216,7 +223,13 @@ public class MetricsOptions implements CLIOptions
* @return the metric categories
*/
public Set getMetricCategories() {
- return metricCategories;
+ checkState(
+ metricCategoryRegistry != null, "Set metricCategoryRegistry before calling this method");
+
+ final var list =
+ metricCategories.stream().map(metricCategoryRegistry::getMetricCategory).toList();
+
+ return Set.copyOf(list);
}
/**
@@ -264,6 +277,33 @@ public class MetricsOptions implements CLIOptions
return metricsPrometheusJob;
}
+ /**
+ * Perform final validation after all the options, and the metric category registry, have been set
+ *
+ * @param commandLine the command line
+ */
+ public void validate(final CommandLine commandLine) {
+ checkState(
+ metricCategoryRegistry != null, "Set metricCategoryRegistry before calling this method");
+ final var unknownCategories =
+ metricCategories.stream()
+ .filter(category -> !metricCategoryRegistry.containsMetricCategory(category))
+ .toList();
+ if (!unknownCategories.isEmpty()) {
+ throw new CommandLine.ParameterException(
+ commandLine, "--metrics-categories contains unknown categories: " + unknownCategories);
+ }
+ }
+
+ /**
+ * Set the metric category registry in order to support verification and conversion
+ *
+ * @param metricCategoryRegistry the metric category registry
+ */
+ public void setMetricCategoryRegistry(final MetricCategoryRegistryImpl metricCategoryRegistry) {
+ this.metricCategoryRegistry = metricCategoryRegistry;
+ }
+
@CommandLine.ArgGroup(validate = false)
private final MetricsOptions.Unstable unstableOptions = new MetricsOptions.Unstable();
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java
index a884edfe33..fa0cf4dc06 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java
@@ -17,27 +17,27 @@ package org.hyperledger.besu.cli.options;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_EXTRA_DATA;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_PRIORITY_FEE_PER_GAS;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_MAX_OMMERS_DEPTH;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POW_JOB_TTL;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_TTL;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_EXTRA_DATA;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_PRIORITY_FEE_PER_GAS;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_MAX_OMMERS_DEPTH;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POW_JOB_TTL;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_TTL;
import org.hyperledger.besu.cli.converter.PositiveNumberConverter;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.util.number.PositiveNumber;
@@ -50,7 +50,7 @@ import picocli.CommandLine.Option;
import picocli.CommandLine.ParameterException;
/** The Mining CLI options. */
-public class MiningOptions implements CLIOptions {
+public class MiningOptions implements CLIOptions {
@Option(
names = {"--miner-enabled"},
@@ -300,43 +300,45 @@ public class MiningOptions implements CLIOptions {
}
}
- static MiningOptions fromConfig(final MiningParameters miningParameters) {
+ static MiningOptions fromConfig(final MiningConfiguration miningConfiguration) {
final MiningOptions miningOptions = MiningOptions.create();
- miningOptions.setTransactionSelectionService(miningParameters.getTransactionSelectionService());
- miningOptions.isMiningEnabled = miningParameters.isMiningEnabled();
- miningOptions.iStratumMiningEnabled = miningParameters.isStratumMiningEnabled();
- miningOptions.stratumNetworkInterface = miningParameters.getStratumNetworkInterface();
- miningOptions.stratumPort = miningParameters.getStratumPort();
- miningOptions.extraData = miningParameters.getExtraData();
- miningOptions.minTransactionGasPrice = miningParameters.getMinTransactionGasPrice();
- miningOptions.minPriorityFeePerGas = miningParameters.getMinPriorityFeePerGas();
- miningOptions.minBlockOccupancyRatio = miningParameters.getMinBlockOccupancyRatio();
+ miningOptions.setTransactionSelectionService(
+ miningConfiguration.getTransactionSelectionService());
+ miningOptions.isMiningEnabled = miningConfiguration.isMiningEnabled();
+ miningOptions.iStratumMiningEnabled = miningConfiguration.isStratumMiningEnabled();
+ miningOptions.stratumNetworkInterface = miningConfiguration.getStratumNetworkInterface();
+ miningOptions.stratumPort = miningConfiguration.getStratumPort();
+ miningOptions.extraData = miningConfiguration.getExtraData();
+ miningOptions.minTransactionGasPrice = miningConfiguration.getMinTransactionGasPrice();
+ miningOptions.minPriorityFeePerGas = miningConfiguration.getMinPriorityFeePerGas();
+ miningOptions.minBlockOccupancyRatio = miningConfiguration.getMinBlockOccupancyRatio();
miningOptions.nonPoaBlockTxsSelectionMaxTime =
- miningParameters.getNonPoaBlockTxsSelectionMaxTime();
- miningOptions.poaBlockTxsSelectionMaxTime = miningParameters.getPoaBlockTxsSelectionMaxTime();
+ miningConfiguration.getNonPoaBlockTxsSelectionMaxTime();
+ miningOptions.poaBlockTxsSelectionMaxTime =
+ miningConfiguration.getPoaBlockTxsSelectionMaxTime();
miningOptions.unstableOptions.remoteSealersLimit =
- miningParameters.getUnstable().getRemoteSealersLimit();
+ miningConfiguration.getUnstable().getRemoteSealersLimit();
miningOptions.unstableOptions.remoteSealersTimeToLive =
- miningParameters.getUnstable().getRemoteSealersTimeToLive();
+ miningConfiguration.getUnstable().getRemoteSealersTimeToLive();
miningOptions.unstableOptions.powJobTimeToLive =
- miningParameters.getUnstable().getPowJobTimeToLive();
+ miningConfiguration.getUnstable().getPowJobTimeToLive();
miningOptions.unstableOptions.maxOmmersDepth =
- miningParameters.getUnstable().getMaxOmmerDepth();
+ miningConfiguration.getUnstable().getMaxOmmerDepth();
miningOptions.unstableOptions.stratumExtranonce =
- miningParameters.getUnstable().getStratumExtranonce();
+ miningConfiguration.getUnstable().getStratumExtranonce();
miningOptions.unstableOptions.posBlockCreationMaxTime =
- miningParameters.getUnstable().getPosBlockCreationMaxTime();
+ miningConfiguration.getUnstable().getPosBlockCreationMaxTime();
miningOptions.unstableOptions.posBlockCreationRepetitionMinDuration =
- miningParameters.getUnstable().getPosBlockCreationRepetitionMinDuration();
+ miningConfiguration.getUnstable().getPosBlockCreationRepetitionMinDuration();
- miningParameters.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase);
- miningParameters.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl);
+ miningConfiguration.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase);
+ miningConfiguration.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl);
return miningOptions;
}
@Override
- public MiningParameters toDomainObject() {
+ public MiningConfiguration toDomainObject() {
checkNotNull(
transactionSelectionService,
"transactionSelectionService must be set before using this object");
@@ -356,7 +358,7 @@ public class MiningOptions implements CLIOptions {
updatableInitValuesBuilder.coinbase(coinbase);
}
- return ImmutableMiningParameters.builder()
+ return ImmutableMiningConfiguration.builder()
.transactionSelectionService(transactionSelectionService)
.mutableInitValues(updatableInitValuesBuilder.build())
.isStratumMiningEnabled(iStratumMiningEnabled)
@@ -365,7 +367,7 @@ public class MiningOptions implements CLIOptions {
.nonPoaBlockTxsSelectionMaxTime(nonPoaBlockTxsSelectionMaxTime)
.poaBlockTxsSelectionMaxTime(poaBlockTxsSelectionMaxTime)
.unstable(
- ImmutableMiningParameters.Unstable.builder()
+ ImmutableMiningConfiguration.Unstable.builder()
.remoteSealersLimit(unstableOptions.remoteSealersLimit)
.remoteSealersTimeToLive(unstableOptions.remoteSealersTimeToLive)
.powJobTimeToLive(unstableOptions.powJobTimeToLive)
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NatOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NatOptions.java
similarity index 97%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NatOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/NatOptions.java
index 31716543d5..11e8051d0e 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NatOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NatOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.nat.kubernetes.KubernetesNatManager.DEFAULT_BESU_SERVICE_NAME_FILTER;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NativeLibraryOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NativeLibraryOptions.java
similarity index 98%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NativeLibraryOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/NativeLibraryOptions.java
index ec7f043b8f..f3fc9c3ba4 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NativeLibraryOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NativeLibraryOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import picocli.CommandLine;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NetworkingOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NetworkingOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NetworkingOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/NetworkingOptions.java
index aed7b079d8..dc001d0231 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NetworkingOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NetworkingOptions.java
@@ -12,10 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
-import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import java.util.Arrays;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NodePrivateKeyFileOption.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/NodePrivateKeyFileOption.java
index 107ced545d..781dcb06e8 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NodePrivateKeyFileOption.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PDiscoveryOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PDiscoveryOptions.java
similarity index 98%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PDiscoveryOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/P2PDiscoveryOptions.java
index a15be99dc7..798d246b52 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PDiscoveryOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PDiscoveryOptions.java
@@ -12,12 +12,11 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.converter.PercentageConverter;
import org.hyperledger.besu.cli.converter.SubnetInfoConverter;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/P2PTLSConfigOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PTLSConfigOptions.java
similarity index 99%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/P2PTLSConfigOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/P2PTLSConfigOptions.java
index 5939eb3d39..ee53a5e96f 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/P2PTLSConfigOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PTLSConfigOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_KEYSTORE_TYPE;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/PermissionsOptions.java
similarity index 99%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/PermissionsOptions.java
index 4dc693d36e..b6c744c98f 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/PermissionsOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.datatypes.Address;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/PluginsConfigurationOptions.java
similarity index 97%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/PluginsConfigurationOptions.java
index 25893fff89..5a5a064608 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/PluginsConfigurationOptions.java
@@ -12,14 +12,13 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_CONTINUE_ON_PLUGIN_ERROR_OPTION_NAME;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_EXTERNAL_ENABLED_OPTION_NAME;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_OPTION_NAME;
import org.hyperledger.besu.cli.converter.PluginInfoConverter;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginInfo;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/PrivacyPluginOptions.java
similarity index 82%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/PrivacyPluginOptions.java
index fe2f4df3fe..7842c09923 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/PrivacyPluginOptions.java
@@ -12,11 +12,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import static picocli.CommandLine.Option;
/** The Privacy plugin Cli options. */
+@Deprecated(since = "24.11.0")
public class PrivacyPluginOptions {
/** Default Constructor. */
PrivacyPluginOptions() {}
@@ -33,7 +34,7 @@ public class PrivacyPluginOptions {
@Option(
names = "--Xprivacy-plugin-enabled",
description =
- "Enables the use of a plugin to implement your own privacy strategy (default: ${DEFAULT-VALUE})",
+ "Deprecated. Tessera-based privacy is deprecated. See CHANGELOG for alternative options. Enables the use of a plugin to implement your own privacy strategy (default: ${DEFAULT-VALUE})",
hidden = true)
private final Boolean isPrivacyPluginEnabled = false;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/RPCOptions.java
similarity index 97%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/RPCOptions.java
index 2dd11f428d..63759af1c6 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/RPCOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java
similarity index 67%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java
index 40edeecc0d..2dde517ccc 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.VALID_APIS;
@@ -120,6 +120,71 @@ public class RpcWebsocketOptions {
arity = "1")
private final File rpcWsAuthenticationPublicKeyFile = null;
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-enabled"},
+ description = "Enable SSL/TLS for the WebSocket RPC service")
+ private final Boolean isRpcWsSslEnabled = false;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-keystore-file"},
+ paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP,
+ description = "Path to the keystore file for the WebSocket RPC service")
+ private String rpcWsKeyStoreFile = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-keystore-password"},
+ paramLabel = "",
+ description = "Password for the WebSocket RPC keystore file")
+ private String rpcWsKeyStorePassword = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-key-file"},
+ paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP,
+ description = "Path to the PEM key file for the WebSocket RPC service")
+ private String rpcWsKeyFile = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-cert-file"},
+ paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP,
+ description = "Path to the PEM cert file for the WebSocket RPC service")
+ private String rpcWsCertFile = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-keystore-type"},
+ paramLabel = "",
+ description = "Type of the WebSocket RPC keystore (JKS, PKCS12, PEM)")
+ private String rpcWsKeyStoreType = null;
+
+ // For client authentication (mTLS)
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-client-auth-enabled"},
+ description = "Enable client authentication for the WebSocket RPC service")
+ private final Boolean isRpcWsClientAuthEnabled = false;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-truststore-file"},
+ paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP,
+ description = "Path to the truststore file for the WebSocket RPC service")
+ private String rpcWsTrustStoreFile = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-truststore-password"},
+ paramLabel = "",
+ description = "Password for the WebSocket RPC truststore file")
+ private String rpcWsTrustStorePassword = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-trustcert-file"},
+ paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP,
+ description = "Path to the PEM trustcert file for the WebSocket RPC service")
+ private String rpcWsTrustCertFile = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-truststore-type"},
+ paramLabel = "",
+ description = "Type of the truststore (JKS, PKCS12, PEM)")
+ private String rpcWsTrustStoreType = null;
+
/** Default Constructor. */
public RpcWebsocketOptions() {}
@@ -184,7 +249,61 @@ public class RpcWebsocketOptions {
"--rpc-ws-authentication-enabled",
"--rpc-ws-authentication-credentials-file",
"--rpc-ws-authentication-public-key-file",
- "--rpc-ws-authentication-jwt-algorithm"));
+ "--rpc-ws-authentication-jwt-algorithm",
+ "--rpc-ws-ssl-enabled"));
+
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-enabled",
+ !isRpcWsSslEnabled,
+ List.of(
+ "--rpc-ws-ssl-keystore-file",
+ "--rpc-ws-ssl-keystore-type",
+ "--rpc-ws-ssl-client-auth-enabled"));
+
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-client-auth-enabled",
+ !isRpcWsClientAuthEnabled,
+ List.of(
+ "--rpc-ws-ssl-truststore-file",
+ "--rpc-ws-ssl-truststore-type",
+ "--rpc-ws-ssl-trustcert-file"));
+
+ if (isRpcWsSslEnabled) {
+ if ("PEM".equalsIgnoreCase(rpcWsKeyStoreType)) {
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-key-file",
+ rpcWsKeyFile == null,
+ List.of("--rpc-ws-ssl-cert-file"));
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-cert-file",
+ rpcWsCertFile == null,
+ List.of("--rpc-ws-ssl-key-file"));
+ } else {
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-keystore-file",
+ rpcWsKeyStoreFile == null,
+ List.of("--rpc-ws-ssl-keystore-password"));
+ }
+ }
+
+ if (isRpcWsClientAuthEnabled && !"PEM".equalsIgnoreCase(rpcWsTrustStoreType)) {
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-truststore-file",
+ rpcWsTrustStoreFile == null,
+ List.of("--rpc-ws-ssl-truststore-password"));
+ }
if (isRpcWsAuthenticationEnabled) {
CommandLineUtils.checkOptionDependencies(
@@ -222,6 +341,18 @@ public class RpcWebsocketOptions {
webSocketConfiguration.setAuthenticationPublicKeyFile(rpcWsAuthenticationPublicKeyFile);
webSocketConfiguration.setAuthenticationAlgorithm(rpcWebsocketsAuthenticationAlgorithm);
webSocketConfiguration.setTimeoutSec(wsTimoutSec);
+ webSocketConfiguration.setSslEnabled(isRpcWsSslEnabled);
+ webSocketConfiguration.setKeyStorePath(rpcWsKeyStoreFile);
+ webSocketConfiguration.setKeyStorePassword(rpcWsKeyStorePassword);
+ webSocketConfiguration.setKeyStoreType(rpcWsKeyStoreType);
+ webSocketConfiguration.setClientAuthEnabled(isRpcWsClientAuthEnabled);
+ webSocketConfiguration.setTrustStorePath(rpcWsTrustStoreFile);
+ webSocketConfiguration.setTrustStorePassword(rpcWsTrustStorePassword);
+ webSocketConfiguration.setTrustStoreType(rpcWsTrustStoreType);
+ webSocketConfiguration.setKeyPath(rpcWsKeyFile);
+ webSocketConfiguration.setCertPath(rpcWsCertFile);
+ webSocketConfiguration.setTrustCertPath(rpcWsTrustCertFile);
+
return webSocketConfiguration;
}
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/SynchronizerOptions.java
similarity index 99%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/SynchronizerOptions.java
index 816d9df00a..c7d20c17fb 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/SynchronizerOptions.java
@@ -12,10 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
-import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.ImmutableSnapSyncConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java
index 73916a936e..593fc6cd77 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java
@@ -20,7 +20,7 @@ import static org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.COMMAND_N
import org.hyperledger.besu.cli.BesuCommand;
import org.hyperledger.besu.cli.DefaultCommandValues;
-import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption;
+import org.hyperledger.besu.cli.options.NodePrivateKeyFileOption;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.AddressSubCommand;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.ExportSubCommand;
import org.hyperledger.besu.cli.util.VersionProvider;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java
deleted file mode 100644
index 67af49c400..0000000000
--- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright ConsenSys AG.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package org.hyperledger.besu.cli.subcommands;
-
-import static org.hyperledger.besu.cli.subcommands.RetestethSubCommand.COMMAND_NAME;
-
-import org.hyperledger.besu.BesuInfo;
-import org.hyperledger.besu.cli.DefaultCommandValues;
-import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
-import org.hyperledger.besu.cli.options.stable.LoggingLevelOption;
-import org.hyperledger.besu.cli.util.VersionProvider;
-import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
-import org.hyperledger.besu.ethereum.retesteth.RetestethConfiguration;
-import org.hyperledger.besu.ethereum.retesteth.RetestethService;
-import org.hyperledger.besu.util.LogConfigurator;
-
-import java.net.InetAddress;
-import java.nio.file.Path;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Mixin;
-import picocli.CommandLine.Option;
-
-/** Subcommand to run a Retesteth compatible server for reference tests. */
-@Command(
- name = COMMAND_NAME,
- description = "Run a Retesteth compatible server for reference tests.",
- mixinStandardHelpOptions = true,
- versionProvider = VersionProvider.class)
-@SuppressWarnings("unused")
-public class RetestethSubCommand implements Runnable {
-
- private static final Logger LOG = LoggerFactory.getLogger(RetestethSubCommand.class);
-
- /** The constant COMMAND_NAME. */
- public static final String COMMAND_NAME = "retesteth";
-
- /**
- * Using a distinct port for retesteth will result in less testing collisions and accidental RPC
- * calls. This is 0xba5e
in hex, a hex speak play on the english translation of
- * "Besu."
- */
- public static final int RETESTETH_PORT = 47710;
-
- @Option(
- names = {"--data-path"},
- paramLabel = DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP,
- description = "The path to Besu data directory (default: ${DEFAULT-VALUE})")
- private final Path dataPath = DefaultCommandValues.getDefaultBesuDataPath(this);
-
- @Mixin private LoggingLevelOption loggingLevelOption;
-
- @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings.
- @Option(
- names = {"--rpc-http-host"},
- paramLabel = DefaultCommandValues.MANDATORY_HOST_FORMAT_HELP,
- description = "Host for Retesteth JSON-RPC HTTP to listen on (default: ${DEFAULT-VALUE})",
- arity = "1")
- private String rpcHttpHost = autoDiscoverDefaultIP().getHostAddress();
-
- @Option(
- names = {"--rpc-http-port"},
- paramLabel = DefaultCommandValues.MANDATORY_PORT_FORMAT_HELP,
- description = "Port for Retesteth JSON-RPC HTTP to listen on (default: ${DEFAULT-VALUE})",
- arity = "1")
- private final Integer rpcHttpPort = RETESTETH_PORT;
-
- @Option(
- names = {"--host-allowlist", "--host-whitelist"},
- paramLabel = "[,...]... or * or all",
- description =
- "Comma separated list of hostnames to allow for RPC access, or * to accept any host (default: ${DEFAULT-VALUE})",
- defaultValue = "localhost,127.0.0.1")
- private final JsonRPCAllowlistHostsProperty hostsAllowlist = new JsonRPCAllowlistHostsProperty();
-
- private InetAddress autoDiscoveredDefaultIP;
-
- /** Default Constructor. */
- public RetestethSubCommand() {}
-
- // Used to discover the default IP of the client.
- // Loopback IP is used by default as this is how smokeTests require it to be
- // and it's probably a good security behaviour to default only on the localhost.
- private InetAddress autoDiscoverDefaultIP() {
-
- if (autoDiscoveredDefaultIP != null) {
- return autoDiscoveredDefaultIP;
- }
-
- autoDiscoveredDefaultIP = InetAddress.getLoopbackAddress();
-
- return autoDiscoveredDefaultIP;
- }
-
- private void prepareLogging() {
- // set log level per CLI flags
- final String logLevel = loggingLevelOption.getLogLevel();
- if (logLevel != null) {
- System.out.println("Setting logging level to " + logLevel);
- LogConfigurator.setLevel("", logLevel);
- }
- }
-
- @Override
- public void run() {
- prepareLogging();
-
- final RetestethConfiguration retestethConfiguration = new RetestethConfiguration(dataPath);
- final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
- jsonRpcConfiguration.setHost(rpcHttpHost);
- jsonRpcConfiguration.setPort(rpcHttpPort);
- jsonRpcConfiguration.setHostsAllowlist(hostsAllowlist);
-
- final RetestethService retestethService =
- new RetestethService(BesuInfo.version(), retestethConfiguration, jsonRpcConfiguration);
-
- Runtime.getRuntime()
- .addShutdownHook(
- new Thread(
- () -> {
- try {
- retestethService.close();
- LogConfigurator.shutdown();
- } catch (final Exception e) {
- LOG.error("Failed to stop Besu Retesteth");
- }
- }));
- retestethService.start();
- try {
- Thread.sleep(Long.MAX_VALUE); // Is there a better way?
- } catch (final InterruptedException e) {
- // e.printStackTrace();
- }
- }
-}
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java
index 5bd0aacee2..95617fe8ca 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java
@@ -31,9 +31,9 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.IncrementingNonceGenerator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.metrics.MetricsService;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
@@ -265,12 +265,12 @@ public class BlocksSubCommand implements Runnable {
}
}
- private MiningParameters getMiningParameters() {
+ private MiningConfiguration getMiningParameters() {
final Wei minTransactionGasPrice = Wei.ZERO;
// Extradata and coinbase can be configured on a per-block level via the json file
final Address coinbase = Address.ZERO;
final Bytes extraData = Bytes.EMPTY;
- return ImmutableMiningParameters.builder()
+ return ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.nonceGenerator(new IncrementingNonceGenerator(0))
@@ -377,7 +377,7 @@ public class BlocksSubCommand implements Runnable {
return parentCommand
.parentCommand
.setupControllerBuilder()
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.build();
}
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java
index 6480380240..47a6c2294a 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java
@@ -34,9 +34,9 @@ import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.trie.Node;
import org.hyperledger.besu.ethereum.trie.PersistVisitor;
import org.hyperledger.besu.ethereum.trie.RestoreVisitor;
+import org.hyperledger.besu.ethereum.trie.common.PmtStateTrieAccountValue;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
-import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.util.io.RollingFileReader;
import java.io.IOException;
@@ -192,8 +192,8 @@ public class RestoreState implements Runnable {
final Bytes accountRlp = accountInput.readBytes();
final Bytes code = accountInput.readBytes();
- final StateTrieAccountValue trieAccount =
- StateTrieAccountValue.readFrom(new BytesValueRLPInput(accountRlp, false, true));
+ final PmtStateTrieAccountValue trieAccount =
+ PmtStateTrieAccountValue.readFrom(new BytesValueRLPInput(accountRlp, false, true));
if (!trieAccount.getCodeHash().equals(Hash.hash(code))) {
throw new RuntimeException("Code hash doesn't match");
}
diff --git a/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java b/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java
index e757fd62a2..ce4f00db73 100644
--- a/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java
+++ b/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java
@@ -20,8 +20,8 @@ import org.hyperledger.besu.chainexport.RlpBlockExporter;
import org.hyperledger.besu.chainimport.JsonBlockImporter;
import org.hyperledger.besu.chainimport.RlpBlockImporter;
import org.hyperledger.besu.cli.BesuCommand;
-import org.hyperledger.besu.cli.options.stable.P2PDiscoveryOptions;
-import org.hyperledger.besu.cli.options.unstable.RPCOptions;
+import org.hyperledger.besu.cli.options.P2PDiscoveryOptions;
+import org.hyperledger.besu.cli.options.RPCOptions;
import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java
index fb99318905..238e5c3c1c 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java
@@ -24,7 +24,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
@@ -71,7 +71,7 @@ public class BesuController implements java.io.Closeable {
private final MiningCoordinator miningCoordinator;
private final PrivacyParameters privacyParameters;
private final List closeables;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
private final PluginServiceFactory additionalPluginServices;
private final SyncState syncState;
private final EthPeers ethPeers;
@@ -91,7 +91,7 @@ public class BesuController implements java.io.Closeable {
* @param transactionPool the transaction pool
* @param miningCoordinator the mining coordinator
* @param privacyParameters the privacy parameters
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param additionalJsonRpcMethodsFactory the additional json rpc methods factory
* @param nodeKey the node key
* @param closeables the closeables
@@ -111,7 +111,7 @@ public class BesuController implements java.io.Closeable {
final TransactionPool transactionPool,
final MiningCoordinator miningCoordinator,
final PrivacyParameters privacyParameters,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final JsonRpcMethods additionalJsonRpcMethodsFactory,
final NodeKey nodeKey,
final List closeables,
@@ -132,7 +132,7 @@ public class BesuController implements java.io.Closeable {
this.miningCoordinator = miningCoordinator;
this.privacyParameters = privacyParameters;
this.closeables = closeables;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
this.additionalPluginServices = additionalPluginServices;
this.ethPeers = ethPeers;
this.storageProvider = storageProvider;
@@ -265,8 +265,8 @@ public class BesuController implements java.io.Closeable {
*
* @return the mining parameters
*/
- public MiningParameters getMiningParameters() {
- return miningParameters;
+ public MiningConfiguration getMiningParameters() {
+ return miningConfiguration;
}
/**
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
index 8f1b8dec84..1953e1aa31 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
@@ -26,7 +26,6 @@ import org.hyperledger.besu.consensus.qbft.BFTPivotSelectorFromPeers;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ConsensusContext;
-import org.hyperledger.besu.ethereum.ConsensusContextFactory;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
@@ -43,8 +42,9 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.chain.VariablesStorage;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
+import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.SnapProtocol;
@@ -55,6 +55,8 @@ import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter;
import org.hyperledger.besu.ethereum.eth.manager.MonitoredExecutors;
+import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskExecutor;
+import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskRequestSender;
import org.hyperledger.besu.ethereum.eth.manager.snap.SnapProtocolManager;
import org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator;
import org.hyperledger.besu.ethereum.eth.peervalidation.ClassicForkPeerValidator;
@@ -93,6 +95,7 @@ import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
+import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive.WorldStateHealer;
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
@@ -113,6 +116,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalLong;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
import org.slf4j.Logger;
@@ -144,7 +148,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
protected BigInteger networkId;
/** The Mining parameters. */
- protected MiningParameters miningParameters;
+ protected MiningConfiguration miningConfiguration;
/** The Metrics system. */
protected ObservableMetricsSystem metricsSystem;
@@ -296,11 +300,11 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
/**
* Mining parameters besu controller builder.
*
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @return the besu controller builder
*/
- public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
return this;
}
@@ -543,7 +547,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
checkNotNull(syncConfig, "Missing sync config");
checkNotNull(ethereumWireProtocolConfiguration, "Missing ethereum protocol configuration");
checkNotNull(networkId, "Missing network ID");
- checkNotNull(miningParameters, "Missing mining parameters");
+ checkNotNull(miningConfiguration, "Missing mining parameters");
checkNotNull(metricsSystem, "Missing metrics system");
checkNotNull(privacyParameters, "Missing privacy parameters");
checkNotNull(dataDirectory, "Missing data directory"); // Why do we need this?
@@ -589,17 +593,24 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
.map(BesuComponent::getCachedMerkleTrieLoader)
.orElseGet(() -> new BonsaiCachedMerkleTrieLoader(metricsSystem));
+ final var worldStateHealerSupplier = new AtomicReference();
+
final WorldStateArchive worldStateArchive =
createWorldStateArchive(
- worldStateStorageCoordinator, blockchain, bonsaiCachedMerkleTrieLoader);
+ worldStateStorageCoordinator,
+ blockchain,
+ bonsaiCachedMerkleTrieLoader,
+ worldStateHealerSupplier::get);
if (maybeStoredGenesisBlockHash.isEmpty()) {
genesisState.writeStateTo(worldStateArchive.getMutable());
}
+ final var consensusContext =
+ createConsensusContext(blockchain, worldStateArchive, protocolSchedule);
+
final ProtocolContext protocolContext =
- createProtocolContext(
- blockchain, worldStateArchive, protocolSchedule, this::createConsensusContext);
+ createProtocolContext(blockchain, worldStateArchive, consensusContext);
validateContext(protocolContext);
protocolSchedule.setPublicWorldStateArchiveForPrivacyBlockProcessor(
@@ -616,7 +627,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
ethereumWireProtocolConfiguration.isLegacyEth64ForkIdEnabled());
final EthPeers ethPeers =
new EthPeers(
- getSupportedProtocol(),
+ EthProtocol.NAME,
currentProtocolSpecSupplier,
clock,
metricsSystem,
@@ -655,6 +666,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
}
final EthContext ethContext = new EthContext(ethPeers, ethMessages, snapMessages, scheduler);
+ final PeerTaskExecutor peerTaskExecutor =
+ new PeerTaskExecutor(ethPeers, new PeerTaskRequestSender(), metricsSystem);
final boolean fullSyncDisabled = !SyncMode.isFullSync(syncConfig.getSyncMode());
final SyncState syncState = new SyncState(blockchain, ethPeers, fullSyncDisabled, checkpoint);
@@ -678,7 +691,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
syncState,
transactionPoolConfiguration,
besuComponent.map(BesuComponent::getBlobCache).orElse(new BlobCache()),
- miningParameters);
+ miningConfiguration);
final List peerValidators = createPeerValidators(protocolSchedule);
@@ -706,10 +719,13 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
worldStateStorageCoordinator,
protocolContext,
ethContext,
+ peerTaskExecutor,
syncState,
ethProtocolManager,
pivotBlockSelector);
+ worldStateHealerSupplier.set(synchronizer::healWorldState);
+
ethPeers.setTrailingPeerRequirementsSupplier(synchronizer::calculateTrailingPeerRequirements);
if (syncConfig.getSyncMode() == SyncMode.SNAP
@@ -720,18 +736,16 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
ethPeers.snapServerPeersNeeded(false);
}
- protocolContext.setSynchronizer(synchronizer);
-
final Optional maybeSnapProtocolManager =
createSnapProtocolManager(
- protocolContext, worldStateStorageCoordinator, ethPeers, snapMessages);
+ protocolContext, worldStateStorageCoordinator, ethPeers, snapMessages, synchronizer);
final MiningCoordinator miningCoordinator =
createMiningCoordinator(
protocolSchedule,
protocolContext,
transactionPool,
- miningParameters,
+ miningConfiguration,
syncState,
ethProtocolManager);
@@ -742,7 +756,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
createSubProtocolConfiguration(ethProtocolManager, maybeSnapProtocolManager);
final JsonRpcMethods additionalJsonRpcMethodFactory =
- createAdditionalJsonRpcMethodFactory(protocolContext, protocolSchedule, miningParameters);
+ createAdditionalJsonRpcMethodFactory(
+ protocolContext, protocolSchedule, miningConfiguration);
if (DataStorageFormat.BONSAI.equals(dataStorageConfiguration.getDataStorageFormat())) {
final DiffBasedSubStorageConfiguration subStorageConfiguration =
@@ -776,7 +791,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
transactionPool,
miningCoordinator,
privacyParameters,
- miningParameters,
+ miningConfiguration,
additionalJsonRpcMethodFactory,
nodeKey,
closeables,
@@ -832,6 +847,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
* @param worldStateStorageCoordinator the world state storage
* @param protocolContext the protocol context
* @param ethContext the eth context
+ * @param peerTaskExecutor the PeerTaskExecutor
* @param syncState the sync state
* @param ethProtocolManager the eth protocol manager
* @param pivotBlockSelector the pivot block selector
@@ -842,6 +858,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
final WorldStateStorageCoordinator worldStateStorageCoordinator,
final ProtocolContext protocolContext,
final EthContext ethContext,
+ final PeerTaskExecutor peerTaskExecutor,
final SyncState syncState,
final EthProtocolManager ethProtocolManager,
final PivotBlockSelector pivotBlockSelector) {
@@ -853,6 +870,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
worldStateStorageCoordinator,
ethProtocolManager.getBlockBroadcaster(),
ethContext,
+ peerTaskExecutor,
syncState,
dataDirectory,
storageProvider,
@@ -932,13 +950,13 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
*
* @param protocolContext the protocol context
* @param protocolSchedule the protocol schedule
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @return the json rpc methods
*/
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
return apis -> Collections.emptyMap();
}
@@ -961,12 +979,12 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
}
/**
- * Create mining coordinator mining coordinator.
+ * Create mining coordinator.
*
* @param protocolSchedule the protocol schedule
* @param protocolContext the protocol context
* @param transactionPool the transaction pool
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param syncState the sync state
* @param ethProtocolManager the eth protocol manager
* @return the mining coordinator
@@ -975,7 +993,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
ProtocolSchedule protocolSchedule,
ProtocolContext protocolContext,
TransactionPool transactionPool,
- MiningParameters miningParameters,
+ MiningConfiguration miningConfiguration,
SyncState syncState,
EthProtocolManager ethProtocolManager);
@@ -1002,18 +1020,9 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
* @return the consensus context
*/
protected abstract ConsensusContext createConsensusContext(
- Blockchain blockchain,
- WorldStateArchive worldStateArchive,
- ProtocolSchedule protocolSchedule);
-
- /**
- * Gets supported protocol.
- *
- * @return the supported protocol
- */
- protected String getSupportedProtocol() {
- return EthProtocol.NAME;
- }
+ final Blockchain blockchain,
+ final WorldStateArchive worldStateArchive,
+ final ProtocolSchedule protocolSchedule);
/**
* Create eth protocol manager eth protocol manager.
@@ -1064,37 +1073,37 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
*
* @param blockchain the blockchain
* @param worldStateArchive the world state archive
- * @param protocolSchedule the protocol schedule
- * @param consensusContextFactory the consensus context factory
+ * @param consensusContext the consensus context
* @return the protocol context
*/
protected ProtocolContext createProtocolContext(
final MutableBlockchain blockchain,
final WorldStateArchive worldStateArchive,
- final ProtocolSchedule protocolSchedule,
- final ConsensusContextFactory consensusContextFactory) {
- return ProtocolContext.init(
- blockchain, worldStateArchive, protocolSchedule, consensusContextFactory, badBlockManager);
+ final ConsensusContext consensusContext) {
+ return new ProtocolContext(blockchain, worldStateArchive, consensusContext, badBlockManager);
}
private Optional createSnapProtocolManager(
final ProtocolContext protocolContext,
final WorldStateStorageCoordinator worldStateStorageCoordinator,
final EthPeers ethPeers,
- final EthMessages snapMessages) {
+ final EthMessages snapMessages,
+ final Synchronizer synchronizer) {
return Optional.of(
new SnapProtocolManager(
worldStateStorageCoordinator,
syncConfig.getSnapSyncConfiguration(),
ethPeers,
snapMessages,
- protocolContext));
+ protocolContext,
+ synchronizer));
}
WorldStateArchive createWorldStateArchive(
final WorldStateStorageCoordinator worldStateStorageCoordinator,
final Blockchain blockchain,
- final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader) {
+ final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader,
+ final Supplier worldStateHealerSupplier) {
return switch (dataStorageConfiguration.getDataStorageFormat()) {
case BONSAI -> {
final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage =
@@ -1109,7 +1118,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
.getMaxLayersToLoad()),
bonsaiCachedMerkleTrieLoader,
besuComponent.map(BesuComponent::getBesuPluginContext).orElse(null),
- evmConfiguration);
+ evmConfiguration,
+ worldStateHealerSupplier);
}
case VERKLE -> {
final VerkleWorldStateKeyValueStorage worldStateKeyValueStorage =
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java
index b4ada60549..ccd4363412 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java
@@ -14,12 +14,11 @@
*/
package org.hyperledger.besu.controller;
-import static org.hyperledger.besu.consensus.clique.CliqueHelpers.installCliqueBlockChoiceRule;
-
import org.hyperledger.besu.config.CliqueConfigOptions;
import org.hyperledger.besu.consensus.clique.CliqueBlockInterface;
import org.hyperledger.besu.consensus.clique.CliqueContext;
import org.hyperledger.besu.consensus.clique.CliqueForksSchedulesFactory;
+import org.hyperledger.besu.consensus.clique.CliqueHelpers;
import org.hyperledger.besu.consensus.clique.CliqueMiningTracker;
import org.hyperledger.besu.consensus.clique.CliqueProtocolSchedule;
import org.hyperledger.besu.consensus.clique.blockcreation.CliqueBlockScheduler;
@@ -36,7 +35,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
@@ -74,8 +73,8 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
- return new CliqueJsonRpcMethods(protocolContext, protocolSchedule, miningParameters);
+ final MiningConfiguration miningConfiguration) {
+ return new CliqueJsonRpcMethods(protocolContext, protocolSchedule, miningConfiguration);
}
@Override
@@ -83,7 +82,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
final CliqueMinerExecutor miningExecutor =
@@ -92,7 +91,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
protocolSchedule,
transactionPool,
nodeKey,
- miningParameters,
+ miningConfiguration,
new CliqueBlockScheduler(
clock,
protocolContext.getConsensusContext(CliqueContext.class).getValidatorProvider(),
@@ -113,7 +112,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
.getBlockchain()
.observeBlockAdded(
o ->
- miningParameters.setBlockPeriodSeconds(
+ miningConfiguration.setBlockPeriodSeconds(
forksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue()
@@ -135,7 +134,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -167,12 +166,13 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
blockchain, epochManager, blockInterface),
epochManager,
blockInterface);
- installCliqueBlockChoiceRule(blockchain, cliqueContext);
+ CliqueHelpers.setCliqueContext(cliqueContext);
+ CliqueHelpers.installCliqueBlockChoiceRule(blockchain, cliqueContext);
return cliqueContext;
}
@Override
- public MiningParameters getMiningParameterOverrides(final MiningParameters fromCli) {
+ public MiningConfiguration getMiningParameterOverrides(final MiningConfiguration fromCli) {
// Clique mines by default, reflect that with in the mining parameters:
return fromCli.setMiningEnabled(true);
}
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java
index 0d0f8d2fd8..31f84b6ae0 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java
@@ -20,20 +20,19 @@ import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.consensus.common.CombinedProtocolScheduleFactory;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.ForksSchedule;
-import org.hyperledger.besu.consensus.common.MigratingContext;
+import org.hyperledger.besu.consensus.common.MigratingConsensusContext;
import org.hyperledger.besu.consensus.common.MigratingMiningCoordinator;
import org.hyperledger.besu.consensus.common.MigratingProtocolContext;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ConsensusContext;
-import org.hyperledger.besu.ethereum.ConsensusContextFactory;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@@ -128,7 +127,7 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
@@ -143,7 +142,7 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
protocolSchedule,
protocolContext,
transactionPool,
- miningParameters,
+ miningConfiguration,
syncState,
ethProtocolManager)))
.collect(Collectors.toList());
@@ -168,10 +167,12 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
protected ProtocolContext createProtocolContext(
final MutableBlockchain blockchain,
final WorldStateArchive worldStateArchive,
- final ProtocolSchedule protocolSchedule,
- final ConsensusContextFactory consensusContextFactory) {
- return MigratingProtocolContext.init(
- blockchain, worldStateArchive, protocolSchedule, consensusContextFactory, badBlockManager);
+ final ConsensusContext consensusContext) {
+ return new MigratingProtocolContext(
+ blockchain,
+ worldStateArchive,
+ consensusContext.as(MigratingConsensusContext.class),
+ badBlockManager);
}
@Override
@@ -188,10 +189,10 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
e.getValue()
.createConsensusContext(
blockchain, worldStateArchive, protocolSchedule)))
- .collect(Collectors.toList());
+ .toList();
final ForksSchedule consensusContextsSchedule =
new ForksSchedule<>(consensusContextSpecs);
- return new MigratingContext(consensusContextsSchedule);
+ return new MigratingConsensusContext(consensusContextsSchedule);
}
@Override
@@ -206,10 +207,11 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
return besuControllerBuilderSchedule
.get(0L)
- .createAdditionalJsonRpcMethodFactory(protocolContext, protocolSchedule, miningParameters);
+ .createAdditionalJsonRpcMethodFactory(
+ protocolContext, protocolSchedule, miningConfiguration);
}
@Override
@@ -226,11 +228,6 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
besuControllerBuilderSchedule.get(GENESIS_BLOCK_NUMBER).validateContext(context);
}
- @Override
- protected String getSupportedProtocol() {
- return besuControllerBuilderSchedule.get(0L).getSupportedProtocol();
- }
-
@Override
protected EthProtocolManager createEthProtocolManager(
final ProtocolContext protocolContext,
@@ -297,9 +294,9 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
}
@Override
- public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) {
- besuControllerBuilderSchedule.values().forEach(b -> b.miningParameters(miningParameters));
- return super.miningParameters(miningParameters);
+ public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) {
+ besuControllerBuilderSchedule.values().forEach(b -> b.miningParameters(miningConfiguration));
+ return super.miningParameters(miningConfiguration);
}
@Override
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
index 738dcfc596..ae08b11cca 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
@@ -60,7 +60,7 @@ import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.MinedBlockObserver;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.SnapProtocol;
@@ -114,8 +114,8 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
- return new IbftJsonRpcMethods(protocolContext, protocolSchedule, miningParameters);
+ final MiningConfiguration miningConfiguration) {
+ return new IbftJsonRpcMethods(protocolContext, protocolSchedule, miningConfiguration);
}
@Override
@@ -141,7 +141,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
final MutableBlockchain blockchain = protocolContext.getBlockchain();
@@ -156,7 +156,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
protocolContext,
bftProtocolSchedule,
forksSchedule,
- miningParameters,
+ miningConfiguration,
localAddress,
bftExtraDataCodec().get(),
ethProtocolManager.ethContext().getScheduler());
@@ -247,7 +247,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
.getBlockchain()
.observeBlockAdded(
o ->
- miningParameters.setBlockPeriodSeconds(
+ miningConfiguration.setBlockPeriodSeconds(
forksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue()
@@ -303,7 +303,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
isRevertReasonEnabled,
bftExtraDataCodec().get(),
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java
index e0fbed608a..a642539ac5 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java
@@ -21,7 +21,7 @@ import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.blockcreation.PoWMinerExecutor;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -31,6 +31,8 @@ import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
+import java.util.Optional;
+
/** The Mainnet besu controller builder. */
public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
@@ -44,7 +46,7 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
@@ -53,7 +55,7 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
protocolContext,
protocolSchedule,
transactionPool,
- miningParameters,
+ miningConfiguration,
new DefaultBlockScheduler(
MainnetBlockHeaderValidator.MINIMUM_SECONDS_SINCE_PARENT,
MainnetBlockHeaderValidator.TIMESTAMP_TOLERANCE_S,
@@ -66,11 +68,11 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
protocolContext.getBlockchain(),
executor,
syncState,
- miningParameters.getUnstable().getRemoteSealersLimit(),
- miningParameters.getUnstable().getRemoteSealersTimeToLive());
+ miningConfiguration.getUnstable().getRemoteSealersLimit(),
+ miningConfiguration.getUnstable().getRemoteSealersTimeToLive());
miningCoordinator.addMinedBlockObserver(ethProtocolManager);
- miningCoordinator.setStratumMiningEnabled(miningParameters.isStratumMiningEnabled());
- if (miningParameters.isMiningEnabled()) {
+ miningCoordinator.setStratumMiningEnabled(miningConfiguration.isStratumMiningEnabled());
+ if (miningConfiguration.isMiningEnabled()) {
miningCoordinator.enable();
}
@@ -95,10 +97,10 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
protected ProtocolSchedule createProtocolSchedule() {
return MainnetProtocolSchedule.fromConfig(
genesisConfigOptions,
- privacyParameters,
- isRevertReasonEnabled,
- evmConfiguration,
- miningParameters,
+ Optional.of(privacyParameters),
+ Optional.of(isRevertReasonEnabled),
+ Optional.of(evmConfiguration),
+ super.miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
index f5fc75959e..e7c1a5c40d 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
@@ -26,7 +26,7 @@ import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthMessages;
@@ -67,14 +67,14 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
return createTransitionMiningCoordinator(
protocolSchedule,
protocolContext,
transactionPool,
- miningParameters,
+ miningConfiguration,
syncState,
new BackwardSyncContext(
protocolContext,
@@ -140,7 +140,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
* @param protocolSchedule the protocol schedule
* @param protocolContext the protocol context
* @param transactionPool the transaction pool
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param syncState the sync state
* @param backwardSyncContext the backward sync context
* @param ethScheduler the scheduler
@@ -150,7 +150,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final BackwardSyncContext backwardSyncContext,
final EthScheduler ethScheduler) {
@@ -165,7 +165,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
protocolSchedule,
ethScheduler,
transactionPool,
- miningParameters,
+ miningConfiguration,
backwardSyncContext,
depositContractAddress);
}
@@ -176,7 +176,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
genesisConfigOptions,
privacyParameters,
isRevertReasonEnabled,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java b/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java
index e4cebc0d64..ae2ae250ba 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java
@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.controller;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
/**
* This interface wraps the provided MiningParameters to enable controller-specific parameter
@@ -27,7 +27,7 @@ public interface MiningParameterOverrides {
* @param fromCli The mining parameters that contains original values.
* @return MiningParameters constructed from provided param with additional overridden parameters.
*/
- default MiningParameters getMiningParameterOverrides(final MiningParameters fromCli) {
+ default MiningConfiguration getMiningParameterOverrides(final MiningConfiguration fromCli) {
return fromCli;
}
}
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
index 498435e4af..b6f579ea68 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
@@ -69,7 +69,7 @@ import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.MinedBlockObserver;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.SnapProtocol;
@@ -112,10 +112,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
@Override
protected Supplier bftExtraDataCodec() {
- return Suppliers.memoize(
- () -> {
- return new QbftExtraDataCodec();
- });
+ return Suppliers.memoize(QbftExtraDataCodec::new);
}
@Override
@@ -130,12 +127,12 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
return new QbftJsonRpcMethods(
protocolContext,
protocolSchedule,
- miningParameters,
+ miningConfiguration,
createReadOnlyValidatorProvider(protocolContext.getBlockchain()),
bftConfigOptions);
}
@@ -181,7 +178,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
final MutableBlockchain blockchain = protocolContext.getBlockchain();
@@ -196,7 +193,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
protocolContext,
bftProtocolSchedule,
qbftForksSchedule,
- miningParameters,
+ miningConfiguration,
localAddress,
bftExtraDataCodec().get(),
ethProtocolManager.ethContext().getScheduler());
@@ -289,12 +286,12 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
.getBlockchain()
.observeBlockAdded(
o -> {
- miningParameters.setBlockPeriodSeconds(
+ miningConfiguration.setBlockPeriodSeconds(
qbftForksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue()
.getBlockPeriodSeconds());
- miningParameters.setEmptyBlockPeriodSeconds(
+ miningConfiguration.setEmptyBlockPeriodSeconds(
qbftForksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue()
@@ -351,7 +348,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
isRevertReasonEnabled,
bftExtraDataCodec().get(),
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java
index ee2611d9c8..75abca6a57 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java
@@ -24,14 +24,13 @@ import org.hyperledger.besu.consensus.merge.blockcreation.TransitionCoordinator;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ConsensusContext;
-import org.hyperledger.besu.ethereum.ConsensusContextFactory;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@@ -40,6 +39,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter;
+import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskExecutor;
import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator;
import org.hyperledger.besu.ethereum.eth.sync.DefaultSynchronizer;
import org.hyperledger.besu.ethereum.eth.sync.PivotBlockSelector;
@@ -101,7 +101,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
@@ -111,8 +111,8 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
// PoA consensus mines by default, get consensus-specific mining parameters for
// TransitionCoordinator:
- MiningParameters transitionMiningParameters =
- preMergeBesuControllerBuilder.getMiningParameterOverrides(miningParameters);
+ MiningConfiguration transitionMiningConfiguration =
+ preMergeBesuControllerBuilder.getMiningParameterOverrides(miningConfiguration);
// construct a transition backward sync context
BackwardSyncContext transitionBackwardsSyncContext =
@@ -130,10 +130,10 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
transitionProtocolSchedule.getPreMergeSchedule(),
protocolContext,
transactionPool,
- ImmutableMiningParameters.builder()
- .from(miningParameters)
+ ImmutableMiningConfiguration.builder()
+ .from(miningConfiguration)
.mutableInitValues(
- ImmutableMiningParameters.MutableInitValues.builder()
+ ImmutableMiningConfiguration.MutableInitValues.builder()
.isMiningEnabled(false)
.build())
.build(),
@@ -143,7 +143,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
transitionProtocolSchedule,
protocolContext,
transactionPool,
- transitionMiningParameters,
+ transitionMiningConfiguration,
syncState,
transitionBackwardsSyncContext,
ethProtocolManager.ethContext().getScheduler()));
@@ -192,11 +192,9 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
protected ProtocolContext createProtocolContext(
final MutableBlockchain blockchain,
final WorldStateArchive worldStateArchive,
- final ProtocolSchedule protocolSchedule,
- final ConsensusContextFactory consensusContextFactory) {
+ final ConsensusContext consensusContext) {
final ProtocolContext protocolContext =
- super.createProtocolContext(
- blockchain, worldStateArchive, protocolSchedule, consensusContextFactory);
+ super.createProtocolContext(blockchain, worldStateArchive, consensusContext);
transitionProtocolSchedule.setProtocolContext(protocolContext);
return protocolContext;
}
@@ -225,6 +223,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
final WorldStateStorageCoordinator worldStateStorageCoordinator,
final ProtocolContext protocolContext,
final EthContext ethContext,
+ final PeerTaskExecutor peerTaskExecutor,
final SyncState syncState,
final EthProtocolManager ethProtocolManager,
final PivotBlockSelector pivotBlockSelector) {
@@ -235,6 +234,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
worldStateStorageCoordinator,
protocolContext,
ethContext,
+ peerTaskExecutor,
syncState,
ethProtocolManager,
pivotBlockSelector);
@@ -326,9 +326,9 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
}
@Override
- public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) {
- super.miningParameters(miningParameters);
- return propagateConfig(z -> z.miningParameters(miningParameters));
+ public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) {
+ super.miningParameters(miningConfiguration);
+ return propagateConfig(z -> z.miningParameters(miningConfiguration));
}
@Override
diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java
index 0adbda23b7..f2f5fa53da 100644
--- a/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java
+++ b/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java
@@ -14,9 +14,9 @@
*/
package org.hyperledger.besu.services;
-import org.hyperledger.besu.cli.options.stable.JsonRpcHttpOptions;
+import org.hyperledger.besu.cli.options.JsonRpcHttpOptions;
import org.hyperledger.besu.datatypes.Wei;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.plugin.services.BesuConfiguration;
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
@@ -31,7 +31,7 @@ public class BesuConfigurationImpl implements BesuConfiguration {
private DataStorageConfiguration dataStorageConfiguration;
// defaults
- private MiningParameters miningParameters = MiningParameters.newDefault();
+ private MiningConfiguration miningConfiguration;
private Optional rpcHttpHost = Optional.of("http://localhost");
private Optional rpcHttpPort = Optional.of(8545);
@@ -59,11 +59,11 @@ public class BesuConfigurationImpl implements BesuConfiguration {
/**
* Set the mining parameters
*
- * @param miningParameters configured mining parameters
+ * @param miningConfiguration configured mining parameters
* @return BesuConfigurationImpl instance
*/
- public BesuConfigurationImpl withMiningParameters(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public BesuConfigurationImpl withMiningParameters(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
return this;
}
@@ -106,7 +106,7 @@ public class BesuConfigurationImpl implements BesuConfiguration {
@Override
public Wei getMinGasPrice() {
- return miningParameters.getMinTransactionGasPrice();
+ return miningConfiguration.getMinTransactionGasPrice();
}
@Override
diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java
index ad4dbd4481..fbee90edef 100644
--- a/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java
+++ b/besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java
@@ -18,8 +18,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
-import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin;
+import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.BesuService;
import org.hyperledger.besu.plugin.services.PluginVersionsProvider;
@@ -49,7 +49,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Besu plugin context implementation. */
-public class BesuPluginContextImpl implements BesuContext, PluginVersionsProvider {
+public class BesuPluginContextImpl implements ServiceManager, PluginVersionsProvider {
private static final Logger LOG = LoggerFactory.getLogger(BesuPluginContextImpl.class);
diff --git a/besu/src/main/java/org/hyperledger/besu/services/BlockchainServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BlockchainServiceImpl.java
index e981a3e78d..76b4d7e150 100644
--- a/besu/src/main/java/org/hyperledger/besu/services/BlockchainServiceImpl.java
+++ b/besu/src/main/java/org/hyperledger/besu/services/BlockchainServiceImpl.java
@@ -16,7 +16,6 @@ package org.hyperledger.besu.services;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
-import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -40,7 +39,6 @@ import java.util.stream.Collectors;
@Unstable
public class BlockchainServiceImpl implements BlockchainService {
- private ProtocolContext protocolContext;
private ProtocolSchedule protocolSchedule;
private MutableBlockchain blockchain;
@@ -50,13 +48,12 @@ public class BlockchainServiceImpl implements BlockchainService {
/**
* Initialize the Blockchain service.
*
- * @param protocolContext the protocol context
+ * @param blockchain the blockchain
* @param protocolSchedule the protocol schedule
*/
- public void init(final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule) {
- this.protocolContext = protocolContext;
+ public void init(final MutableBlockchain blockchain, final ProtocolSchedule protocolSchedule) {
this.protocolSchedule = protocolSchedule;
- this.blockchain = protocolContext.getBlockchain();
+ this.blockchain = blockchain;
}
/**
@@ -67,25 +64,24 @@ public class BlockchainServiceImpl implements BlockchainService {
*/
@Override
public Optional getBlockByNumber(final long number) {
- return protocolContext
- .getBlockchain()
+ return blockchain
.getBlockByNumber(number)
.map(block -> blockContext(block::getHeader, block::getBody));
}
@Override
public Hash getChainHeadHash() {
- return protocolContext.getBlockchain().getChainHeadHash();
+ return blockchain.getChainHeadHash();
}
@Override
public BlockHeader getChainHeadHeader() {
- return protocolContext.getBlockchain().getChainHeadHeader();
+ return blockchain.getChainHeadHeader();
}
@Override
public Optional getNextBlockBaseFee() {
- final var chainHeadHeader = protocolContext.getBlockchain().getChainHeadHeader();
+ final var chainHeadHeader = blockchain.getChainHeadHeader();
final var protocolSpec =
protocolSchedule.getForNextBlockHeader(chainHeadHeader, System.currentTimeMillis());
return Optional.of(protocolSpec.getFeeMarket())
diff --git a/besu/src/main/java/org/hyperledger/besu/services/MiningServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/MiningServiceImpl.java
new file mode 100644
index 0000000000..1ee4355066
--- /dev/null
+++ b/besu/src/main/java/org/hyperledger/besu/services/MiningServiceImpl.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright contributors to Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.services;
+
+import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
+import org.hyperledger.besu.plugin.services.mining.MiningService;
+
+/**
+ * Implementation of the {@link MiningService} interface. This class provides methods to start and
+ * stop the mining process using a {@link MiningCoordinator}.
+ */
+public class MiningServiceImpl implements MiningService {
+
+ private final MiningCoordinator miningCoordinator;
+
+ /**
+ * Constructs a new {@code MiningServiceImpl} with the specified {@link MiningCoordinator}.
+ *
+ * @param miningCoordinator the mining coordinator to be used for starting and stopping the mining
+ * process
+ */
+ public MiningServiceImpl(final MiningCoordinator miningCoordinator) {
+ this.miningCoordinator = miningCoordinator;
+ }
+
+ /** Stops the mining process by delegating to the {@link MiningCoordinator}. */
+ @Override
+ public void stop() {
+ miningCoordinator.stop();
+ }
+
+ /** Starts the mining process by delegating to the {@link MiningCoordinator}. */
+ @Override
+ public void start() {
+ miningCoordinator.start();
+ }
+}
diff --git a/besu/src/main/java/org/hyperledger/besu/services/PrivacyPluginServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/PrivacyPluginServiceImpl.java
index 4592753b9c..fe61c7a450 100644
--- a/besu/src/main/java/org/hyperledger/besu/services/PrivacyPluginServiceImpl.java
+++ b/besu/src/main/java/org/hyperledger/besu/services/PrivacyPluginServiceImpl.java
@@ -24,6 +24,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Privacy plugin service implementation. */
+@Deprecated(since = "24.11.0")
public class PrivacyPluginServiceImpl implements PrivacyPluginService {
private static final Logger LOG = LoggerFactory.getLogger(PrivacyPluginServiceImpl.class);
diff --git a/besu/src/main/java/org/hyperledger/besu/services/TransactionSimulationServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/TransactionSimulationServiceImpl.java
index 54cce205a3..4dc411ee0b 100644
--- a/besu/src/main/java/org/hyperledger/besu/services/TransactionSimulationServiceImpl.java
+++ b/besu/src/main/java/org/hyperledger/besu/services/TransactionSimulationServiceImpl.java
@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.services;
+import org.hyperledger.besu.datatypes.AccountOverrideMap;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Transaction;
import org.hyperledger.besu.ethereum.chain.Blockchain;
@@ -62,6 +63,17 @@ public class TransactionSimulationServiceImpl implements TransactionSimulationSe
final Hash blockHash,
final OperationTracer operationTracer,
final boolean isAllowExceedingBalance) {
+ return simulate(
+ transaction, Optional.empty(), blockHash, operationTracer, isAllowExceedingBalance);
+ }
+
+ @Override
+ public Optional simulate(
+ final Transaction transaction,
+ final Optional maybeAccountOverrides,
+ final Hash blockHash,
+ final OperationTracer operationTracer,
+ final boolean isAllowExceedingBalance) {
final CallParameter callParameter = CallParameter.fromTransaction(transaction);
@@ -79,6 +91,7 @@ public class TransactionSimulationServiceImpl implements TransactionSimulationSe
return transactionSimulator
.process(
callParameter,
+ maybeAccountOverrides,
isAllowExceedingBalance
? SIMULATOR_ALLOWING_EXCEEDING_BALANCE
: TransactionValidationParams.transactionSimulator(),
diff --git a/besu/src/main/scripts/unixStartScript.txt b/besu/src/main/scripts/unixStartScript.txt
index 3302b9c2fe..9e5c5a300b 100644
--- a/besu/src/main/scripts/unixStartScript.txt
+++ b/besu/src/main/scripts/unixStartScript.txt
@@ -182,19 +182,19 @@ APP_ARGS=`save "\$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- \$DEFAULT_JVM_OPTS \$JAVA_OPTS \$${optsEnvironmentVar} <% if ( appNameSystemProperty ) { %>"\"-D${appNameSystemProperty}=\$APP_BASE_NAME\"" <% } %>-classpath "\"\$CLASSPATH\"" <% if ( mainClassName.startsWith('--module ') ) { %>--module-path "\"\$MODULE_PATH\"" <% } %>${mainClassName} "\$APP_ARGS"
-unset BESU_USING_JEMALLOC
if [ "\$darwin" = "false" -a "\$msys" = "false" ]; then
- # check if jemalloc is available
- TEST_JEMALLOC=\$(LD_PRELOAD=libjemalloc.so sh -c true 2>&1)
-
- # if jemalloc is available the output is empty, otherwise the output has an error line
- if [ -z "\$TEST_JEMALLOC" ]; then
- export LD_PRELOAD=libjemalloc.so
- export BESU_USING_JEMALLOC=true
- else
- # jemalloc not available, as fallback limit malloc to 2 arenas
- export MALLOC_ARENA_MAX=2
- fi
+ if [ "\$BESU_USING_JEMALLOC" != "FALSE" -a "\$BESU_USING_JEMALLOC" != "false" ]; then
+ # check if jemalloc is available
+ TEST_JEMALLOC=\$(LD_PRELOAD=libjemalloc.so sh -c true 2>&1)
+
+ # if jemalloc is available the output is empty, otherwise the output has an error line
+ if [ -z "\$TEST_JEMALLOC" ]; then
+ export LD_PRELOAD=libjemalloc.so
+ else
+ # jemalloc not available, as fallback limit malloc to 2 arenas
+ export MALLOC_ARENA_MAX=2
+ fi
+ fi
fi
exec "\$JAVACMD" "\$@"
diff --git a/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java
index a246d18d2f..ff205e8751 100644
--- a/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java
@@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@@ -150,7 +150,7 @@ class FlexGroupPrivacyTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.dataStorageConfiguration(dataStorageConfiguration)
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
diff --git a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java
index 5a58091577..87bab916f2 100644
--- a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java
@@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.GenesisState;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.forkid.ForkId;
import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@@ -174,7 +174,7 @@ public class ForkIdsNetworkConfigTest {
(DefaultProtocolSchedule)
MainnetProtocolSchedule.fromConfig(
configOptions,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()));
@@ -184,7 +184,7 @@ public class ForkIdsNetworkConfigTest {
MergeProtocolSchedule.create(
configOptions,
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()));
diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java
index 6298b70a95..a79b664458 100644
--- a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java
@@ -47,7 +47,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.InMemoryPrivacyStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
@@ -547,7 +547,7 @@ public class PrivacyReorgTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.dataDirectory(dataDir)
diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java
index 4d488ced3b..305d786b8b 100644
--- a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java
@@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@@ -125,7 +125,7 @@ class PrivacyTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.dataStorageConfiguration(dataStorageConfiguration)
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
diff --git a/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java
index 7c5579d471..230de6efd2 100644
--- a/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java
@@ -49,7 +49,7 @@ import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@@ -128,7 +128,7 @@ public final class RunnerBuilderTest {
when(besuController.getProtocolContext()).thenReturn(protocolContext);
when(besuController.getProtocolSchedule()).thenReturn(protocolSchedule);
when(besuController.getNodeKey()).thenReturn(nodeKey);
- when(besuController.getMiningParameters()).thenReturn(mock(MiningParameters.class));
+ when(besuController.getMiningParameters()).thenReturn(mock(MiningConfiguration.class));
when(besuController.getPrivacyParameters()).thenReturn(mock(PrivacyParameters.class));
when(besuController.getTransactionPool())
.thenReturn(mock(TransactionPool.class, RETURNS_DEEP_STUBS));
diff --git a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java
index cbbf980408..4239cbdc34 100644
--- a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java
@@ -46,7 +46,7 @@ import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockImporter;
import org.hyperledger.besu.ethereum.core.BlockSyncTestUtils;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@@ -153,7 +153,15 @@ public final class RunnerTest {
// set merge flag to false, otherwise this test can fail if a merge test runs first
MergeConfiguration.setMergeEnabled(false);
- syncFromGenesis(SyncMode.FULL, getFastSyncGenesis());
+ syncFromGenesis(SyncMode.FULL, getFastSyncGenesis(), false);
+ }
+
+ @Test
+ public void fullSyncFromGenesisUsingPeerTaskSystem() throws Exception {
+ // set merge flag to false, otherwise this test can fail if a merge test runs first
+ MergeConfiguration.setMergeEnabled(false);
+
+ syncFromGenesis(SyncMode.FULL, getFastSyncGenesis(), true);
}
@Test
@@ -161,10 +169,21 @@ public final class RunnerTest {
// set merge flag to false, otherwise this test can fail if a merge test runs first
MergeConfiguration.setMergeEnabled(false);
- syncFromGenesis(SyncMode.FAST, getFastSyncGenesis());
+ syncFromGenesis(SyncMode.FAST, getFastSyncGenesis(), false);
+ }
+
+ @Test
+ public void fastSyncFromGenesisUsingPeerTaskSystem() throws Exception {
+ // set merge flag to false, otherwise this test can fail if a merge test runs first
+ MergeConfiguration.setMergeEnabled(false);
+
+ syncFromGenesis(SyncMode.FAST, getFastSyncGenesis(), true);
}
- private void syncFromGenesis(final SyncMode mode, final GenesisConfigFile genesisConfig)
+ private void syncFromGenesis(
+ final SyncMode mode,
+ final GenesisConfigFile genesisConfig,
+ final boolean isPeerTaskSystemEnabled)
throws Exception {
final Path dataDirAhead = Files.createTempDirectory(temp, "db-ahead");
final Path dbAhead = dataDirAhead.resolve("database");
@@ -172,9 +191,12 @@ public final class RunnerTest {
final NodeKey aheadDbNodeKey = NodeKeyUtils.createFrom(KeyPairUtil.loadKeyPair(dataDirAhead));
final NodeKey behindDbNodeKey = NodeKeyUtils.generate();
final SynchronizerConfiguration syncConfigAhead =
- SynchronizerConfiguration.builder().syncMode(SyncMode.FULL).build();
+ SynchronizerConfiguration.builder()
+ .syncMode(SyncMode.FULL)
+ .isPeerTaskSystemEnabled(isPeerTaskSystemEnabled)
+ .build();
final ObservableMetricsSystem noOpMetricsSystem = new NoOpMetricsSystem();
- final var miningParameters = MiningParameters.newDefault();
+ final var miningParameters = MiningConfiguration.newDefault();
final var dataStorageConfiguration = DataStorageConfiguration.DEFAULT_FOREST_CONFIG;
// Setup Runner with blocks
final BesuController controllerAhead =
@@ -393,11 +415,11 @@ public final class RunnerTest {
final Path dataDir,
final Path dbDir,
final DataStorageConfiguration dataStorageConfiguration,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
final var besuConfiguration = new BesuConfigurationImpl();
besuConfiguration
.init(dataDir, dbDir, dataStorageConfiguration)
- .withMiningParameters(miningParameters);
+ .withMiningParameters(miningConfiguration);
return new KeyValueStorageProviderBuilder()
.withStorageFactory(
new RocksDBKeyValueStorageFactory(
@@ -466,14 +488,14 @@ public final class RunnerTest {
final NodeKey nodeKey,
final StorageProvider storageProvider,
final ObservableMetricsSystem metricsSystem,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
return new MainnetBesuControllerBuilder()
.genesisConfigFile(genesisConfig)
.synchronizerConfiguration(syncConfig)
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.dataDirectory(dataDir)
.networkId(NETWORK_ID)
- .miningParameters(miningParameters)
+ .miningParameters(miningConfiguration)
.nodeKey(nodeKey)
.storageProvider(storageProvider)
.metricsSystem(metricsSystem)
diff --git a/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java
index bbc7dea1ab..e76c06fe2d 100644
--- a/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java
@@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@@ -94,7 +94,7 @@ public final class RlpBlockExporterTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT)
diff --git a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java
index 7b1a4bc7d2..2b534660ed 100644
--- a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java
@@ -17,9 +17,10 @@ package org.hyperledger.besu.chainimport;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Mockito.mock;
+import org.hyperledger.besu.components.BesuCommandModule;
import org.hyperledger.besu.components.BesuComponent;
+import org.hyperledger.besu.components.BesuPluginContextModule;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.JsonUtil;
import org.hyperledger.besu.controller.BesuController;
@@ -31,17 +32,21 @@ import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Transaction;
+import org.hyperledger.besu.ethereum.core.components.MiningParametersModule;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
+import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
+import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
+import org.hyperledger.besu.metrics.MetricsSystemModule;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@@ -52,9 +57,13 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
+import javax.inject.Singleton;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.io.Resources;
+import dagger.Component;
+import dagger.Module;
+import dagger.Provides;
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -449,7 +458,7 @@ public abstract class JsonBlockImporterTest {
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.valueOf(10))
.miningParameters(
- ImmutableMiningParameters.builder()
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
@@ -465,7 +474,28 @@ public abstract class JsonBlockImporterTest {
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
- .besuComponent(mock(BesuComponent.class))
+ .besuComponent(DaggerJsonBlockImporterTest_JsonBlockImportComponent.builder().build())
.build();
}
+
+ @Module
+ public static class JsonBlockImporterModule {
+
+ @Provides
+ BonsaiCachedMerkleTrieLoader provideCachedMerkleTrieLoaderModule() {
+ return new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem());
+ }
+ }
+
+ @Singleton
+ @Component(
+ modules = {
+ BesuCommandModule.class,
+ MiningParametersModule.class,
+ MetricsSystemModule.class,
+ JsonBlockImporterModule.class,
+ BesuPluginContextModule.class,
+ BlobCacheModule.class
+ })
+ interface JsonBlockImportComponent extends BesuComponent {}
}
diff --git a/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java
index 2d9e587c3f..9f405d4cb3 100644
--- a/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java
@@ -26,7 +26,7 @@ import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@@ -69,7 +69,7 @@ public final class RlpBlockImporterTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT)
@@ -103,7 +103,7 @@ public final class RlpBlockImporterTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT)
@@ -134,7 +134,7 @@ public final class RlpBlockImporterTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT)
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
index 019e8d83cd..eb789478b9 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
@@ -37,9 +37,11 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNotNull;
+import static org.mockito.Mockito.argThat;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
import org.hyperledger.besu.BesuInfo;
import org.hyperledger.besu.cli.config.EthNetworkConfig;
@@ -56,7 +58,7 @@ import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
@@ -99,7 +101,6 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
@@ -277,8 +278,8 @@ public class BesuCommandTest extends CommandTestAbstract {
verify(mockRunnerBuilder).build();
verify(mockControllerBuilderFactory).fromEthNetworkConfig(ethNetworkArg.capture(), any());
- final ArgumentCaptor miningArg =
- ArgumentCaptor.forClass(MiningParameters.class);
+ final ArgumentCaptor miningArg =
+ ArgumentCaptor.forClass(MiningConfiguration.class);
verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture());
verify(mockControllerBuilder).dataDirectory(isNotNull());
verify(mockControllerBuilder).miningParameters(miningArg.capture());
@@ -566,7 +567,7 @@ public class BesuCommandTest extends CommandTestAbstract {
parseCommand("--genesis-file", genesisFile.toString(), "--network", "mainnet");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
@@ -578,7 +579,7 @@ public class BesuCommandTest extends CommandTestAbstract {
final String nonExistentGenesis = "non-existent-genesis.json";
parseCommand("--genesis-file", nonExistentGenesis);
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).startsWith("Unable to load genesis file");
@@ -1177,7 +1178,7 @@ public class BesuCommandTest extends CommandTestAbstract {
parseCommand(
"--remote-connections-limit-enabled", "--remote-connections-max-percentage", "invalid");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1190,7 +1191,7 @@ public class BesuCommandTest extends CommandTestAbstract {
parseCommand(
"--remote-connections-limit-enabled", "--remote-connections-max-percentage", "150");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1225,7 +1226,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test
public void syncMode_invalid() {
parseCommand("--sync-mode", "bogus");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
@@ -1275,7 +1276,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void helpShouldDisplayFastSyncOptions() {
parseCommand("--help");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).contains("--fast-sync-min-peers");
// whitelist is now a hidden option
@@ -1335,7 +1336,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void parsesInvalidFastSyncMinPeersOptionWrongFormatShouldFail() {
parseCommand("--sync-mode", "FAST", "--fast-sync-min-peers", "ten");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains("Invalid value for option '--fast-sync-min-peers': 'ten' is not an int");
@@ -1358,7 +1359,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void netRestrictInvalidShouldFail() {
final String subnet = "127.0.0.1/abc";
parseCommand("--net-restrict", subnet);
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandErrorOutput.toString(UTF_8))
.contains("Invalid value for option '--net-restrict'");
}
@@ -1382,7 +1383,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test
public void ethStatsContactOptionCannotBeUsedWithoutEthStatsServerProvided() {
parseCommand("--ethstats-contact", "besu-updated");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1435,7 +1436,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void parsesInvalidWhenFullSyncAndBonsaiLimitTrieLogsExplicitlyTrue() {
parseCommand("--sync-mode=FULL", "--bonsai-limit-trie-logs-enabled=true");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1467,7 +1468,7 @@ public class BesuCommandTest extends CommandTestAbstract {
parseCommand("--data-storage-format", "BONSAI", "--bonsai-maximum-back-layers-to-load", "ten");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1501,7 +1502,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test
public void dnsUpdateEnabledOptionCannotBeUsedWithoutDnsEnabled() {
parseCommand("--Xdns-update-enabled", "true");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1720,6 +1721,17 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
+ @Test
+ public void metricsUnknownCategoryRaiseError() {
+ parseCommand("--metrics-enabled", "--metrics-category", "UNKNOWN_CATEGORY");
+
+ verifyNoInteractions(mockRunnerBuilder);
+
+ assertThat(commandOutput.toString(UTF_8)).isEmpty();
+ assertThat(commandErrorOutput.toString(UTF_8))
+ .startsWith("--metrics-categories contains unknown categories: [UNKNOWN_CATEGORY]");
+ }
+
@Test
public void metricsPushEnabledPropertyMustBeUsed() {
parseCommand("--metrics-push-enabled");
@@ -1799,7 +1811,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void metricsAndMetricsPushMustNotBeUsedTogether() {
parseCommand("--metrics-enabled", "--metrics-push-enabled");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
@@ -2023,7 +2035,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void fullCLIOptionsShown() {
parseCommand("--help");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).contains("--config-file");
assertThat(commandOutput.toString(UTF_8)).contains("--data-path");
@@ -2401,13 +2413,16 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test
public void logsWarningWhenFailToLoadJemalloc() {
assumeTrue(PlatformDetector.getOSType().equals("linux"));
- setEnvironmentVariable("BESU_USING_JEMALLOC", "true");
+ setEnvironmentVariable("BESU_USING_JEMALLOC", "false");
parseCommand();
verify(mockLogger)
.warn(
- eq(
- "BESU_USING_JEMALLOC is present but we failed to load jemalloc library to get the version"),
- any(Throwable.class));
+ argThat(
+ arg ->
+ arg.equals(
+ "besu_using_jemalloc is present but is not set to true, jemalloc library not loaded")
+ || arg.equals(
+ "besu_using_jemalloc is present but we failed to load jemalloc library to get the version")));
}
@Test
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java b/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java
index 4cdd8163d9..c142838814 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java
@@ -33,7 +33,7 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
@@ -200,7 +200,7 @@ public class CascadingDefaultProviderTest extends CommandTestAbstract {
setEnvironmentVariable("BESU_MINER_COINBASE", expectedCoinbase);
parseCommand("--config-file", configFile);
- final var captMiningParameters = ArgumentCaptor.forClass(MiningParameters.class);
+ final var captMiningParameters = ArgumentCaptor.forClass(MiningConfiguration.class);
verify(mockControllerBuilder).miningParameters(captMiningParameters.capture());
assertThat(captMiningParameters.getValue().getCoinbase())
@@ -219,7 +219,7 @@ public class CascadingDefaultProviderTest extends CommandTestAbstract {
setEnvironmentVariable("BESU_MINER_COINBASE", "0x0000000000000000000000000000000000000004");
parseCommand("--config-file", configFile, "--miner-coinbase", expectedCoinbase);
- final var captMiningParameters = ArgumentCaptor.forClass(MiningParameters.class);
+ final var captMiningParameters = ArgumentCaptor.forClass(MiningConfiguration.class);
verify(mockControllerBuilder).miningParameters(captMiningParameters.capture());
assertThat(captMiningParameters.getValue().getCoinbase())
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
index 5c7bf3ce88..7239659398 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
@@ -34,13 +34,13 @@ import org.hyperledger.besu.chainexport.RlpBlockExporter;
import org.hyperledger.besu.chainimport.JsonBlockImporter;
import org.hyperledger.besu.chainimport.RlpBlockImporter;
import org.hyperledger.besu.cli.config.EthNetworkConfig;
+import org.hyperledger.besu.cli.options.EthProtocolOptions;
+import org.hyperledger.besu.cli.options.EthstatsOptions;
import org.hyperledger.besu.cli.options.MiningOptions;
+import org.hyperledger.besu.cli.options.NetworkingOptions;
+import org.hyperledger.besu.cli.options.SynchronizerOptions;
import org.hyperledger.besu.cli.options.TransactionPoolOptions;
-import org.hyperledger.besu.cli.options.stable.EthstatsOptions;
import org.hyperledger.besu.cli.options.storage.DataStorageOptions;
-import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
-import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
-import org.hyperledger.besu.cli.options.unstable.SynchronizerOptions;
import org.hyperledger.besu.components.BesuComponent;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.controller.BesuController;
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java b/besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java
deleted file mode 100644
index 8c78b7fecc..0000000000
--- a/besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright ConsenSys AG.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package org.hyperledger.besu.cli.converter;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.Mockito.when;
-
-import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-@ExtendWith(MockitoExtension.class)
-public class MetricCategoryConverterTest {
-
- private MetricCategoryConverter metricCategoryConverter;
-
- @Mock MetricCategory metricCategory;
-
- @BeforeEach
- public void setUp() {
- metricCategoryConverter = new MetricCategoryConverter();
- }
-
- @Test
- public void convertShouldFailIfValueNotRegistered() {
- assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> metricCategoryConverter.convert("notRegistered"));
- }
-
- @Test
- public void addRegistryCategoryShouldUppercaseInputValues() {
- when(metricCategory.getName()).thenReturn("testcat");
- metricCategoryConverter.addRegistryCategory(metricCategory);
- when(metricCategory.getName()).thenReturn("tesTCat2");
- metricCategoryConverter.addRegistryCategory(metricCategory);
-
- final boolean containsLowercase =
- metricCategoryConverter.getMetricCategories().keySet().stream()
- .anyMatch(testString -> testString.chars().anyMatch(Character::isLowerCase));
-
- assertThat(containsLowercase).isFalse();
- assertThat(metricCategoryConverter.getMetricCategories().size()).isEqualTo(2);
- assertThat(metricCategoryConverter.getMetricCategories().keySet())
- .containsExactlyInAnyOrder("TESTCAT", "TESTCAT2");
- }
-}
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java
index 6f7aa637cd..33c91f2c03 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java
@@ -18,7 +18,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verifyNoInteractions;
-import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.junit.jupiter.api.Test;
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/LoggingLevelOptionTest.java
similarity index 97%
rename from besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java
rename to besu/src/test/java/org/hyperledger/besu/cli/options/LoggingLevelOptionTest.java
index b1fb3217c2..78c0f694ad 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/options/LoggingLevelOptionTest.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java
index 992dcc437d..f68a87643b 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java
@@ -14,15 +14,32 @@
*/
package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.stable.MetricsOptions;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.hyperledger.besu.metrics.BesuMetricCategory;
+import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl;
+import org.hyperledger.besu.metrics.StandardMetricCategory;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
+import java.util.EnumSet;
+import java.util.stream.Collectors;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
public class MetricsOptionsTest
extends AbstractCLIOptionsTest {
+ private MetricCategoryRegistryImpl categoryRegistry;
+
+ @BeforeEach
+ public void setUp() {
+ categoryRegistry = new MetricCategoryRegistryImpl();
+ categoryRegistry.addCategories(BesuMetricCategory.class);
+ categoryRegistry.addCategories(StandardMetricCategory.class);
+ }
@Override
protected MetricsConfiguration.Builder createDefaultDomainObject() {
@@ -39,11 +56,36 @@ public class MetricsOptionsTest
@Override
protected MetricsOptions optionsFromDomainObject(
final MetricsConfiguration.Builder domainObject) {
- return MetricsOptions.fromConfiguration(domainObject.build());
+ final var options = MetricsOptions.fromConfiguration(domainObject.build());
+ options.setMetricCategoryRegistry(categoryRegistry);
+ return options;
}
@Override
protected MetricsOptions getOptionsFromBesuCommand(final TestBesuCommand besuCommand) {
return besuCommand.getMetricsOptions();
}
+
+ @Override
+ protected String[] getNonOptionFields() {
+ return new String[] {"metricCategoryRegistry"};
+ }
+
+ @Test
+ public void enableRocksDbCategories() {
+ final var rocksDbMetricsCategories =
+ EnumSet.of(
+ BesuMetricCategory.KVSTORE_ROCKSDB,
+ BesuMetricCategory.KVSTORE_ROCKSDB_STATS,
+ BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB,
+ BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB_STATS);
+
+ internalTestSuccess(
+ metricsConfBuilder -> {
+ assertThat(metricsConfBuilder.build().getMetricCategories())
+ .containsExactlyInAnyOrderElementsOf(rocksDbMetricsCategories);
+ },
+ "--metrics-categories",
+ rocksDbMetricsCategories.stream().map(Enum::name).collect(Collectors.joining(",")));
+ }
}
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java
index e32ff0e463..f94504ea47 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java
@@ -15,19 +15,19 @@
package org.hyperledger.besu.cli.options;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.verify;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.Unstable;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.Unstable;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber;
import java.io.IOException;
@@ -42,7 +42,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
-public class MiningOptionsTest extends AbstractCLIOptionsTest {
+public class MiningOptionsTest extends AbstractCLIOptionsTest {
@Test
public void besuDoesNotStartInMiningModeIfCoinbaseNotSet() {
@@ -390,13 +390,13 @@ public class MiningOptionsTest extends AbstractCLIOptionsTest besuControllerBuilderSchedule = new TreeMap<>();
besuControllerBuilderSchedule.put(0L, besuControllerBuilder1);
@@ -180,15 +180,14 @@ public class ConsensusScheduleBesuControllerBuilderTest {
new ConsensusScheduleBesuControllerBuilder(besuControllerBuilderSchedule);
final ConsensusContext consensusContext =
controllerBuilder.createConsensusContext(
- Mockito.mock(Blockchain.class),
- Mockito.mock(WorldStateArchive.class),
- Mockito.mock(ProtocolSchedule.class));
+ mock(Blockchain.class), mock(WorldStateArchive.class), mock(ProtocolSchedule.class));
- assertThat(consensusContext).isInstanceOf(MigratingContext.class);
- final MigratingContext migratingContext = (MigratingContext) consensusContext;
+ assertThat(consensusContext).isInstanceOf(MigratingConsensusContext.class);
+ final MigratingConsensusContext migratingConsensusContext =
+ (MigratingConsensusContext) consensusContext;
final ForksSchedule contextSchedule =
- migratingContext.getConsensusContextSchedule();
+ migratingConsensusContext.getConsensusContextSchedule();
final NavigableSet> expectedConsensusContextSpecs =
new TreeSet<>(ForkSpec.COMPARATOR);
diff --git a/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java
index f8c00b20ea..47971b6442 100644
--- a/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java
@@ -41,7 +41,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
@@ -95,7 +95,7 @@ public class MergeBesuControllerBuilderTest {
@Mock CheckpointConfigOptions checkpointConfigOptions;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- MiningParameters miningParameters;
+ MiningConfiguration miningConfiguration;
@Mock PrivacyParameters privacyParameters;
@Mock Clock clock;
@@ -167,7 +167,7 @@ public class MergeBesuControllerBuilderTest {
lenient()
.when(worldStateKeyValueStorage.updater())
.thenReturn(mock(ForestWorldStateKeyValueStorage.Updater.class));
- lenient().when(miningParameters.getTargetGasLimit()).thenReturn(OptionalLong.empty());
+ lenient().when(miningConfiguration.getTargetGasLimit()).thenReturn(OptionalLong.empty());
besuControllerBuilder = visitWithMockConfigs(new MergeBesuControllerBuilder());
}
@@ -179,7 +179,7 @@ public class MergeBesuControllerBuilderTest {
.genesisConfigFile(genesisConfigFile)
.synchronizerConfiguration(synchronizerConfiguration)
.ethProtocolConfiguration(ethProtocolConfiguration)
- .miningParameters(miningParameters)
+ .miningParameters(miningConfiguration)
.metricsSystem(observableMetricsSystem)
.privacyParameters(privacyParameters)
.dataDirectory(tempDir)
diff --git a/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java
index a6cb42b185..5e41a65bd0 100644
--- a/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java
@@ -32,7 +32,7 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import java.util.List;
@@ -108,7 +108,7 @@ public class QbftBesuControllerBuilderTest extends AbstractBftBesuControllerBuil
assertThatThrownBy(
() ->
bftBesuControllerBuilder.createAdditionalJsonRpcMethodFactory(
- protocolContext, protocolSchedule, MiningParameters.newDefault()))
+ protocolContext, protocolSchedule, MiningConfiguration.newDefault()))
.isInstanceOf(NullPointerException.class)
.hasMessage("transactionValidatorProvider should have been initialised");
}
diff --git a/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java
index 40d72e4ed1..24b0133a0f 100644
--- a/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java
@@ -35,10 +35,10 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -84,7 +84,7 @@ public class TransitionControllerBuilderTest {
CliqueBesuControllerBuilder cliqueBuilder = new CliqueBesuControllerBuilder();
BesuControllerBuilder powBuilder = new MainnetBesuControllerBuilder();
MergeBesuControllerBuilder postMergeBuilder = new MergeBesuControllerBuilder();
- MiningParameters miningParameters;
+ MiningConfiguration miningConfiguration;
TransitionProtocolSchedule transitionProtocolSchedule;
@@ -118,27 +118,27 @@ public class TransitionControllerBuilderTest {
.thenReturn(mergeContext);
when(ethProtocolManager.ethContext().getScheduler())
.thenReturn(new DeterministicEthScheduler());
- miningParameters = MiningParameters.newDefault();
+ miningConfiguration = MiningConfiguration.newDefault();
}
@Test
public void assertCliqueMiningOverridePreMerge() {
- assertThat(miningParameters.isMiningEnabled()).isFalse();
+ assertThat(miningConfiguration.isMiningEnabled()).isFalse();
var transCoordinator = buildTransitionCoordinator(cliqueBuilder, postMergeBuilder);
assertThat(transCoordinator.isMiningBeforeMerge()).isTrue();
}
@Test
public void assertPoWIsNotMiningPreMerge() {
- assertThat(miningParameters.isMiningEnabled()).isFalse();
+ assertThat(miningConfiguration.isMiningEnabled()).isFalse();
var transCoordinator = buildTransitionCoordinator(powBuilder, postMergeBuilder);
assertThat(transCoordinator.isMiningBeforeMerge()).isFalse();
}
@Test
public void assertPowMiningPreMerge() {
- miningParameters =
- ImmutableMiningParameters.builder()
+ miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(MutableInitValues.builder().isMiningEnabled(true).build())
.build();
var transCoordinator = buildTransitionCoordinator(powBuilder, postMergeBuilder);
@@ -273,7 +273,7 @@ public class TransitionControllerBuilderTest {
transitionProtocolSchedule,
protocolContext,
transactionPool,
- miningParameters,
+ miningConfiguration,
syncState,
ethProtocolManager);
diff --git a/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java
index f2f78f102a..7e1edb601e 100644
--- a/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java
@@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
@@ -173,7 +173,7 @@ public class BesuEventsImplTest {
syncState,
txPoolConfig,
new BlobCache(),
- MiningParameters.newDefault());
+ MiningConfiguration.newDefault());
serviceImpl =
new BesuEventsImpl(
diff --git a/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java
index 1e734f6231..bcbf1c2fe7 100644
--- a/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java
@@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.log.Log;
import org.hyperledger.besu.evm.worldstate.WorldView;
@@ -80,7 +80,7 @@ class TraceServiceImplTest {
blockchainSetupUtil.getProtocolSchedule(),
blockchain,
worldStateArchive,
- MiningParameters.newDefault());
+ MiningConfiguration.newDefault());
traceService =
new TraceServiceImpl(blockchainQueries, blockchainSetupUtil.getProtocolSchedule());
}
diff --git a/besu/src/test/resources/everything_config.toml b/besu/src/test/resources/everything_config.toml
index e89442f7f7..960b2b5772 100644
--- a/besu/src/test/resources/everything_config.toml
+++ b/besu/src/test/resources/everything_config.toml
@@ -120,6 +120,19 @@ rpc-ws-max-frame-size=65535
rpc-ws-authentication-enabled=false
rpc-ws-authentication-credentials-file="none"
rpc-ws-authentication-jwt-public-key-file="none"
+rpc-ws-ssl-enabled=false
+rpc-ws-ssl-keystore-file="none.pfx"
+rpc-ws-ssl-keystore-password="none.passwd"
+rpc-ws-ssl-keystore-type="none"
+rpc-ws-ssl-client-auth-enabled=false
+rpc-ws-ssl-truststore-file="none.pfx"
+rpc-ws-ssl-truststore-password="none.passwd"
+rpc-ws-ssl-truststore-type="none"
+rpc-ws-ssl-key-file="none.pfx"
+rpc-ws-ssl-cert-file="none.pfx"
+rpc-ws-ssl-trustcert-file="none.pfx"
+
+
# API
api-gas-price-blocks=100
diff --git a/build.gradle b/build.gradle
index 09a600dd25..1981965a8e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -418,9 +418,6 @@ configure(allprojects - project(':platform')) {
'-org.hyperledger.besu.ethereum.permissioning.*,' +
// referencetests module
'-org.hyperledger.besu.ethereum.referencetests,' +
- // retesteth module
- '-org.hyperledger.besu.ethereum.retesteth.methods,' +
- '-org.hyperledger.besu.ethereum.retesteth,' +
//rlp module
'-org.hyperledger.besu.ethereum.rlp,' +
// stratum module
diff --git a/config/build.gradle b/config/build.gradle
index a78b9a7105..e269ce51fc 100644
--- a/config/build.gradle
+++ b/config/build.gradle
@@ -36,11 +36,13 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.guava:guava'
+ implementation 'com.google.dagger:dagger'
implementation 'info.picocli:picocli'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'
implementation "org.immutables:value-annotations"
annotationProcessor "org.immutables:value"
+ annotationProcessor 'com.google.dagger:dagger-compiler'
testImplementation project(':testutil')
diff --git a/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java b/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java
index 6b42c3c2ed..4ee99f0bd8 100644
--- a/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java
+++ b/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java
@@ -80,7 +80,9 @@ interface GenesisReader {
final var on = normalizeKeys((ObjectNode) entry.getValue());
return new GenesisAccount(
Address.fromHexString(entry.getKey()),
- JsonUtil.getString(on, "nonce").map(ParserUtils::parseUnsignedLong).orElse(0L),
+ JsonUtil.getValueAsString(on, "nonce")
+ .map(ParserUtils::parseUnsignedLong)
+ .orElse(0L),
JsonUtil.getString(on, "balance")
.map(ParserUtils::parseBalance)
.orElse(Wei.ZERO),
diff --git a/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java b/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java
index f8327174a3..eab6dfac73 100644
--- a/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java
+++ b/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java
@@ -17,6 +17,7 @@ package org.hyperledger.besu.config;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.config.GenesisReader.ALLOCATION_FIELD;
import static org.hyperledger.besu.config.GenesisReader.CONFIG_FIELD;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
@@ -27,6 +28,7 @@ import java.nio.file.Path;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -111,4 +113,17 @@ public class GenesisReaderTest {
entry.put("balance", balance.toShortHexString());
return entry;
}
+
+ @Test
+ void testNonceHandlingAsStringAndInteger() {
+ ObjectNode accountNode = JsonNodeFactory.instance.objectNode();
+
+ accountNode.put("nonce", 10);
+ String nonceAsStringFromInt = JsonUtil.getValueAsString(accountNode, "nonce").orElse("");
+ assertEquals("10", nonceAsStringFromInt, "Nonce should convert integer to string correctly");
+
+ accountNode.put("nonce", "20");
+ String nonceAsStringDirect = JsonUtil.getValueAsString(accountNode, "nonce").orElse("");
+ assertEquals("20", nonceAsStringDirect, "Nonce should keep string as string correctly");
+ }
}
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculator.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculator.java
index a5771238d2..b0869feb23 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculator.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculator.java
@@ -15,7 +15,6 @@
package org.hyperledger.besu.consensus.clique;
import org.hyperledger.besu.datatypes.Address;
-import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.mainnet.DifficultyCalculator;
@@ -39,12 +38,9 @@ public class CliqueDifficultyCalculator implements DifficultyCalculator {
}
@Override
- public BigInteger nextDifficulty(
- final long time, final BlockHeader parent, final ProtocolContext context) {
+ public BigInteger nextDifficulty(final long time, final BlockHeader parent) {
- final Address nextProposer =
- CliqueHelpers.getProposerForBlockAfter(
- parent, context.getConsensusContext(CliqueContext.class).getValidatorProvider());
+ final Address nextProposer = CliqueHelpers.getProposerForBlockAfter(parent);
return nextProposer.equals(localAddress) ? IN_TURN_DIFFICULTY : OUT_OF_TURN_DIFFICULTY;
}
}
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueHelpers.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueHelpers.java
index cba98a5a5e..d64fe899a6 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueHelpers.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueHelpers.java
@@ -27,9 +27,20 @@ import java.util.Comparator;
/** The Clique helpers. */
public class CliqueHelpers {
+ private static CliqueContext cliqueContext;
+
/** Default constructor. */
CliqueHelpers() {}
+ /**
+ * Set the clique consensus context
+ *
+ * @param cliqueContext the clique consensus context
+ */
+ public static void setCliqueContext(final CliqueContext cliqueContext) {
+ CliqueHelpers.cliqueContext = cliqueContext;
+ }
+
/**
* Gets proposer of block.
*
@@ -45,12 +56,11 @@ public class CliqueHelpers {
* Gets proposer for block after.
*
* @param parent the parent
- * @param validatorProvider the validator provider
* @return the proposer for block after
*/
- static Address getProposerForBlockAfter(
- final BlockHeader parent, final ValidatorProvider validatorProvider) {
- final CliqueProposerSelector proposerSelector = new CliqueProposerSelector(validatorProvider);
+ static Address getProposerForBlockAfter(final BlockHeader parent) {
+ final CliqueProposerSelector proposerSelector =
+ new CliqueProposerSelector(cliqueContext.getValidatorProvider());
return proposerSelector.selectProposerForNextBlock(parent);
}
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueMiningTracker.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueMiningTracker.java
index d636212283..8f350609dc 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueMiningTracker.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueMiningTracker.java
@@ -42,10 +42,7 @@ public class CliqueMiningTracker {
* @return the boolean
*/
public boolean isProposerAfter(final BlockHeader header) {
- final Address nextProposer =
- CliqueHelpers.getProposerForBlockAfter(
- header,
- protocolContext.getConsensusContext(CliqueContext.class).getValidatorProvider());
+ final Address nextProposer = CliqueHelpers.getProposerForBlockAfter(header);
return localAddress.equals(nextProposer);
}
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java
index cd19755638..a60fcc5812 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java
@@ -22,7 +22,7 @@ import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
@@ -44,8 +44,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
-import com.google.common.annotations.VisibleForTesting;
-
/** Defines the protocol behaviours for a blockchain using Clique. */
public class CliqueProtocolSchedule {
@@ -63,7 +61,7 @@ public class CliqueProtocolSchedule {
* @param privacyParameters the privacy parameters
* @param isRevertReasonEnabled the is revert reason enabled
* @param evmConfiguration the evm configuration
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining configuration
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -77,7 +75,7 @@ public class CliqueProtocolSchedule {
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -110,57 +108,18 @@ public class CliqueProtocolSchedule {
return new ProtocolScheduleBuilder(
config,
- DEFAULT_CHAIN_ID,
+ Optional.of(DEFAULT_CHAIN_ID),
specAdapters,
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem)
.createProtocolSchedule();
}
- /**
- * Create protocol schedule.
- *
- * @param config the config
- * @param forksSchedule the transitions
- * @param nodeKey the node key
- * @param isRevertReasonEnabled the is revert reason enabled
- * @param evmConfiguration the evm configuration
- * @param miningParameters the mining parameters
- * @param badBlockManager the cache to use to keep invalid blocks
- * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
- * @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
- * calls
- * @return the protocol schedule
- */
- @VisibleForTesting
- public static ProtocolSchedule create(
- final GenesisConfigOptions config,
- final ForksSchedule forksSchedule,
- final NodeKey nodeKey,
- final boolean isRevertReasonEnabled,
- final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
- final BadBlockManager badBlockManager,
- final boolean isParallelTxProcessingEnabled,
- final MetricsSystem metricsSystem) {
- return create(
- config,
- forksSchedule,
- nodeKey,
- PrivacyParameters.DEFAULT,
- isRevertReasonEnabled,
- evmConfiguration,
- miningParameters,
- badBlockManager,
- isParallelTxProcessingEnabled,
- metricsSystem);
- }
-
private static ProtocolSpecBuilder applyCliqueSpecificModifications(
final EpochManager epochManager,
final long secondsBetweenBlocks,
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java
index ed17529a9f..18d3449ba8 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java
@@ -29,7 +29,7 @@ import org.hyperledger.besu.ethereum.blockcreation.AbstractBlockCreator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.SealableBlockHeader;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -48,7 +48,7 @@ public class CliqueBlockCreator extends AbstractBlockCreator {
/**
* Instantiates a new Clique block creator.
*
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param extraDataCalculator the extra data calculator
* @param transactionPool the pending transactions
* @param protocolContext the protocol context
@@ -58,7 +58,7 @@ public class CliqueBlockCreator extends AbstractBlockCreator {
* @param ethScheduler the scheduler for asynchronous block creation tasks
*/
public CliqueBlockCreator(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final ExtraDataCalculator extraDataCalculator,
final TransactionPool transactionPool,
final ProtocolContext protocolContext,
@@ -67,7 +67,7 @@ public class CliqueBlockCreator extends AbstractBlockCreator {
final EpochManager epochManager,
final EthScheduler ethScheduler) {
super(
- miningParameters,
+ miningConfiguration,
__ -> Util.publicKeyToAddress(nodeKey.getPublicKey()),
extraDataCalculator,
transactionPool,
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java
index ef3d58fbff..998a237e91 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java
@@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.blockcreation.AbstractMinerExecutor;
import org.hyperledger.besu.ethereum.chain.MinedBlockObserver;
import org.hyperledger.besu.ethereum.chain.PoWObserver;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -70,7 +70,7 @@ public class CliqueMinerExecutor extends AbstractMinerExecutor
final ProtocolSchedule protocolSchedule,
final TransactionPool transactionPool,
final NodeKey nodeKey,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final AbstractBlockScheduler blockScheduler,
final EpochManager epochManager,
final ForksSchedule forksSchedule,
@@ -97,7 +97,7 @@ public class CliqueMinerExecutor extends AbstractMinerExecutor
final Function blockCreator =
(header) ->
new CliqueBlockCreator(
- miningParameters,
+ miningConfiguration,
this::calculateExtraData,
transactionPool,
protocolContext,
@@ -119,7 +119,7 @@ public class CliqueMinerExecutor extends AbstractMinerExecutor
@Override
public Optional getCoinbase() {
- return miningParameters.getCoinbase();
+ return miningConfiguration.getCoinbase();
}
/**
@@ -134,7 +134,7 @@ public class CliqueMinerExecutor extends AbstractMinerExecutor
final Bytes vanityDataToInsert =
ConsensusHelpers.zeroLeftPad(
- miningParameters.getExtraData(), CliqueExtraData.EXTRA_VANITY_LENGTH);
+ miningConfiguration.getExtraData(), CliqueExtraData.EXTRA_VANITY_LENGTH);
// Building ON TOP of canonical head, if the next block is epoch, include validators.
if (epochManager.isEpochBlock(parentHeader.getNumber() + 1)) {
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRule.java
index a14b5187ef..87c83b2cb0 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRule.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRule.java
@@ -38,10 +38,9 @@ public class CliqueDifficultyValidationRule implements AttachedBlockHeaderValida
public boolean validate(
final BlockHeader header, final BlockHeader parent, final ProtocolContext protocolContext) {
final Address actualBlockCreator = CliqueHelpers.getProposerOfBlock(header);
-
final CliqueDifficultyCalculator diffCalculator =
new CliqueDifficultyCalculator(actualBlockCreator);
- final BigInteger expectedDifficulty = diffCalculator.nextDifficulty(0, parent, protocolContext);
+ final BigInteger expectedDifficulty = diffCalculator.nextDifficulty(0, parent);
final BigInteger actualDifficulty = header.getDifficulty().toBigInteger();
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java
index 762cce1c56..4e1e75f54c 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java
@@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.ApiGroupJsonRpcMethods;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
@@ -41,22 +41,22 @@ import java.util.Map;
public class CliqueJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final ProtocolContext context;
private final ProtocolSchedule protocolSchedule;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
/**
* Instantiates a new Clique json rpc methods.
*
* @param context the protocol context
* @param protocolSchedule the protocol schedule
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
*/
public CliqueJsonRpcMethods(
final ProtocolContext context,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
this.context = context;
this.protocolSchedule = protocolSchedule;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -69,7 +69,7 @@ public class CliqueJsonRpcMethods extends ApiGroupJsonRpcMethods {
final MutableBlockchain blockchain = context.getBlockchain();
final WorldStateArchive worldStateArchive = context.getWorldStateArchive();
final BlockchainQueries blockchainQueries =
- new BlockchainQueries(protocolSchedule, blockchain, worldStateArchive, miningParameters);
+ new BlockchainQueries(protocolSchedule, blockchain, worldStateArchive, miningConfiguration);
final ValidatorProvider validatorProvider =
context.getConsensusContext(CliqueContext.class).getValidatorProvider();
diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculatorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculatorTest.java
index 3c9da2520d..74537b2ad1 100644
--- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculatorTest.java
+++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueDifficultyCalculatorTest.java
@@ -23,8 +23,6 @@ import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.datatypes.Address;
-import org.hyperledger.besu.ethereum.ProtocolContext;
-import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.AddressHelpers;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
@@ -43,9 +41,7 @@ public class CliqueDifficultyCalculatorTest {
private Address localAddr;
private final List validatorList = Lists.newArrayList();
- private ProtocolContext cliqueProtocolContext;
private BlockHeaderTestFixture blockHeaderBuilder;
- private final CliqueBlockInterface blockInterface = new CliqueBlockInterface();
@BeforeEach
public void setup() {
@@ -56,9 +52,7 @@ public class CliqueDifficultyCalculatorTest {
final ValidatorProvider validatorProvider = mock(ValidatorProvider.class);
when(validatorProvider.getValidatorsAfterBlock(any())).thenReturn(validatorList);
-
- final CliqueContext cliqueContext = new CliqueContext(validatorProvider, null, blockInterface);
- cliqueProtocolContext = new ProtocolContext(null, null, cliqueContext, new BadBlockManager());
+ CliqueHelpers.setCliqueContext(new CliqueContext(validatorProvider, null, null));
blockHeaderBuilder = new BlockHeaderTestFixture();
}
@@ -68,8 +62,7 @@ public class CliqueDifficultyCalculatorTest {
final BlockHeader parentHeader = blockHeaderBuilder.number(1).buildHeader();
- assertThat(calculator.nextDifficulty(0, parentHeader, cliqueProtocolContext))
- .isEqualTo(BigInteger.valueOf(2));
+ assertThat(calculator.nextDifficulty(0, parentHeader)).isEqualTo(BigInteger.valueOf(2));
}
@Test
@@ -78,7 +71,6 @@ public class CliqueDifficultyCalculatorTest {
final BlockHeader parentHeader = blockHeaderBuilder.number(2).buildHeader();
- assertThat(calculator.nextDifficulty(0, parentHeader, cliqueProtocolContext))
- .isEqualTo(BigInteger.valueOf(1));
+ assertThat(calculator.nextDifficulty(0, parentHeader)).isEqualTo(BigInteger.valueOf(1));
}
}
diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java
index 5cbdbb6d06..4774120622 100644
--- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java
+++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java
@@ -32,7 +32,8 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
+import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
@@ -66,9 +67,10 @@ public class CliqueProtocolScheduleTest {
config,
new ForksSchedule<>(List.of()),
NODE_KEY,
+ PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -92,9 +94,10 @@ public class CliqueProtocolScheduleTest {
GenesisConfigFile.DEFAULT.getConfigOptions(),
forksSchedule,
NODE_KEY,
+ PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
@@ -118,9 +121,10 @@ public class CliqueProtocolScheduleTest {
genesisConfig,
new ForksSchedule<>(List.of()),
NODE_KEY,
+ PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()))
@@ -140,9 +144,10 @@ public class CliqueProtocolScheduleTest {
genesisConfig,
new ForksSchedule<>(List.of()),
NODE_KEY,
+ PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()))
@@ -166,9 +171,10 @@ public class CliqueProtocolScheduleTest {
config,
forksSchedule,
NODE_KEY,
+ PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java
index ca76517c62..0ece282332 100644
--- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java
+++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java
@@ -49,9 +49,10 @@ import org.hyperledger.besu.ethereum.core.AddressHelpers;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
+import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -99,26 +100,29 @@ public class CliqueBlockCreatorTest {
@BeforeEach
void setup() {
+ final Address otherAddress = Util.publicKeyToAddress(otherKeyPair.getPublicKey());
+ validatorList.add(otherAddress);
+
+ validatorProvider = mock(ValidatorProvider.class);
+ voteProvider = mock(VoteProvider.class);
+ when(validatorProvider.getVoteProviderAtHead()).thenReturn(Optional.of(voteProvider));
+ when(validatorProvider.getValidatorsAfterBlock(any())).thenReturn(validatorList);
+
protocolSchedule =
CliqueProtocolSchedule.create(
GenesisConfigFile.DEFAULT.getConfigOptions(),
new ForksSchedule<>(List.of()),
proposerNodeKey,
+ PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
- final Address otherAddress = Util.publicKeyToAddress(otherKeyPair.getPublicKey());
- validatorList.add(otherAddress);
-
- validatorProvider = mock(ValidatorProvider.class);
- voteProvider = mock(VoteProvider.class);
- when(validatorProvider.getVoteProviderAtHead()).thenReturn(Optional.of(voteProvider));
- when(validatorProvider.getValidatorsAfterBlock(any())).thenReturn(validatorList);
final CliqueContext cliqueContext = new CliqueContext(validatorProvider, null, blockInterface);
+ CliqueHelpers.setCliqueContext(cliqueContext);
final Block genesis =
GenesisState.fromConfig(GenesisConfigFile.mainnet(), protocolSchedule).getBlock();
@@ -146,11 +150,11 @@ public class CliqueBlockCreatorTest {
final Address coinbase = AddressHelpers.ofValue(1);
- final MiningParameters miningParameters = createMiningParameters(extraData, coinbase);
+ final MiningConfiguration miningConfiguration = createMiningConfiguration(extraData, coinbase);
final CliqueBlockCreator blockCreator =
new CliqueBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> extraData,
createTransactionPool(),
protocolContext,
@@ -175,11 +179,11 @@ public class CliqueBlockCreatorTest {
when(voteProvider.getVoteAfterBlock(any(), any()))
.thenReturn(Optional.of(new ValidatorVote(VoteType.ADD, coinbase, a1)));
- final MiningParameters miningParameters = createMiningParameters(extraData, coinbase);
+ final MiningConfiguration miningConfiguration = createMiningConfiguration(extraData, coinbase);
final CliqueBlockCreator blockCreator =
new CliqueBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> extraData,
createTransactionPool(),
protocolContext,
@@ -209,11 +213,11 @@ public class CliqueBlockCreatorTest {
when(mockVoteProvider.getVoteAfterBlock(any(), any()))
.thenReturn(Optional.of(new ValidatorVote(VoteType.ADD, coinbase, a1)));
- final MiningParameters miningParameters = createMiningParameters(extraData, coinbase);
+ final MiningConfiguration miningConfiguration = createMiningConfiguration(extraData, coinbase);
final CliqueBlockCreator blockCreator =
new CliqueBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> extraData,
createTransactionPool(),
protocolContext,
@@ -252,10 +256,10 @@ public class CliqueBlockCreatorTest {
return transactionPool;
}
- private static MiningParameters createMiningParameters(
+ private static MiningConfiguration createMiningConfiguration(
final Bytes extraData, final Address coinbase) {
- final MiningParameters miningParameters =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(extraData)
@@ -264,6 +268,6 @@ public class CliqueBlockCreatorTest {
.coinbase(coinbase)
.build())
.build();
- return miningParameters;
+ return miningConfiguration;
}
}
diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java
index 1aa2d75ef3..9c2bf04bce 100644
--- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java
+++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java
@@ -26,6 +26,7 @@ import org.hyperledger.besu.consensus.clique.CliqueBlockHeaderFunctions;
import org.hyperledger.besu.consensus.clique.CliqueBlockInterface;
import org.hyperledger.besu.consensus.clique.CliqueContext;
import org.hyperledger.besu.consensus.clique.CliqueExtraData;
+import org.hyperledger.besu.consensus.clique.CliqueHelpers;
import org.hyperledger.besu.consensus.clique.CliqueProtocolSchedule;
import org.hyperledger.besu.consensus.common.EpochManager;
import org.hyperledger.besu.consensus.common.ForksSchedule;
@@ -39,9 +40,10 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.AddressHelpers;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
+import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -97,15 +99,17 @@ public class CliqueMinerExecutorTest {
when(validatorProvider.getValidatorsAfterBlock(any())).thenReturn(validatorList);
final CliqueContext cliqueContext = new CliqueContext(validatorProvider, null, blockInterface);
+ CliqueHelpers.setCliqueContext(cliqueContext);
cliqueProtocolContext = new ProtocolContext(null, null, cliqueContext, new BadBlockManager());
cliqueProtocolSchedule =
CliqueProtocolSchedule.create(
GENESIS_CONFIG_OPTIONS,
new ForksSchedule<>(List.of()),
proposerNodeKey,
+ PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -117,7 +121,7 @@ public class CliqueMinerExecutorTest {
public void extraDataCreatedOnEpochBlocksContainsValidators() {
final Bytes vanityData = generateRandomVanityData();
- final MiningParameters miningParameters = createMiningParameters(vanityData);
+ final MiningConfiguration miningConfiguration = createMiningConfiguration(vanityData);
final CliqueMinerExecutor executor =
new CliqueMinerExecutor(
@@ -125,7 +129,7 @@ public class CliqueMinerExecutorTest {
cliqueProtocolSchedule,
createTransactionPool(),
proposerNodeKey,
- miningParameters,
+ miningConfiguration,
mock(CliqueBlockScheduler.class),
new EpochManager(EPOCH_LENGTH),
null,
@@ -153,7 +157,7 @@ public class CliqueMinerExecutorTest {
public void extraDataForNonEpochBlocksDoesNotContainValidaors() {
final Bytes vanityData = generateRandomVanityData();
- final MiningParameters miningParameters = createMiningParameters(vanityData);
+ final MiningConfiguration miningConfiguration = createMiningConfiguration(vanityData);
final CliqueMinerExecutor executor =
new CliqueMinerExecutor(
@@ -161,7 +165,7 @@ public class CliqueMinerExecutorTest {
cliqueProtocolSchedule,
createTransactionPool(),
proposerNodeKey,
- miningParameters,
+ miningConfiguration,
mock(CliqueBlockScheduler.class),
new EpochManager(EPOCH_LENGTH),
null,
@@ -189,7 +193,7 @@ public class CliqueMinerExecutorTest {
final Bytes initialVanityData = generateRandomVanityData();
final Bytes modifiedVanityData = generateRandomVanityData();
- final MiningParameters miningParameters = createMiningParameters(initialVanityData);
+ final MiningConfiguration miningConfiguration = createMiningConfiguration(initialVanityData);
final CliqueMinerExecutor executor =
new CliqueMinerExecutor(
@@ -197,13 +201,13 @@ public class CliqueMinerExecutorTest {
cliqueProtocolSchedule,
createTransactionPool(),
proposerNodeKey,
- miningParameters,
+ miningConfiguration,
mock(CliqueBlockScheduler.class),
new EpochManager(EPOCH_LENGTH),
null,
ethScheduler);
- miningParameters.setExtraData(modifiedVanityData);
+ miningConfiguration.setExtraData(modifiedVanityData);
final Bytes extraDataBytes = executor.calculateExtraData(blockHeaderBuilder.buildHeader());
final CliqueExtraData cliqueExtraData =
@@ -253,8 +257,8 @@ public class CliqueMinerExecutorTest {
return Bytes.wrap(vanityData);
}
- private static MiningParameters createMiningParameters(final Bytes vanityData) {
- return ImmutableMiningParameters.builder()
+ private static MiningConfiguration createMiningConfiguration(final Bytes vanityData) {
+ return ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(vanityData)
diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinatorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinatorTest.java
index 543d110ef4..fd39a46cfc 100644
--- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinatorTest.java
+++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMiningCoordinatorTest.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.consensus.clique.CliqueBlockInterface;
import org.hyperledger.besu.consensus.clique.CliqueContext;
+import org.hyperledger.besu.consensus.clique.CliqueHelpers;
import org.hyperledger.besu.consensus.clique.CliqueMiningTracker;
import org.hyperledger.besu.consensus.clique.TestHelpers;
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
@@ -258,6 +259,7 @@ public class CliqueMiningCoordinatorTest {
when(validatorProvider.getValidatorsAfterBlock(any())).thenReturn(validators);
final CliqueContext cliqueContext = new CliqueContext(validatorProvider, null, blockInterface);
+ CliqueHelpers.setCliqueContext(cliqueContext);
when(protocolContext.getConsensusContext(CliqueContext.class)).thenReturn(cliqueContext);
when(protocolContext.getBlockchain()).thenReturn(blockChain);
diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRuleTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRuleTest.java
index d970d83d80..d7e4d07409 100644
--- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRuleTest.java
+++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/headervalidationrules/CliqueDifficultyValidationRuleTest.java
@@ -21,6 +21,7 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.consensus.clique.CliqueBlockInterface;
import org.hyperledger.besu.consensus.clique.CliqueContext;
+import org.hyperledger.besu.consensus.clique.CliqueHelpers;
import org.hyperledger.besu.consensus.clique.TestHelpers;
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
import org.hyperledger.besu.crypto.KeyPair;
@@ -58,6 +59,7 @@ public class CliqueDifficultyValidationRuleTest {
when(validatorProvider.getValidatorsAfterBlock(any())).thenReturn(validatorList);
final CliqueContext cliqueContext = new CliqueContext(validatorProvider, null, blockInterface);
+ CliqueHelpers.setCliqueContext(cliqueContext);
cliqueProtocolContext = new ProtocolContext(null, null, cliqueContext, new BadBlockManager());
blockHeaderBuilder = new BlockHeaderTestFixture();
}
diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingContext.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingConsensusContext.java
similarity index 88%
rename from consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingContext.java
rename to consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingConsensusContext.java
index f71e3ac7f3..91ace1a04b 100644
--- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingContext.java
+++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingConsensusContext.java
@@ -17,7 +17,7 @@ package org.hyperledger.besu.consensus.common;
import org.hyperledger.besu.ethereum.ConsensusContext;
/** The Migrating context. */
-public class MigratingContext implements ConsensusContext {
+public class MigratingConsensusContext implements ConsensusContext {
private final ForksSchedule consensusContextSchedule;
@@ -26,7 +26,7 @@ public class MigratingContext implements ConsensusContext {
*
* @param consensusContextSchedule the consensus context schedule
*/
- public MigratingContext(final ForksSchedule consensusContextSchedule) {
+ public MigratingConsensusContext(final ForksSchedule consensusContextSchedule) {
this.consensusContextSchedule = consensusContextSchedule;
}
diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingProtocolContext.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingProtocolContext.java
index c0557485f3..27cce3157b 100644
--- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingProtocolContext.java
+++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/MigratingProtocolContext.java
@@ -15,11 +15,9 @@
package org.hyperledger.besu.consensus.common;
import org.hyperledger.besu.ethereum.ConsensusContext;
-import org.hyperledger.besu.ethereum.ConsensusContextFactory;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
/** The Migrating protocol context. */
@@ -32,42 +30,16 @@ public class MigratingProtocolContext extends ProtocolContext {
*
* @param blockchain the blockchain
* @param worldStateArchive the world state archive
- * @param consensusContextSchedule the consensus context schedule
+ * @param migratingConsensusContext the consensus context
* @param badBlockManager the cache to use to keep invalid blocks
*/
public MigratingProtocolContext(
final MutableBlockchain blockchain,
final WorldStateArchive worldStateArchive,
- final ForksSchedule consensusContextSchedule,
+ final MigratingConsensusContext migratingConsensusContext,
final BadBlockManager badBlockManager) {
- super(blockchain, worldStateArchive, null, badBlockManager);
- this.consensusContextSchedule = consensusContextSchedule;
- }
-
- /**
- * Init protocol context.
- *
- * @param blockchain the blockchain
- * @param worldStateArchive the world state archive
- * @param protocolSchedule the protocol schedule
- * @param consensusContextFactory the consensus context factory
- * @param badBlockManager the cache to use to keep invalid blocks
- * @return the protocol context
- */
- public static ProtocolContext init(
- final MutableBlockchain blockchain,
- final WorldStateArchive worldStateArchive,
- final ProtocolSchedule protocolSchedule,
- final ConsensusContextFactory consensusContextFactory,
- final BadBlockManager badBlockManager) {
- final ConsensusContext consensusContext =
- consensusContextFactory.create(blockchain, worldStateArchive, protocolSchedule);
- final MigratingContext migratingContext = consensusContext.as(MigratingContext.class);
- return new MigratingProtocolContext(
- blockchain,
- worldStateArchive,
- migratingContext.getConsensusContextSchedule(),
- badBlockManager);
+ super(blockchain, worldStateArchive, migratingConsensusContext, badBlockManager);
+ this.consensusContextSchedule = migratingConsensusContext.getConsensusContextSchedule();
}
@Override
diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java
index 311bf30fae..f92b58bbfa 100644
--- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java
+++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java
@@ -19,7 +19,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@@ -38,6 +38,7 @@ import org.hyperledger.besu.plugin.services.MetricsSystem;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
import java.util.function.Function;
/** Defines the protocol behaviours for a blockchain using a BFT consensus mechanism. */
@@ -57,7 +58,7 @@ public abstract class BaseBftProtocolScheduleBuilder {
* @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @param metricsSystem metricsSystem A metricSystem instance to be able to expose metrics in the
@@ -71,7 +72,7 @@ public abstract class BaseBftProtocolScheduleBuilder {
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -90,12 +91,12 @@ public abstract class BaseBftProtocolScheduleBuilder {
final ProtocolSchedule protocolSchedule =
new ProtocolScheduleBuilder(
config,
- DEFAULT_CHAIN_ID,
+ Optional.of(DEFAULT_CHAIN_ID),
specAdapters,
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem)
@@ -132,7 +133,7 @@ public abstract class BaseBftProtocolScheduleBuilder {
.blockBodyValidatorBuilder(MainnetBlockBodyValidator::new)
.blockValidatorBuilder(MainnetProtocolSpecs.blockValidatorBuilder())
.blockImporterBuilder(MainnetBlockImporter::new)
- .difficultyCalculator((time, parent, protocolContext) -> BigInteger.ONE)
+ .difficultyCalculator((time, parent) -> BigInteger.ONE)
.skipZeroBlockRewards(true)
.blockHeaderFunctions(BftBlockHeaderFunctions.forOnchainBlock(bftExtraDataCodec))
.blockReward(Wei.of(configOptions.getBlockRewardWei()))
diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java
index 6bc0254b69..70d18fc3c9 100644
--- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java
+++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java
@@ -25,7 +25,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.AbstractBlockCreator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.SealableBlockHeader;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -46,7 +46,7 @@ public class BftBlockCreator extends AbstractBlockCreator {
/**
* Instantiates a new Bft block creator.
*
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param forksSchedule the forks schedule
* @param localAddress the local address
* @param extraDataCalculator the extra data calculator
@@ -57,7 +57,7 @@ public class BftBlockCreator extends AbstractBlockCreator {
* @param ethScheduler the scheduler for asynchronous block creation tasks
*/
public BftBlockCreator(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final ForksSchedule extends BftConfigOptions> forksSchedule,
final Address localAddress,
final ExtraDataCalculator extraDataCalculator,
@@ -67,7 +67,7 @@ public class BftBlockCreator extends AbstractBlockCreator {
final BftExtraDataCodec bftExtraDataCodec,
final EthScheduler ethScheduler) {
super(
- miningParameters.setCoinbase(localAddress),
+ miningConfiguration.setCoinbase(localAddress),
miningBeneficiaryCalculator(localAddress, forksSchedule),
extraDataCalculator,
transactionPool,
diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java
index 7c679763b6..1349bbf461 100644
--- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java
+++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java
@@ -31,7 +31,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.BlockCreator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.AbstractGasLimitSpecification;
@@ -54,7 +54,7 @@ public class BftBlockCreatorFactory {
protected final ForksSchedule forksSchedule;
/** The Mining parameters */
- protected final MiningParameters miningParameters;
+ protected final MiningConfiguration miningConfiguration;
private final TransactionPool transactionPool;
@@ -89,7 +89,7 @@ public class BftBlockCreatorFactory {
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
final ForksSchedule forksSchedule,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final Address localAddress,
final BftExtraDataCodec bftExtraDataCodec,
final EthScheduler ethScheduler) {
@@ -98,7 +98,7 @@ public class BftBlockCreatorFactory {
this.protocolSchedule = protocolSchedule;
this.forksSchedule = forksSchedule;
this.localAddress = localAddress;
- this.miningParameters = miningParams;
+ this.miningConfiguration = miningParams;
this.bftExtraDataCodec = bftExtraDataCodec;
this.ethScheduler = ethScheduler;
}
@@ -111,7 +111,7 @@ public class BftBlockCreatorFactory {
*/
public BlockCreator create(final int round) {
return new BftBlockCreator(
- miningParameters,
+ miningConfiguration,
forksSchedule,
localAddress,
ph -> createExtraData(round, ph),
@@ -128,7 +128,7 @@ public class BftBlockCreatorFactory {
* @param minTransactionGasPrice the min transaction gas price
*/
public void setMinTransactionGasPrice(final Wei minTransactionGasPrice) {
- miningParameters.setMinTransactionGasPrice(minTransactionGasPrice);
+ miningConfiguration.setMinTransactionGasPrice(minTransactionGasPrice);
}
/**
@@ -137,7 +137,7 @@ public class BftBlockCreatorFactory {
* @return the min transaction gas price
*/
public Wei getMinTransactionGasPrice() {
- return miningParameters.getMinTransactionGasPrice();
+ return miningConfiguration.getMinTransactionGasPrice();
}
/**
@@ -146,7 +146,7 @@ public class BftBlockCreatorFactory {
* @return min priority fee per gas
*/
public Wei getMinPriorityFeePerGas() {
- return miningParameters.getMinPriorityFeePerGas();
+ return miningConfiguration.getMinPriorityFeePerGas();
}
/**
@@ -171,7 +171,7 @@ public class BftBlockCreatorFactory {
final BftExtraData extraData =
new BftExtraData(
ConsensusHelpers.zeroLeftPad(
- miningParameters.getExtraData(), BftExtraDataCodec.EXTRA_VANITY_LENGTH),
+ miningConfiguration.getExtraData(), BftExtraDataCodec.EXTRA_VANITY_LENGTH),
Collections.emptyList(),
toVote(proposal),
round,
@@ -187,7 +187,7 @@ public class BftBlockCreatorFactory {
*/
public void changeTargetGasLimit(final Long newTargetGasLimit) {
if (AbstractGasLimitSpecification.isValidTargetGasLimit(newTargetGasLimit)) {
- miningParameters.setTargetGasLimit(newTargetGasLimit);
+ miningConfiguration.setTargetGasLimit(newTargetGasLimit);
} else {
throw new UnsupportedOperationException("Specified target gas limit is invalid");
}
diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java
index 02689d52af..02da30f507 100644
--- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java
+++ b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java
@@ -21,7 +21,7 @@ import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -172,12 +172,12 @@ public class CombinedProtocolScheduleFactoryTest {
final ProtocolScheduleBuilder protocolScheduleBuilder =
new ProtocolScheduleBuilder(
genesisConfigOptions,
- BigInteger.ONE,
+ Optional.of(BigInteger.ONE),
ProtocolSpecAdapters.create(0, Function.identity()),
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/MigratingProtocolContextTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/MigratingProtocolContextTest.java
index d62de57eac..39ab9f8cb2 100644
--- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/MigratingProtocolContextTest.java
+++ b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/MigratingProtocolContextTest.java
@@ -43,9 +43,13 @@ public class MigratingProtocolContextTest {
final ForksSchedule contextSchedule =
new ForksSchedule<>(List.of(new ForkSpec<>(0L, context1), new ForkSpec<>(10L, context2)));
+
final MigratingProtocolContext migratingProtocolContext =
new MigratingProtocolContext(
- blockchain, worldStateArchive, contextSchedule, new BadBlockManager());
+ blockchain,
+ worldStateArchive,
+ new MigratingConsensusContext(contextSchedule),
+ new BadBlockManager());
assertThat(migratingProtocolContext.getConsensusContext(ConsensusContext.class))
.isSameAs(context1);
diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java
index e23664fd8d..56a0e33986 100644
--- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java
+++ b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java
@@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@@ -245,7 +245,7 @@ public class BaseBftProtocolScheduleBuilderTest {
false,
bftExtraDataCodec,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/ibft/build.gradle b/consensus/ibft/build.gradle
index da6304c4e5..e95c866143 100644
--- a/consensus/ibft/build.gradle
+++ b/consensus/ibft/build.gradle
@@ -76,4 +76,6 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'
+ testImplementation 'com.google.dagger:dagger'
+ testAnnotationProcessor 'com.google.dagger:dagger-compiler'
}
diff --git a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java
index 8896733548..a5d24ff4db 100644
--- a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java
+++ b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java
@@ -78,9 +78,9 @@ import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -310,8 +310,8 @@ public class TestContextBuilder {
final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive();
- final MiningParameters miningParams =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningParams =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
@@ -334,7 +334,7 @@ public class TestContextBuilder {
forksSchedule,
IBFT_EXTRA_DATA_ENCODER,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java
index 3adf571895..adc4698e4d 100644
--- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java
+++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java
@@ -21,7 +21,7 @@ import org.hyperledger.besu.consensus.common.bft.BaseBftProtocolScheduleBuilder;
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
@@ -46,7 +46,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
* @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -60,7 +60,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -72,7 +72,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
isRevertReasonEnabled,
bftExtraDataCodec,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -85,7 +85,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
* @param forksSchedule the forks schedule
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -97,7 +97,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
final ForksSchedule forksSchedule,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -108,7 +108,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
false,
bftExtraDataCodec,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java
index 1afe067867..a777d7d175 100644
--- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java
+++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java
@@ -32,7 +32,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.ApiGroupJsonRpcMethods;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import java.util.Map;
@@ -42,22 +42,22 @@ public class IbftJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final ProtocolContext context;
private final ProtocolSchedule protocolSchedule;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
/**
* Instantiates a new Ibft json rpc methods.
*
* @param context the protocol context
* @param protocolSchedule the protocol schedule
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
*/
public IbftJsonRpcMethods(
final ProtocolContext context,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
this.context = context;
this.protocolSchedule = protocolSchedule;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -70,7 +70,7 @@ public class IbftJsonRpcMethods extends ApiGroupJsonRpcMethods {
final MutableBlockchain blockchain = context.getBlockchain();
final BlockchainQueries blockchainQueries =
new BlockchainQueries(
- protocolSchedule, blockchain, context.getWorldStateArchive(), miningParameters);
+ protocolSchedule, blockchain, context.getWorldStateArchive(), miningConfiguration);
final BftContext bftContext = context.getConsensusContext(BftContext.class);
final BlockInterface blockInterface = bftContext.getBlockInterface();
final ValidatorProvider validatorProvider =
diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java
index e5551ff3f3..9cb760551e 100644
--- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java
+++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.hyperledger.besu.config.BftConfigOptions;
-import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.JsonGenesisConfigOptions;
import org.hyperledger.besu.config.JsonQbftConfigOptions;
import org.hyperledger.besu.config.JsonUtil;
@@ -40,31 +39,39 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
+import org.hyperledger.besu.ethereum.core.components.EthereumCoreComponent;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import java.math.BigInteger;
-import java.util.Collection;
import java.util.List;
+import javax.inject.Singleton;
+import dagger.Component;
+import dagger.Module;
+import dagger.Provides;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class IbftProtocolScheduleTest {
- private final BftExtraDataCodec bftExtraDataCodec = mock(BftExtraDataCodec.class);
- private final BftExtraData bftExtraData = mock(BftExtraData.class);
- private final NodeKey proposerNodeKey = NodeKeyUtils.generate();
- private final Address proposerAddress = Util.publicKeyToAddress(proposerNodeKey.getPublicKey());
- private final List validators = singletonList(proposerAddress);
+
+ private ProtocolContext protocolContext;
+ private List validators;
+ private NodeKey proposerNodeKey;
+ private TestEthCoreComponent component;
@BeforeEach
public void setup() {
- when(bftExtraDataCodec.decode(any())).thenReturn(bftExtraData);
- when(bftExtraData.getValidators()).thenReturn(validators);
+ TestEthCoreComponent component =
+ DaggerIbftProtocolScheduleTest_TestEthCoreComponent.builder().build();
+ this.component = component;
+ this.protocolContext = component.protocolContext();
+ this.validators = component.validators();
+ this.proposerNodeKey = component.nodeKey();
}
@Test
@@ -81,52 +88,111 @@ public class IbftProtocolScheduleTest {
.buildHeader();
final BftProtocolSchedule schedule =
- createProtocolSchedule(
- JsonGenesisConfigOptions.fromJsonObject(JsonUtil.createEmptyObjectNode()),
- List.of(
- new ForkSpec<>(0, JsonQbftConfigOptions.DEFAULT),
- new ForkSpec<>(1, arbitraryTransition),
- new ForkSpec<>(2, JsonQbftConfigOptions.DEFAULT)));
+ createProtocolSchedule(component.bftExtraDataCodec(), arbitraryTransition);
assertThat(new MilestoneStreamingProtocolSchedule(schedule).streamMilestoneBlocks().count())
.isEqualTo(3);
- assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 0)).isTrue();
- assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 1)).isTrue();
- assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 2)).isTrue();
+ assertThat(validateHeader(schedule, parentHeader, blockHeader, 0)).isTrue();
+ assertThat(validateHeader(schedule, parentHeader, blockHeader, 1)).isTrue();
+ assertThat(validateHeader(schedule, parentHeader, blockHeader, 2)).isTrue();
+ }
+
+ private boolean validateHeader(
+ final BftProtocolSchedule schedule,
+ final BlockHeader parentHeader,
+ final BlockHeader blockHeader,
+ final int block) {
+ return schedule
+ .getByBlockNumberOrTimestamp(block, blockHeader.getTimestamp())
+ .getBlockHeaderValidator()
+ .validateHeader(
+ blockHeader, parentHeader, this.protocolContext, HeaderValidationMode.LIGHT);
}
private BftProtocolSchedule createProtocolSchedule(
- final GenesisConfigOptions genesisConfig, final List> forks) {
+ final BftExtraDataCodec bftExtraDataCodec,
+ final MutableBftConfigOptions arbitraryTransition) {
+
+ var genesisConfig = JsonGenesisConfigOptions.fromJsonObject(JsonUtil.createEmptyObjectNode());
+ ForksSchedule forkSched =
+ new ForksSchedule<>(
+ List.of(
+ new ForkSpec<>(0, JsonQbftConfigOptions.DEFAULT),
+ new ForkSpec<>(1, arbitraryTransition),
+ new ForkSpec<>(2, JsonQbftConfigOptions.DEFAULT)));
+
return IbftProtocolScheduleBuilder.create(
genesisConfig,
- new ForksSchedule<>(forks),
+ forkSched,
PrivacyParameters.DEFAULT,
false,
bftExtraDataCodec,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
}
- private boolean validateHeader(
- final BftProtocolSchedule schedule,
- final List validators,
- final BlockHeader parentHeader,
- final BlockHeader blockHeader,
- final int block) {
- return schedule
- .getByBlockNumberOrTimestamp(block, blockHeader.getTimestamp())
- .getBlockHeaderValidator()
- .validateHeader(
- blockHeader, parentHeader, protocolContext(validators), HeaderValidationMode.LIGHT);
+ @Module
+ static class IbftProtocolScheduleModule {
+ @Provides
+ @Singleton
+ NodeKey nodeKey() {
+ return NodeKeyUtils.generate();
+ }
+
+ @Provides
+ Address provideProposerAddress(final NodeKey proposerNodeKey) {
+ return Util.publicKeyToAddress(proposerNodeKey.getPublicKey());
+ }
+
+ @Provides
+ List provideValidators(final Address proposerAddress) {
+ return singletonList(proposerAddress);
+ }
+
+ @Provides
+ public BftExtraData mockBftExtraData(final List validators) {
+ BftExtraData bftExtraData = mock(BftExtraData.class);
+ when(bftExtraData.getValidators()).thenReturn(validators);
+ return bftExtraData;
+ }
+
+ @Provides
+ public BftExtraDataCodec mockBftExtraDataCodec(final BftExtraData bftExtraData) {
+ BftExtraDataCodec bftExtraDataCodec = mock(BftExtraDataCodec.class);
+ when(bftExtraDataCodec.decode(any())).thenReturn(bftExtraData);
+ return bftExtraDataCodec;
+ }
+
+ @Provides
+ ProtocolContext protocolContext(
+ final List validators, final BftExtraDataCodec bftExtraDataCodec) {
+ return new ProtocolContext(
+ null,
+ null,
+ setupContextWithBftExtraDataEncoder(BftContext.class, validators, bftExtraDataCodec),
+ new BadBlockManager());
+ }
+ }
+
+ @Singleton
+ @Component(modules = {NoMiningParamters.class, IbftProtocolScheduleModule.class})
+ interface TestEthCoreComponent extends EthereumCoreComponent {
+ ProtocolContext protocolContext();
+
+ List validators();
+
+ NodeKey nodeKey();
+
+ BftExtraDataCodec bftExtraDataCodec();
}
- private ProtocolContext protocolContext(final Collection validators) {
- return new ProtocolContext(
- null,
- null,
- setupContextWithBftExtraDataEncoder(BftContext.class, validators, bftExtraDataCodec),
- new BadBlockManager());
+ @Module
+ static class NoMiningParamters {
+ @Provides
+ MiningConfiguration provideMiningParameters() {
+ return MiningConfiguration.MINING_DISABLED;
+ }
}
}
diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java
index 5469717b13..df5a313ae7 100644
--- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java
+++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java
@@ -42,9 +42,9 @@ import org.hyperledger.besu.ethereum.core.AddressHelpers;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCache;
@@ -122,7 +122,7 @@ public class BftBlockCreatorTest {
false,
bftExtraDataEncoder,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -159,8 +159,8 @@ public class BftBlockCreatorTest {
transactionPool.setEnabled();
- final MiningParameters miningParameters =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(
@@ -178,7 +178,7 @@ public class BftBlockCreatorTest {
final BftBlockCreator blockCreator =
new BftBlockCreator(
- miningParameters,
+ miningConfiguration,
forksSchedule,
initialValidatorList.get(0),
parent ->
diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java
index b9f57debb6..79022b7d54 100644
--- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java
+++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java
@@ -70,7 +70,7 @@ import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@@ -180,12 +180,12 @@ public class IbftBlockHeightManagerTest {
final ProtocolScheduleBuilder protocolScheduleBuilder =
new ProtocolScheduleBuilder(
new StubGenesisConfigOptions(),
- BigInteger.ONE,
+ Optional.empty(),
ProtocolSpecAdapters.create(0, Function.identity()),
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java
index abbc3b130a..66e177efee 100644
--- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java
+++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java
@@ -17,7 +17,7 @@ package org.hyperledger.besu.consensus.merge;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -48,7 +48,7 @@ public class MergeProtocolSchedule {
*
* @param config the config
* @param isRevertReasonEnabled the is revert reason enabled
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @return the protocol schedule
@@ -56,7 +56,7 @@ public class MergeProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final boolean isRevertReasonEnabled,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -64,7 +64,7 @@ public class MergeProtocolSchedule {
config,
PrivacyParameters.DEFAULT,
isRevertReasonEnabled,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -76,7 +76,7 @@ public class MergeProtocolSchedule {
* @param config the config
* @param privacyParameters the privacy parameters
* @param isRevertReasonEnabled the is revert reason enabled
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @return the protocol schedule
@@ -85,7 +85,7 @@ public class MergeProtocolSchedule {
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -101,12 +101,12 @@ public class MergeProtocolSchedule {
return new ProtocolScheduleBuilder(
config,
- DEFAULT_CHAIN_ID,
+ Optional.of(DEFAULT_CHAIN_ID),
new ProtocolSpecAdapters(postMergeModifications),
privacyParameters,
isRevertReasonEnabled,
EvmConfiguration.DEFAULT,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem)
@@ -129,7 +129,7 @@ public class MergeProtocolSchedule {
gasCalculator, chainId.orElse(BigInteger.ZERO), EvmConfiguration.DEFAULT))
.blockHeaderValidatorBuilder(MergeProtocolSchedule::getBlockHeaderValidator)
.blockReward(Wei.ZERO)
- .difficultyCalculator((a, b, c) -> BigInteger.ZERO)
+ .difficultyCalculator((a, b) -> BigInteger.ZERO)
.skipZeroBlockRewards(true)
.isPoS(true)
.name("Paris");
diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java
index e733cc800e..44fd5f8edf 100644
--- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java
+++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java
@@ -20,7 +20,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PermissionTransactionFilter;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
@@ -65,21 +65,21 @@ public class TransitionProtocolSchedule implements ProtocolSchedule {
*
* @param genesisConfigOptions {@link GenesisConfigOptions} containing the config options for the
* milestone starting points
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @return an initialised TransitionProtocolSchedule using post-merge defaults
*/
public static TransitionProtocolSchedule fromConfig(
final GenesisConfigOptions genesisConfigOptions,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
ProtocolSchedule preMergeProtocolSchedule =
MainnetProtocolSchedule.fromConfig(
genesisConfigOptions,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -87,7 +87,7 @@ public class TransitionProtocolSchedule implements ProtocolSchedule {
MergeProtocolSchedule.create(
genesisConfigOptions,
false,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java
index c56c62d80d..56c78877a6 100644
--- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java
+++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java
@@ -19,7 +19,7 @@ import org.hyperledger.besu.ethereum.blockcreation.AbstractBlockCreator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.SealableBlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Withdrawal;
@@ -39,7 +39,7 @@ class MergeBlockCreator extends AbstractBlockCreator {
/**
* Instantiates a new Merge block creator.
*
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param extraDataCalculator the extra data calculator
* @param transactionPool the pending transactions
* @param protocolContext the protocol context
@@ -47,7 +47,7 @@ class MergeBlockCreator extends AbstractBlockCreator {
* @param parentHeader the parent header
*/
public MergeBlockCreator(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final ExtraDataCalculator extraDataCalculator,
final TransactionPool transactionPool,
final ProtocolContext protocolContext,
@@ -55,8 +55,8 @@ class MergeBlockCreator extends AbstractBlockCreator {
final BlockHeader parentHeader,
final EthScheduler ethScheduler) {
super(
- miningParameters,
- __ -> miningParameters.getCoinbase().orElseThrow(),
+ miningConfiguration,
+ __ -> miningConfiguration.getCoinbase().orElseThrow(),
extraDataCalculator,
transactionPool,
protocolContext,
diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java
index a3f9a4b69f..16daa442d3 100644
--- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java
+++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java
@@ -33,7 +33,7 @@ import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockWithReceipts;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Withdrawal;
@@ -81,7 +81,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
private static final long DEFAULT_TARGET_GAS_LIMIT = 30000000L;
/** The Mining parameters. */
- protected final MiningParameters miningParameters;
+ protected final MiningConfiguration miningConfiguration;
/** The Merge block creator factory. */
protected final MergeBlockCreatorFactory mergeBlockCreatorFactory;
@@ -120,7 +120,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
final ProtocolSchedule protocolSchedule,
final EthScheduler ethScheduler,
final TransactionPool transactionPool,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final BackwardSyncContext backwardSyncContext,
final Optional depositContractAddress) {
this.protocolContext = protocolContext;
@@ -137,14 +137,14 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
}
miningParams.setMinBlockOccupancyRatio(TRY_FILL_BLOCK);
- this.miningParameters = miningParams;
+ this.miningConfiguration = miningParams;
this.mergeBlockCreatorFactory =
(parentHeader, address) -> {
address.ifPresent(miningParams::setCoinbase);
return new MergeBlockCreator(
- miningParameters,
- parent -> miningParameters.getExtraData(),
+ miningConfiguration,
+ parent -> miningConfiguration.getExtraData(),
transactionPool,
protocolContext,
protocolSchedule,
@@ -169,7 +169,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
final EthScheduler ethScheduler,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final BackwardSyncContext backwardSyncContext,
final MergeBlockCreatorFactory mergeBlockCreatorFactory) {
@@ -182,7 +182,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
miningParams.setTargetGasLimit(DEFAULT_TARGET_GAS_LIMIT);
}
miningParams.setMinBlockOccupancyRatio(TRY_FILL_BLOCK);
- this.miningParameters = miningParams;
+ this.miningConfiguration = miningParams;
this.mergeBlockCreatorFactory = mergeBlockCreatorFactory;
@@ -215,17 +215,17 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
@Override
public Wei getMinTransactionGasPrice() {
- return miningParameters.getMinTransactionGasPrice();
+ return miningConfiguration.getMinTransactionGasPrice();
}
@Override
public Wei getMinPriorityFeePerGas() {
- return miningParameters.getMinPriorityFeePerGas();
+ return miningConfiguration.getMinPriorityFeePerGas();
}
@Override
public Optional getCoinbase() {
- return miningParameters.getCoinbase();
+ return miningConfiguration.getCoinbase();
}
@Override
@@ -244,7 +244,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
@Override
public void changeTargetGasLimit(final Long newTargetGasLimit) {
if (AbstractGasLimitSpecification.isValidTargetGasLimit(newTargetGasLimit)) {
- this.miningParameters.setTargetGasLimit(newTargetGasLimit);
+ this.miningConfiguration.setTargetGasLimit(newTargetGasLimit);
} else {
throw new IllegalArgumentException("Specified target gas limit is invalid");
}
@@ -383,13 +383,13 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
LOG.debug(
"Block creation started for payload id {}, remaining time is {}ms",
payloadIdentifier,
- miningParameters.getUnstable().getPosBlockCreationMaxTime());
+ miningConfiguration.getUnstable().getPosBlockCreationMaxTime());
ethScheduler
.scheduleBlockCreationTask(
() -> retryBlockCreationUntilUseful(payloadIdentifier, blockCreator))
.orTimeout(
- miningParameters.getUnstable().getPosBlockCreationMaxTime(), TimeUnit.MILLISECONDS)
+ miningConfiguration.getUnstable().getPosBlockCreationMaxTime(), TimeUnit.MILLISECONDS)
.whenComplete(
(unused, throwable) -> {
if (throwable != null) {
@@ -416,7 +416,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
final long waitBeforeRepetition =
Math.max(
100,
- miningParameters.getUnstable().getPosBlockCreationRepetitionMinDuration()
+ miningConfiguration.getUnstable().getPosBlockCreationRepetitionMinDuration()
- lastDuration);
LOG.debug("Waiting {}ms before repeating block creation", waitBeforeRepetition);
Thread.sleep(waitBeforeRepetition);
@@ -726,7 +726,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
@Override
public boolean isMiningBeforeMerge() {
- return miningParameters.isMiningEnabled();
+ return miningConfiguration.isMiningEnabled();
}
private Optional findValidAncestor(final Blockchain chain, final Hash parentHash) {
diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java
index 0d4aede3a1..2fff61a829 100644
--- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java
+++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java
@@ -22,7 +22,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockProcessor;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
@@ -51,7 +51,7 @@ public class MergeProtocolScheduleTest {
MergeProtocolSchedule.create(
config,
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -72,7 +72,7 @@ public class MergeProtocolScheduleTest {
MergeProtocolSchedule.create(
config,
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -113,7 +113,7 @@ public class MergeProtocolScheduleTest {
MergeProtocolSchedule.create(
config,
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -146,7 +146,7 @@ public class MergeProtocolScheduleTest {
MergeProtocolSchedule.create(
config,
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -180,7 +180,7 @@ public class MergeProtocolScheduleTest {
MergeProtocolSchedule.create(
GenesisConfigFile.DEFAULT.getConfigOptions(),
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
@@ -193,8 +193,7 @@ public class MergeProtocolScheduleTest {
private static void assertProofOfStakeConfigIsEnabled(final ProtocolSpec spec) {
assertThat(spec.isPoS()).isTrue();
assertThat(spec.getEvm().getOperationsUnsafe()[0x44]).isInstanceOf(PrevRanDaoOperation.class);
- assertThat(spec.getDifficultyCalculator().nextDifficulty(-1, null, null))
- .isEqualTo(BigInteger.ZERO);
+ assertThat(spec.getDifficultyCalculator().nextDifficulty(-1, null)).isEqualTo(BigInteger.ZERO);
assertThat(spec.getBlockReward()).isEqualTo(Wei.ZERO);
assertThat(spec.isSkipZeroBlockRewards()).isTrue();
assertThat(spec.getBlockProcessor()).isInstanceOf(MainnetBlockProcessor.class);
diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java
index 4efcdc1e0f..90c4b6866e 100644
--- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java
+++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java
@@ -55,11 +55,10 @@ import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.Unstable;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
-import org.hyperledger.besu.ethereum.core.Synchronizer;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.Unstable;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -135,8 +134,8 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
private final Address coinbase = genesisAllocations(getPosGenesisConfigFile()).findFirst().get();
- private MiningParameters miningParameters =
- ImmutableMiningParameters.builder()
+ private MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(MutableInitValues.builder().coinbase(coinbase).build())
.unstable(
Unstable.builder()
@@ -190,7 +189,6 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
protocolContext =
new ProtocolContext(blockchain, worldStateArchive, mergeContext, badBlockManager);
- protocolContext.setSynchronizer(mock(Synchronizer.class));
var mutable = worldStateArchive.getMutable();
genesisState.writeStateTo(mutable);
mutable.persist(null);
@@ -228,7 +226,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
protocolSchedule,
ethScheduler,
transactionPool,
- miningParameters,
+ miningConfiguration,
backwardSyncContext,
Optional.empty());
}
@@ -273,7 +271,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
MergeBlockCreator beingSpiedOn =
spy(
new MergeBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> Bytes.EMPTY,
transactionPool,
protocolContext,
@@ -302,7 +300,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
protocolContext,
protocolSchedule,
ethScheduler,
- miningParameters,
+ miningConfiguration,
backwardSyncContext,
mergeBlockCreatorFactory));
@@ -543,9 +541,9 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
@Test
public void shouldStopRetryBlockCreationIfTimeExpired() throws InterruptedException {
final AtomicLong retries = new AtomicLong(0);
- miningParameters =
- ImmutableMiningParameters.builder()
- .from(miningParameters)
+ miningConfiguration =
+ ImmutableMiningConfiguration.builder()
+ .from(miningConfiguration)
.unstable(Unstable.builder().posBlockCreationMaxTime(100).build())
.build();
doAnswer(
@@ -737,8 +735,8 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
public void shouldUseExtraDataFromMiningParameters() {
final Bytes extraData = Bytes.fromHexString("0x1234");
- miningParameters =
- ImmutableMiningParameters.builder()
+ miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(MutableInitValues.builder().extraData(extraData).build())
.build();
@@ -748,7 +746,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
protocolSchedule,
ethScheduler,
transactionPool,
- miningParameters,
+ miningConfiguration,
backwardSyncContext,
Optional.empty());
diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java
index dcfe5f98e3..582c8c5dd5 100644
--- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java
+++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java
@@ -19,7 +19,7 @@ import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.consensus.merge.MergeProtocolSchedule;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -56,7 +56,7 @@ public interface MergeGenesisConfigHelper {
return MergeProtocolSchedule.create(
getPosGenesisConfigFile().getConfigOptions(),
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java
index 7b111268e0..22153eecee 100644
--- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java
+++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java
@@ -34,8 +34,8 @@ import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.sync.backwardsync.BackwardSyncContext;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -96,7 +96,7 @@ public class MergeReorgTest implements MergeGenesisConfigHelper {
mockProtocolSchedule,
ethScheduler,
mockTransactionPool,
- ImmutableMiningParameters.builder()
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(MutableInitValues.builder().coinbase(coinbase).build())
.build(),
mock(BackwardSyncContext.class),
diff --git a/consensus/qbft/build.gradle b/consensus/qbft/build.gradle
index 9675c4df89..23e5576eba 100644
--- a/consensus/qbft/build.gradle
+++ b/consensus/qbft/build.gradle
@@ -40,8 +40,6 @@ dependencies {
implementation project(':ethereum:p2p')
implementation project(':ethereum:rlp')
implementation project(':evm')
- implementation project(':pki')
- implementation project(':services:kvstore')
implementation 'com.google.guava:guava'
implementation 'io.vertx:vertx-core'
diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
index d90d5a1527..cc7066f17e 100644
--- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
+++ b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
@@ -91,9 +91,9 @@ import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@@ -387,8 +387,8 @@ public class TestContextBuilder {
final boolean useFixedBaseFee,
final List qbftForks) {
- final MiningParameters miningParams =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningParams =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
@@ -438,7 +438,7 @@ public class TestContextBuilder {
forksSchedule,
BFT_EXTRA_DATA_ENCODER,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java
index e1cbc134b6..473b99332e 100644
--- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java
+++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java
@@ -24,7 +24,7 @@ import org.hyperledger.besu.consensus.common.bft.BaseBftProtocolScheduleBuilder;
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -50,7 +50,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
* @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
- * @param miningParameters The mining parameters
+ * @param miningConfiguration The mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -64,7 +64,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -76,7 +76,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
isRevertReasonEnabled,
bftExtraDataCodec,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -89,7 +89,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
* @param qbftForksSchedule the qbft forks schedule
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
- * @param miningParameters The mining parameters
+ * @param miningConfiguration The mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -101,7 +101,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
final ForksSchedule qbftForksSchedule,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -112,7 +112,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
false,
bftExtraDataCodec,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -125,7 +125,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
* @param qbftForksSchedule the qbft forks schedule
* @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec
- * @param miningParameters The mining parameters
+ * @param miningConfiguration The mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -137,7 +137,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
final ForksSchedule qbftForksSchedule,
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -148,7 +148,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
isRevertReasonEnabled,
bftExtraDataCodec,
EvmConfiguration.DEFAULT,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java
index 10f61713d9..fc46b6c32f 100644
--- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java
+++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java
@@ -23,7 +23,7 @@ import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreatorFa
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -52,7 +52,7 @@ public class QbftBlockCreatorFactory extends BftBlockCreatorFactory forksSchedule,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final Address localAddress,
final BftExtraDataCodec bftExtraDataCodec,
final EthScheduler ethScheduler) {
@@ -74,7 +74,7 @@ public class QbftBlockCreatorFactory extends BftBlockCreatorFactory balance;
+ private final Optional nonce;
+ private final Optional code;
+ private final Optional