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 --> <!-- * read the Code of Conduct? By filing an Issue, you are expected to -->
<!-- comply with it, including treating everyone with respect: --> <!-- comply with it, including treating everyone with respect: -->
<!-- https://github.com/hyperledger/besu/blob/main/CODE_OF_CONDUCT.md --> <!-- 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 --> <!-- * 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) ### Versions (Add all that apply)
* Software version: [`besu --version`] * 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 # Changelog
## [Unreleased] ## [Unreleased]
- Added isLabelsObserved to LabelledGauge in plugin-api. Default implementation returns false.
### Breaking Changes ### Breaking Changes
- Removed Retesteth rpc service and commands [#7833](https://github.com/hyperledger/besu/pull/7783)
### Upcoming Breaking Changes ### 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 ### 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) - 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) - 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) - 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) - 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 ### 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 ## 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) - Remove long-deprecated `perm*whitelist*` methods [#7401](https://github.com/hyperledger/besu/pull/7401)
### Additions and Improvements ### 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) - 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) - In process RPC service [#7395](https://github.com/hyperledger/besu/pull/7395)
- Added support for tracing private transactions using `priv_traceTransaction` API. [#6161](https://github.com/hyperledger/besu/pull/6161) - Added support for tracing private transactions using `priv_traceTransaction` API. [#6161](https://github.com/hyperledger/besu/pull/6161)

@ -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. 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 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). * 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]. * To edit pages in our wiki, you'll need a [Linux Foundation (LF) account].
### Useful contributing links ### 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. 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 | | Luis Pinto | lu-pinto | lu-pinto |
| Lucas Saldanha | lucassaldanha | lucassaldanha | | Lucas Saldanha | lucassaldanha | lucassaldanha |
| Sally MacFarlane | macfarla | macfarla | | Sally MacFarlane | macfarla | macfarla |
| Matilda Clerke | Matilda-Clerke | MatildaClerke |
| Karim Taam | matkt | matkt | | Karim Taam | matkt | matkt |
| Matthew Whitehead| matthew1001 | matthew.whitehead | | Matthew Whitehead| matthew1001 | matthew.whitehead |
| Meredith Baxter | mbaxter | mbaxter | | 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 - 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. 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 - 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) the [mailing list](https://lists.hyperledger.org/g/besu)
and any maintainer/community call. and any maintainer/community call.
- Approval by at least 3 current maintainers within two weeks of the proposal or - 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) [![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) [![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) [![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) [![Twitter Follow](https://img.shields.io/twitter/follow/HyperledgerBesu)](https://twitter.com/HyperledgerBesu)
[Download](https://github.com/hyperledger/besu/releases) [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 Issues]: https://github.com/hyperledger/besu/issues
[Besu User Documentation]: https://besu.hyperledger.org [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 [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 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 [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.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; 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 boolean revertReasonEnabled;
private final String name; private final String name;
private MiningParameters miningParameters; private MiningConfiguration miningConfiguration;
private TransactionPoolConfiguration txPoolConfiguration; private TransactionPoolConfiguration txPoolConfiguration;
private final List<String> runCommand; private final List<String> runCommand;
private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT; private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT;
@ -139,7 +139,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
public BesuNode( public BesuNode(
final String name, final String name,
final Optional<Path> dataPath, final Optional<Path> dataPath,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final TransactionPoolConfiguration txPoolConfiguration, final TransactionPoolConfiguration txPoolConfiguration,
final JsonRpcConfiguration jsonRpcConfiguration, final JsonRpcConfiguration jsonRpcConfiguration,
final Optional<JsonRpcConfiguration> engineRpcConfiguration, final Optional<JsonRpcConfiguration> engineRpcConfiguration,
@ -191,7 +191,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
}, },
() -> this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory)); () -> this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory));
this.name = name; this.name = name;
this.miningParameters = miningParameters; this.miningConfiguration = miningConfiguration;
this.txPoolConfiguration = txPoolConfiguration; this.txPoolConfiguration = txPoolConfiguration;
this.jsonRpcConfiguration = jsonRpcConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration;
this.engineRpcConfiguration = engineRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration;
@ -678,12 +678,12 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
this.bootnodes.addAll(bootnodes); this.bootnodes.addAll(bootnodes);
} }
public MiningParameters getMiningParameters() { public MiningConfiguration getMiningParameters() {
return miningParameters; return miningConfiguration;
} }
public void setMiningParameters(final MiningParameters miningParameters) { public void setMiningParameters(final MiningConfiguration miningConfiguration) {
this.miningParameters = miningParameters; this.miningConfiguration = miningConfiguration;
} }
public TransactionPoolConfiguration getTransactionPoolConfiguration() { 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 com.google.common.base.Preconditions.checkState;
import static java.nio.charset.StandardCharsets.UTF_8; 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.TransactionPoolOptions;
import org.hyperledger.besu.cli.options.storage.DataStorageOptions; 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.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; 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.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginInfo; import org.hyperledger.besu.ethereum.core.plugins.PluginInfo;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; 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.MetricCategoryRegistryImpl;
import org.hyperledger.besu.metrics.MetricsSystemModule; import org.hyperledger.besu.metrics.MetricsSystemModule;
import org.hyperledger.besu.metrics.ObservableMetricsSystem; import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.plugin.data.EnodeURL; import org.hyperledger.besu.plugin.data.EnodeURL;
import org.hyperledger.besu.plugin.services.BesuConfiguration; 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.TransactionSelectionService;
import org.hyperledger.besu.plugin.services.TransactionSimulationService; import org.hyperledger.besu.plugin.services.TransactionSimulationService;
import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry; 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.storage.rocksdb.RocksDBPlugin;
import org.hyperledger.besu.plugin.services.transactionpool.TransactionPoolService;
import org.hyperledger.besu.services.BesuConfigurationImpl; import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuEventsImpl; import org.hyperledger.besu.services.BesuEventsImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl; import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.BlockchainServiceImpl; import org.hyperledger.besu.services.BlockchainServiceImpl;
import org.hyperledger.besu.services.MiningServiceImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl; import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PicoCLIOptionsImpl; import org.hyperledger.besu.services.PicoCLIOptionsImpl;
import org.hyperledger.besu.services.PrivacyPluginServiceImpl; import org.hyperledger.besu.services.PrivacyPluginServiceImpl;
import org.hyperledger.besu.services.RpcEndpointServiceImpl; import org.hyperledger.besu.services.RpcEndpointServiceImpl;
import org.hyperledger.besu.services.SecurityModuleServiceImpl; import org.hyperledger.besu.services.SecurityModuleServiceImpl;
import org.hyperledger.besu.services.StorageServiceImpl; import org.hyperledger.besu.services.StorageServiceImpl;
import org.hyperledger.besu.services.TransactionPoolServiceImpl;
import org.hyperledger.besu.services.TransactionPoolValidatorServiceImpl; import org.hyperledger.besu.services.TransactionPoolValidatorServiceImpl;
import org.hyperledger.besu.services.TransactionSelectionServiceImpl; import org.hyperledger.besu.services.TransactionSelectionServiceImpl;
import org.hyperledger.besu.services.TransactionSimulationServiceImpl; import org.hyperledger.besu.services.TransactionSimulationServiceImpl;
@ -214,6 +219,11 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
besuController.getTransactionPool(), besuController.getTransactionPool(),
besuController.getSyncState(), besuController.getSyncState(),
besuController.getProtocolContext().getBadBlockManager())); besuController.getProtocolContext().getBadBlockManager()));
besuPluginContext.addService(
TransactionPoolService.class,
new TransactionPoolServiceImpl(besuController.getTransactionPool()));
besuPluginContext.addService(
MiningService.class, new MiningServiceImpl(besuController.getMiningCoordinator()));
component.rpcEndpointService().init(runner.getInProcessRpcMethods()); component.rpcEndpointService().init(runner.getInProcessRpcMethods());
@ -326,7 +336,9 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
@Singleton @Singleton
BlockchainServiceImpl provideBlockchainService(final BesuController besuController) { BlockchainServiceImpl provideBlockchainService(final BesuController besuController) {
BlockchainServiceImpl retval = new BlockchainServiceImpl(); BlockchainServiceImpl retval = new BlockchainServiceImpl();
retval.init(besuController.getProtocolContext(), besuController.getProtocolSchedule()); retval.init(
besuController.getProtocolContext().getBlockchain(),
besuController.getProtocolSchedule());
return retval; 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 @Module
@SuppressWarnings("CloseableProvides") @SuppressWarnings("CloseableProvides")
static class BesuControllerModule { public static class BesuControllerModule {
@Provides @Provides
@Singleton @Singleton
public SynchronizerConfiguration provideSynchronizationConfiguration() { public SynchronizerConfiguration provideSynchronizationConfiguration() {
@ -438,7 +459,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
final BesuControllerBuilder builder, final BesuControllerBuilder builder,
final MetricsSystem metricsSystem, final MetricsSystem metricsSystem,
final KeyValueStorageProvider storageProvider, final KeyValueStorageProvider storageProvider,
final MiningParameters miningParameters) { final MiningConfiguration miningConfiguration) {
builder builder
.synchronizerConfiguration(synchronizerConfiguration) .synchronizerConfiguration(synchronizerConfiguration)
@ -451,7 +472,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
.evmConfiguration(EvmConfiguration.DEFAULT) .evmConfiguration(EvmConfiguration.DEFAULT)
.maxPeers(25) .maxPeers(25)
.maxRemotelyInitiatedPeers(15) .maxRemotelyInitiatedPeers(15)
.miningParameters(miningParameters) .miningParameters(miningConfiguration)
.randomPeerPriority(false) .randomPeerPriority(false)
.besuComponent(null); .besuComponent(null);
return builder.build(); return builder.build();
@ -484,6 +505,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
final RpcEndpointServiceImpl rpcEndpointServiceImpl, final RpcEndpointServiceImpl rpcEndpointServiceImpl,
final BesuConfiguration commonPluginConfiguration, final BesuConfiguration commonPluginConfiguration,
final PermissioningServiceImpl permissioningService, final PermissioningServiceImpl permissioningService,
final MetricsConfiguration metricsConfiguration,
final MetricCategoryRegistryImpl metricCategoryRegistry, final MetricCategoryRegistryImpl metricCategoryRegistry,
final MetricsSystem metricsSystem, final MetricsSystem metricsSystem,
final @Named("ExtraCLIOptions") List<String> extraCLIOptions, final @Named("ExtraCLIOptions") List<String> extraCLIOptions,
@ -502,6 +524,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
TransactionSimulationService.class, transactionSimulationServiceImpl); TransactionSimulationService.class, transactionSimulationServiceImpl);
besuPluginContext.addService(BlockchainService.class, blockchainServiceImpl); besuPluginContext.addService(BlockchainService.class, blockchainServiceImpl);
besuPluginContext.addService(BesuConfiguration.class, commonPluginConfiguration); besuPluginContext.addService(BesuConfiguration.class, commonPluginConfiguration);
metricCategoryRegistry.setMetricsConfiguration(metricsConfiguration);
besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry); besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry);
besuPluginContext.addService(MetricsSystem.class, metricsSystem); besuPluginContext.addService(MetricsSystem.class, metricsSystem);
@ -554,11 +577,11 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
} }
@Provides @Provides
public MiningParameters provideMiningParameters( public MiningConfiguration provideMiningParameters(
final TransactionSelectionServiceImpl transactionSelectionServiceImpl, final TransactionSelectionServiceImpl transactionSelectionServiceImpl,
final BesuNode node) { final BesuNode node) {
final var miningParameters = final var miningParameters =
ImmutableMiningParameters.builder() ImmutableMiningConfiguration.builder()
.from(node.getMiningParameters()) .from(node.getMiningParameters())
.transactionSelectionService(transactionSelectionServiceImpl) .transactionSelectionService(transactionSelectionServiceImpl)
.build(); .build();
@ -569,17 +592,26 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
@Provides @Provides
@Inject @Inject
BesuConfiguration provideBesuConfiguration( 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(); final BesuConfigurationImpl commonPluginConfiguration = new BesuConfigurationImpl();
commonPluginConfiguration.init( commonPluginConfiguration.init(
dataDir, dataDir.resolve(DATABASE_PATH), node.getDataStorageConfiguration()); dataDir, dataDir.resolve(DATABASE_PATH), node.getDataStorageConfiguration());
commonPluginConfiguration.withMiningParameters(miningParameters); commonPluginConfiguration.withMiningParameters(miningConfiguration);
return commonPluginConfiguration; return commonPluginConfiguration;
} }
} }
@Module @Module
static class MockBesuCommandModule { public static class ObservableMetricsSystemModule {
@Provides
@Singleton
public ObservableMetricsSystem provideObservableMetricsSystem() {
return new NoOpMetricsSystem();
}
}
@Module
public static class MockBesuCommandModule {
@Provides @Provides
BesuCommand provideBesuCommand(final BesuPluginContextImpl pluginContext) { BesuCommand provideBesuCommand(final BesuPluginContextImpl pluginContext) {
@ -610,6 +642,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
modules = { modules = {
ThreadBesuNodeRunner.BesuControllerModule.class, ThreadBesuNodeRunner.BesuControllerModule.class,
ThreadBesuNodeRunner.MockBesuCommandModule.class, ThreadBesuNodeRunner.MockBesuCommandModule.class,
ThreadBesuNodeRunner.ObservableMetricsSystemModule.class,
ThreadBesuNodeRunnerModule.class,
BonsaiCachedMerkleTrieLoaderModule.class, BonsaiCachedMerkleTrieLoaderModule.class,
MetricsSystemModule.class, MetricsSystemModule.class,
ThreadBesuNodeRunner.BesuNodeProviderModule.class, ThreadBesuNodeRunner.BesuNodeProviderModule.class,
@ -625,5 +659,9 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
RpcEndpointServiceImpl rpcEndpointService(); RpcEndpointServiceImpl rpcEndpointService();
BlockchainServiceImpl blockchainService(); 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.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
@ -40,7 +40,7 @@ public class BesuNodeConfiguration {
private final String name; private final String name;
private final Optional<Path> dataPath; private final Optional<Path> dataPath;
private final MiningParameters miningParameters; private final MiningConfiguration miningConfiguration;
private final TransactionPoolConfiguration transactionPoolConfiguration; private final TransactionPoolConfiguration transactionPoolConfiguration;
private final JsonRpcConfiguration jsonRpcConfiguration; private final JsonRpcConfiguration jsonRpcConfiguration;
private final Optional<JsonRpcConfiguration> engineRpcConfiguration; private final Optional<JsonRpcConfiguration> engineRpcConfiguration;
@ -78,7 +78,7 @@ public class BesuNodeConfiguration {
BesuNodeConfiguration( BesuNodeConfiguration(
final String name, final String name,
final Optional<Path> dataPath, final Optional<Path> dataPath,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final TransactionPoolConfiguration transactionPoolConfiguration, final TransactionPoolConfiguration transactionPoolConfiguration,
final JsonRpcConfiguration jsonRpcConfiguration, final JsonRpcConfiguration jsonRpcConfiguration,
final Optional<JsonRpcConfiguration> engineRpcConfiguration, final Optional<JsonRpcConfiguration> engineRpcConfiguration,
@ -113,7 +113,7 @@ public class BesuNodeConfiguration {
final boolean strictTxReplayProtectionEnabled, final boolean strictTxReplayProtectionEnabled,
final Map<String, String> environment) { final Map<String, String> environment) {
this.name = name; this.name = name;
this.miningParameters = miningParameters; this.miningConfiguration = miningConfiguration;
this.transactionPoolConfiguration = transactionPoolConfiguration; this.transactionPoolConfiguration = transactionPoolConfiguration;
this.jsonRpcConfiguration = jsonRpcConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration;
this.engineRpcConfiguration = engineRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration;
@ -154,8 +154,8 @@ public class BesuNodeConfiguration {
return name; return name;
} }
public MiningParameters getMiningParameters() { public MiningConfiguration getMiningParameters() {
return miningParameters; return miningConfiguration;
} }
public TransactionPoolConfiguration getTransactionPoolConfiguration() { 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.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.api.tls.FileBasedPasswordProvider; import org.hyperledger.besu.ethereum.api.tls.FileBasedPasswordProvider;
import org.hyperledger.besu.ethereum.core.AddressHelpers; import org.hyperledger.besu.ethereum.core.AddressHelpers;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
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.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
@ -61,8 +61,8 @@ public class BesuNodeConfigurationBuilder {
private String name; private String name;
private Optional<Path> dataPath = Optional.empty(); private Optional<Path> dataPath = Optional.empty();
private MiningParameters miningParameters = private MiningConfiguration miningConfiguration =
ImmutableMiningParameters.builder() ImmutableMiningConfiguration.builder()
.mutableInitValues( .mutableInitValues(
MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build()) MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build())
.build(); .build();
@ -125,13 +125,14 @@ public class BesuNodeConfigurationBuilder {
} }
public BesuNodeConfigurationBuilder miningEnabled(final boolean enabled) { public BesuNodeConfigurationBuilder miningEnabled(final boolean enabled) {
this.miningParameters = miningParameters.setMiningEnabled(enabled); this.miningConfiguration = miningConfiguration.setMiningEnabled(enabled);
this.jsonRpcConfiguration.addRpcApi(RpcApis.MINER.name()); this.jsonRpcConfiguration.addRpcApi(RpcApis.MINER.name());
return this; return this;
} }
public BesuNodeConfigurationBuilder miningConfiguration(final MiningParameters miningParameters) { public BesuNodeConfigurationBuilder miningConfiguration(
this.miningParameters = miningParameters; final MiningConfiguration miningConfiguration) {
this.miningConfiguration = miningConfiguration;
this.jsonRpcConfiguration.addRpcApi(RpcApis.MINER.name()); this.jsonRpcConfiguration.addRpcApi(RpcApis.MINER.name());
return this; return this;
} }
@ -527,7 +528,7 @@ public class BesuNodeConfigurationBuilder {
return new BesuNodeConfiguration( return new BesuNodeConfiguration(
name, name,
dataPath, dataPath,
miningParameters, miningConfiguration,
transactionPoolConfiguration, transactionPoolConfiguration,
jsonRpcConfiguration, jsonRpcConfiguration,
Optional.of(engineRpcConfiguration), Optional.of(engineRpcConfiguration),

@ -16,8 +16,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import static java.nio.charset.StandardCharsets.UTF_8; 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.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.PicoCLIOptions; import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import java.io.File; import java.io.File;
@ -39,7 +39,7 @@ public class BadCLIOptionsPlugin implements BesuPlugin {
private File callbackDir; private File callbackDir;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
LOG.info("Registering BadCliOptionsPlugin"); LOG.info("Registering BadCliOptionsPlugin");
callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins")); callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins"));
writeStatus("init"); writeStatus("init");

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.tests.acceptance.plugins; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; 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.BlockHeader;
import org.hyperledger.besu.plugin.data.PropagatedBlockContext; import org.hyperledger.besu.plugin.data.PropagatedBlockContext;
import org.hyperledger.besu.plugin.services.BesuEvents; import org.hyperledger.besu.plugin.services.BesuEvents;
@ -35,14 +35,14 @@ import org.slf4j.LoggerFactory;
public class TestBesuEventsPlugin implements BesuPlugin { public class TestBesuEventsPlugin implements BesuPlugin {
private static final Logger LOG = LoggerFactory.getLogger(TestBesuEventsPlugin.class); private static final Logger LOG = LoggerFactory.getLogger(TestBesuEventsPlugin.class);
private BesuContext context; private ServiceManager context;
private Optional<Long> subscriptionId; private Optional<Long> subscriptionId;
private final AtomicInteger blockCounter = new AtomicInteger(); private final AtomicInteger blockCounter = new AtomicInteger();
private File callbackDir; private File callbackDir;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
this.context = context; this.context = context;
LOG.info("Registered"); LOG.info("Registered");
callbackDir = new File(System.getProperty("besu.plugins.dir", "plugins")); 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.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import 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.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.data.BlockContext; import org.hyperledger.besu.plugin.data.BlockContext;
import org.hyperledger.besu.plugin.services.BlockchainService; import org.hyperledger.besu.plugin.services.BlockchainService;
import org.hyperledger.besu.plugin.services.RpcEndpointService; 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"; private static final String RPC_METHOD_SAFE_BLOCK = "updateSafeBlockV1";
@Override @Override
public void register(final BesuContext besuContext) { public void register(final ServiceManager serviceManager) {
LOG.trace("Registering plugin ..."); LOG.trace("Registering plugin ...");
final RpcEndpointService rpcEndpointService = final RpcEndpointService rpcEndpointService =
besuContext serviceManager
.getService(RpcEndpointService.class) .getService(RpcEndpointService.class)
.orElseThrow( .orElseThrow(
() -> () ->
@ -52,7 +52,7 @@ public class TestBlockchainServiceFinalizedPlugin implements BesuPlugin {
"Failed to obtain RpcEndpointService from the BesuContext.")); "Failed to obtain RpcEndpointService from the BesuContext."));
final BlockchainService blockchainService = final BlockchainService blockchainService =
besuContext serviceManager
.getService(BlockchainService.class) .getService(BlockchainService.class)
.orElseThrow( .orElseThrow(
() -> () ->

@ -15,8 +15,8 @@
package org.hyperledger.besu.tests.acceptance.plugins; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; 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.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.RpcEndpointService; import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; import org.hyperledger.besu.plugin.services.rpc.RpcResponseType;
@ -36,7 +36,7 @@ public class TestInProcessRpcServicePlugin implements BesuPlugin {
long minGasPrice = -1; long minGasPrice = -1;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
final PicoCLIOptions cmdlineOptions = final PicoCLIOptions cmdlineOptions =
context context
.getService(PicoCLIOptions.class) .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; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; 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.PermissioningService;
import org.hyperledger.besu.plugin.services.PicoCLIOptions; import org.hyperledger.besu.plugin.services.PicoCLIOptions;
@ -40,7 +40,7 @@ public class TestPermissioningPlugin implements BesuPlugin {
PermissioningService service; PermissioningService service;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
context.getService(PicoCLIOptions.class).orElseThrow().addPicoCLIOptions("permissioning", this); context.getService(PicoCLIOptions.class).orElseThrow().addPicoCLIOptions("permissioning", this);
service = context.getService(PermissioningService.class).orElseThrow(); service = context.getService(PermissioningService.class).orElseThrow();
} }

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.tests.acceptance.plugins; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; 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.PicoCLIOptions;
import java.io.File; import java.io.File;
@ -57,7 +57,7 @@ public class TestPicoCLIPlugin implements BesuPlugin {
private File callbackDir; private File callbackDir;
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
LOG.info("Registering. Test Option is '{}'", testOption); LOG.info("Registering. Test Option is '{}'", testOption);
state = "registering"; state = "registering";

@ -14,8 +14,8 @@
*/ */
package org.hyperledger.besu.tests.acceptance.plugins; package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.BesuPlugin; 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.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.PrivacyPluginService; import org.hyperledger.besu.plugin.services.PrivacyPluginService;
import org.hyperledger.besu.tests.acceptance.plugins.privacy.TestPrivacyGroupGenesisProvider; 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); private static final Logger LOG = LoggerFactory.getLogger(TestPrivacyServicePlugin.class);
PrivacyPluginService pluginService; PrivacyPluginService pluginService;
BesuContext context; ServiceManager context;
TestPrivacyGroupGenesisProvider privacyGroupGenesisProvider = TestPrivacyGroupGenesisProvider privacyGroupGenesisProvider =
new TestPrivacyGroupGenesisProvider(); new TestPrivacyGroupGenesisProvider();
@ -40,7 +40,7 @@ public class TestPrivacyServicePlugin implements BesuPlugin {
new TestSigningPrivateMarkerTransactionFactory(); new TestSigningPrivateMarkerTransactionFactory();
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
this.context = context; this.context = context;
context context

@ -16,8 +16,8 @@ package org.hyperledger.besu.tests.acceptance.plugins;
import static com.google.common.base.Preconditions.checkArgument; 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.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.RpcEndpointService; import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.rpc.PluginRpcRequest; import org.hyperledger.besu.plugin.services.rpc.PluginRpcRequest;
@ -51,7 +51,7 @@ public class TestRpcEndpointServicePlugin implements BesuPlugin {
} }
@Override @Override
public void register(final BesuContext context) { public void register(final ServiceManager context) {
context context
.getService(RpcEndpointService.class) .getService(RpcEndpointService.class)
.ifPresent( .ifPresent(

@ -28,6 +28,7 @@ import org.apache.tuweni.bytes.Bytes;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@Deprecated(since = "24.11.0")
public class TestPrivacyPluginPayloadProvider implements PrivacyPluginPayloadProvider { public class TestPrivacyPluginPayloadProvider implements PrivacyPluginPayloadProvider {
private static final Logger LOG = LoggerFactory.getLogger(TestPrivacyPluginPayloadProvider.class); private static final Logger LOG = LoggerFactory.getLogger(TestPrivacyPluginPayloadProvider.class);
private String prefix; private String prefix;

@ -31,6 +31,7 @@ dependencies {
api 'org.slf4j:slf4j-api' api 'org.slf4j:slf4j-api'
implementation project(':crypto:algorithms') implementation project(':crypto:algorithms')
implementation project(':ethereum:eth')
testImplementation project(':acceptance-tests:dsl') testImplementation project(':acceptance-tests:dsl')
testImplementation project(':acceptance-tests:test-plugins') testImplementation project(':acceptance-tests:test-plugins')
@ -42,6 +43,7 @@ dependencies {
testImplementation project(':ethereum:api') testImplementation project(':ethereum:api')
testImplementation project(':ethereum:core') testImplementation project(':ethereum:core')
testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')
testImplementation project(':ethereum:eth')
testImplementation project(':ethereum:p2p') testImplementation project(':ethereum:p2p')
testImplementation project(':ethereum:permissioning') testImplementation project(':ethereum:permissioning')
testImplementation project(':ethereum:rlp') testImplementation project(':ethereum:rlp')
@ -78,6 +80,8 @@ dependencies {
testImplementation 'org.web3j:besu' testImplementation 'org.web3j:besu'
testImplementation 'org.web3j:core' testImplementation 'org.web3j:core'
testImplementation 'org.wiremock:wiremock' testImplementation 'org.wiremock:wiremock'
testImplementation 'com.google.dagger:dagger'
testAnnotationProcessor 'com.google.dagger:dagger-compiler'
testImplementation project(path: ':acceptance-tests:tests:shanghai') 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.config.JsonUtil;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.AddressHelpers; import org.hyperledger.besu.ethereum.core.AddressHelpers;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.account.Account; 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.blockchain.Amount;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; 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 { final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception {
setUp(testName, nodeFactory); setUp(testName, nodeFactory);
final BesuNode minerNode = nodeFactory.createNode(besu, "miner1"); final BesuNode minerNode = nodeFactory.createNode(besu, "miner1");
final MiningParameters zeroGasMiningParams = final MiningConfiguration zeroGasMiningParams =
ImmutableMiningParameters.builder() ImmutableMiningConfiguration.builder()
.mutableInitValues( .mutableInitValues(
MutableInitValues.builder() MutableInitValues.builder()
.isMiningEnabled(true) .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:eth')
implementation project(':ethereum:p2p') implementation project(':ethereum:p2p')
implementation project(':ethereum:permissioning') implementation project(':ethereum:permissioning')
implementation project(':ethereum:retesteth')
implementation project(':ethereum:rlp') implementation project(':ethereum:rlp')
implementation project(':ethereum:trie') implementation project(':ethereum:trie')
implementation project(':ethereum:stratum') 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.EthNetworkConfig;
import org.hyperledger.besu.cli.config.NetworkName; 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.controller.BesuController;
import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.ethereum.ProtocolContext; 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.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
@ -773,7 +773,7 @@ public class RunnerBuilder {
final TransactionPool transactionPool = besuController.getTransactionPool(); final TransactionPool transactionPool = besuController.getTransactionPool();
final MiningCoordinator miningCoordinator = besuController.getMiningCoordinator(); final MiningCoordinator miningCoordinator = besuController.getMiningCoordinator();
final MiningParameters miningParameters = besuController.getMiningParameters(); final MiningConfiguration miningConfiguration = besuController.getMiningParameters();
final BlockchainQueries blockchainQueries = final BlockchainQueries blockchainQueries =
new BlockchainQueries( new BlockchainQueries(
@ -783,7 +783,7 @@ public class RunnerBuilder {
Optional.of(dataDir.resolve(CACHE_PATH)), Optional.of(dataDir.resolve(CACHE_PATH)),
Optional.of(besuController.getProtocolManager().ethContext().getScheduler()), Optional.of(besuController.getProtocolManager().ethContext().getScheduler()),
apiConfiguration, apiConfiguration,
miningParameters); miningConfiguration);
final PrivacyParameters privacyParameters = besuController.getPrivacyParameters(); final PrivacyParameters privacyParameters = besuController.getPrivacyParameters();
@ -802,7 +802,7 @@ public class RunnerBuilder {
Optional<StratumServer> stratumServer = Optional.empty(); Optional<StratumServer> stratumServer = Optional.empty();
if (miningParameters.isStratumMiningEnabled()) { if (miningConfiguration.isStratumMiningEnabled()) {
if (!(miningCoordinator instanceof PoWMiningCoordinator powMiningCoordinator)) { if (!(miningCoordinator instanceof PoWMiningCoordinator powMiningCoordinator)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Stratum mining requires the network option(--network) to be set to CLASSIC. Stratum server requires a PoWMiningCoordinator not " "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( new StratumServer(
vertx, vertx,
powMiningCoordinator, powMiningCoordinator,
miningParameters.getStratumPort(), miningConfiguration.getStratumPort(),
miningParameters.getStratumNetworkInterface(), miningConfiguration.getStratumNetworkInterface(),
miningParameters.getUnstable().getStratumExtranonce(), miningConfiguration.getUnstable().getStratumExtranonce(),
metricsSystem)); metricsSystem));
miningCoordinator.addEthHashObserver(stratumServer.get()); miningCoordinator.addEthHashObserver(stratumServer.get());
LOG.debug("added ethash observer: {}", stratumServer.get()); LOG.debug("added ethash observer: {}", stratumServer.get());
@ -849,7 +849,7 @@ public class RunnerBuilder {
blockchainQueries, blockchainQueries,
synchronizer, synchronizer,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
miningCoordinator, miningCoordinator,
metricsSystem, metricsSystem,
supportedCapabilities, supportedCapabilities,
@ -896,7 +896,7 @@ public class RunnerBuilder {
blockchainQueries, blockchainQueries,
synchronizer, synchronizer,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
miningCoordinator, miningCoordinator,
metricsSystem, metricsSystem,
supportedCapabilities, supportedCapabilities,
@ -989,7 +989,7 @@ public class RunnerBuilder {
blockchainQueries, blockchainQueries,
synchronizer, synchronizer,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
miningCoordinator, miningCoordinator,
metricsSystem, metricsSystem,
supportedCapabilities, supportedCapabilities,
@ -1070,7 +1070,7 @@ public class RunnerBuilder {
blockchainQueries, blockchainQueries,
synchronizer, synchronizer,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
miningCoordinator, miningCoordinator,
metricsSystem, metricsSystem,
supportedCapabilities, supportedCapabilities,
@ -1111,7 +1111,7 @@ public class RunnerBuilder {
blockchainQueries, blockchainQueries,
synchronizer, synchronizer,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
miningCoordinator, miningCoordinator,
metricsSystem, metricsSystem,
supportedCapabilities, supportedCapabilities,
@ -1273,7 +1273,7 @@ public class RunnerBuilder {
final BlockchainQueries blockchainQueries, final BlockchainQueries blockchainQueries,
final Synchronizer synchronizer, final Synchronizer synchronizer,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final MiningCoordinator miningCoordinator, final MiningCoordinator miningCoordinator,
final ObservableMetricsSystem metricsSystem, final ObservableMetricsSystem metricsSystem,
final Set<Capability> supportedCapabilities, final Set<Capability> supportedCapabilities,
@ -1308,7 +1308,7 @@ public class RunnerBuilder {
protocolContext, protocolContext,
filterManager, filterManager,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
miningCoordinator, miningCoordinator,
metricsSystem, metricsSystem,
supportedCapabilities, supportedCapabilities,

@ -37,45 +37,43 @@ import org.hyperledger.besu.chainimport.RlpBlockImporter;
import org.hyperledger.besu.cli.config.EthNetworkConfig; import org.hyperledger.besu.cli.config.EthNetworkConfig;
import org.hyperledger.besu.cli.config.NetworkName; import org.hyperledger.besu.cli.config.NetworkName;
import org.hyperledger.besu.cli.config.ProfilesCompletionCandidates; 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.custom.JsonRPCAllowlistHostsProperty;
import org.hyperledger.besu.cli.error.BesuExecutionExceptionHandler; import org.hyperledger.besu.cli.error.BesuExecutionExceptionHandler;
import org.hyperledger.besu.cli.error.BesuParameterExceptionHandler; 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.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.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.DataStorageOptions;
import org.hyperledger.besu.cli.options.storage.DiffBasedSubStorageOptions; 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.PreSynchronizationTaskRunner;
import org.hyperledger.besu.cli.presynctasks.PrivateDatabaseMigrationPreSyncTask; import org.hyperledger.besu.cli.presynctasks.PrivateDatabaseMigrationPreSyncTask;
import org.hyperledger.besu.cli.subcommands.PasswordSubCommand; import org.hyperledger.besu.cli.subcommands.PasswordSubCommand;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand; 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.TxParseSubCommand;
import org.hyperledger.besu.cli.subcommands.ValidateConfigSubCommand; import org.hyperledger.besu.cli.subcommands.ValidateConfigSubCommand;
import org.hyperledger.besu.cli.subcommands.blocks.BlocksSubCommand; 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.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.Blockchain; 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.MiningParametersMetrics;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.VersionMetadata; 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.TransactionSelectionService;
import org.hyperledger.besu.plugin.services.TransactionSimulationService; import org.hyperledger.besu.plugin.services.TransactionSimulationService;
import org.hyperledger.besu.plugin.services.exception.StorageException; 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.metrics.MetricCategoryRegistry;
import org.hyperledger.besu.plugin.services.mining.MiningService;
import org.hyperledger.besu.plugin.services.p2p.P2PService; import org.hyperledger.besu.plugin.services.p2p.P2PService;
import org.hyperledger.besu.plugin.services.rlp.RlpConverterService; import org.hyperledger.besu.plugin.services.rlp.RlpConverterService;
import org.hyperledger.besu.plugin.services.securitymodule.SecurityModule; 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.BesuEventsImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl; import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.BlockchainServiceImpl; import org.hyperledger.besu.services.BlockchainServiceImpl;
import org.hyperledger.besu.services.MiningServiceImpl;
import org.hyperledger.besu.services.P2PServiceImpl; import org.hyperledger.besu.services.P2PServiceImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl; import org.hyperledger.besu.services.PermissioningServiceImpl;
import org.hyperledger.besu.services.PicoCLIOptionsImpl; import org.hyperledger.besu.services.PicoCLIOptionsImpl;
@ -332,7 +331,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final Map<String, String> environment; private final Map<String, String> environment;
private final MetricCategoryRegistryImpl metricCategoryRegistry = private final MetricCategoryRegistryImpl metricCategoryRegistry =
new MetricCategoryRegistryImpl(); new MetricCategoryRegistryImpl();
private final MetricCategoryConverter metricCategoryConverter = new MetricCategoryConverter();
private final PreSynchronizationTaskRunner preSynchronizationTaskRunner = private final PreSynchronizationTaskRunner preSynchronizationTaskRunner =
new PreSynchronizationTaskRunner(); new PreSynchronizationTaskRunner();
@ -342,7 +340,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
Suppliers.memoize(this::readGenesisConfigFile); Suppliers.memoize(this::readGenesisConfigFile);
private final Supplier<GenesisConfigOptions> genesisConfigOptionsSupplier = private final Supplier<GenesisConfigOptions> genesisConfigOptionsSupplier =
Suppliers.memoize(this::readGenesisConfigOptions); Suppliers.memoize(this::readGenesisConfigOptions);
private final Supplier<MiningParameters> miningParametersSupplier = private final Supplier<MiningConfiguration> miningParametersSupplier =
Suppliers.memoize(this::getMiningParameters); Suppliers.memoize(this::getMiningParameters);
private RocksDBPlugin rocksDBPlugin; private RocksDBPlugin rocksDBPlugin;
@ -509,77 +507,95 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
@CommandLine.ArgGroup(validate = false, heading = "@|bold In-Process RPC Options|@%n") @CommandLine.ArgGroup(validate = false, heading = "@|bold In-Process RPC Options|@%n")
InProcessRpcOptions inProcessRpcOptions = InProcessRpcOptions.create(); 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 // 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(); PrivacyOptionGroup privacyOptionGroup = new PrivacyOptionGroup();
static class PrivacyOptionGroup { static class PrivacyOptionGroup {
@Option( @Option(
names = {"--privacy-tls-enabled"}, names = {"--privacy-tls-enabled"},
paramLabel = MANDATORY_FILE_FORMAT_HELP, 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; private final Boolean isPrivacyTlsEnabled = false;
@Option( @Option(
names = "--privacy-tls-keystore-file", names = "--privacy-tls-keystore-file",
paramLabel = MANDATORY_FILE_FORMAT_HELP, paramLabel = MANDATORY_FILE_FORMAT_HELP,
description = 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; private final Path privacyKeyStoreFile = null;
@Option( @Option(
names = "--privacy-tls-keystore-password-file", names = "--privacy-tls-keystore-password-file",
paramLabel = MANDATORY_FILE_FORMAT_HELP, 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; private final Path privacyKeyStorePasswordFile = null;
@Option( @Option(
names = "--privacy-tls-known-enclave-file", names = "--privacy-tls-known-enclave-file",
paramLabel = MANDATORY_FILE_FORMAT_HELP, paramLabel = MANDATORY_FILE_FORMAT_HELP,
description = 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; private final Path privacyTlsKnownEnclaveFile = null;
@Option( @Option(
names = {"--privacy-enabled"}, 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; private final Boolean isPrivacyEnabled = false;
@Option( @Option(
names = {"--privacy-multi-tenancy-enabled"}, 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; private final Boolean isPrivacyMultiTenancyEnabled = false;
@Option( @Option(
names = {"--privacy-url"}, 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; private final URI privacyUrl = PrivacyParameters.DEFAULT_ENCLAVE_URL;
@Option( @Option(
names = {"--privacy-public-key-file"}, 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; private final File privacyPublicKeyFile = null;
@Option( @Option(
names = {"--privacy-marker-transaction-signing-key-file"}, names = {"--privacy-marker-transaction-signing-key-file"},
description = 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; private final Path privateMarkerTransactionSigningKeyPath = null;
@Option( @Option(
names = {"--privacy-enable-database-migration"}, 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; private final Boolean migratePrivateDatabase = false;
@Option( @Option(
names = {"--privacy-flexible-groups-enabled"}, 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; private final Boolean isFlexiblePrivacyGroupsEnabled = false;
@Option( @Option(
names = {"--privacy-nonce-always-increments"}, names = {"--privacy-nonce-always-increments"},
description = description =
"Enable private nonce " PRIVACY_DEPRECATION_PREFIX
+ "Enable private nonce "
+ "incrementation even if the transaction didn't succeeded (default: ${DEFAULT-VALUE})") + "incrementation even if the transaction didn't succeeded (default: ${DEFAULT-VALUE})")
private final Boolean isPrivateNonceAlwaysIncrementsEnabled = false; private final Boolean isPrivateNonceAlwaysIncrementsEnabled = false;
} }
@ -1108,7 +1124,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
PublicKeySubCommand.COMMAND_NAME, new PublicKeySubCommand(commandLine.getOut())); PublicKeySubCommand.COMMAND_NAME, new PublicKeySubCommand(commandLine.getOut()));
commandLine.addSubcommand( commandLine.addSubcommand(
PasswordSubCommand.COMMAND_NAME, new PasswordSubCommand(commandLine.getOut())); PasswordSubCommand.COMMAND_NAME, new PasswordSubCommand(commandLine.getOut()));
commandLine.addSubcommand(RetestethSubCommand.COMMAND_NAME, new RetestethSubCommand());
commandLine.addSubcommand( commandLine.addSubcommand(
RLPSubCommand.COMMAND_NAME, new RLPSubCommand(commandLine.getOut(), in)); RLPSubCommand.COMMAND_NAME, new RLPSubCommand(commandLine.getOut(), in));
commandLine.addSubcommand( commandLine.addSubcommand(
@ -1136,10 +1151,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
commandLine.registerConverter(Hash.class, Hash::fromHexString); commandLine.registerConverter(Hash.class, Hash::fromHexString);
commandLine.registerConverter(Optional.class, Optional::of); commandLine.registerConverter(Optional.class, Optional::of);
commandLine.registerConverter(Double.class, Double::parseDouble); commandLine.registerConverter(Double.class, Double::parseDouble);
metricCategoryConverter.addCategories(BesuMetricCategory.class);
metricCategoryConverter.addCategories(StandardMetricCategory.class);
commandLine.registerConverter(MetricCategory.class, metricCategoryConverter);
} }
private void handleStableOptions() { private void handleStableOptions() {
@ -1174,6 +1185,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
besuPluginContext.addService(PicoCLIOptions.class, new PicoCLIOptionsImpl(commandLine)); besuPluginContext.addService(PicoCLIOptions.class, new PicoCLIOptionsImpl(commandLine));
besuPluginContext.addService(SecurityModuleService.class, securityModuleService); besuPluginContext.addService(SecurityModuleService.class, securityModuleService);
besuPluginContext.addService(StorageService.class, storageService); besuPluginContext.addService(StorageService.class, storageService);
metricCategoryRegistry.addCategories(BesuMetricCategory.class);
metricCategoryRegistry.addCategories(StandardMetricCategory.class);
besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry); besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry);
besuPluginContext.addService(PermissioningService.class, permissioningService); besuPluginContext.addService(PermissioningService.class, permissioningService);
besuPluginContext.addService(PrivacyPluginService.class, privacyPluginService); besuPluginContext.addService(PrivacyPluginService.class, privacyPluginService);
@ -1191,10 +1205,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
rocksDBPlugin.register(besuPluginContext); rocksDBPlugin.register(besuPluginContext);
new InMemoryStoragePlugin().register(besuPluginContext); new InMemoryStoragePlugin().register(besuPluginContext);
metricCategoryRegistry
.getMetricCategories()
.forEach(metricCategoryConverter::addRegistryCategory);
// register default security module // register default security module
securityModuleService.register( securityModuleService.register(
DEFAULT_SECURITY_MODULE, Suppliers.memoize(this::defaultSecurityModule)); DEFAULT_SECURITY_MODULE, Suppliers.memoize(this::defaultSecurityModule));
@ -1243,7 +1253,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private void startPlugins(final Runner runner) { private void startPlugins(final Runner runner) {
blockchainServiceImpl.init( blockchainServiceImpl.init(
besuController.getProtocolContext(), besuController.getProtocolSchedule()); besuController.getProtocolContext().getBlockchain(), besuController.getProtocolSchedule());
transactionSimulationServiceImpl.init( transactionSimulationServiceImpl.init(
besuController.getProtocolContext().getBlockchain(), besuController.getProtocolContext().getBlockchain(),
new TransactionSimulator( new TransactionSimulator(
@ -1293,6 +1303,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
miningParametersSupplier.get()), miningParametersSupplier.get()),
besuController.getProtocolSchedule())); besuController.getProtocolSchedule()));
besuPluginContext.addService(
MiningService.class, new MiningServiceImpl(besuController.getMiningCoordinator()));
besuController.getAdditionalPluginServices().appendPluginServices(besuPluginContext); besuController.getAdditionalPluginServices().appendPluginServices(besuPluginContext);
besuPluginContext.startPlugins(); besuPluginContext.startPlugins();
} }
@ -1303,6 +1316,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
// after start has been called on plugins // after start has been called on plugins
if (Boolean.TRUE.equals(privacyOptionGroup.isPrivacyEnabled)) { if (Boolean.TRUE.equals(privacyOptionGroup.isPrivacyEnabled)) {
logger.warn(
"--Xprivacy-plugin-enabled and related options are " + PRIVACY_DEPRECATION_PREFIX);
if (privacyOptionGroup.privateMarkerTransactionSigningKeyPath != null if (privacyOptionGroup.privateMarkerTransactionSigningKeyPath != null
&& privacyPluginService != null && privacyPluginService != null
@ -1342,7 +1357,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private void setReleaseMetrics() { private void setReleaseMetrics() {
besuComponent besuComponent
.getMetricsSystem() .getMetricsSystem()
.createLabelledGauge( .createLabelledSuppliedGauge(
StandardMetricCategory.PROCESS, "release", "Release information", "version") StandardMetricCategory.PROCESS, "release", "Release information", "version")
.labels(() -> 1, BesuInfo.version()); .labels(() -> 1, BesuInfo.version());
} }
@ -1891,6 +1906,10 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
"--metrics-push-interval", "--metrics-push-interval",
"--metrics-push-prometheus-job")); "--metrics-push-prometheus-job"));
metricsOptions.setMetricCategoryRegistry(metricCategoryRegistry);
metricsOptions.validate(commandLine);
final MetricsConfiguration.Builder metricsConfigurationBuilder = final MetricsConfiguration.Builder metricsConfigurationBuilder =
metricsOptions.toDomainObject(); metricsOptions.toDomainObject();
metricsConfigurationBuilder metricsConfigurationBuilder
@ -1903,7 +1922,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
? p2PDiscoveryOptions.autoDiscoverDefaultIP().getHostAddress() ? p2PDiscoveryOptions.autoDiscoverDefaultIP().getHostAddress()
: metricsOptions.getMetricsPushHost()) : metricsOptions.getMetricsPushHost())
.hostsAllowlist(hostsAllowlist); .hostsAllowlist(hostsAllowlist);
return metricsConfigurationBuilder.build(); final var metricsConfiguration = metricsConfigurationBuilder.build();
metricCategoryRegistry.setMetricsConfiguration(metricsConfiguration);
return metricsConfiguration;
} }
private PrivacyParameters privacyParameters() { private PrivacyParameters privacyParameters() {
@ -1926,6 +1947,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
final PrivacyParameters.Builder privacyParametersBuilder = new PrivacyParameters.Builder(); final PrivacyParameters.Builder privacyParametersBuilder = new PrivacyParameters.Builder();
if (Boolean.TRUE.equals(privacyOptionGroup.isPrivacyEnabled)) { 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."; final String errorSuffix = "cannot be enabled with privacy.";
if (syncMode == SyncMode.FAST) { if (syncMode == SyncMode.FAST) {
throw new ParameterException(commandLine, String.format("%s %s", "Fast sync", errorSuffix)); throw new ParameterException(commandLine, String.format("%s %s", "Fast sync", errorSuffix));
@ -2121,7 +2143,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return txPoolConfBuilder.build(); return txPoolConfBuilder.build();
} }
private MiningParameters getMiningParameters() { private MiningConfiguration getMiningParameters() {
miningOptions.setTransactionSelectionService(transactionSelectionServiceImpl); miningOptions.setTransactionSelectionService(transactionSelectionServiceImpl);
final var miningParameters = miningOptions.toDomainObject(); final var miningParameters = miningOptions.toDomainObject();
getGenesisBlockPeriodSeconds(genesisConfigOptionsSupplier.get()) getGenesisBlockPeriodSeconds(genesisConfigOptionsSupplier.get())
@ -2173,8 +2195,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return dataStorageConfiguration; return dataStorageConfiguration;
} }
private void initMiningParametersMetrics(final MiningParameters miningParameters) { private void initMiningParametersMetrics(final MiningConfiguration miningConfiguration) {
new MiningParametersMetrics(getMetricsSystem(), miningParameters); new MiningParametersMetrics(getMetricsSystem(), miningConfiguration);
} }
private OptionalInt getGenesisBlockPeriodSeconds( private OptionalInt getGenesisBlockPeriodSeconds(

@ -433,14 +433,18 @@ public class ConfigurationOverviewBuilder {
private void detectJemalloc(final List<String> lines) { private void detectJemalloc(final List<String> lines) {
Optional.ofNullable(Objects.isNull(environment) ? null : environment.get("BESU_USING_JEMALLOC")) Optional.ofNullable(Objects.isNull(environment) ? null : environment.get("BESU_USING_JEMALLOC"))
.ifPresentOrElse( .ifPresentOrElse(
t -> { jemallocEnabled -> {
try { try {
final String version = PlatformDetector.getJemalloc(); if (Boolean.parseBoolean(jemallocEnabled)) {
lines.add("jemalloc: " + version); 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) { } catch (final Throwable throwable) {
logger.warn( logger.warn(
"BESU_USING_JEMALLOC is present but we failed to load jemalloc library to get the version", "besu_using_jemalloc is present but we failed to load jemalloc library to get the version");
throwable);
} }
}, },
() -> { () -> {

@ -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 * 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 java.util.Arrays.asList;

@ -12,9 +12,8 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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.ethereum.chain.ChainPrunerConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber; import org.hyperledger.besu.util.number.PositiveNumber;

@ -12,9 +12,8 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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.EnodeDnsConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.ImmutableEnodeDnsConfiguration; import org.hyperledger.besu.ethereum.p2p.peers.ImmutableEnodeDnsConfiguration;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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; import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;

@ -12,13 +12,12 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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 static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_ENGINE_JSON_RPC_PORT;
import org.hyperledger.besu.cli.DefaultCommandValues; import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty; import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils; import org.hyperledger.besu.cli.util.CommandLineUtils;
import java.nio.file.Path; import java.nio.file.Path;

@ -12,10 +12,8 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber; import org.hyperledger.besu.util.number.PositiveNumber;

@ -12,9 +12,8 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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 org.hyperledger.besu.ethstats.util.EthStatsConnectOptions;
import java.nio.file.Path; import java.nio.file.Path;

@ -12,9 +12,8 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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 org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.util.List; import java.util.List;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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 java.util.Arrays.asList;
import static org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_PORT; import static org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_PORT;

@ -12,12 +12,11 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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_APIS;
import static org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration.DEFAULT_IN_PROCESS_RPC_ENABLED; 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.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.api.jsonrpc.ImmutableInProcessRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.ImmutableInProcessRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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 java.util.Arrays.asList;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_HOST; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_HOST;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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.Locale;
import java.util.Set; import java.util.Set;

@ -12,8 +12,10 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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_HOST_FORMAT_HELP;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_INTEGER_FORMAT_HELP; import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_INTEGER_FORMAT_HELP;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_PORT_FORMAT_HELP; import static org.hyperledger.besu.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_PORT;
import static org.hyperledger.besu.metrics.prometheus.MetricsConfiguration.DEFAULT_METRICS_PUSH_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.cli.util.CommandLineUtils;
import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl;
import org.hyperledger.besu.metrics.MetricsProtocol; import org.hyperledger.besu.metrics.MetricsProtocol;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.plugin.services.metrics.MetricCategory; import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
@ -36,6 +38,7 @@ import picocli.CommandLine;
/** Command line options for configuring metrics. */ /** Command line options for configuring metrics. */
// TODO: implement CLIOption<MetricsConfiguration> // TODO: implement CLIOption<MetricsConfiguration>
public class MetricsOptions implements CLIOptions<MetricsConfiguration.Builder> { public class MetricsOptions implements CLIOptions<MetricsConfiguration.Builder> {
private MetricCategoryRegistryImpl metricCategoryRegistry;
/** /**
* Returns a MetricsConfiguration.Builder because fields are often overridden from other domains, * 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.metricsHost = config.getHost();
metricsOptions.metricsPort = config.getPort(); metricsOptions.metricsPort = config.getPort();
metricsOptions.metricsProtocol = config.getProtocol(); metricsOptions.metricsProtocol = config.getProtocol();
metricsOptions.metricCategories = config.getMetricCategories(); metricsOptions.metricCategories =
config.getMetricCategories().stream()
.map(MetricCategory::getName)
.collect(toUnmodifiableSet());
metricsOptions.metricsPrometheusJob = config.getPrometheusJob(); metricsOptions.metricsPrometheusJob = config.getPrometheusJob();
metricsOptions.isMetricsPushEnabled = config.isPushEnabled(); metricsOptions.isMetricsPushEnabled = config.isPushEnabled();
metricsOptions.metricsPushHost = config.getPushHost(); metricsOptions.metricsPushHost = config.getPushHost();
@ -126,7 +132,8 @@ public class MetricsOptions implements CLIOptions<MetricsConfiguration.Builder>
arity = "1..*", arity = "1..*",
description = description =
"Comma separated list of categories to track metrics for (default: ${DEFAULT-VALUE})") "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( @CommandLine.Option(
names = {"--metrics-push-enabled"}, names = {"--metrics-push-enabled"},
@ -216,7 +223,13 @@ public class MetricsOptions implements CLIOptions<MetricsConfiguration.Builder>
* @return the metric categories * @return the metric categories
*/ */
public Set<MetricCategory> getMetricCategories() { 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; 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) @CommandLine.ArgGroup(validate = false)
private final MetricsOptions.Unstable unstableOptions = new MetricsOptions.Unstable(); 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 com.google.common.base.Preconditions.checkNotNull;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static java.util.Collections.singletonList; 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.MiningConfiguration.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.MiningConfiguration.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.MiningConfiguration.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.MiningConfiguration.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.MiningConfiguration.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.MiningConfiguration.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.MiningConfiguration.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.MiningConfiguration.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.MiningConfiguration.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.MiningConfiguration.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.MiningConfiguration.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.Unstable.DEFAULT_REMOTE_SEALERS_TTL;
import org.hyperledger.besu.cli.converter.PositiveNumberConverter; import org.hyperledger.besu.cli.converter.PositiveNumberConverter;
import org.hyperledger.besu.cli.util.CommandLineUtils; import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.plugin.services.TransactionSelectionService; import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.util.number.PositiveNumber; import org.hyperledger.besu.util.number.PositiveNumber;
@ -50,7 +50,7 @@ import picocli.CommandLine.Option;
import picocli.CommandLine.ParameterException; import picocli.CommandLine.ParameterException;
/** The Mining CLI options. */ /** The Mining CLI options. */
public class MiningOptions implements CLIOptions<MiningParameters> { public class MiningOptions implements CLIOptions<MiningConfiguration> {
@Option( @Option(
names = {"--miner-enabled"}, 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(); final MiningOptions miningOptions = MiningOptions.create();
miningOptions.setTransactionSelectionService(miningParameters.getTransactionSelectionService()); miningOptions.setTransactionSelectionService(
miningOptions.isMiningEnabled = miningParameters.isMiningEnabled(); miningConfiguration.getTransactionSelectionService());
miningOptions.iStratumMiningEnabled = miningParameters.isStratumMiningEnabled(); miningOptions.isMiningEnabled = miningConfiguration.isMiningEnabled();
miningOptions.stratumNetworkInterface = miningParameters.getStratumNetworkInterface(); miningOptions.iStratumMiningEnabled = miningConfiguration.isStratumMiningEnabled();
miningOptions.stratumPort = miningParameters.getStratumPort(); miningOptions.stratumNetworkInterface = miningConfiguration.getStratumNetworkInterface();
miningOptions.extraData = miningParameters.getExtraData(); miningOptions.stratumPort = miningConfiguration.getStratumPort();
miningOptions.minTransactionGasPrice = miningParameters.getMinTransactionGasPrice(); miningOptions.extraData = miningConfiguration.getExtraData();
miningOptions.minPriorityFeePerGas = miningParameters.getMinPriorityFeePerGas(); miningOptions.minTransactionGasPrice = miningConfiguration.getMinTransactionGasPrice();
miningOptions.minBlockOccupancyRatio = miningParameters.getMinBlockOccupancyRatio(); miningOptions.minPriorityFeePerGas = miningConfiguration.getMinPriorityFeePerGas();
miningOptions.minBlockOccupancyRatio = miningConfiguration.getMinBlockOccupancyRatio();
miningOptions.nonPoaBlockTxsSelectionMaxTime = miningOptions.nonPoaBlockTxsSelectionMaxTime =
miningParameters.getNonPoaBlockTxsSelectionMaxTime(); miningConfiguration.getNonPoaBlockTxsSelectionMaxTime();
miningOptions.poaBlockTxsSelectionMaxTime = miningParameters.getPoaBlockTxsSelectionMaxTime(); miningOptions.poaBlockTxsSelectionMaxTime =
miningConfiguration.getPoaBlockTxsSelectionMaxTime();
miningOptions.unstableOptions.remoteSealersLimit = miningOptions.unstableOptions.remoteSealersLimit =
miningParameters.getUnstable().getRemoteSealersLimit(); miningConfiguration.getUnstable().getRemoteSealersLimit();
miningOptions.unstableOptions.remoteSealersTimeToLive = miningOptions.unstableOptions.remoteSealersTimeToLive =
miningParameters.getUnstable().getRemoteSealersTimeToLive(); miningConfiguration.getUnstable().getRemoteSealersTimeToLive();
miningOptions.unstableOptions.powJobTimeToLive = miningOptions.unstableOptions.powJobTimeToLive =
miningParameters.getUnstable().getPowJobTimeToLive(); miningConfiguration.getUnstable().getPowJobTimeToLive();
miningOptions.unstableOptions.maxOmmersDepth = miningOptions.unstableOptions.maxOmmersDepth =
miningParameters.getUnstable().getMaxOmmerDepth(); miningConfiguration.getUnstable().getMaxOmmerDepth();
miningOptions.unstableOptions.stratumExtranonce = miningOptions.unstableOptions.stratumExtranonce =
miningParameters.getUnstable().getStratumExtranonce(); miningConfiguration.getUnstable().getStratumExtranonce();
miningOptions.unstableOptions.posBlockCreationMaxTime = miningOptions.unstableOptions.posBlockCreationMaxTime =
miningParameters.getUnstable().getPosBlockCreationMaxTime(); miningConfiguration.getUnstable().getPosBlockCreationMaxTime();
miningOptions.unstableOptions.posBlockCreationRepetitionMinDuration = miningOptions.unstableOptions.posBlockCreationRepetitionMinDuration =
miningParameters.getUnstable().getPosBlockCreationRepetitionMinDuration(); miningConfiguration.getUnstable().getPosBlockCreationRepetitionMinDuration();
miningParameters.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase); miningConfiguration.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase);
miningParameters.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl); miningConfiguration.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl);
return miningOptions; return miningOptions;
} }
@Override @Override
public MiningParameters toDomainObject() { public MiningConfiguration toDomainObject() {
checkNotNull( checkNotNull(
transactionSelectionService, transactionSelectionService,
"transactionSelectionService must be set before using this object"); "transactionSelectionService must be set before using this object");
@ -356,7 +358,7 @@ public class MiningOptions implements CLIOptions<MiningParameters> {
updatableInitValuesBuilder.coinbase(coinbase); updatableInitValuesBuilder.coinbase(coinbase);
} }
return ImmutableMiningParameters.builder() return ImmutableMiningConfiguration.builder()
.transactionSelectionService(transactionSelectionService) .transactionSelectionService(transactionSelectionService)
.mutableInitValues(updatableInitValuesBuilder.build()) .mutableInitValues(updatableInitValuesBuilder.build())
.isStratumMiningEnabled(iStratumMiningEnabled) .isStratumMiningEnabled(iStratumMiningEnabled)
@ -365,7 +367,7 @@ public class MiningOptions implements CLIOptions<MiningParameters> {
.nonPoaBlockTxsSelectionMaxTime(nonPoaBlockTxsSelectionMaxTime) .nonPoaBlockTxsSelectionMaxTime(nonPoaBlockTxsSelectionMaxTime)
.poaBlockTxsSelectionMaxTime(poaBlockTxsSelectionMaxTime) .poaBlockTxsSelectionMaxTime(poaBlockTxsSelectionMaxTime)
.unstable( .unstable(
ImmutableMiningParameters.Unstable.builder() ImmutableMiningConfiguration.Unstable.builder()
.remoteSealersLimit(unstableOptions.remoteSealersLimit) .remoteSealersLimit(unstableOptions.remoteSealersLimit)
.remoteSealersTimeToLive(unstableOptions.remoteSealersTimeToLive) .remoteSealersTimeToLive(unstableOptions.remoteSealersTimeToLive)
.powJobTimeToLive(unstableOptions.powJobTimeToLive) .powJobTimeToLive(unstableOptions.powJobTimeToLive)

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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; import static org.hyperledger.besu.nat.kubernetes.KubernetesNatManager.DEFAULT_BESU_SERVICE_NAME_FILTER;

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

@ -12,10 +12,8 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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 org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import java.util.Arrays; import java.util.Arrays;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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; import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP;

@ -12,12 +12,11 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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.DefaultCommandValues;
import org.hyperledger.besu.cli.converter.PercentageConverter; import org.hyperledger.besu.cli.converter.PercentageConverter;
import org.hyperledger.besu.cli.converter.SubnetInfoConverter; 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.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration; import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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 java.util.Arrays.asList;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_KEYSTORE_TYPE; import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_KEYSTORE_TYPE;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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.DefaultCommandValues;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;

@ -12,14 +12,13 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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_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_EXTERNAL_ENABLED_OPTION_NAME;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_OPTION_NAME; import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_OPTION_NAME;
import org.hyperledger.besu.cli.converter.PluginInfoConverter; import org.hyperledger.besu.cli.converter.PluginInfoConverter;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils; import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginInfo; import org.hyperledger.besu.ethereum.core.plugins.PluginInfo;

@ -12,11 +12,12 @@
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
package org.hyperledger.besu.cli.options.unstable; package org.hyperledger.besu.cli.options;
import static picocli.CommandLine.Option; import static picocli.CommandLine.Option;
/** The Privacy plugin Cli options. */ /** The Privacy plugin Cli options. */
@Deprecated(since = "24.11.0")
public class PrivacyPluginOptions { public class PrivacyPluginOptions {
/** Default Constructor. */ /** Default Constructor. */
PrivacyPluginOptions() {} PrivacyPluginOptions() {}
@ -33,7 +34,7 @@ public class PrivacyPluginOptions {
@Option( @Option(
names = "--Xprivacy-plugin-enabled", names = "--Xprivacy-plugin-enabled",
description = 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) hidden = true)
private final Boolean isPrivacyPluginEnabled = false; private final Boolean isPrivacyPluginEnabled = false;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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; import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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.DEFAULT_RPC_APIS;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.VALID_APIS; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.VALID_APIS;
@ -120,6 +120,71 @@ public class RpcWebsocketOptions {
arity = "1") arity = "1")
private final File rpcWsAuthenticationPublicKeyFile = null; 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. */ /** Default Constructor. */
public RpcWebsocketOptions() {} public RpcWebsocketOptions() {}
@ -184,7 +249,61 @@ public class RpcWebsocketOptions {
"--rpc-ws-authentication-enabled", "--rpc-ws-authentication-enabled",
"--rpc-ws-authentication-credentials-file", "--rpc-ws-authentication-credentials-file",
"--rpc-ws-authentication-public-key-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) { if (isRpcWsAuthenticationEnabled) {
CommandLineUtils.checkOptionDependencies( CommandLineUtils.checkOptionDependencies(
@ -222,6 +341,18 @@ public class RpcWebsocketOptions {
webSocketConfiguration.setAuthenticationPublicKeyFile(rpcWsAuthenticationPublicKeyFile); webSocketConfiguration.setAuthenticationPublicKeyFile(rpcWsAuthenticationPublicKeyFile);
webSocketConfiguration.setAuthenticationAlgorithm(rpcWebsocketsAuthenticationAlgorithm); webSocketConfiguration.setAuthenticationAlgorithm(rpcWebsocketsAuthenticationAlgorithm);
webSocketConfiguration.setTimeoutSec(wsTimoutSec); 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; return webSocketConfiguration;
} }

@ -12,10 +12,8 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.ImmutableSnapSyncConfiguration; import org.hyperledger.besu.ethereum.eth.sync.snapsync.ImmutableSnapSyncConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; 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.BesuCommand;
import org.hyperledger.besu.cli.DefaultCommandValues; 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.AddressSubCommand;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.ExportSubCommand; import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.ExportSubCommand;
import org.hyperledger.besu.cli.util.VersionProvider; 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.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.IncrementingNonceGenerator; import org.hyperledger.besu.ethereum.blockcreation.IncrementingNonceGenerator;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.metrics.MetricsService; import org.hyperledger.besu.metrics.MetricsService;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; 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; final Wei minTransactionGasPrice = Wei.ZERO;
// Extradata and coinbase can be configured on a per-block level via the json file // Extradata and coinbase can be configured on a per-block level via the json file
final Address coinbase = Address.ZERO; final Address coinbase = Address.ZERO;
final Bytes extraData = Bytes.EMPTY; final Bytes extraData = Bytes.EMPTY;
return ImmutableMiningParameters.builder() return ImmutableMiningConfiguration.builder()
.mutableInitValues( .mutableInitValues(
MutableInitValues.builder() MutableInitValues.builder()
.nonceGenerator(new IncrementingNonceGenerator(0)) .nonceGenerator(new IncrementingNonceGenerator(0))
@ -377,7 +377,7 @@ public class BlocksSubCommand implements Runnable {
return parentCommand return parentCommand
.parentCommand .parentCommand
.setupControllerBuilder() .setupControllerBuilder()
.miningParameters(MiningParameters.newDefault()) .miningParameters(MiningConfiguration.newDefault())
.build(); .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.Node;
import org.hyperledger.besu.ethereum.trie.PersistVisitor; import org.hyperledger.besu.ethereum.trie.PersistVisitor;
import org.hyperledger.besu.ethereum.trie.RestoreVisitor; 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.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.util.io.RollingFileReader; import org.hyperledger.besu.util.io.RollingFileReader;
import java.io.IOException; import java.io.IOException;
@ -192,8 +192,8 @@ public class RestoreState implements Runnable {
final Bytes accountRlp = accountInput.readBytes(); final Bytes accountRlp = accountInput.readBytes();
final Bytes code = accountInput.readBytes(); final Bytes code = accountInput.readBytes();
final StateTrieAccountValue trieAccount = final PmtStateTrieAccountValue trieAccount =
StateTrieAccountValue.readFrom(new BytesValueRLPInput(accountRlp, false, true)); PmtStateTrieAccountValue.readFrom(new BytesValueRLPInput(accountRlp, false, true));
if (!trieAccount.getCodeHash().equals(Hash.hash(code))) { if (!trieAccount.getCodeHash().equals(Hash.hash(code))) {
throw new RuntimeException("Code hash doesn't match"); 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.JsonBlockImporter;
import org.hyperledger.besu.chainimport.RlpBlockImporter; import org.hyperledger.besu.chainimport.RlpBlockImporter;
import org.hyperledger.besu.cli.BesuCommand; import org.hyperledger.besu.cli.BesuCommand;
import org.hyperledger.besu.cli.options.stable.P2PDiscoveryOptions; import org.hyperledger.besu.cli.options.P2PDiscoveryOptions;
import org.hyperledger.besu.cli.options.unstable.RPCOptions; import org.hyperledger.besu.cli.options.RPCOptions;
import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration; import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; 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.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods; import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers; 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 MiningCoordinator miningCoordinator;
private final PrivacyParameters privacyParameters; private final PrivacyParameters privacyParameters;
private final List<Closeable> closeables; private final List<Closeable> closeables;
private final MiningParameters miningParameters; private final MiningConfiguration miningConfiguration;
private final PluginServiceFactory additionalPluginServices; private final PluginServiceFactory additionalPluginServices;
private final SyncState syncState; private final SyncState syncState;
private final EthPeers ethPeers; private final EthPeers ethPeers;
@ -91,7 +91,7 @@ public class BesuController implements java.io.Closeable {
* @param transactionPool the transaction pool * @param transactionPool the transaction pool
* @param miningCoordinator the mining coordinator * @param miningCoordinator the mining coordinator
* @param privacyParameters the privacy parameters * @param privacyParameters the privacy parameters
* @param miningParameters the mining parameters * @param miningConfiguration the mining parameters
* @param additionalJsonRpcMethodsFactory the additional json rpc methods factory * @param additionalJsonRpcMethodsFactory the additional json rpc methods factory
* @param nodeKey the node key * @param nodeKey the node key
* @param closeables the closeables * @param closeables the closeables
@ -111,7 +111,7 @@ public class BesuController implements java.io.Closeable {
final TransactionPool transactionPool, final TransactionPool transactionPool,
final MiningCoordinator miningCoordinator, final MiningCoordinator miningCoordinator,
final PrivacyParameters privacyParameters, final PrivacyParameters privacyParameters,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final JsonRpcMethods additionalJsonRpcMethodsFactory, final JsonRpcMethods additionalJsonRpcMethodsFactory,
final NodeKey nodeKey, final NodeKey nodeKey,
final List<Closeable> closeables, final List<Closeable> closeables,
@ -132,7 +132,7 @@ public class BesuController implements java.io.Closeable {
this.miningCoordinator = miningCoordinator; this.miningCoordinator = miningCoordinator;
this.privacyParameters = privacyParameters; this.privacyParameters = privacyParameters;
this.closeables = closeables; this.closeables = closeables;
this.miningParameters = miningParameters; this.miningConfiguration = miningConfiguration;
this.additionalPluginServices = additionalPluginServices; this.additionalPluginServices = additionalPluginServices;
this.ethPeers = ethPeers; this.ethPeers = ethPeers;
this.storageProvider = storageProvider; this.storageProvider = storageProvider;
@ -265,8 +265,8 @@ public class BesuController implements java.io.Closeable {
* *
* @return the mining parameters * @return the mining parameters
*/ */
public MiningParameters getMiningParameters() { public MiningConfiguration getMiningParameters() {
return miningParameters; return miningConfiguration;
} }
/** /**

@ -26,7 +26,6 @@ import org.hyperledger.besu.consensus.qbft.BFTPivotSelectorFromPeers;
import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ConsensusContext; import org.hyperledger.besu.ethereum.ConsensusContext;
import org.hyperledger.besu.ethereum.ConsensusContextFactory;
import org.hyperledger.besu.ethereum.GasLimitCalculator; import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods; 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.chain.VariablesStorage;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.SnapProtocol; 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.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter; import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter;
import org.hyperledger.besu.ethereum.eth.manager.MonitoredExecutors; 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.manager.snap.SnapProtocolManager;
import org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator; import org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator;
import org.hyperledger.besu.ethereum.eth.peervalidation.ClassicForkPeerValidator; 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.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration; import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; 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.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
@ -113,6 +116,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.OptionalLong; import java.util.OptionalLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -144,7 +148,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
protected BigInteger networkId; protected BigInteger networkId;
/** The Mining parameters. */ /** The Mining parameters. */
protected MiningParameters miningParameters; protected MiningConfiguration miningConfiguration;
/** The Metrics system. */ /** The Metrics system. */
protected ObservableMetricsSystem metricsSystem; protected ObservableMetricsSystem metricsSystem;
@ -296,11 +300,11 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
/** /**
* Mining parameters besu controller builder. * Mining parameters besu controller builder.
* *
* @param miningParameters the mining parameters * @param miningConfiguration the mining parameters
* @return the besu controller builder * @return the besu controller builder
*/ */
public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) { public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) {
this.miningParameters = miningParameters; this.miningConfiguration = miningConfiguration;
return this; return this;
} }
@ -543,7 +547,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
checkNotNull(syncConfig, "Missing sync config"); checkNotNull(syncConfig, "Missing sync config");
checkNotNull(ethereumWireProtocolConfiguration, "Missing ethereum protocol configuration"); checkNotNull(ethereumWireProtocolConfiguration, "Missing ethereum protocol configuration");
checkNotNull(networkId, "Missing network ID"); checkNotNull(networkId, "Missing network ID");
checkNotNull(miningParameters, "Missing mining parameters"); checkNotNull(miningConfiguration, "Missing mining parameters");
checkNotNull(metricsSystem, "Missing metrics system"); checkNotNull(metricsSystem, "Missing metrics system");
checkNotNull(privacyParameters, "Missing privacy parameters"); checkNotNull(privacyParameters, "Missing privacy parameters");
checkNotNull(dataDirectory, "Missing data directory"); // Why do we need this? checkNotNull(dataDirectory, "Missing data directory"); // Why do we need this?
@ -589,17 +593,24 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
.map(BesuComponent::getCachedMerkleTrieLoader) .map(BesuComponent::getCachedMerkleTrieLoader)
.orElseGet(() -> new BonsaiCachedMerkleTrieLoader(metricsSystem)); .orElseGet(() -> new BonsaiCachedMerkleTrieLoader(metricsSystem));
final var worldStateHealerSupplier = new AtomicReference<WorldStateHealer>();
final WorldStateArchive worldStateArchive = final WorldStateArchive worldStateArchive =
createWorldStateArchive( createWorldStateArchive(
worldStateStorageCoordinator, blockchain, bonsaiCachedMerkleTrieLoader); worldStateStorageCoordinator,
blockchain,
bonsaiCachedMerkleTrieLoader,
worldStateHealerSupplier::get);
if (maybeStoredGenesisBlockHash.isEmpty()) { if (maybeStoredGenesisBlockHash.isEmpty()) {
genesisState.writeStateTo(worldStateArchive.getMutable()); genesisState.writeStateTo(worldStateArchive.getMutable());
} }
final var consensusContext =
createConsensusContext(blockchain, worldStateArchive, protocolSchedule);
final ProtocolContext protocolContext = final ProtocolContext protocolContext =
createProtocolContext( createProtocolContext(blockchain, worldStateArchive, consensusContext);
blockchain, worldStateArchive, protocolSchedule, this::createConsensusContext);
validateContext(protocolContext); validateContext(protocolContext);
protocolSchedule.setPublicWorldStateArchiveForPrivacyBlockProcessor( protocolSchedule.setPublicWorldStateArchiveForPrivacyBlockProcessor(
@ -616,7 +627,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
ethereumWireProtocolConfiguration.isLegacyEth64ForkIdEnabled()); ethereumWireProtocolConfiguration.isLegacyEth64ForkIdEnabled());
final EthPeers ethPeers = final EthPeers ethPeers =
new EthPeers( new EthPeers(
getSupportedProtocol(), EthProtocol.NAME,
currentProtocolSpecSupplier, currentProtocolSpecSupplier,
clock, clock,
metricsSystem, metricsSystem,
@ -655,6 +666,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
} }
final EthContext ethContext = new EthContext(ethPeers, ethMessages, snapMessages, scheduler); 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 boolean fullSyncDisabled = !SyncMode.isFullSync(syncConfig.getSyncMode());
final SyncState syncState = new SyncState(blockchain, ethPeers, fullSyncDisabled, checkpoint); final SyncState syncState = new SyncState(blockchain, ethPeers, fullSyncDisabled, checkpoint);
@ -678,7 +691,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
syncState, syncState,
transactionPoolConfiguration, transactionPoolConfiguration,
besuComponent.map(BesuComponent::getBlobCache).orElse(new BlobCache()), besuComponent.map(BesuComponent::getBlobCache).orElse(new BlobCache()),
miningParameters); miningConfiguration);
final List<PeerValidator> peerValidators = createPeerValidators(protocolSchedule); final List<PeerValidator> peerValidators = createPeerValidators(protocolSchedule);
@ -706,10 +719,13 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
worldStateStorageCoordinator, worldStateStorageCoordinator,
protocolContext, protocolContext,
ethContext, ethContext,
peerTaskExecutor,
syncState, syncState,
ethProtocolManager, ethProtocolManager,
pivotBlockSelector); pivotBlockSelector);
worldStateHealerSupplier.set(synchronizer::healWorldState);
ethPeers.setTrailingPeerRequirementsSupplier(synchronizer::calculateTrailingPeerRequirements); ethPeers.setTrailingPeerRequirementsSupplier(synchronizer::calculateTrailingPeerRequirements);
if (syncConfig.getSyncMode() == SyncMode.SNAP if (syncConfig.getSyncMode() == SyncMode.SNAP
@ -720,18 +736,16 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
ethPeers.snapServerPeersNeeded(false); ethPeers.snapServerPeersNeeded(false);
} }
protocolContext.setSynchronizer(synchronizer);
final Optional<SnapProtocolManager> maybeSnapProtocolManager = final Optional<SnapProtocolManager> maybeSnapProtocolManager =
createSnapProtocolManager( createSnapProtocolManager(
protocolContext, worldStateStorageCoordinator, ethPeers, snapMessages); protocolContext, worldStateStorageCoordinator, ethPeers, snapMessages, synchronizer);
final MiningCoordinator miningCoordinator = final MiningCoordinator miningCoordinator =
createMiningCoordinator( createMiningCoordinator(
protocolSchedule, protocolSchedule,
protocolContext, protocolContext,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
syncState, syncState,
ethProtocolManager); ethProtocolManager);
@ -742,7 +756,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
createSubProtocolConfiguration(ethProtocolManager, maybeSnapProtocolManager); createSubProtocolConfiguration(ethProtocolManager, maybeSnapProtocolManager);
final JsonRpcMethods additionalJsonRpcMethodFactory = final JsonRpcMethods additionalJsonRpcMethodFactory =
createAdditionalJsonRpcMethodFactory(protocolContext, protocolSchedule, miningParameters); createAdditionalJsonRpcMethodFactory(
protocolContext, protocolSchedule, miningConfiguration);
if (DataStorageFormat.BONSAI.equals(dataStorageConfiguration.getDataStorageFormat())) { if (DataStorageFormat.BONSAI.equals(dataStorageConfiguration.getDataStorageFormat())) {
final DiffBasedSubStorageConfiguration subStorageConfiguration = final DiffBasedSubStorageConfiguration subStorageConfiguration =
@ -776,7 +791,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
transactionPool, transactionPool,
miningCoordinator, miningCoordinator,
privacyParameters, privacyParameters,
miningParameters, miningConfiguration,
additionalJsonRpcMethodFactory, additionalJsonRpcMethodFactory,
nodeKey, nodeKey,
closeables, closeables,
@ -832,6 +847,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
* @param worldStateStorageCoordinator the world state storage * @param worldStateStorageCoordinator the world state storage
* @param protocolContext the protocol context * @param protocolContext the protocol context
* @param ethContext the eth context * @param ethContext the eth context
* @param peerTaskExecutor the PeerTaskExecutor
* @param syncState the sync state * @param syncState the sync state
* @param ethProtocolManager the eth protocol manager * @param ethProtocolManager the eth protocol manager
* @param pivotBlockSelector the pivot block selector * @param pivotBlockSelector the pivot block selector
@ -842,6 +858,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
final WorldStateStorageCoordinator worldStateStorageCoordinator, final WorldStateStorageCoordinator worldStateStorageCoordinator,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final EthContext ethContext, final EthContext ethContext,
final PeerTaskExecutor peerTaskExecutor,
final SyncState syncState, final SyncState syncState,
final EthProtocolManager ethProtocolManager, final EthProtocolManager ethProtocolManager,
final PivotBlockSelector pivotBlockSelector) { final PivotBlockSelector pivotBlockSelector) {
@ -853,6 +870,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
worldStateStorageCoordinator, worldStateStorageCoordinator,
ethProtocolManager.getBlockBroadcaster(), ethProtocolManager.getBlockBroadcaster(),
ethContext, ethContext,
peerTaskExecutor,
syncState, syncState,
dataDirectory, dataDirectory,
storageProvider, storageProvider,
@ -932,13 +950,13 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
* *
* @param protocolContext the protocol context * @param protocolContext the protocol context
* @param protocolSchedule the protocol schedule * @param protocolSchedule the protocol schedule
* @param miningParameters the mining parameters * @param miningConfiguration the mining parameters
* @return the json rpc methods * @return the json rpc methods
*/ */
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory( protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final MiningParameters miningParameters) { final MiningConfiguration miningConfiguration) {
return apis -> Collections.emptyMap(); 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 protocolSchedule the protocol schedule
* @param protocolContext the protocol context * @param protocolContext the protocol context
* @param transactionPool the transaction pool * @param transactionPool the transaction pool
* @param miningParameters the mining parameters * @param miningConfiguration the mining parameters
* @param syncState the sync state * @param syncState the sync state
* @param ethProtocolManager the eth protocol manager * @param ethProtocolManager the eth protocol manager
* @return the mining coordinator * @return the mining coordinator
@ -975,7 +993,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
ProtocolSchedule protocolSchedule, ProtocolSchedule protocolSchedule,
ProtocolContext protocolContext, ProtocolContext protocolContext,
TransactionPool transactionPool, TransactionPool transactionPool,
MiningParameters miningParameters, MiningConfiguration miningConfiguration,
SyncState syncState, SyncState syncState,
EthProtocolManager ethProtocolManager); EthProtocolManager ethProtocolManager);
@ -1002,18 +1020,9 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
* @return the consensus context * @return the consensus context
*/ */
protected abstract ConsensusContext createConsensusContext( protected abstract ConsensusContext createConsensusContext(
Blockchain blockchain, final Blockchain blockchain,
WorldStateArchive worldStateArchive, final WorldStateArchive worldStateArchive,
ProtocolSchedule protocolSchedule); final ProtocolSchedule protocolSchedule);
/**
* Gets supported protocol.
*
* @return the supported protocol
*/
protected String getSupportedProtocol() {
return EthProtocol.NAME;
}
/** /**
* Create eth protocol manager eth protocol manager. * Create eth protocol manager eth protocol manager.
@ -1064,37 +1073,37 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
* *
* @param blockchain the blockchain * @param blockchain the blockchain
* @param worldStateArchive the world state archive * @param worldStateArchive the world state archive
* @param protocolSchedule the protocol schedule * @param consensusContext the consensus context
* @param consensusContextFactory the consensus context factory
* @return the protocol context * @return the protocol context
*/ */
protected ProtocolContext createProtocolContext( protected ProtocolContext createProtocolContext(
final MutableBlockchain blockchain, final MutableBlockchain blockchain,
final WorldStateArchive worldStateArchive, final WorldStateArchive worldStateArchive,
final ProtocolSchedule protocolSchedule, final ConsensusContext consensusContext) {
final ConsensusContextFactory consensusContextFactory) { return new ProtocolContext(blockchain, worldStateArchive, consensusContext, badBlockManager);
return ProtocolContext.init(
blockchain, worldStateArchive, protocolSchedule, consensusContextFactory, badBlockManager);
} }
private Optional<SnapProtocolManager> createSnapProtocolManager( private Optional<SnapProtocolManager> createSnapProtocolManager(
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final WorldStateStorageCoordinator worldStateStorageCoordinator, final WorldStateStorageCoordinator worldStateStorageCoordinator,
final EthPeers ethPeers, final EthPeers ethPeers,
final EthMessages snapMessages) { final EthMessages snapMessages,
final Synchronizer synchronizer) {
return Optional.of( return Optional.of(
new SnapProtocolManager( new SnapProtocolManager(
worldStateStorageCoordinator, worldStateStorageCoordinator,
syncConfig.getSnapSyncConfiguration(), syncConfig.getSnapSyncConfiguration(),
ethPeers, ethPeers,
snapMessages, snapMessages,
protocolContext)); protocolContext,
synchronizer));
} }
WorldStateArchive createWorldStateArchive( WorldStateArchive createWorldStateArchive(
final WorldStateStorageCoordinator worldStateStorageCoordinator, final WorldStateStorageCoordinator worldStateStorageCoordinator,
final Blockchain blockchain, final Blockchain blockchain,
final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader) { final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader,
final Supplier<WorldStateHealer> worldStateHealerSupplier) {
return switch (dataStorageConfiguration.getDataStorageFormat()) { return switch (dataStorageConfiguration.getDataStorageFormat()) {
case BONSAI -> { case BONSAI -> {
final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage = final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage =
@ -1109,7 +1118,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
.getMaxLayersToLoad()), .getMaxLayersToLoad()),
bonsaiCachedMerkleTrieLoader, bonsaiCachedMerkleTrieLoader,
besuComponent.map(BesuComponent::getBesuPluginContext).orElse(null), besuComponent.map(BesuComponent::getBesuPluginContext).orElse(null),
evmConfiguration); evmConfiguration,
worldStateHealerSupplier);
} }
case VERKLE -> { case VERKLE -> {
final VerkleWorldStateKeyValueStorage worldStateKeyValueStorage = final VerkleWorldStateKeyValueStorage worldStateKeyValueStorage =

@ -14,12 +14,11 @@
*/ */
package org.hyperledger.besu.controller; package org.hyperledger.besu.controller;
import static org.hyperledger.besu.consensus.clique.CliqueHelpers.installCliqueBlockChoiceRule;
import org.hyperledger.besu.config.CliqueConfigOptions; import org.hyperledger.besu.config.CliqueConfigOptions;
import org.hyperledger.besu.consensus.clique.CliqueBlockInterface; import org.hyperledger.besu.consensus.clique.CliqueBlockInterface;
import org.hyperledger.besu.consensus.clique.CliqueContext; import org.hyperledger.besu.consensus.clique.CliqueContext;
import org.hyperledger.besu.consensus.clique.CliqueForksSchedulesFactory; 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.CliqueMiningTracker;
import org.hyperledger.besu.consensus.clique.CliqueProtocolSchedule; import org.hyperledger.besu.consensus.clique.CliqueProtocolSchedule;
import org.hyperledger.besu.consensus.clique.blockcreation.CliqueBlockScheduler; 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.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader; 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.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
@ -74,8 +73,8 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory( protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final MiningParameters miningParameters) { final MiningConfiguration miningConfiguration) {
return new CliqueJsonRpcMethods(protocolContext, protocolSchedule, miningParameters); return new CliqueJsonRpcMethods(protocolContext, protocolSchedule, miningConfiguration);
} }
@Override @Override
@ -83,7 +82,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final SyncState syncState, final SyncState syncState,
final EthProtocolManager ethProtocolManager) { final EthProtocolManager ethProtocolManager) {
final CliqueMinerExecutor miningExecutor = final CliqueMinerExecutor miningExecutor =
@ -92,7 +91,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
protocolSchedule, protocolSchedule,
transactionPool, transactionPool,
nodeKey, nodeKey,
miningParameters, miningConfiguration,
new CliqueBlockScheduler( new CliqueBlockScheduler(
clock, clock,
protocolContext.getConsensusContext(CliqueContext.class).getValidatorProvider(), protocolContext.getConsensusContext(CliqueContext.class).getValidatorProvider(),
@ -113,7 +112,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
.getBlockchain() .getBlockchain()
.observeBlockAdded( .observeBlockAdded(
o -> o ->
miningParameters.setBlockPeriodSeconds( miningConfiguration.setBlockPeriodSeconds(
forksSchedule forksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1) .getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue() .getValue()
@ -135,7 +134,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters, miningConfiguration,
badBlockManager, badBlockManager,
isParallelTxProcessingEnabled, isParallelTxProcessingEnabled,
metricsSystem); metricsSystem);
@ -167,12 +166,13 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
blockchain, epochManager, blockInterface), blockchain, epochManager, blockInterface),
epochManager, epochManager,
blockInterface); blockInterface);
installCliqueBlockChoiceRule(blockchain, cliqueContext); CliqueHelpers.setCliqueContext(cliqueContext);
CliqueHelpers.installCliqueBlockChoiceRule(blockchain, cliqueContext);
return cliqueContext; return cliqueContext;
} }
@Override @Override
public MiningParameters getMiningParameterOverrides(final MiningParameters fromCli) { public MiningConfiguration getMiningParameterOverrides(final MiningConfiguration fromCli) {
// Clique mines by default, reflect that with in the mining parameters: // Clique mines by default, reflect that with in the mining parameters:
return fromCli.setMiningEnabled(true); 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.CombinedProtocolScheduleFactory;
import org.hyperledger.besu.consensus.common.ForkSpec; import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.ForksSchedule; 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.MigratingMiningCoordinator;
import org.hyperledger.besu.consensus.common.MigratingProtocolContext; import org.hyperledger.besu.consensus.common.MigratingProtocolContext;
import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ConsensusContext; import org.hyperledger.besu.ethereum.ConsensusContext;
import org.hyperledger.besu.ethereum.ConsensusContextFactory;
import org.hyperledger.besu.ethereum.GasLimitCalculator; import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods; import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain; 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.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@ -128,7 +127,7 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final SyncState syncState, final SyncState syncState,
final EthProtocolManager ethProtocolManager) { final EthProtocolManager ethProtocolManager) {
@ -143,7 +142,7 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
protocolSchedule, protocolSchedule,
protocolContext, protocolContext,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
syncState, syncState,
ethProtocolManager))) ethProtocolManager)))
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -168,10 +167,12 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
protected ProtocolContext createProtocolContext( protected ProtocolContext createProtocolContext(
final MutableBlockchain blockchain, final MutableBlockchain blockchain,
final WorldStateArchive worldStateArchive, final WorldStateArchive worldStateArchive,
final ProtocolSchedule protocolSchedule, final ConsensusContext consensusContext) {
final ConsensusContextFactory consensusContextFactory) { return new MigratingProtocolContext(
return MigratingProtocolContext.init( blockchain,
blockchain, worldStateArchive, protocolSchedule, consensusContextFactory, badBlockManager); worldStateArchive,
consensusContext.as(MigratingConsensusContext.class),
badBlockManager);
} }
@Override @Override
@ -188,10 +189,10 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
e.getValue() e.getValue()
.createConsensusContext( .createConsensusContext(
blockchain, worldStateArchive, protocolSchedule))) blockchain, worldStateArchive, protocolSchedule)))
.collect(Collectors.toList()); .toList();
final ForksSchedule<ConsensusContext> consensusContextsSchedule = final ForksSchedule<ConsensusContext> consensusContextsSchedule =
new ForksSchedule<>(consensusContextSpecs); new ForksSchedule<>(consensusContextSpecs);
return new MigratingContext(consensusContextsSchedule); return new MigratingConsensusContext(consensusContextsSchedule);
} }
@Override @Override
@ -206,10 +207,11 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory( protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final MiningParameters miningParameters) { final MiningConfiguration miningConfiguration) {
return besuControllerBuilderSchedule return besuControllerBuilderSchedule
.get(0L) .get(0L)
.createAdditionalJsonRpcMethodFactory(protocolContext, protocolSchedule, miningParameters); .createAdditionalJsonRpcMethodFactory(
protocolContext, protocolSchedule, miningConfiguration);
} }
@Override @Override
@ -226,11 +228,6 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
besuControllerBuilderSchedule.get(GENESIS_BLOCK_NUMBER).validateContext(context); besuControllerBuilderSchedule.get(GENESIS_BLOCK_NUMBER).validateContext(context);
} }
@Override
protected String getSupportedProtocol() {
return besuControllerBuilderSchedule.get(0L).getSupportedProtocol();
}
@Override @Override
protected EthProtocolManager createEthProtocolManager( protected EthProtocolManager createEthProtocolManager(
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
@ -297,9 +294,9 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
} }
@Override @Override
public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) { public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) {
besuControllerBuilderSchedule.values().forEach(b -> b.miningParameters(miningParameters)); besuControllerBuilderSchedule.values().forEach(b -> b.miningParameters(miningConfiguration));
return super.miningParameters(miningParameters); return super.miningParameters(miningConfiguration);
} }
@Override @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.MinedBlockObserver;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader; 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.core.Util;
import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.SnapProtocol; import org.hyperledger.besu.ethereum.eth.SnapProtocol;
@ -114,8 +114,8 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory( protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final MiningParameters miningParameters) { final MiningConfiguration miningConfiguration) {
return new IbftJsonRpcMethods(protocolContext, protocolSchedule, miningParameters); return new IbftJsonRpcMethods(protocolContext, protocolSchedule, miningConfiguration);
} }
@Override @Override
@ -141,7 +141,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final SyncState syncState, final SyncState syncState,
final EthProtocolManager ethProtocolManager) { final EthProtocolManager ethProtocolManager) {
final MutableBlockchain blockchain = protocolContext.getBlockchain(); final MutableBlockchain blockchain = protocolContext.getBlockchain();
@ -156,7 +156,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
protocolContext, protocolContext,
bftProtocolSchedule, bftProtocolSchedule,
forksSchedule, forksSchedule,
miningParameters, miningConfiguration,
localAddress, localAddress,
bftExtraDataCodec().get(), bftExtraDataCodec().get(),
ethProtocolManager.ethContext().getScheduler()); ethProtocolManager.ethContext().getScheduler());
@ -247,7 +247,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
.getBlockchain() .getBlockchain()
.observeBlockAdded( .observeBlockAdded(
o -> o ->
miningParameters.setBlockPeriodSeconds( miningConfiguration.setBlockPeriodSeconds(
forksSchedule forksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1) .getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue() .getValue()
@ -303,7 +303,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
isRevertReasonEnabled, isRevertReasonEnabled,
bftExtraDataCodec().get(), bftExtraDataCodec().get(),
evmConfiguration, evmConfiguration,
miningParameters, miningConfiguration,
badBlockManager, badBlockManager,
isParallelTxProcessingEnabled, isParallelTxProcessingEnabled,
metricsSystem); 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.PoWMinerExecutor;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain; 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.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; 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.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import java.util.Optional;
/** The Mainnet besu controller builder. */ /** The Mainnet besu controller builder. */
public class MainnetBesuControllerBuilder extends BesuControllerBuilder { public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
@ -44,7 +46,7 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final SyncState syncState, final SyncState syncState,
final EthProtocolManager ethProtocolManager) { final EthProtocolManager ethProtocolManager) {
@ -53,7 +55,7 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
protocolContext, protocolContext,
protocolSchedule, protocolSchedule,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
new DefaultBlockScheduler( new DefaultBlockScheduler(
MainnetBlockHeaderValidator.MINIMUM_SECONDS_SINCE_PARENT, MainnetBlockHeaderValidator.MINIMUM_SECONDS_SINCE_PARENT,
MainnetBlockHeaderValidator.TIMESTAMP_TOLERANCE_S, MainnetBlockHeaderValidator.TIMESTAMP_TOLERANCE_S,
@ -66,11 +68,11 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
protocolContext.getBlockchain(), protocolContext.getBlockchain(),
executor, executor,
syncState, syncState,
miningParameters.getUnstable().getRemoteSealersLimit(), miningConfiguration.getUnstable().getRemoteSealersLimit(),
miningParameters.getUnstable().getRemoteSealersTimeToLive()); miningConfiguration.getUnstable().getRemoteSealersTimeToLive());
miningCoordinator.addMinedBlockObserver(ethProtocolManager); miningCoordinator.addMinedBlockObserver(ethProtocolManager);
miningCoordinator.setStratumMiningEnabled(miningParameters.isStratumMiningEnabled()); miningCoordinator.setStratumMiningEnabled(miningConfiguration.isStratumMiningEnabled());
if (miningParameters.isMiningEnabled()) { if (miningConfiguration.isMiningEnabled()) {
miningCoordinator.enable(); miningCoordinator.enable();
} }
@ -95,10 +97,10 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
protected ProtocolSchedule createProtocolSchedule() { protected ProtocolSchedule createProtocolSchedule() {
return MainnetProtocolSchedule.fromConfig( return MainnetProtocolSchedule.fromConfig(
genesisConfigOptions, genesisConfigOptions,
privacyParameters, Optional.of(privacyParameters),
isRevertReasonEnabled, Optional.of(isRevertReasonEnabled),
evmConfiguration, Optional.of(evmConfiguration),
miningParameters, super.miningConfiguration,
badBlockManager, badBlockManager,
isParallelTxProcessingEnabled, isParallelTxProcessingEnabled,
metricsSystem); metricsSystem);

@ -26,7 +26,7 @@ import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty; 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.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthMessages; import org.hyperledger.besu.ethereum.eth.manager.EthMessages;
@ -67,14 +67,14 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final SyncState syncState, final SyncState syncState,
final EthProtocolManager ethProtocolManager) { final EthProtocolManager ethProtocolManager) {
return createTransitionMiningCoordinator( return createTransitionMiningCoordinator(
protocolSchedule, protocolSchedule,
protocolContext, protocolContext,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
syncState, syncState,
new BackwardSyncContext( new BackwardSyncContext(
protocolContext, protocolContext,
@ -140,7 +140,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
* @param protocolSchedule the protocol schedule * @param protocolSchedule the protocol schedule
* @param protocolContext the protocol context * @param protocolContext the protocol context
* @param transactionPool the transaction pool * @param transactionPool the transaction pool
* @param miningParameters the mining parameters * @param miningConfiguration the mining parameters
* @param syncState the sync state * @param syncState the sync state
* @param backwardSyncContext the backward sync context * @param backwardSyncContext the backward sync context
* @param ethScheduler the scheduler * @param ethScheduler the scheduler
@ -150,7 +150,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final SyncState syncState, final SyncState syncState,
final BackwardSyncContext backwardSyncContext, final BackwardSyncContext backwardSyncContext,
final EthScheduler ethScheduler) { final EthScheduler ethScheduler) {
@ -165,7 +165,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
protocolSchedule, protocolSchedule,
ethScheduler, ethScheduler,
transactionPool, transactionPool,
miningParameters, miningConfiguration,
backwardSyncContext, backwardSyncContext,
depositContractAddress); depositContractAddress);
} }
@ -176,7 +176,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
genesisConfigOptions, genesisConfigOptions,
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
miningParameters, miningConfiguration,
badBlockManager, badBlockManager,
isParallelTxProcessingEnabled, isParallelTxProcessingEnabled,
metricsSystem); metricsSystem);

@ -14,7 +14,7 @@
*/ */
package org.hyperledger.besu.controller; 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 * 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. * @param fromCli The mining parameters that contains original values.
* @return MiningParameters constructed from provided param with additional overridden parameters. * @return MiningParameters constructed from provided param with additional overridden parameters.
*/ */
default MiningParameters getMiningParameterOverrides(final MiningParameters fromCli) { default MiningConfiguration getMiningParameterOverrides(final MiningConfiguration fromCli) {
return 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.MinedBlockObserver;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader; 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.core.Util;
import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.SnapProtocol; import org.hyperledger.besu.ethereum.eth.SnapProtocol;
@ -112,10 +112,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
@Override @Override
protected Supplier<BftExtraDataCodec> bftExtraDataCodec() { protected Supplier<BftExtraDataCodec> bftExtraDataCodec() {
return Suppliers.memoize( return Suppliers.memoize(QbftExtraDataCodec::new);
() -> {
return new QbftExtraDataCodec();
});
} }
@Override @Override
@ -130,12 +127,12 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory( protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final MiningParameters miningParameters) { final MiningConfiguration miningConfiguration) {
return new QbftJsonRpcMethods( return new QbftJsonRpcMethods(
protocolContext, protocolContext,
protocolSchedule, protocolSchedule,
miningParameters, miningConfiguration,
createReadOnlyValidatorProvider(protocolContext.getBlockchain()), createReadOnlyValidatorProvider(protocolContext.getBlockchain()),
bftConfigOptions); bftConfigOptions);
} }
@ -181,7 +178,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final SyncState syncState, final SyncState syncState,
final EthProtocolManager ethProtocolManager) { final EthProtocolManager ethProtocolManager) {
final MutableBlockchain blockchain = protocolContext.getBlockchain(); final MutableBlockchain blockchain = protocolContext.getBlockchain();
@ -196,7 +193,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
protocolContext, protocolContext,
bftProtocolSchedule, bftProtocolSchedule,
qbftForksSchedule, qbftForksSchedule,
miningParameters, miningConfiguration,
localAddress, localAddress,
bftExtraDataCodec().get(), bftExtraDataCodec().get(),
ethProtocolManager.ethContext().getScheduler()); ethProtocolManager.ethContext().getScheduler());
@ -289,12 +286,12 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
.getBlockchain() .getBlockchain()
.observeBlockAdded( .observeBlockAdded(
o -> { o -> {
miningParameters.setBlockPeriodSeconds( miningConfiguration.setBlockPeriodSeconds(
qbftForksSchedule qbftForksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1) .getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue() .getValue()
.getBlockPeriodSeconds()); .getBlockPeriodSeconds());
miningParameters.setEmptyBlockPeriodSeconds( miningConfiguration.setEmptyBlockPeriodSeconds(
qbftForksSchedule qbftForksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1) .getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue() .getValue()
@ -351,7 +348,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
isRevertReasonEnabled, isRevertReasonEnabled,
bftExtraDataCodec().get(), bftExtraDataCodec().get(),
evmConfiguration, evmConfiguration,
miningParameters, miningConfiguration,
badBlockManager, badBlockManager,
isParallelTxProcessingEnabled, isParallelTxProcessingEnabled,
metricsSystem); metricsSystem);

@ -24,14 +24,13 @@ import org.hyperledger.besu.consensus.merge.blockcreation.TransitionCoordinator;
import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ConsensusContext; import org.hyperledger.besu.ethereum.ConsensusContext;
import org.hyperledger.besu.ethereum.ConsensusContextFactory;
import org.hyperledger.besu.ethereum.GasLimitCalculator; import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
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.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext; 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.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter; 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.peervalidation.PeerValidator;
import org.hyperledger.besu.ethereum.eth.sync.DefaultSynchronizer; import org.hyperledger.besu.ethereum.eth.sync.DefaultSynchronizer;
import org.hyperledger.besu.ethereum.eth.sync.PivotBlockSelector; import org.hyperledger.besu.ethereum.eth.sync.PivotBlockSelector;
@ -101,7 +101,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
final ProtocolSchedule protocolSchedule, final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final TransactionPool transactionPool, final TransactionPool transactionPool,
final MiningParameters miningParameters, final MiningConfiguration miningConfiguration,
final SyncState syncState, final SyncState syncState,
final EthProtocolManager ethProtocolManager) { final EthProtocolManager ethProtocolManager) {
@ -111,8 +111,8 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
// PoA consensus mines by default, get consensus-specific mining parameters for // PoA consensus mines by default, get consensus-specific mining parameters for
// TransitionCoordinator: // TransitionCoordinator:
MiningParameters transitionMiningParameters = MiningConfiguration transitionMiningConfiguration =
preMergeBesuControllerBuilder.getMiningParameterOverrides(miningParameters); preMergeBesuControllerBuilder.getMiningParameterOverrides(miningConfiguration);
// construct a transition backward sync context // construct a transition backward sync context
BackwardSyncContext transitionBackwardsSyncContext = BackwardSyncContext transitionBackwardsSyncContext =
@ -130,10 +130,10 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
transitionProtocolSchedule.getPreMergeSchedule(), transitionProtocolSchedule.getPreMergeSchedule(),
protocolContext, protocolContext,
transactionPool, transactionPool,
ImmutableMiningParameters.builder() ImmutableMiningConfiguration.builder()
.from(miningParameters) .from(miningConfiguration)
.mutableInitValues( .mutableInitValues(
ImmutableMiningParameters.MutableInitValues.builder() ImmutableMiningConfiguration.MutableInitValues.builder()
.isMiningEnabled(false) .isMiningEnabled(false)
.build()) .build())
.build(), .build(),
@ -143,7 +143,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
transitionProtocolSchedule, transitionProtocolSchedule,
protocolContext, protocolContext,
transactionPool, transactionPool,
transitionMiningParameters, transitionMiningConfiguration,
syncState, syncState,
transitionBackwardsSyncContext, transitionBackwardsSyncContext,
ethProtocolManager.ethContext().getScheduler())); ethProtocolManager.ethContext().getScheduler()));
@ -192,11 +192,9 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
protected ProtocolContext createProtocolContext( protected ProtocolContext createProtocolContext(
final MutableBlockchain blockchain, final MutableBlockchain blockchain,
final WorldStateArchive worldStateArchive, final WorldStateArchive worldStateArchive,
final ProtocolSchedule protocolSchedule, final ConsensusContext consensusContext) {
final ConsensusContextFactory consensusContextFactory) {
final ProtocolContext protocolContext = final ProtocolContext protocolContext =
super.createProtocolContext( super.createProtocolContext(blockchain, worldStateArchive, consensusContext);
blockchain, worldStateArchive, protocolSchedule, consensusContextFactory);
transitionProtocolSchedule.setProtocolContext(protocolContext); transitionProtocolSchedule.setProtocolContext(protocolContext);
return protocolContext; return protocolContext;
} }
@ -225,6 +223,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
final WorldStateStorageCoordinator worldStateStorageCoordinator, final WorldStateStorageCoordinator worldStateStorageCoordinator,
final ProtocolContext protocolContext, final ProtocolContext protocolContext,
final EthContext ethContext, final EthContext ethContext,
final PeerTaskExecutor peerTaskExecutor,
final SyncState syncState, final SyncState syncState,
final EthProtocolManager ethProtocolManager, final EthProtocolManager ethProtocolManager,
final PivotBlockSelector pivotBlockSelector) { final PivotBlockSelector pivotBlockSelector) {
@ -235,6 +234,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
worldStateStorageCoordinator, worldStateStorageCoordinator,
protocolContext, protocolContext,
ethContext, ethContext,
peerTaskExecutor,
syncState, syncState,
ethProtocolManager, ethProtocolManager,
pivotBlockSelector); pivotBlockSelector);
@ -326,9 +326,9 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
} }
@Override @Override
public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) { public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) {
super.miningParameters(miningParameters); super.miningParameters(miningConfiguration);
return propagateConfig(z -> z.miningParameters(miningParameters)); return propagateConfig(z -> z.miningParameters(miningConfiguration));
} }
@Override @Override

@ -14,9 +14,9 @@
*/ */
package org.hyperledger.besu.services; 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.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.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.plugin.services.BesuConfiguration; import org.hyperledger.besu.plugin.services.BesuConfiguration;
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat; import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
@ -31,7 +31,7 @@ public class BesuConfigurationImpl implements BesuConfiguration {
private DataStorageConfiguration dataStorageConfiguration; private DataStorageConfiguration dataStorageConfiguration;
// defaults // defaults
private MiningParameters miningParameters = MiningParameters.newDefault(); private MiningConfiguration miningConfiguration;
private Optional<String> rpcHttpHost = Optional.of("http://localhost"); private Optional<String> rpcHttpHost = Optional.of("http://localhost");
private Optional<Integer> rpcHttpPort = Optional.of(8545); private Optional<Integer> rpcHttpPort = Optional.of(8545);
@ -59,11 +59,11 @@ public class BesuConfigurationImpl implements BesuConfiguration {
/** /**
* Set the mining parameters * Set the mining parameters
* *
* @param miningParameters configured mining parameters * @param miningConfiguration configured mining parameters
* @return BesuConfigurationImpl instance * @return BesuConfigurationImpl instance
*/ */
public BesuConfigurationImpl withMiningParameters(final MiningParameters miningParameters) { public BesuConfigurationImpl withMiningParameters(final MiningConfiguration miningConfiguration) {
this.miningParameters = miningParameters; this.miningConfiguration = miningConfiguration;
return this; return this;
} }
@ -106,7 +106,7 @@ public class BesuConfigurationImpl implements BesuConfiguration {
@Override @Override
public Wei getMinGasPrice() { public Wei getMinGasPrice() {
return miningParameters.getMinTransactionGasPrice(); return miningConfiguration.getMinTransactionGasPrice();
} }
@Override @Override

@ -18,8 +18,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; 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.BesuPlugin;
import org.hyperledger.besu.plugin.ServiceManager;
import org.hyperledger.besu.plugin.services.BesuService; import org.hyperledger.besu.plugin.services.BesuService;
import org.hyperledger.besu.plugin.services.PluginVersionsProvider; import org.hyperledger.besu.plugin.services.PluginVersionsProvider;
@ -49,7 +49,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** The Besu plugin context implementation. */ /** 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); 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.Hash;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@ -40,7 +39,6 @@ import java.util.stream.Collectors;
@Unstable @Unstable
public class BlockchainServiceImpl implements BlockchainService { public class BlockchainServiceImpl implements BlockchainService {
private ProtocolContext protocolContext;
private ProtocolSchedule protocolSchedule; private ProtocolSchedule protocolSchedule;
private MutableBlockchain blockchain; private MutableBlockchain blockchain;
@ -50,13 +48,12 @@ public class BlockchainServiceImpl implements BlockchainService {
/** /**
* Initialize the Blockchain service. * Initialize the Blockchain service.
* *
* @param protocolContext the protocol context * @param blockchain the blockchain
* @param protocolSchedule the protocol schedule * @param protocolSchedule the protocol schedule
*/ */
public void init(final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule) { public void init(final MutableBlockchain blockchain, final ProtocolSchedule protocolSchedule) {
this.protocolContext = protocolContext;
this.protocolSchedule = protocolSchedule; this.protocolSchedule = protocolSchedule;
this.blockchain = protocolContext.getBlockchain(); this.blockchain = blockchain;
} }
/** /**
@ -67,25 +64,24 @@ public class BlockchainServiceImpl implements BlockchainService {
*/ */
@Override @Override
public Optional<BlockContext> getBlockByNumber(final long number) { public Optional<BlockContext> getBlockByNumber(final long number) {
return protocolContext return blockchain
.getBlockchain()
.getBlockByNumber(number) .getBlockByNumber(number)
.map(block -> blockContext(block::getHeader, block::getBody)); .map(block -> blockContext(block::getHeader, block::getBody));
} }
@Override @Override
public Hash getChainHeadHash() { public Hash getChainHeadHash() {
return protocolContext.getBlockchain().getChainHeadHash(); return blockchain.getChainHeadHash();
} }
@Override @Override
public BlockHeader getChainHeadHeader() { public BlockHeader getChainHeadHeader() {
return protocolContext.getBlockchain().getChainHeadHeader(); return blockchain.getChainHeadHeader();
} }
@Override @Override
public Optional<Wei> getNextBlockBaseFee() { public Optional<Wei> getNextBlockBaseFee() {
final var chainHeadHeader = protocolContext.getBlockchain().getChainHeadHeader(); final var chainHeadHeader = blockchain.getChainHeadHeader();
final var protocolSpec = final var protocolSpec =
protocolSchedule.getForNextBlockHeader(chainHeadHeader, System.currentTimeMillis()); protocolSchedule.getForNextBlockHeader(chainHeadHeader, System.currentTimeMillis());
return Optional.of(protocolSpec.getFeeMarket()) 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; import org.slf4j.LoggerFactory;
/** The Privacy plugin service implementation. */ /** The Privacy plugin service implementation. */
@Deprecated(since = "24.11.0")
public class PrivacyPluginServiceImpl implements PrivacyPluginService { public class PrivacyPluginServiceImpl implements PrivacyPluginService {
private static final Logger LOG = LoggerFactory.getLogger(PrivacyPluginServiceImpl.class); private static final Logger LOG = LoggerFactory.getLogger(PrivacyPluginServiceImpl.class);

@ -14,6 +14,7 @@
*/ */
package org.hyperledger.besu.services; package org.hyperledger.besu.services;
import org.hyperledger.besu.datatypes.AccountOverrideMap;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Transaction; import org.hyperledger.besu.datatypes.Transaction;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
@ -62,6 +63,17 @@ public class TransactionSimulationServiceImpl implements TransactionSimulationSe
final Hash blockHash, final Hash blockHash,
final OperationTracer operationTracer, final OperationTracer operationTracer,
final boolean isAllowExceedingBalance) { 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); final CallParameter callParameter = CallParameter.fromTransaction(transaction);
@ -79,6 +91,7 @@ public class TransactionSimulationServiceImpl implements TransactionSimulationSe
return transactionSimulator return transactionSimulator
.process( .process(
callParameter, callParameter,
maybeAccountOverrides,
isAllowExceedingBalance isAllowExceedingBalance
? SIMULATOR_ALLOWING_EXCEEDING_BALANCE ? SIMULATOR_ALLOWING_EXCEEDING_BALANCE
: TransactionValidationParams.transactionSimulator(), : TransactionValidationParams.transactionSimulator(),

@ -182,19 +182,19 @@ APP_ARGS=`save "\$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules # 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" 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 if [ "\$darwin" = "false" -a "\$msys" = "false" ]; then
# check if jemalloc is available if [ "\$BESU_USING_JEMALLOC" != "FALSE" -a "\$BESU_USING_JEMALLOC" != "false" ]; then
TEST_JEMALLOC=\$(LD_PRELOAD=libjemalloc.so sh -c true 2>&1) # 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 # if jemalloc is available the output is empty, otherwise the output has an error line
export LD_PRELOAD=libjemalloc.so if [ -z "\$TEST_JEMALLOC" ]; then
export BESU_USING_JEMALLOC=true export LD_PRELOAD=libjemalloc.so
else else
# jemalloc not available, as fallback limit malloc to 2 arenas # jemalloc not available, as fallback limit malloc to 2 arenas
export MALLOC_ARENA_MAX=2 export MALLOC_ARENA_MAX=2
fi fi
fi
fi fi
exec "\$JAVACMD" "\$@" 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.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@ -150,7 +150,7 @@ class FlexGroupPrivacyTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider()) .storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE) .networkId(BigInteger.ONE)
.miningParameters(MiningParameters.newDefault()) .miningParameters(MiningConfiguration.newDefault())
.dataStorageConfiguration(dataStorageConfiguration) .dataStorageConfiguration(dataStorageConfiguration)
.nodeKey(NodeKeyUtils.generate()) .nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem()) .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.chain.GenesisState;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; 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.ForkId;
import org.hyperledger.besu.ethereum.forkid.ForkIdManager; import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@ -174,7 +174,7 @@ public class ForkIdsNetworkConfigTest {
(DefaultProtocolSchedule) (DefaultProtocolSchedule)
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
configOptions, configOptions,
MiningParameters.MINING_DISABLED, MiningConfiguration.MINING_DISABLED,
new BadBlockManager(), new BadBlockManager(),
false, false,
new NoOpMetricsSystem())); new NoOpMetricsSystem()));
@ -184,7 +184,7 @@ public class ForkIdsNetworkConfigTest {
MergeProtocolSchedule.create( MergeProtocolSchedule.create(
configOptions, configOptions,
false, false,
MiningParameters.MINING_DISABLED, MiningConfiguration.MINING_DISABLED,
new BadBlockManager(), new BadBlockManager(),
false, false,
new NoOpMetricsSystem())); 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.Difficulty;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.InMemoryPrivacyStorageProvider; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
@ -547,7 +547,7 @@ public class PrivacyReorgTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider()) .storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE) .networkId(BigInteger.ONE)
.miningParameters(MiningParameters.newDefault()) .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate()) .nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem()) .metricsSystem(new NoOpMetricsSystem())
.dataDirectory(dataDir) .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.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@ -125,7 +125,7 @@ class PrivacyTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider()) .storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE) .networkId(BigInteger.ONE)
.miningParameters(MiningParameters.newDefault()) .miningParameters(MiningConfiguration.newDefault())
.dataStorageConfiguration(dataStorageConfiguration) .dataStorageConfiguration(dataStorageConfiguration)
.nodeKey(NodeKeyUtils.generate()) .nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem()) .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.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@ -128,7 +128,7 @@ public final class RunnerBuilderTest {
when(besuController.getProtocolContext()).thenReturn(protocolContext); when(besuController.getProtocolContext()).thenReturn(protocolContext);
when(besuController.getProtocolSchedule()).thenReturn(protocolSchedule); when(besuController.getProtocolSchedule()).thenReturn(protocolSchedule);
when(besuController.getNodeKey()).thenReturn(nodeKey); 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.getPrivacyParameters()).thenReturn(mock(PrivacyParameters.class));
when(besuController.getTransactionPool()) when(besuController.getTransactionPool())
.thenReturn(mock(TransactionPool.class, RETURNS_DEEP_STUBS)); .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.BlockImporter;
import org.hyperledger.besu.ethereum.core.BlockSyncTestUtils; import org.hyperledger.besu.ethereum.core.BlockSyncTestUtils;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode; 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 // set merge flag to false, otherwise this test can fail if a merge test runs first
MergeConfiguration.setMergeEnabled(false); 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 @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 // set merge flag to false, otherwise this test can fail if a merge test runs first
MergeConfiguration.setMergeEnabled(false); 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 { throws Exception {
final Path dataDirAhead = Files.createTempDirectory(temp, "db-ahead"); final Path dataDirAhead = Files.createTempDirectory(temp, "db-ahead");
final Path dbAhead = dataDirAhead.resolve("database"); final Path dbAhead = dataDirAhead.resolve("database");
@ -172,9 +191,12 @@ public final class RunnerTest {
final NodeKey aheadDbNodeKey = NodeKeyUtils.createFrom(KeyPairUtil.loadKeyPair(dataDirAhead)); final NodeKey aheadDbNodeKey = NodeKeyUtils.createFrom(KeyPairUtil.loadKeyPair(dataDirAhead));
final NodeKey behindDbNodeKey = NodeKeyUtils.generate(); final NodeKey behindDbNodeKey = NodeKeyUtils.generate();
final SynchronizerConfiguration syncConfigAhead = final SynchronizerConfiguration syncConfigAhead =
SynchronizerConfiguration.builder().syncMode(SyncMode.FULL).build(); SynchronizerConfiguration.builder()
.syncMode(SyncMode.FULL)
.isPeerTaskSystemEnabled(isPeerTaskSystemEnabled)
.build();
final ObservableMetricsSystem noOpMetricsSystem = new NoOpMetricsSystem(); final ObservableMetricsSystem noOpMetricsSystem = new NoOpMetricsSystem();
final var miningParameters = MiningParameters.newDefault(); final var miningParameters = MiningConfiguration.newDefault();
final var dataStorageConfiguration = DataStorageConfiguration.DEFAULT_FOREST_CONFIG; final var dataStorageConfiguration = DataStorageConfiguration.DEFAULT_FOREST_CONFIG;
// Setup Runner with blocks // Setup Runner with blocks
final BesuController controllerAhead = final BesuController controllerAhead =
@ -393,11 +415,11 @@ public final class RunnerTest {
final Path dataDir, final Path dataDir,
final Path dbDir, final Path dbDir,
final DataStorageConfiguration dataStorageConfiguration, final DataStorageConfiguration dataStorageConfiguration,
final MiningParameters miningParameters) { final MiningConfiguration miningConfiguration) {
final var besuConfiguration = new BesuConfigurationImpl(); final var besuConfiguration = new BesuConfigurationImpl();
besuConfiguration besuConfiguration
.init(dataDir, dbDir, dataStorageConfiguration) .init(dataDir, dbDir, dataStorageConfiguration)
.withMiningParameters(miningParameters); .withMiningParameters(miningConfiguration);
return new KeyValueStorageProviderBuilder() return new KeyValueStorageProviderBuilder()
.withStorageFactory( .withStorageFactory(
new RocksDBKeyValueStorageFactory( new RocksDBKeyValueStorageFactory(
@ -466,14 +488,14 @@ public final class RunnerTest {
final NodeKey nodeKey, final NodeKey nodeKey,
final StorageProvider storageProvider, final StorageProvider storageProvider,
final ObservableMetricsSystem metricsSystem, final ObservableMetricsSystem metricsSystem,
final MiningParameters miningParameters) { final MiningConfiguration miningConfiguration) {
return new MainnetBesuControllerBuilder() return new MainnetBesuControllerBuilder()
.genesisConfigFile(genesisConfig) .genesisConfigFile(genesisConfig)
.synchronizerConfiguration(syncConfig) .synchronizerConfiguration(syncConfig)
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.dataDirectory(dataDir) .dataDirectory(dataDir)
.networkId(NETWORK_ID) .networkId(NETWORK_ID)
.miningParameters(miningParameters) .miningParameters(miningConfiguration)
.nodeKey(nodeKey) .nodeKey(nodeKey)
.storageProvider(storageProvider) .storageProvider(storageProvider)
.metricsSystem(metricsSystem) .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.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@ -94,7 +94,7 @@ public final class RlpBlockExporterTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider()) .storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE) .networkId(BigInteger.ONE)
.miningParameters(MiningParameters.newDefault()) .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate()) .nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem()) .metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT) .privacyParameters(PrivacyParameters.DEFAULT)

@ -17,9 +17,10 @@ package org.hyperledger.besu.chainimport;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; 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.BesuComponent;
import org.hyperledger.besu.components.BesuPluginContextModule;
import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.JsonUtil; import org.hyperledger.besu.config.JsonUtil;
import org.hyperledger.besu.controller.BesuController; 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.Block;
import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Transaction; 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.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; 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.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; 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.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.MetricsSystemModule;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.testutil.TestClock; import org.hyperledger.besu.testutil.TestClock;
@ -52,9 +57,13 @@ import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.inject.Singleton;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import dagger.Component;
import dagger.Module;
import dagger.Provides;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -449,7 +458,7 @@ public abstract class JsonBlockImporterTest {
.storageProvider(new InMemoryKeyValueStorageProvider()) .storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.valueOf(10)) .networkId(BigInteger.valueOf(10))
.miningParameters( .miningParameters(
ImmutableMiningParameters.builder() ImmutableMiningConfiguration.builder()
.mutableInitValues( .mutableInitValues(
MutableInitValues.builder() MutableInitValues.builder()
.isMiningEnabled(true) .isMiningEnabled(true)
@ -465,7 +474,28 @@ public abstract class JsonBlockImporterTest {
.gasLimitCalculator(GasLimitCalculator.constant()) .gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT) .evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create()) .networkConfiguration(NetworkingConfiguration.create())
.besuComponent(mock(BesuComponent.class)) .besuComponent(DaggerJsonBlockImporterTest_JsonBlockImportComponent.builder().build())
.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.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.ethereum.GasLimitCalculator; import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@ -69,7 +69,7 @@ public final class RlpBlockImporterTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider()) .storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE) .networkId(BigInteger.ONE)
.miningParameters(MiningParameters.newDefault()) .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate()) .nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem()) .metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT) .privacyParameters(PrivacyParameters.DEFAULT)
@ -103,7 +103,7 @@ public final class RlpBlockImporterTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider()) .storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE) .networkId(BigInteger.ONE)
.miningParameters(MiningParameters.newDefault()) .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate()) .nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem()) .metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT) .privacyParameters(PrivacyParameters.DEFAULT)
@ -134,7 +134,7 @@ public final class RlpBlockImporterTest {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider()) .storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE) .networkId(BigInteger.ONE)
.miningParameters(MiningParameters.newDefault()) .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate()) .nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem()) .metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT) .privacyParameters(PrivacyParameters.DEFAULT)

@ -37,9 +37,11 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.contains; import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNotNull; import static org.mockito.ArgumentMatchers.isNotNull;
import static org.mockito.Mockito.argThat;
import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import org.hyperledger.besu.BesuInfo; import org.hyperledger.besu.BesuInfo;
import org.hyperledger.besu.cli.config.EthNetworkConfig; 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.handlers.TimeoutOptions;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; 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.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; 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.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.api.io.TempDir;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine; import picocli.CommandLine;
@ -277,8 +278,8 @@ public class BesuCommandTest extends CommandTestAbstract {
verify(mockRunnerBuilder).build(); verify(mockRunnerBuilder).build();
verify(mockControllerBuilderFactory).fromEthNetworkConfig(ethNetworkArg.capture(), any()); verify(mockControllerBuilderFactory).fromEthNetworkConfig(ethNetworkArg.capture(), any());
final ArgumentCaptor<MiningParameters> miningArg = final ArgumentCaptor<MiningConfiguration> miningArg =
ArgumentCaptor.forClass(MiningParameters.class); ArgumentCaptor.forClass(MiningConfiguration.class);
verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture()); verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture());
verify(mockControllerBuilder).dataDirectory(isNotNull()); verify(mockControllerBuilder).dataDirectory(isNotNull());
verify(mockControllerBuilder).miningParameters(miningArg.capture()); verify(mockControllerBuilder).miningParameters(miningArg.capture());
@ -566,7 +567,7 @@ public class BesuCommandTest extends CommandTestAbstract {
parseCommand("--genesis-file", genesisFile.toString(), "--network", "mainnet"); parseCommand("--genesis-file", genesisFile.toString(), "--network", "mainnet");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
@ -578,7 +579,7 @@ public class BesuCommandTest extends CommandTestAbstract {
final String nonExistentGenesis = "non-existent-genesis.json"; final String nonExistentGenesis = "non-existent-genesis.json";
parseCommand("--genesis-file", nonExistentGenesis); parseCommand("--genesis-file", nonExistentGenesis);
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).startsWith("Unable to load genesis file"); assertThat(commandErrorOutput.toString(UTF_8)).startsWith("Unable to load genesis file");
@ -1177,7 +1178,7 @@ public class BesuCommandTest extends CommandTestAbstract {
parseCommand( parseCommand(
"--remote-connections-limit-enabled", "--remote-connections-max-percentage", "invalid"); "--remote-connections-limit-enabled", "--remote-connections-max-percentage", "invalid");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
.contains( .contains(
@ -1190,7 +1191,7 @@ public class BesuCommandTest extends CommandTestAbstract {
parseCommand( parseCommand(
"--remote-connections-limit-enabled", "--remote-connections-max-percentage", "150"); "--remote-connections-limit-enabled", "--remote-connections-max-percentage", "150");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
.contains( .contains(
@ -1225,7 +1226,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void syncMode_invalid() { public void syncMode_invalid() {
parseCommand("--sync-mode", "bogus"); parseCommand("--sync-mode", "bogus");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
@ -1275,7 +1276,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void helpShouldDisplayFastSyncOptions() { public void helpShouldDisplayFastSyncOptions() {
parseCommand("--help"); parseCommand("--help");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).contains("--fast-sync-min-peers"); assertThat(commandOutput.toString(UTF_8)).contains("--fast-sync-min-peers");
// whitelist is now a hidden option // whitelist is now a hidden option
@ -1335,7 +1336,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void parsesInvalidFastSyncMinPeersOptionWrongFormatShouldFail() { public void parsesInvalidFastSyncMinPeersOptionWrongFormatShouldFail() {
parseCommand("--sync-mode", "FAST", "--fast-sync-min-peers", "ten"); parseCommand("--sync-mode", "FAST", "--fast-sync-min-peers", "ten");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
.contains("Invalid value for option '--fast-sync-min-peers': 'ten' is not an int"); .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() { public void netRestrictInvalidShouldFail() {
final String subnet = "127.0.0.1/abc"; final String subnet = "127.0.0.1/abc";
parseCommand("--net-restrict", subnet); parseCommand("--net-restrict", subnet);
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
.contains("Invalid value for option '--net-restrict'"); .contains("Invalid value for option '--net-restrict'");
} }
@ -1382,7 +1383,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void ethStatsContactOptionCannotBeUsedWithoutEthStatsServerProvided() { public void ethStatsContactOptionCannotBeUsedWithoutEthStatsServerProvided() {
parseCommand("--ethstats-contact", "besu-updated"); parseCommand("--ethstats-contact", "besu-updated");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
.contains( .contains(
@ -1435,7 +1436,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void parsesInvalidWhenFullSyncAndBonsaiLimitTrieLogsExplicitlyTrue() { public void parsesInvalidWhenFullSyncAndBonsaiLimitTrieLogsExplicitlyTrue() {
parseCommand("--sync-mode=FULL", "--bonsai-limit-trie-logs-enabled=true"); parseCommand("--sync-mode=FULL", "--bonsai-limit-trie-logs-enabled=true");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
.contains( .contains(
@ -1467,7 +1468,7 @@ public class BesuCommandTest extends CommandTestAbstract {
parseCommand("--data-storage-format", "BONSAI", "--bonsai-maximum-back-layers-to-load", "ten"); parseCommand("--data-storage-format", "BONSAI", "--bonsai-maximum-back-layers-to-load", "ten");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
.contains( .contains(
@ -1501,7 +1502,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void dnsUpdateEnabledOptionCannotBeUsedWithoutDnsEnabled() { public void dnsUpdateEnabledOptionCannotBeUsedWithoutDnsEnabled() {
parseCommand("--Xdns-update-enabled", "true"); parseCommand("--Xdns-update-enabled", "true");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
.contains( .contains(
@ -1720,6 +1721,17 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); 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 @Test
public void metricsPushEnabledPropertyMustBeUsed() { public void metricsPushEnabledPropertyMustBeUsed() {
parseCommand("--metrics-push-enabled"); parseCommand("--metrics-push-enabled");
@ -1799,7 +1811,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void metricsAndMetricsPushMustNotBeUsedTogether() { public void metricsAndMetricsPushMustNotBeUsedTogether() {
parseCommand("--metrics-enabled", "--metrics-push-enabled"); parseCommand("--metrics-enabled", "--metrics-push-enabled");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty(); assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)) assertThat(commandErrorOutput.toString(UTF_8))
@ -2023,7 +2035,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void fullCLIOptionsShown() { public void fullCLIOptionsShown() {
parseCommand("--help"); parseCommand("--help");
Mockito.verifyNoInteractions(mockRunnerBuilder); verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).contains("--config-file"); assertThat(commandOutput.toString(UTF_8)).contains("--config-file");
assertThat(commandOutput.toString(UTF_8)).contains("--data-path"); assertThat(commandOutput.toString(UTF_8)).contains("--data-path");
@ -2401,13 +2413,16 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test @Test
public void logsWarningWhenFailToLoadJemalloc() { public void logsWarningWhenFailToLoadJemalloc() {
assumeTrue(PlatformDetector.getOSType().equals("linux")); assumeTrue(PlatformDetector.getOSType().equals("linux"));
setEnvironmentVariable("BESU_USING_JEMALLOC", "true"); setEnvironmentVariable("BESU_USING_JEMALLOC", "false");
parseCommand(); parseCommand();
verify(mockLogger) verify(mockLogger)
.warn( .warn(
eq( argThat(
"BESU_USING_JEMALLOC is present but we failed to load jemalloc library to get the version"), arg ->
any(Throwable.class)); 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 @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.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; 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.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
@ -200,7 +200,7 @@ public class CascadingDefaultProviderTest extends CommandTestAbstract {
setEnvironmentVariable("BESU_MINER_COINBASE", expectedCoinbase); setEnvironmentVariable("BESU_MINER_COINBASE", expectedCoinbase);
parseCommand("--config-file", configFile); parseCommand("--config-file", configFile);
final var captMiningParameters = ArgumentCaptor.forClass(MiningParameters.class); final var captMiningParameters = ArgumentCaptor.forClass(MiningConfiguration.class);
verify(mockControllerBuilder).miningParameters(captMiningParameters.capture()); verify(mockControllerBuilder).miningParameters(captMiningParameters.capture());
assertThat(captMiningParameters.getValue().getCoinbase()) assertThat(captMiningParameters.getValue().getCoinbase())
@ -219,7 +219,7 @@ public class CascadingDefaultProviderTest extends CommandTestAbstract {
setEnvironmentVariable("BESU_MINER_COINBASE", "0x0000000000000000000000000000000000000004"); setEnvironmentVariable("BESU_MINER_COINBASE", "0x0000000000000000000000000000000000000004");
parseCommand("--config-file", configFile, "--miner-coinbase", expectedCoinbase); 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()); verify(mockControllerBuilder).miningParameters(captMiningParameters.capture());
assertThat(captMiningParameters.getValue().getCoinbase()) 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.JsonBlockImporter;
import org.hyperledger.besu.chainimport.RlpBlockImporter; import org.hyperledger.besu.chainimport.RlpBlockImporter;
import org.hyperledger.besu.cli.config.EthNetworkConfig; 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.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.TransactionPoolOptions;
import org.hyperledger.besu.cli.options.stable.EthstatsOptions;
import org.hyperledger.besu.cli.options.storage.DataStorageOptions; 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.components.BesuComponent;
import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.controller.BesuController; 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.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoInteractions;
import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

@ -12,7 +12,7 @@
* *
* SPDX-License-Identifier: Apache-2.0 * 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.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;

@ -14,15 +14,32 @@
*/ */
package org.hyperledger.besu.cli.options; 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 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.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class MetricsOptionsTest public class MetricsOptionsTest
extends AbstractCLIOptionsTest<MetricsConfiguration.Builder, MetricsOptions> { extends AbstractCLIOptionsTest<MetricsConfiguration.Builder, MetricsOptions> {
private MetricCategoryRegistryImpl categoryRegistry;
@BeforeEach
public void setUp() {
categoryRegistry = new MetricCategoryRegistryImpl();
categoryRegistry.addCategories(BesuMetricCategory.class);
categoryRegistry.addCategories(StandardMetricCategory.class);
}
@Override @Override
protected MetricsConfiguration.Builder createDefaultDomainObject() { protected MetricsConfiguration.Builder createDefaultDomainObject() {
@ -39,11 +56,36 @@ public class MetricsOptionsTest
@Override @Override
protected MetricsOptions optionsFromDomainObject( protected MetricsOptions optionsFromDomainObject(
final MetricsConfiguration.Builder domainObject) { final MetricsConfiguration.Builder domainObject) {
return MetricsOptions.fromConfiguration(domainObject.build()); final var options = MetricsOptions.fromConfiguration(domainObject.build());
options.setMetricCategoryRegistry(categoryRegistry);
return options;
} }
@Override @Override
protected MetricsOptions getOptionsFromBesuCommand(final TestBesuCommand besuCommand) { protected MetricsOptions getOptionsFromBesuCommand(final TestBesuCommand besuCommand) {
return besuCommand.getMetricsOptions(); 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; package org.hyperledger.besu.cli.options;
import static org.assertj.core.api.Assertions.assertThat; 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.MiningConfiguration.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.MiningConfiguration.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.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.GasLimitCalculator; import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.Unstable; import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.Unstable;
import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber; import org.hyperledger.besu.util.number.PositiveNumber;
import java.io.IOException; import java.io.IOException;
@ -42,7 +42,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningParameters, MiningOptions> { public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningConfiguration, MiningOptions> {
@Test @Test
public void besuDoesNotStartInMiningModeIfCoinbaseNotSet() { public void besuDoesNotStartInMiningModeIfCoinbaseNotSet() {
@ -390,13 +390,13 @@ public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningParameters,
} }
@Override @Override
protected MiningParameters createDefaultDomainObject() { protected MiningConfiguration createDefaultDomainObject() {
return MiningParameters.newDefault(); return MiningConfiguration.newDefault();
} }
@Override @Override
protected MiningParameters createCustomizedDomainObject() { protected MiningConfiguration createCustomizedDomainObject() {
return ImmutableMiningParameters.builder() return ImmutableMiningConfiguration.builder()
.mutableInitValues( .mutableInitValues(
MutableInitValues.builder() MutableInitValues.builder()
.isMiningEnabled(true) .isMiningEnabled(true)
@ -410,7 +410,7 @@ public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningParameters,
} }
@Override @Override
protected MiningOptions optionsFromDomainObject(final MiningParameters domainObject) { protected MiningOptions optionsFromDomainObject(final MiningConfiguration domainObject) {
return MiningOptions.fromConfig(domainObject); return MiningOptions.fromConfig(domainObject);
} }
@ -424,11 +424,11 @@ public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningParameters,
return new String[] {"transactionSelectionService"}; return new String[] {"transactionSelectionService"};
} }
private MiningParameters runtimeConfiguration( private MiningConfiguration runtimeConfiguration(
final TestBesuCommand besuCommand, final MiningParameters miningParameters) { final TestBesuCommand besuCommand, final MiningConfiguration miningConfiguration) {
if (besuCommand.getGenesisConfigOptions().isPoa()) { 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 java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat; 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 org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import java.util.Arrays; import java.util.Arrays;

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

Loading…
Cancel
Save