merge main into verkle (#7928)

Signed-off-by: Karim Taam <karim.t2am@gmail.com>
pull/7959/head
Karim Taam 4 days ago committed by GitHub
parent 445235dd2a
commit 72d2781f1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 50
      .github/ISSUE_TEMPLATE/bug-report.md
  2. 45
      .github/ISSUE_TEMPLATE/feature-request.md
  3. 22
      .github/issue_template.md
  4. 27
      .github/workflows/stale-issues.yml
  5. 19
      CHANGELOG.md
  6. 2
      CONTRIBUTING.md
  7. 2
      DCO.md
  8. 3
      MAINTAINERS.md
  9. 4
      README.md
  10. 2
      SUPPORT.md
  11. 16
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
  12. 2
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
  13. 60
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
  14. 12
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
  15. 19
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
  16. 4
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPlugin.java
  17. 6
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBesuEventsPlugin.java
  18. 8
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestBlockchainServiceFinalizedPlugin.java
  19. 4
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestInProcessRpcServicePlugin.java
  20. 76
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java
  21. 4
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPermissioningPlugin.java
  22. 4
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPicoCLIPlugin.java
  23. 6
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestPrivacyServicePlugin.java
  24. 4
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java
  25. 1
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestPrivacyPluginPayloadProvider.java
  26. 4
      acceptance-tests/tests/build.gradle
  27. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java
  28. 73
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/MetricsPluginTest.java
  29. 1
      besu/build.gradle
  30. 30
      besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
  31. 142
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  32. 14
      besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java
  33. 73
      besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java
  34. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java
  35. 3
      besu/src/main/java/org/hyperledger/besu/cli/options/ChainPruningOptions.java
  36. 3
      besu/src/main/java/org/hyperledger/besu/cli/options/DnsOptions.java
  37. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCConfiguration.java
  38. 3
      besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCOptions.java
  39. 4
      besu/src/main/java/org/hyperledger/besu/cli/options/EthProtocolOptions.java
  40. 3
      besu/src/main/java/org/hyperledger/besu/cli/options/EthstatsOptions.java
  41. 3
      besu/src/main/java/org/hyperledger/besu/cli/options/EvmOptions.java
  42. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/GraphQlOptions.java
  43. 3
      besu/src/main/java/org/hyperledger/besu/cli/options/InProcessRpcOptions.java
  44. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/IpcOptions.java
  45. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/JsonRpcHttpOptions.java
  46. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/LoggingLevelOption.java
  47. 50
      besu/src/main/java/org/hyperledger/besu/cli/options/MetricsOptions.java
  48. 82
      besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java
  49. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/NatOptions.java
  50. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/NativeLibraryOptions.java
  51. 4
      besu/src/main/java/org/hyperledger/besu/cli/options/NetworkingOptions.java
  52. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/NodePrivateKeyFileOption.java
  53. 3
      besu/src/main/java/org/hyperledger/besu/cli/options/P2PDiscoveryOptions.java
  54. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/P2PTLSConfigOptions.java
  55. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/PermissionsOptions.java
  56. 3
      besu/src/main/java/org/hyperledger/besu/cli/options/PluginsConfigurationOptions.java
  57. 5
      besu/src/main/java/org/hyperledger/besu/cli/options/PrivacyPluginOptions.java
  58. 2
      besu/src/main/java/org/hyperledger/besu/cli/options/RPCOptions.java
  59. 135
      besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java
  60. 4
      besu/src/main/java/org/hyperledger/besu/cli/options/SynchronizerOptions.java
  61. 2
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java
  62. 149
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java
  63. 12
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java
  64. 6
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java
  65. 4
      besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java
  66. 14
      besu/src/main/java/org/hyperledger/besu/controller/BesuController.java
  67. 100
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  68. 22
      besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java
  69. 39
      besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java
  70. 14
      besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
  71. 24
      besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java
  72. 14
      besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
  73. 4
      besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java
  74. 21
      besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
  75. 34
      besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java
  76. 14
      besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java
  77. 4
      besu/src/main/java/org/hyperledger/besu/services/BesuPluginContextImpl.java
  78. 18
      besu/src/main/java/org/hyperledger/besu/services/BlockchainServiceImpl.java
  79. 49
      besu/src/main/java/org/hyperledger/besu/services/MiningServiceImpl.java
  80. 1
      besu/src/main/java/org/hyperledger/besu/services/PrivacyPluginServiceImpl.java
  81. 13
      besu/src/main/java/org/hyperledger/besu/services/TransactionSimulationServiceImpl.java
  82. 24
      besu/src/main/scripts/unixStartScript.txt
  83. 4
      besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java
  84. 6
      besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java
  85. 4
      besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java
  86. 4
      besu/src/test/java/org/hyperledger/besu/PrivacyTest.java
  87. 4
      besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java
  88. 42
      besu/src/test/java/org/hyperledger/besu/RunnerTest.java
  89. 4
      besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java
  90. 40
      besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java
  91. 8
      besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java
  92. 59
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
  93. 6
      besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java
  94. 8
      besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
  95. 63
      besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java
  96. 1
      besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java
  97. 2
      besu/src/test/java/org/hyperledger/besu/cli/options/LoggingLevelOptionTest.java
  98. 46
      besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java
  99. 34
      besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java
  100. 1
      besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,50 @@
---
name: Bug Report
about: necessary information to help us resolve the issue
title: ''
labels: 'bug'
assignees: ''
---
<!-- Have you done the following? -->
<!-- * read the Code of Conduct? By filing an Issue, you are expected to -->
<!-- comply with it, including treating everyone with respect: -->
<!-- https://github.com/hyperledger/besu/blob/main/CODE_OF_CONDUCT.md -->
<!-- * Reproduced the issue in the latest version of the software -->
<!-- * Read the debugging docs: https://besu.hyperledger.org/private-networks/how-to -->
<!-- * Duplicate Issue check: https://github.com/search?q=+is%3Aissue+repo%3Ahyperledger/Besu -->
### 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

@ -0,0 +1,45 @@
---
name: Feature Request
about: suggesting new or altered functionality
title: ''
labels: ''
assignees: ''
---
<!-- Have you done the following? -->
<!-- * read the Code of Conduct? By filing an Issue, you are expected to -->
<!-- comply with it, including treating everyone with respect: -->
<!-- https://github.com/hyperledger/besu/blob/main/CODE_OF_CONDUCT.md -->
<!-- * Duplicate Issue check: https://github.com/search?q=+is%3Aissue+repo%3Ahyperledger/Besu -->
### 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

@ -2,30 +2,10 @@
<!-- * read the Code of Conduct? By filing an Issue, you are expected to -->
<!-- comply with it, including treating everyone with respect: -->
<!-- https://github.com/hyperledger/besu/blob/main/CODE_OF_CONDUCT.md -->
<!-- * Reproduced the issue in the latest version of the software -->
<!-- * Read the debugging docs: https://besu.hyperledger.org/private-networks/how-to -->
<!-- * Duplicate Issue check: https://github.com/search?q=+is%3Aissue+repo%3Ahyperledger/Besu -->
<!-- Note: Not all sections will apply to all issue types. -->
<!-- * Considered using a specific template for submitting a Bug or Feature Request? -->
### 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`]

@ -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 }}

@ -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)

@ -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

@ -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).

@ -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

@ -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 <a href="https://www.yourkit.com/youmonitor/">YourKit YouMonitor</a>.
[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

@ -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

@ -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<String> runCommand;
private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT;
@ -139,7 +139,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
public BesuNode(
final String name,
final Optional<Path> dataPath,
final MiningParameters miningParameters,
final MiningConfiguration miningConfiguration,
final TransactionPoolConfiguration txPoolConfiguration,
final JsonRpcConfiguration jsonRpcConfiguration,
final Optional<JsonRpcConfiguration> 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() {

@ -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;

@ -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<String> 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();
}
}

@ -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<Path> dataPath;
private final MiningParameters miningParameters;
private final MiningConfiguration miningConfiguration;
private final TransactionPoolConfiguration transactionPoolConfiguration;
private final JsonRpcConfiguration jsonRpcConfiguration;
private final Optional<JsonRpcConfiguration> engineRpcConfiguration;
@ -78,7 +78,7 @@ public class BesuNodeConfiguration {
BesuNodeConfiguration(
final String name,
final Optional<Path> dataPath,
final MiningParameters miningParameters,
final MiningConfiguration miningConfiguration,
final TransactionPoolConfiguration transactionPoolConfiguration,
final JsonRpcConfiguration jsonRpcConfiguration,
final Optional<JsonRpcConfiguration> engineRpcConfiguration,
@ -113,7 +113,7 @@ public class BesuNodeConfiguration {
final boolean strictTxReplayProtectionEnabled,
final Map<String, String> 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() {

@ -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<Path> 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),

@ -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");

@ -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<Long> 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"));

@ -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(
() ->

@ -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)

@ -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<String> getApplicationPrefix() {
return Optional.of("plugin_test_");
}
}
}

@ -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();
}

@ -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";

@ -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

@ -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(

@ -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;

@ -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')
}

@ -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)

@ -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");
}
}

@ -49,7 +49,6 @@ dependencies {
implementation project(':ethereum:eth')
implementation project(':ethereum:p2p')
implementation project(':ethereum:permissioning')
implementation project(':ethereum:retesteth')
implementation project(':ethereum:rlp')
implementation project(':ethereum:trie')
implementation project(':ethereum:stratum')

@ -23,7 +23,7 @@ import static org.hyperledger.besu.ethereum.core.PrivacyParameters.FLEXIBLE_PRIV
import org.hyperledger.besu.cli.config.EthNetworkConfig;
import org.hyperledger.besu.cli.config.NetworkName;
import org.hyperledger.besu.cli.options.stable.EthstatsOptions;
import org.hyperledger.besu.cli.options.EthstatsOptions;
import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.ethereum.ProtocolContext;
@ -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> 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<Capability> supportedCapabilities,
@ -1308,7 +1308,7 @@ public class RunnerBuilder {
protocolContext,
filterManager,
transactionPool,
miningParameters,
miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,

@ -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<String, String> 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<GenesisConfigOptions> genesisConfigOptionsSupplier =
Suppliers.memoize(this::readGenesisConfigOptions);
private final Supplier<MiningParameters> miningParametersSupplier =
private final Supplier<MiningConfiguration> 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(

@ -433,14 +433,18 @@ public class ConfigurationOverviewBuilder {
private void detectJemalloc(final List<String> 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");
}
},
() -> {

@ -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<MetricCategory> {
private final Map<String, MetricCategory> 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 <T> the type parameter
* @param categoryEnum the category enum
*/
public <T extends Enum<T> & MetricCategory> void addCategories(final Class<T> 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<String, MetricCategory> getMetricCategories() {
return metricCategories;
}
}

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;

@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethereum.chain.ChainPrunerConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber;

@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.ImmutableEnodeDnsConfiguration;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;

@ -12,13 +12,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_ENGINE_JSON_RPC_PORT;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import java.nio.file.Path;

@ -12,10 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber;

@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethstats.util.EthStatsConnectOptions;
import java.nio.file.Path;

@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.util.List;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
import static org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_PORT;

@ -12,12 +12,11 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration.DEFAULT_IN_PROCESS_RPC_APIS;
import static org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration.DEFAULT_IN_PROCESS_RPC_ENABLED;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.api.jsonrpc.ImmutableInProcessRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_HOST;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import java.util.Locale;
import java.util.Set;

@ -12,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<MetricsConfiguration>
public class MetricsOptions implements CLIOptions<MetricsConfiguration.Builder> {
private MetricCategoryRegistryImpl metricCategoryRegistry;
/**
* Returns a MetricsConfiguration.Builder because fields are often overridden from other domains,
@ -77,7 +80,10 @@ public class MetricsOptions implements CLIOptions<MetricsConfiguration.Builder>
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<MetricsConfiguration.Builder>
arity = "1..*",
description =
"Comma separated list of categories to track metrics for (default: ${DEFAULT-VALUE})")
private Set<MetricCategory> metricCategories = DEFAULT_METRIC_CATEGORIES;
private Set<String> 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<MetricsConfiguration.Builder>
* @return the metric categories
*/
public Set<MetricCategory> 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<MetricsConfiguration.Builder>
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();

@ -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<MiningParameters> {
public class MiningOptions implements CLIOptions<MiningConfiguration> {
@Option(
names = {"--miner-enabled"},
@ -300,43 +300,45 @@ public class MiningOptions implements CLIOptions<MiningParameters> {
}
}
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<MiningParameters> {
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<MiningParameters> {
.nonPoaBlockTxsSelectionMaxTime(nonPoaBlockTxsSelectionMaxTime)
.poaBlockTxsSelectionMaxTime(poaBlockTxsSelectionMaxTime)
.unstable(
ImmutableMiningParameters.Unstable.builder()
ImmutableMiningConfiguration.Unstable.builder()
.remoteSealersLimit(unstableOptions.remoteSealersLimit)
.remoteSealersTimeToLive(unstableOptions.remoteSealersTimeToLive)
.powJobTimeToLive(unstableOptions.powJobTimeToLive)

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.nat.kubernetes.KubernetesNatManager.DEFAULT_BESU_SERVICE_NAME_FILTER;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import picocli.CommandLine;

@ -12,10 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import java.util.Arrays;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP;

@ -12,12 +12,11 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.converter.PercentageConverter;
import org.hyperledger.besu.cli.converter.SubnetInfoConverter;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_KEYSTORE_TYPE;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.datatypes.Address;

@ -12,14 +12,13 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_CONTINUE_ON_PLUGIN_ERROR_OPTION_NAME;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_EXTERNAL_ENABLED_OPTION_NAME;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_OPTION_NAME;
import org.hyperledger.besu.cli.converter.PluginInfoConverter;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginInfo;

@ -12,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;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.VALID_APIS;
@ -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 = "<PASSWORD>",
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 = "<TYPE>",
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 = "<PASSWORD>",
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 = "<TYPE>",
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;
}

@ -12,10 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.ImmutableSnapSyncConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration;

@ -20,7 +20,7 @@ import static org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.COMMAND_N
import org.hyperledger.besu.cli.BesuCommand;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption;
import org.hyperledger.besu.cli.options.NodePrivateKeyFileOption;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.AddressSubCommand;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.ExportSubCommand;
import org.hyperledger.besu.cli.util.VersionProvider;

@ -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 <code>0xba5e</code> 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 = "<hostname>[,<hostname>...]... 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();
}
}
}

@ -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();
}

@ -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");
}

@ -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;

@ -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<Closeable> 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<Closeable> 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;
}
/**

@ -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<WorldStateHealer>();
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<PeerValidator> 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<SnapProtocolManager> 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<SnapProtocolManager> 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<WorldStateHealer> 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 =

@ -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);
}

@ -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<ConsensusContext> 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

@ -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);

@ -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);

@ -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);

@ -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;
}
}

@ -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> 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);

@ -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

@ -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<String> rpcHttpHost = Optional.of("http://localhost");
private Optional<Integer> 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

@ -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);

@ -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<BlockContext> 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<Wei> 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())

@ -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();
}
}

@ -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);

@ -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<TransactionSimulationResult> simulate(
final Transaction transaction,
final Optional<AccountOverrideMap> 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(),

@ -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" "\$@"

@ -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())

@ -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()));

@ -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)

@ -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())

@ -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));

@ -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)

@ -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)

@ -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 {}
}

@ -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)

@ -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<MiningParameters> miningArg =
ArgumentCaptor.forClass(MiningParameters.class);
final ArgumentCaptor<MiningConfiguration> 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

@ -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())

@ -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;

@ -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");
}
}

@ -18,7 +18,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verifyNoInteractions;
import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.junit.jupiter.api.Test;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.stable;
package org.hyperledger.besu.cli.options;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

@ -14,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<MetricsConfiguration.Builder, MetricsOptions> {
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(",")));
}
}

@ -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<MiningParameters, MiningOptions> {
public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningConfiguration, MiningOptions> {
@Test
public void besuDoesNotStartInMiningModeIfCoinbaseNotSet() {
@ -390,13 +390,13 @@ public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningParameters,
}
@Override
protected MiningParameters createDefaultDomainObject() {
return MiningParameters.newDefault();
protected MiningConfiguration createDefaultDomainObject() {
return MiningConfiguration.newDefault();
}
@Override
protected MiningParameters createCustomizedDomainObject() {
return ImmutableMiningParameters.builder()
protected MiningConfiguration createCustomizedDomainObject() {
return ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
@ -410,7 +410,7 @@ public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningParameters,
}
@Override
protected MiningOptions optionsFromDomainObject(final MiningParameters domainObject) {
protected MiningOptions optionsFromDomainObject(final MiningConfiguration domainObject) {
return MiningOptions.fromConfig(domainObject);
}
@ -424,11 +424,11 @@ public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningParameters,
return new String[] {"transactionSelectionService"};
}
private MiningParameters runtimeConfiguration(
final TestBesuCommand besuCommand, final MiningParameters miningParameters) {
private MiningConfiguration runtimeConfiguration(
final TestBesuCommand besuCommand, final MiningConfiguration miningConfiguration) {
if (besuCommand.getGenesisConfigOptions().isPoa()) {
miningParameters.setBlockPeriodSeconds(POA_BLOCK_PERIOD_SECONDS);
miningConfiguration.setBlockPeriodSeconds(POA_BLOCK_PERIOD_SECONDS);
}
return miningParameters;
return miningConfiguration;
}
}

@ -17,7 +17,6 @@ package org.hyperledger.besu.cli.options;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import java.util.Arrays;

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

Loading…
Cancel
Save