diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md
new file mode 100644
index 00000000000..7b88a843790
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug-report.md
@@ -0,0 +1,50 @@
+---
+name: Bug Report
+about: necessary information to help us resolve the issue
+title: ''
+labels: 'bug'
+assignees: ''
+
+---
+
+
+
+
+
+
+
+
+
+### Steps to Reproduce
+1. [Step 1]
+2. [Step 2]
+3. [Step ...]
+
+**Expected behavior:** [What you expect to happen]
+
+**Actual behavior:** [What actually happens]
+
+**Frequency:** [What percentage of the time does it occur?]
+
+### Logs
+Please post relevant logs from Besu (and the consensus client, if running proof of stake) from before and after the issue.
+
+### Versions (Add all that apply)
+* Software version: [`besu --version`]
+* Java version: [`java -version`]
+* OS Name & Version: [`cat /etc/*release`]
+* Kernel Version: [`uname -a`]
+* Virtual Machine software & version: [`vmware -v`]
+* Docker Version: [`docker version`]
+* Cloud VM, type, size: [Amazon Web Services I3-large]
+* Consensus Client & Version if using Proof of Stake: [e.g. Teku, Lighthouse, Prysm, Nimbus, Lodestar]
+
+### Smart contract information (If you're reporting an issue arising from deploying or calling a smart contract, please supply related information)
+* Solidity version [`solc --version`]
+* Repo with minimal set of deployable/reproducible contract code - please provide a link
+* Please include specifics on how you are deploying/calling the contract
+* Have you reproduced the issue on other eth clients
+
+### Additional Information (Add any of the following or anything else that may be relevant)
+* Besu setup info - genesis file, config options
+* System info - memory, CPU
diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md
new file mode 100644
index 00000000000..73ebe5f060e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature-request.md
@@ -0,0 +1,45 @@
+---
+name: Feature Request
+about: suggesting new or altered functionality
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+
+
+
+
+
+
+### Description
+As an [Actor], I want [feature] so that [why].
+
+### Acceptance Criteria
+* [Criteria 1]
+* [Criteria 2]
+* [Criteria 3...]
+
+### Logs (if a change in behavior)
+Please post relevant logs from Besu (and the consensus client, if running proof of stake) illustrating behavior to be altered
+
+### Versions (Add all that apply)
+* Software version: [`besu --version`]
+* Java version: [`java -version`]
+* OS Name & Version: [`cat /etc/*release`]
+* Kernel Version: [`uname -a`]
+* Virtual Machine software & version: [`vmware -v`]
+* Docker Version: [`docker version`]
+* Cloud VM, type, size: [Amazon Web Services I3-large]
+* Consensus Client & Version if using Proof of Stake: [e.g. Teku, Lighthouse, Prysm, Nimbus, Lodestar]
+
+### Smart contract information (If you're reporting an issue arising from deploying or calling a smart contract, please supply related information)
+* Solidity version [`solc --version`]
+* Repo with minimal set of deployable/reproducible contract code - please provide a link
+* Please include specifics on how you are deploying/calling the contract
+* Have you reproduced the issue on other eth clients
+
+### Additional Information (Add any of the following or anything else that may be relevant)
+* Besu setup info - genesis file, config options
+* System info - memory, CPU
diff --git a/.github/issue_template.md b/.github/issue_template.md
index 54acf4c1968..7fe82b4f078 100644
--- a/.github/issue_template.md
+++ b/.github/issue_template.md
@@ -2,30 +2,10 @@
-
-
-
+
-### Description
-As an [Actor], I want [feature] so that [why].
-### Acceptance Criteria
-* [Criteria 1]
-
-### Steps to Reproduce (Bug)
-1. [Step 1]
-2. [Step 2]
-3. [Step ...]
-
-**Expected behavior:** [What you expect to happen]
-
-**Actual behavior:** [What actually happens]
-
-**Frequency:** [What percentage of the time does it occur?]
-
-### Logs (if a bug)
-Please post relevant logs from Besu (and the consensus client, if running proof of stake) from before and after the issue.
### Versions (Add all that apply)
* Software version: [`besu --version`]
diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml
new file mode 100644
index 00000000000..fe45d91b49f
--- /dev/null
+++ b/.github/workflows/stale-issues.yml
@@ -0,0 +1,27 @@
+name: Close inactive issues
+on:
+ schedule:
+ - cron: "30 1 * * *"
+
+jobs:
+ close-issues:
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ pull-requests: write
+ contents: write
+ steps:
+ - uses: actions/stale@v5
+ with:
+ days-before-issue-stale: 180
+ days-before-issue-close: 14
+ stale-issue-label: "stale"
+ stale-issue-message: "This issue is stale because it has been open for 6 months with no activity."
+ close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
+ days-before-pr-stale: 30
+ days-before-pr-close: 14
+ stale-pr-message: "This pr is stale because it has been open for 30 days with no activity."
+ close-pr-message: "This pr was closed because it has been inactive for 14 days since being marked as stale."
+ remove-issue-stale-when-updated: true
+ remove-pr-stale-when-updated: true
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f862ed866fe..a0a53280feb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,15 +4,21 @@
- Added isLabelsObserved to LabelledGauge in plugin-api. Default implementation returns false.
### Breaking Changes
+- Removed Retesteth rpc service and commands [#7833](https://github.com/hyperledger/besu/pull/7783)
### Upcoming Breaking Changes
### Additions and Improvements
- Fine tune already seen txs tracker when a tx is removed from the pool [#7755](https://github.com/hyperledger/besu/pull/7755)
+- Support for enabling and configuring TLS/mTLS in WebSocket service. [#7854](https://github.com/hyperledger/besu/pull/7854)
- Create and publish Besu BOM (Bill of Materials) [#7615](https://github.com/hyperledger/besu/pull/7615)
- Update Java dependencies [#7786](https://github.com/hyperledger/besu/pull/7786)
+- Add a method to get all the transaction in the pool, to the `TransactionPoolService`, to easily access the transaction pool content from plugins [#7813](https://github.com/hyperledger/besu/pull/7813)
+- Add a method to check if a metric category is enabled to the plugin API [#7832](https://github.com/hyperledger/besu/pull/7832)
### 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
@@ -98,6 +104,7 @@ This release version has been deprecated release due to CI bug
- Remove long-deprecated `perm*whitelist*` methods [#7401](https://github.com/hyperledger/besu/pull/7401)
### Additions and Improvements
+- Allow optional loading of `jemalloc` (if installed) by setting the environment variable `BESU_USING_JEMALLOC` to true/false. It that env is not set at all it will behave as if it is set to `true`
- Expose set finalized/safe block in plugin api BlockchainService. These method can be used by plugins to set finalized/safe block for a PoA network (such as QBFT, IBFT and Clique).[#7382](https://github.com/hyperledger/besu/pull/7382)
- In process RPC service [#7395](https://github.com/hyperledger/besu/pull/7395)
- Added support for tracing private transactions using `priv_traceTransaction` API. [#6161](https://github.com/hyperledger/besu/pull/6161)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c2d6c57d25a..c13ea678524 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,7 +8,7 @@ Welcome to the Besu repository! The following links are a set of guidelines for
Having the following accounts is necessary for contributing code/issues to Besu.
* If you want to contribute code, you can make a [github account here](https://github.com).
* If you want to raise an issue, do so [in the issues tab](https://github.com/hyperledger/besu/issues).
-* To ask questions or chat with us, join our [Discord](https://discord.gg/hyperledger)
+* To ask questions or chat with us, join our [Discord](https://discord.com/invite/hyperledger)
* To edit pages in our wiki, you'll need a [Linux Foundation (LF) account].
### Useful contributing links
diff --git a/DCO.md b/DCO.md
index 4bf56cb80ae..48227cadcdf 100644
--- a/DCO.md
+++ b/DCO.md
@@ -5,4 +5,4 @@ As per section 13.a of the [Hyperledger Charter](https://www.hyperledger.org/abo
The sign off needs to be using your legal name, not a pseudonym. Git has a built-in mechanism to allow this with the `-s` or `--signoff` argument to `git commit` command, providing your `user.name` and `user.email` have been setup correctly.
-If you have any questions, you can reach us on Besu chat; first, [join the Discord server](https://discord.gg/hyperledger/) then [join the Besu channel](https://discord.com/channels/905194001349627914/938504958909747250).
+If you have any questions, you can reach us on Besu chat; first, [join the Discord server](https://discord.com/invite/hyperledger) then [join the Besu channel](https://discord.com/channels/905194001349627914/938504958909747250).
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
index ae6720632a4..6c17df88239 100644
--- a/MAINTAINERS.md
+++ b/MAINTAINERS.md
@@ -22,6 +22,7 @@
| Luis Pinto | lu-pinto | lu-pinto |
| Lucas Saldanha | lucassaldanha | lucassaldanha |
| Sally MacFarlane | macfarla | macfarla |
+| Matilda Clerke | Matilda-Clerke | MatildaClerke |
| Karim Taam | matkt | matkt |
| Matthew Whitehead| matthew1001 | matthew.whitehead |
| Meredith Baxter | mbaxter | mbaxter |
@@ -84,7 +85,7 @@ The following steps must occur for a contributor to be "upgraded" as a maintaine
- The proposed maintainer accepts the nomination and expresses a willingness
to be a long-term (more than 6 month) committer by adding a comment in the proposal PR.
- The PR will be communicated in all appropriate communication channels
- including at least [besu-contributors channel on Discord](https://discord.gg/hyperledger),
+ including at least [besu-contributors channel on Discord](https://discord.com/invite/hyperledger),
the [mailing list](https://lists.hyperledger.org/g/besu)
and any maintainer/community call.
- Approval by at least 3 current maintainers within two weeks of the proposal or
diff --git a/README.md b/README.md
index 00aad005ac7..8f5f51a7264 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
[![Documentation](https://img.shields.io/github/actions/workflow/status/hyperledger/besu-docs/publish-main-docs.yml?branch=main&label=docs)](https://github.com/hyperledger/besu-docs/actions/workflows/publish-main-docs.yml)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3174/badge)](https://bestpractices.coreinfrastructure.org/projects/3174)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/hyperledger/besu/blob/main/LICENSE)
- [![Discord](https://img.shields.io/discord/905194001349627914?logo=Hyperledger&style=plastic)](https://discord.gg/hyperledger)
+ [![Discord](https://img.shields.io/discord/905194001349627914?logo=Hyperledger&style=plastic)](https://discord.com/invite/hyperledger)
[![Twitter Follow](https://img.shields.io/twitter/follow/HyperledgerBesu)](https://twitter.com/HyperledgerBesu)
[Download](https://github.com/hyperledger/besu/releases)
@@ -14,15 +14,15 @@ Besu is an Apache 2.0 licensed, MainNet compatible, Ethereum client written in J
* [Besu User Documentation]
* [Besu Issues]
-* [Besu Wiki](https://wiki.hyperledger.org/display/BESU/Besu)
-* [How to Contribute to Besu](https://wiki.hyperledger.org/display/BESU/How+to+Contribute)
-* [Besu Roadmap & Planning](https://wiki.hyperledger.org/pages/viewpage.action?pageId=24781786)
+* [Besu Wiki](https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/)
+* [How to Contribute to Besu](https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/pages/22156850/How+to+Contribute)
+* [Besu Roadmap & Planning](https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/pages/22154278/Besu+Roadmap+Planning)
## Issues
Besu issues are tracked [in the github issues tab][Besu Issues].
-See our [guidelines](https://wiki.hyperledger.org/display/BESU/Issues) for more details on searching and creating issues.
+See our [guidelines](https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/pages/22154243/Issues) for more details on searching and creating issues.
If you have any questions, queries or comments, [Besu channel on Discord] is the place to find us.
@@ -34,20 +34,19 @@ To install the Besu binary, follow [these instructions](https://besu.hyperledger
## Besu Developers
* [Contributing Guidelines]
-* [Coding Conventions](https://wiki.hyperledger.org/display/BESU/Coding+Conventions)
-* [Command Line Interface (CLI) Style Guide](https://wiki.hyperledger.org/display/BESU/Besu+CLI+Style+Guide)
+* [Coding Conventions](https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/pages/22154259/Coding+Conventions)
+* [Command Line Interface (CLI) Style Guide](https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/pages/22154260/Besu+CLI+Style+Guide)
* [Besu User Documentation] for running and using Besu
### Development
Instructions for how to get started with developing on the Besu codebase. Please also read the
-[wiki](https://wiki.hyperledger.org/display/BESU/Pull+Requests) for more details on how to submit a pull request (PR).
+[wiki](https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/pages/22154251/Pull+Requests) for more details on how to submit a pull request (PR).
-* [Checking Out and Building](https://wiki.hyperledger.org/display/BESU/Building+from+source)
-* [Running Developer Builds](https://wiki.hyperledger.org/display/BESU/Building+from+source#running-developer-builds)
-* [Code Coverage](https://wiki.hyperledger.org/display/BESU/Code+coverage)
-* [Logging](https://wiki.hyperledger.org/display/BESU/Logging) or the [Documentation's Logging section](https://besu.hyperledger.org/public-networks/how-to/monitor/logging)
+* [Checking Out and Building](https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/pages/22154264/Building+from+source)
+* [Code Coverage](https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/pages/22154288/Code+coverage)
+* [Logging](https://lf-hyperledger.atlassian.net/wiki/spaces/BESU/pages/22154291/Logging) or the [Documentation's Logging section](https://besu.hyperledger.org/public-networks/how-to/monitor/logging)
## Release Notes
@@ -68,5 +67,5 @@ and YourKit YouMonitor.
[Besu Issues]: https://github.com/hyperledger/besu/issues
[Besu User Documentation]: https://besu.hyperledger.org
-[Besu channel on Discord]: https://discord.gg/hyperledger
+[Besu channel on Discord]: https://discord.com/invite/hyperledger
[Contributing Guidelines]: CONTRIBUTING.md
diff --git a/SUPPORT.md b/SUPPORT.md
index 9e4a7b7b42b..97715857cb4 100644
--- a/SUPPORT.md
+++ b/SUPPORT.md
@@ -20,5 +20,5 @@ Having Github, Discord, and Linux Foundation accounts is necessary for obtaining
[Besu User Documentation]: https://besu.hyperledger.org
-[Besu channel on Discord]: https://discord.gg/hyperledger
+[Besu channel on Discord]: https://discord.com/invite/hyperledger
[Contributing Guidelines]: CONTRIBUTING.md
diff --git a/acceptance-tests/dsl/build.gradle b/acceptance-tests/dsl/build.gradle
index aa5db9ce1e7..0b664c52556 100644
--- a/acceptance-tests/dsl/build.gradle
+++ b/acceptance-tests/dsl/build.gradle
@@ -45,6 +45,5 @@ dependencies {
implementation 'org.web3j:crypto'
implementation 'org.wiremock:wiremock'
- implementation 'org.testcontainers:testcontainers'
implementation 'org.junit.jupiter:junit-jupiter'
}
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java
index 5256e71ee30..72233adbb8b 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java
@@ -49,13 +49,15 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.lang.ProcessBuilder.Redirect;
import java.math.BigInteger;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import org.junit.After;
+import org.apache.logging.log4j.ThreadContext;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -125,7 +127,15 @@ protected AcceptanceTestBase() {
exitedSuccessfully = new ExitedWithCode(0);
}
- @After
+ @BeforeEach
+ public void setUp(final TestInfo testInfo) {
+ // log4j is configured to create a file per test
+ // build/acceptanceTestLogs/${ctx:class}.${ctx:test}.log
+ ThreadContext.put("class", this.getClass().getSimpleName());
+ ThreadContext.put("test", testInfo.getTestMethod().get().getName());
+ }
+
+ @AfterEach
public void tearDownAcceptanceTestBase() {
reportMemory();
cluster.close();
@@ -143,7 +153,9 @@ public void reportMemory() {
if (command != null) {
LOG.info("Memory usage at end of test:");
final ProcessBuilder processBuilder =
- new ProcessBuilder(command).redirectErrorStream(true).redirectInput(Redirect.INHERIT);
+ new ProcessBuilder(command)
+ .redirectErrorStream(true)
+ .redirectInput(ProcessBuilder.Redirect.INHERIT);
try {
final Process memInfoProcess = processBuilder.start();
outputProcessorExecutor.execute(() -> printOutput(memInfoProcess));
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java
deleted file mode 100644
index 4f3046c1abf..00000000000
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseJunit5.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright contributors to Hyperledger Besu.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package org.hyperledger.besu.tests.acceptance.dsl;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.hyperledger.besu.tests.acceptance.dsl.account.Accounts;
-import org.hyperledger.besu.tests.acceptance.dsl.blockchain.Blockchain;
-import org.hyperledger.besu.tests.acceptance.dsl.condition.admin.AdminConditions;
-import org.hyperledger.besu.tests.acceptance.dsl.condition.bft.BftConditions;
-import org.hyperledger.besu.tests.acceptance.dsl.condition.clique.CliqueConditions;
-import org.hyperledger.besu.tests.acceptance.dsl.condition.eth.EthConditions;
-import org.hyperledger.besu.tests.acceptance.dsl.condition.login.LoginConditions;
-import org.hyperledger.besu.tests.acceptance.dsl.condition.net.NetConditions;
-import org.hyperledger.besu.tests.acceptance.dsl.condition.perm.PermissioningConditions;
-import org.hyperledger.besu.tests.acceptance.dsl.condition.process.ExitedWithCode;
-import org.hyperledger.besu.tests.acceptance.dsl.condition.txpool.TxPoolConditions;
-import org.hyperledger.besu.tests.acceptance.dsl.condition.web3.Web3Conditions;
-import org.hyperledger.besu.tests.acceptance.dsl.contract.ContractVerifier;
-import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
-import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster;
-import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeFactory;
-import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.permissioning.PermissionedNodeBuilder;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.account.AccountTransactions;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.admin.AdminTransactions;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.bft.BftTransactions;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.clique.CliqueTransactions;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.contract.ContractTransactions;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.eth.EthTransactions;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.miner.MinerTransactions;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.net.NetTransactions;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.perm.PermissioningTransactions;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.txpool.TxPoolTransactions;
-import org.hyperledger.besu.tests.acceptance.dsl.transaction.web3.Web3Transactions;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.math.BigInteger;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.logging.log4j.ThreadContext;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInfo;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Superclass for acceptance tests. For now (transition to junit5 is ongoing) this class supports
- * junit5 format. Once the transition is complete, this class can be removed and recombined with
- * AcceptanceTestBase (original).
- */
-@ExtendWith(AcceptanceTestBaseTestWatcher.class)
-public class AcceptanceTestBaseJunit5 {
-
- private static final Logger LOG = LoggerFactory.getLogger(AcceptanceTestBaseJunit5.class);
-
- protected final Accounts accounts;
- protected final AccountTransactions accountTransactions;
- protected final AdminConditions admin;
- protected final AdminTransactions adminTransactions;
- protected final Blockchain blockchain;
- protected final CliqueConditions clique;
- protected final CliqueTransactions cliqueTransactions;
- protected final Cluster cluster;
- protected final ContractVerifier contractVerifier;
- protected final ContractTransactions contractTransactions;
- protected final EthConditions eth;
- protected final EthTransactions ethTransactions;
- protected final BftTransactions bftTransactions;
- protected final BftConditions bft;
- protected final LoginConditions login;
- protected final NetConditions net;
- protected final BesuNodeFactory besu;
- protected final PermissioningConditions perm;
- protected final PermissionedNodeBuilder permissionedNodeBuilder;
- protected final PermissioningTransactions permissioningTransactions;
- protected final MinerTransactions minerTransactions;
- protected final Web3Conditions web3;
- protected final TxPoolConditions txPoolConditions;
- protected final TxPoolTransactions txPoolTransactions;
- protected final ExitedWithCode exitedSuccessfully;
-
- private final ExecutorService outputProcessorExecutor = Executors.newCachedThreadPool();
-
- protected AcceptanceTestBaseJunit5() {
- ethTransactions = new EthTransactions();
- accounts = new Accounts(ethTransactions);
- adminTransactions = new AdminTransactions();
- cliqueTransactions = new CliqueTransactions();
- bftTransactions = new BftTransactions();
- accountTransactions = new AccountTransactions(accounts);
- permissioningTransactions = new PermissioningTransactions();
- contractTransactions = new ContractTransactions();
- minerTransactions = new MinerTransactions();
- blockchain = new Blockchain(ethTransactions);
- clique = new CliqueConditions(ethTransactions, cliqueTransactions);
- eth = new EthConditions(ethTransactions);
- bft = new BftConditions(bftTransactions);
- login = new LoginConditions();
- net = new NetConditions(new NetTransactions());
- cluster = new Cluster(net);
- perm = new PermissioningConditions(permissioningTransactions);
- admin = new AdminConditions(adminTransactions);
- web3 = new Web3Conditions(new Web3Transactions());
- besu = new BesuNodeFactory();
- txPoolTransactions = new TxPoolTransactions();
- txPoolConditions = new TxPoolConditions(txPoolTransactions);
- contractVerifier = new ContractVerifier(accounts.getPrimaryBenefactor());
- permissionedNodeBuilder = new PermissionedNodeBuilder();
- exitedSuccessfully = new ExitedWithCode(0);
- }
-
- @BeforeEach
- public void setUp(final TestInfo testInfo) {
- // log4j is configured to create a file per test
- // build/acceptanceTestLogs/${ctx:class}.${ctx:test}.log
- ThreadContext.put("class", this.getClass().getSimpleName());
- ThreadContext.put("test", testInfo.getTestMethod().get().getName());
- }
-
- @AfterEach
- public void tearDownAcceptanceTestBase() {
- reportMemory();
- cluster.close();
- }
-
- public void reportMemory() {
- String os = System.getProperty("os.name");
- String[] command = null;
- if (os.contains("Linux")) {
- command = new String[] {"/usr/bin/top", "-n", "1", "-o", "%MEM", "-b", "-c", "-w", "180"};
- }
- if (os.contains("Mac")) {
- command = new String[] {"/usr/bin/top", "-l", "1", "-o", "mem", "-n", "20"};
- }
- if (command != null) {
- LOG.info("Memory usage at end of test:");
- final ProcessBuilder processBuilder =
- new ProcessBuilder(command)
- .redirectErrorStream(true)
- .redirectInput(ProcessBuilder.Redirect.INHERIT);
- try {
- final Process memInfoProcess = processBuilder.start();
- outputProcessorExecutor.execute(() -> printOutput(memInfoProcess));
- memInfoProcess.waitFor();
- LOG.debug("Memory info process exited with code {}", memInfoProcess.exitValue());
- } catch (final Exception e) {
- LOG.warn("Error running memory information process", e);
- }
- } else {
- LOG.info("Don't know how to report memory for OS {}", os);
- }
- }
-
- private void printOutput(final Process process) {
- try (final BufferedReader in =
- new BufferedReader(new InputStreamReader(process.getInputStream(), UTF_8))) {
- String line = in.readLine();
- while (line != null) {
- LOG.info(line);
- line = in.readLine();
- }
- } catch (final IOException e) {
- LOG.warn("Failed to read output from memory information process: ", e);
- }
- }
-
- protected void waitForBlockHeight(final Node node, final long blockchainHeight) {
- WaitUtils.waitFor(
- 120,
- () ->
- assertThat(node.execute(ethTransactions.blockNumber()))
- .isGreaterThanOrEqualTo(BigInteger.valueOf(blockchainHeight)));
- }
-
- @Test
- void dryRunDetector() {
- assertThat(true)
- .withFailMessage("This test is here so gradle --dry-run executes this class")
- .isTrue();
- }
-}
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/BlockUtils.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/BlockUtils.java
index 3a4ca71002b..29f60dd74a6 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/BlockUtils.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/BlockUtils.java
@@ -58,6 +58,7 @@ public static BlockHeader createBlockHeader(
null,
null,
null,
+ null,
blockHeaderFunctions);
}
}
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
index 21ca45070bd..76e18812b09 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
@@ -27,7 +27,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
@@ -101,7 +101,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private final boolean revertReasonEnabled;
private final String name;
- private MiningParameters miningParameters;
+ private MiningConfiguration miningConfiguration;
private TransactionPoolConfiguration txPoolConfiguration;
private final List runCommand;
private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT;
@@ -139,7 +139,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
public BesuNode(
final String name,
final Optional dataPath,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final TransactionPoolConfiguration txPoolConfiguration,
final JsonRpcConfiguration jsonRpcConfiguration,
final Optional engineRpcConfiguration,
@@ -191,7 +191,7 @@ public BesuNode(
},
() -> this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory));
this.name = name;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
this.txPoolConfiguration = txPoolConfiguration;
this.jsonRpcConfiguration = jsonRpcConfiguration;
this.engineRpcConfiguration = engineRpcConfiguration;
@@ -678,12 +678,12 @@ public void setBootnodes(final List bootnodes) {
this.bootnodes.addAll(bootnodes);
}
- public MiningParameters getMiningParameters() {
- return miningParameters;
+ public MiningConfiguration getMiningParameters() {
+ return miningConfiguration;
}
- public void setMiningParameters(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public void setMiningParameters(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
}
public TransactionPoolConfiguration getTransactionPoolConfiguration() {
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
index 75307d95202..ee865a81425 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
@@ -17,9 +17,9 @@
import static com.google.common.base.Preconditions.checkState;
import static java.nio.charset.StandardCharsets.UTF_8;
+import org.hyperledger.besu.cli.options.NetworkingOptions;
import org.hyperledger.besu.cli.options.TransactionPoolOptions;
import org.hyperledger.besu.cli.options.storage.DataStorageOptions;
-import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration;
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
index 42c0df73c71..fc2a7d372ea 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
@@ -36,8 +36,8 @@
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;
import org.hyperledger.besu.ethereum.chain.Blockchain;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginInfo;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
@@ -57,6 +57,7 @@
import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl;
import org.hyperledger.besu.metrics.MetricsSystemModule;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
+import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.plugin.data.EnodeURL;
import org.hyperledger.besu.plugin.services.BesuConfiguration;
@@ -406,9 +407,18 @@ MetricCategoryRegistryImpl provideMetricCategoryRegistry() {
}
}
+ @Module
+ public static class ThreadBesuNodeRunnerModule {
+ @Provides
+ @Singleton
+ public ThreadBesuNodeRunner provideThreadBesuNodeRunner() {
+ return new ThreadBesuNodeRunner();
+ }
+ }
+
@Module
@SuppressWarnings("CloseableProvides")
- static class BesuControllerModule {
+ public static class BesuControllerModule {
@Provides
@Singleton
public SynchronizerConfiguration provideSynchronizationConfiguration() {
@@ -438,7 +448,7 @@ public BesuController provideBesuController(
final BesuControllerBuilder builder,
final MetricsSystem metricsSystem,
final KeyValueStorageProvider storageProvider,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
builder
.synchronizerConfiguration(synchronizerConfiguration)
@@ -451,7 +461,7 @@ public BesuController provideBesuController(
.evmConfiguration(EvmConfiguration.DEFAULT)
.maxPeers(25)
.maxRemotelyInitiatedPeers(15)
- .miningParameters(miningParameters)
+ .miningParameters(miningConfiguration)
.randomPeerPriority(false)
.besuComponent(null);
return builder.build();
@@ -484,6 +494,7 @@ public BesuPluginContextImpl providePluginContext(
final RpcEndpointServiceImpl rpcEndpointServiceImpl,
final BesuConfiguration commonPluginConfiguration,
final PermissioningServiceImpl permissioningService,
+ final MetricsConfiguration metricsConfiguration,
final MetricCategoryRegistryImpl metricCategoryRegistry,
final MetricsSystem metricsSystem,
final @Named("ExtraCLIOptions") List extraCLIOptions,
@@ -502,6 +513,7 @@ public BesuPluginContextImpl providePluginContext(
TransactionSimulationService.class, transactionSimulationServiceImpl);
besuPluginContext.addService(BlockchainService.class, blockchainServiceImpl);
besuPluginContext.addService(BesuConfiguration.class, commonPluginConfiguration);
+ metricCategoryRegistry.setMetricsConfiguration(metricsConfiguration);
besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry);
besuPluginContext.addService(MetricsSystem.class, metricsSystem);
@@ -554,11 +566,11 @@ public KeyValueStorageProvider provideKeyValueStorageProvider(
}
@Provides
- public MiningParameters provideMiningParameters(
+ public MiningConfiguration provideMiningParameters(
final TransactionSelectionServiceImpl transactionSelectionServiceImpl,
final BesuNode node) {
final var miningParameters =
- ImmutableMiningParameters.builder()
+ ImmutableMiningConfiguration.builder()
.from(node.getMiningParameters())
.transactionSelectionService(transactionSelectionServiceImpl)
.build();
@@ -569,17 +581,26 @@ public MiningParameters provideMiningParameters(
@Provides
@Inject
BesuConfiguration provideBesuConfiguration(
- final Path dataDir, final MiningParameters miningParameters, final BesuNode node) {
+ final Path dataDir, final MiningConfiguration miningConfiguration, final BesuNode node) {
final BesuConfigurationImpl commonPluginConfiguration = new BesuConfigurationImpl();
commonPluginConfiguration.init(
dataDir, dataDir.resolve(DATABASE_PATH), node.getDataStorageConfiguration());
- commonPluginConfiguration.withMiningParameters(miningParameters);
+ commonPluginConfiguration.withMiningParameters(miningConfiguration);
return commonPluginConfiguration;
}
}
@Module
- static class MockBesuCommandModule {
+ public static class ObservableMetricsSystemModule {
+ @Provides
+ @Singleton
+ public ObservableMetricsSystem provideObservableMetricsSystem() {
+ return new NoOpMetricsSystem();
+ }
+ }
+
+ @Module
+ public static class MockBesuCommandModule {
@Provides
BesuCommand provideBesuCommand(final BesuPluginContextImpl pluginContext) {
@@ -610,6 +631,8 @@ Logger provideBesuCommandLogger() {
modules = {
ThreadBesuNodeRunner.BesuControllerModule.class,
ThreadBesuNodeRunner.MockBesuCommandModule.class,
+ ThreadBesuNodeRunner.ObservableMetricsSystemModule.class,
+ ThreadBesuNodeRunnerModule.class,
BonsaiCachedMerkleTrieLoaderModule.class,
MetricsSystemModule.class,
ThreadBesuNodeRunner.BesuNodeProviderModule.class,
@@ -625,5 +648,9 @@ public interface AcceptanceTestBesuComponent extends BesuComponent {
RpcEndpointServiceImpl rpcEndpointService();
BlockchainServiceImpl blockchainService();
+
+ ObservableMetricsSystem getObservableMetricsSystem();
+
+ ThreadBesuNodeRunner getThreadBesuNodeRunner();
}
}
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
index ba69e4ddd72..5840f1e4f1f 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
@@ -21,7 +21,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
@@ -40,7 +40,7 @@ public class BesuNodeConfiguration {
private final String name;
private final Optional dataPath;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
private final TransactionPoolConfiguration transactionPoolConfiguration;
private final JsonRpcConfiguration jsonRpcConfiguration;
private final Optional engineRpcConfiguration;
@@ -78,7 +78,7 @@ public class BesuNodeConfiguration {
BesuNodeConfiguration(
final String name,
final Optional dataPath,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final TransactionPoolConfiguration transactionPoolConfiguration,
final JsonRpcConfiguration jsonRpcConfiguration,
final Optional engineRpcConfiguration,
@@ -113,7 +113,7 @@ public class BesuNodeConfiguration {
final boolean strictTxReplayProtectionEnabled,
final Map environment) {
this.name = name;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
this.transactionPoolConfiguration = transactionPoolConfiguration;
this.jsonRpcConfiguration = jsonRpcConfiguration;
this.engineRpcConfiguration = engineRpcConfiguration;
@@ -154,8 +154,8 @@ public String getName() {
return name;
}
- public MiningParameters getMiningParameters() {
- return miningParameters;
+ public MiningConfiguration getMiningParameters() {
+ return miningConfiguration;
}
public TransactionPoolConfiguration getTransactionPoolConfiguration() {
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
index ead01ce97d2..9b000f56f12 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
@@ -33,9 +33,9 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.api.tls.FileBasedPasswordProvider;
import org.hyperledger.besu.ethereum.core.AddressHelpers;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
@@ -61,8 +61,8 @@ public class BesuNodeConfigurationBuilder {
private String name;
private Optional dataPath = Optional.empty();
- private MiningParameters miningParameters =
- ImmutableMiningParameters.builder()
+ private MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build())
.build();
@@ -125,13 +125,14 @@ public BesuNodeConfigurationBuilder miningEnabled() {
}
public BesuNodeConfigurationBuilder miningEnabled(final boolean enabled) {
- this.miningParameters = miningParameters.setMiningEnabled(enabled);
+ this.miningConfiguration = miningConfiguration.setMiningEnabled(enabled);
this.jsonRpcConfiguration.addRpcApi(RpcApis.MINER.name());
return this;
}
- public BesuNodeConfigurationBuilder miningConfiguration(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public BesuNodeConfigurationBuilder miningConfiguration(
+ final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
this.jsonRpcConfiguration.addRpcApi(RpcApis.MINER.name());
return this;
}
@@ -527,7 +528,7 @@ public BesuNodeConfiguration build() {
return new BesuNodeConfiguration(
name,
dataPath,
- miningParameters,
+ miningConfiguration,
transactionPoolConfiguration,
jsonRpcConfiguration,
Optional.of(engineRpcConfiguration),
diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/account/TransferTransactionBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/account/TransferTransactionBuilder.java
index 1d859694440..bb5fd5c4ed3 100644
--- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/account/TransferTransactionBuilder.java
+++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/account/TransferTransactionBuilder.java
@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.tests.acceptance.dsl.transaction.account;
-import static org.testcontainers.shaded.com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkNotNull;
import org.hyperledger.besu.crypto.SECP256K1;
import org.hyperledger.besu.crypto.SignatureAlgorithm;
diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java
new file mode 100644
index 00000000000..af179c57cfe
--- /dev/null
+++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestMetricsPlugin.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright contributors to Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.tests.acceptance.plugins;
+
+import org.hyperledger.besu.plugin.BesuContext;
+import org.hyperledger.besu.plugin.BesuPlugin;
+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 BesuContext besuContext;
+
+ @Override
+ public void register(final BesuContext context) {
+ LOG.info("Registering TestMetricsPlugin");
+ besuContext = context;
+ context
+ .getService(MetricCategoryRegistry.class)
+ .orElseThrow()
+ .addMetricCategory(TestMetricCategory.TEST_METRIC_CATEGORY);
+ }
+
+ @Override
+ public void start() {
+ LOG.info("Starting TestMetricsPlugin");
+ besuContext
+ .getService(MetricsSystem.class)
+ .orElseThrow()
+ .createGauge(
+ TestMetricCategory.TEST_METRIC_CATEGORY,
+ "test_metric",
+ "Returns 1 on success",
+ () -> 1.0);
+ }
+
+ @Override
+ public void stop() {
+ LOG.info("Stopping TestMetricsPlugin");
+ }
+
+ public enum TestMetricCategory implements MetricCategory {
+ TEST_METRIC_CATEGORY;
+
+ @Override
+ public String getName() {
+ return name().toLowerCase(Locale.ROOT);
+ }
+
+ @Override
+ public Optional getApplicationPrefix() {
+ return Optional.of("plugin_test_");
+ }
+ }
+}
diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle
index e9724151abd..b6c388172e7 100644
--- a/acceptance-tests/tests/build.gradle
+++ b/acceptance-tests/tests/build.gradle
@@ -31,6 +31,7 @@ dependencies {
api 'org.slf4j:slf4j-api'
implementation project(':crypto:algorithms')
+ implementation project(':ethereum:eth')
testImplementation project(':acceptance-tests:dsl')
testImplementation project(':acceptance-tests:test-plugins')
@@ -42,6 +43,7 @@ dependencies {
testImplementation project(':ethereum:api')
testImplementation project(':ethereum:core')
testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')
+ testImplementation project(':ethereum:eth')
testImplementation project(':ethereum:p2p')
testImplementation project(':ethereum:permissioning')
testImplementation project(':ethereum:rlp')
@@ -74,11 +76,12 @@ dependencies {
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.junit.jupiter:junit-jupiter'
- testImplementation 'org.testcontainers:testcontainers'
testImplementation 'org.web3j:abi'
testImplementation 'org.web3j:besu'
testImplementation 'org.web3j:core'
testImplementation 'org.wiremock:wiremock'
+ testImplementation 'com.google.dagger:dagger'
+ testAnnotationProcessor 'com.google.dagger:dagger-compiler'
testImplementation project(path: ':acceptance-tests:tests:shanghai')
}
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java
index 1e741a5cc68..177987aaaff 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java
@@ -17,9 +17,9 @@
import org.hyperledger.besu.config.JsonUtil;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.AddressHelpers;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.account.Account;
import org.hyperledger.besu.tests.acceptance.dsl.blockchain.Amount;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
@@ -62,8 +62,8 @@ public void shouldMineOnSingleNodeWithFreeGas_Berlin(
final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception {
setUp(testName, nodeFactory);
final BesuNode minerNode = nodeFactory.createNode(besu, "miner1");
- final MiningParameters zeroGasMiningParams =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration zeroGasMiningParams =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/ParameterizedBftTestBase.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/ParameterizedBftTestBase.java
index b3d1e321aea..76a1a4a6bcc 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/ParameterizedBftTestBase.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/ParameterizedBftTestBase.java
@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.tests.acceptance.bft;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import java.util.stream.Stream;
@@ -22,7 +22,7 @@
import org.junit.jupiter.params.provider.Arguments;
@Disabled("This is not a test class, it offers BFT parameterization only.")
-public abstract class ParameterizedBftTestBase extends AcceptanceTestBaseJunit5 {
+public abstract class ParameterizedBftTestBase extends AcceptanceTestBase {
protected String bftType;
protected BftAcceptanceTestParameterization nodeFactory;
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java
index b62eb96e195..038f2be16c1 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java
@@ -14,13 +14,13 @@
*/
package org.hyperledger.besu.tests.acceptance.bft.qbft;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.account.Account;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.junit.jupiter.api.Test;
-public class QbftContractAcceptanceTest extends AcceptanceTestBaseJunit5 {
+public class QbftContractAcceptanceTest extends AcceptanceTestBase {
@Test
public void shouldMineOnMultipleNodesEvenWhenClusterContainsNonValidator() throws Exception {
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java
index 6ea274b6991..3ac42cb056c 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java
@@ -14,14 +14,14 @@
*/
package org.hyperledger.besu.tests.acceptance.clique;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import java.io.IOException;
import org.junit.jupiter.api.Test;
-public class CliqueDiscardRpcAcceptanceTest extends AcceptanceTestBaseJunit5 {
+public class CliqueDiscardRpcAcceptanceTest extends AcceptanceTestBase {
@Test
public void shouldDiscardVotes() throws IOException {
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueGetSignersRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueGetSignersRpcAcceptanceTest.java
index ba848b0052c..25a1d335105 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueGetSignersRpcAcceptanceTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueGetSignersRpcAcceptanceTest.java
@@ -16,7 +16,7 @@
import static org.hyperledger.besu.tests.acceptance.dsl.transaction.clique.CliqueTransactions.LATEST;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.junit.jupiter.api.BeforeEach;
@@ -24,7 +24,7 @@
import org.junit.jupiter.api.Test;
@Disabled("flaky test due to hardcoded block numbers")
-public class CliqueGetSignersRpcAcceptanceTest extends AcceptanceTestBaseJunit5 {
+public class CliqueGetSignersRpcAcceptanceTest extends AcceptanceTestBase {
private BesuNode minerNode1;
private BesuNode minerNode2;
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java
index f6718b4ded1..f2bae445806 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java
@@ -18,7 +18,7 @@
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.assertj.core.data.Percentage.withPercentage;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.account.Account;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationFactory.CliqueOptions;
@@ -32,7 +32,7 @@
import org.junit.jupiter.api.Test;
import org.web3j.protocol.core.DefaultBlockParameter;
-public class CliqueMiningAcceptanceTest extends AcceptanceTestBaseJunit5 {
+public class CliqueMiningAcceptanceTest extends AcceptanceTestBase {
@Test
public void shouldMineTransactionsOnSingleNode() throws IOException {
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposalRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposalRpcAcceptanceTest.java
index a7e8ebb9c9c..6cbfbbda0f0 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposalRpcAcceptanceTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposalRpcAcceptanceTest.java
@@ -14,14 +14,14 @@
*/
package org.hyperledger.besu.tests.acceptance.clique;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import java.io.IOException;
import org.junit.jupiter.api.Test;
-public class CliqueProposalRpcAcceptanceTest extends AcceptanceTestBaseJunit5 {
+public class CliqueProposalRpcAcceptanceTest extends AcceptanceTestBase {
@Test
public void shouldReturnProposals() throws IOException {
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java
index d4fb71c36b4..1674c551a4b 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java
@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.tests.acceptance.clique;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.condition.clique.ExpectNonceVote.CLIQUE_NONCE_VOTE;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
@@ -23,7 +23,7 @@
import org.junit.jupiter.api.Test;
-public class CliqueProposeRpcAcceptanceTest extends AcceptanceTestBaseJunit5 {
+public class CliqueProposeRpcAcceptanceTest extends AcceptanceTestBase {
@Test
public void shouldAddValidators() throws IOException {
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueZeroValidatorsAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueZeroValidatorsAcceptanceTest.java
index b0c6afd93fc..e124e669d92 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueZeroValidatorsAcceptanceTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueZeroValidatorsAcceptanceTest.java
@@ -14,14 +14,14 @@
*/
package org.hyperledger.besu.tests.acceptance.clique;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import java.io.IOException;
import org.junit.jupiter.api.Test;
-public class CliqueZeroValidatorsAcceptanceTest extends AcceptanceTestBaseJunit5 {
+public class CliqueZeroValidatorsAcceptanceTest extends AcceptanceTestBase {
@Test
public void zeroValidatorsFormValidCluster() throws IOException {
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEnginePragueAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEnginePragueAcceptanceTest.java
index 966c02bebde..f38a192d4df 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEnginePragueAcceptanceTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEnginePragueAcceptanceTest.java
@@ -20,8 +20,11 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.provider.Arguments;
+// TODO SLD
+@Disabled("TODO SLD - Enable when Prague spec is finalized")
public class ExecutionEnginePragueAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/prague/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/prague/test-cases/";
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPluginTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPluginTest.java
index fb35aaacf54..91c70439da9 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPluginTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPluginTest.java
@@ -16,7 +16,7 @@
import static org.assertj.core.api.Assertions.assertThat;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import java.io.File;
@@ -34,7 +34,7 @@
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
-public class BadCLIOptionsPluginTest extends AcceptanceTestBaseJunit5 {
+public class BadCLIOptionsPluginTest extends AcceptanceTestBase {
private BesuNode node;
@BeforeEach
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BesuEventsPluginTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BesuEventsPluginTest.java
index a35309ef6f0..4906193362c 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BesuEventsPluginTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BesuEventsPluginTest.java
@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.tests.acceptance.plugins;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import java.io.File;
@@ -28,7 +28,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class BesuEventsPluginTest extends AcceptanceTestBaseJunit5 {
+public class BesuEventsPluginTest extends AcceptanceTestBase {
private BesuNode pluginNode;
private BesuNode minerNode;
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/MetricsPluginTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/MetricsPluginTest.java
new file mode 100644
index 00000000000..75592007204
--- /dev/null
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/MetricsPluginTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright contributors to Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.tests.acceptance.plugins;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.hyperledger.besu.tests.acceptance.plugins.TestMetricsPlugin.TestMetricCategory.TEST_METRIC_CATEGORY;
+
+import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
+import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
+import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class MetricsPluginTest extends AcceptanceTestBase {
+ private BesuNode node;
+ private MetricsConfiguration metricsConfiguration;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ metricsConfiguration =
+ MetricsConfiguration.builder()
+ .enabled(true)
+ .port(0)
+ .metricCategories(Set.of(TEST_METRIC_CATEGORY))
+ .build();
+ node =
+ besu.create(
+ new BesuNodeConfigurationBuilder()
+ .name("node1")
+ .plugins(List.of("testPlugins"))
+ .metricsConfiguration(metricsConfiguration)
+ .build());
+
+ cluster.start(node);
+ }
+
+ @Test
+ public void metricCategoryAdded() throws IOException, InterruptedException {
+ final var httpClient = HttpClient.newHttpClient();
+ final var req = HttpRequest.newBuilder(URI.create(node.metricsHttpUrl().get())).build();
+ final var resp = httpClient.send(req, HttpResponse.BodyHandlers.ofLines());
+ assertThat(resp.statusCode()).isEqualTo(200);
+ final var foundMetric =
+ resp.body()
+ .filter(
+ line -> line.startsWith(TEST_METRIC_CATEGORY.getApplicationPrefix().orElseThrow()))
+ .findFirst()
+ .orElseThrow();
+ assertThat(foundMetric).endsWith("1.0");
+ }
+}
diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java
index 86756a42082..c469802fc1e 100644
--- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java
+++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java
@@ -15,7 +15,7 @@
package org.hyperledger.besu.tests.acceptance.plugins;
import org.hyperledger.besu.datatypes.Hash;
-import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5;
+import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.account.Account;
import org.hyperledger.besu.tests.acceptance.dsl.blockchain.Amount;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
@@ -27,7 +27,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class PermissioningPluginTest extends AcceptanceTestBaseJunit5 {
+public class PermissioningPluginTest extends AcceptanceTestBase {
private BesuNode minerNode;
private BesuNode aliceNode;
diff --git a/benchmark/docker-compose.yml b/benchmark/docker-compose.yml
index a62afa7b151..c4054e1a21c 100644
--- a/benchmark/docker-compose.yml
+++ b/benchmark/docker-compose.yml
@@ -66,7 +66,6 @@ services:
- --rpc-ws-enabled
- --rpc-ws-apis=admin,eth,miner,web3,net,priv,eea
- --rpc-ws-host=0.0.0.0
- - --host-whitelist=*
- --graphql-http-enabled
- --discovery-enabled=false
- --privacy-enabled=true
@@ -84,7 +83,6 @@ services:
- --rpc-ws-enabled
- --rpc-ws-apis=admin,eth,miner,web3,net,priv,eea
- --rpc-ws-host=0.0.0.0
- - --host-whitelist=*
- --graphql-http-enabled
- --discovery-enabled=false
- --privacy-enabled=true
diff --git a/besu/build.gradle b/besu/build.gradle
index fb9aeef9e67..b6e506d9c14 100644
--- a/besu/build.gradle
+++ b/besu/build.gradle
@@ -49,7 +49,6 @@ dependencies {
implementation project(':ethereum:eth')
implementation project(':ethereum:p2p')
implementation project(':ethereum:permissioning')
- implementation project(':ethereum:retesteth')
implementation project(':ethereum:rlp')
implementation project(':ethereum:trie')
implementation project(':ethereum:stratum')
@@ -104,7 +103,6 @@ dependencies {
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core'
- testImplementation 'org.testcontainers:testcontainers'
testImplementation 'tech.pegasys.discovery:discovery'
testImplementation 'com.google.dagger:dagger'
diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
index 96eef547fed..06dca6c6f0a 100644
--- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
@@ -23,7 +23,7 @@
import org.hyperledger.besu.cli.config.EthNetworkConfig;
import org.hyperledger.besu.cli.config.NetworkName;
-import org.hyperledger.besu.cli.options.stable.EthstatsOptions;
+import org.hyperledger.besu.cli.options.EthstatsOptions;
import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.ethereum.ProtocolContext;
@@ -70,7 +70,7 @@
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
@@ -773,7 +773,7 @@ public Runner build() {
final TransactionPool transactionPool = besuController.getTransactionPool();
final MiningCoordinator miningCoordinator = besuController.getMiningCoordinator();
- final MiningParameters miningParameters = besuController.getMiningParameters();
+ final MiningConfiguration miningConfiguration = besuController.getMiningParameters();
final BlockchainQueries blockchainQueries =
new BlockchainQueries(
@@ -783,7 +783,7 @@ public Runner build() {
Optional.of(dataDir.resolve(CACHE_PATH)),
Optional.of(besuController.getProtocolManager().ethContext().getScheduler()),
apiConfiguration,
- miningParameters);
+ miningConfiguration);
final PrivacyParameters privacyParameters = besuController.getPrivacyParameters();
@@ -802,7 +802,7 @@ public Runner build() {
Optional stratumServer = Optional.empty();
- if (miningParameters.isStratumMiningEnabled()) {
+ if (miningConfiguration.isStratumMiningEnabled()) {
if (!(miningCoordinator instanceof PoWMiningCoordinator powMiningCoordinator)) {
throw new IllegalArgumentException(
"Stratum mining requires the network option(--network) to be set to CLASSIC. Stratum server requires a PoWMiningCoordinator not "
@@ -813,9 +813,9 @@ public Runner build() {
new StratumServer(
vertx,
powMiningCoordinator,
- miningParameters.getStratumPort(),
- miningParameters.getStratumNetworkInterface(),
- miningParameters.getUnstable().getStratumExtranonce(),
+ miningConfiguration.getStratumPort(),
+ miningConfiguration.getStratumNetworkInterface(),
+ miningConfiguration.getUnstable().getStratumExtranonce(),
metricsSystem));
miningCoordinator.addEthHashObserver(stratumServer.get());
LOG.debug("added ethash observer: {}", stratumServer.get());
@@ -849,7 +849,7 @@ public Runner build() {
blockchainQueries,
synchronizer,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
@@ -896,7 +896,7 @@ public Runner build() {
blockchainQueries,
synchronizer,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
@@ -989,7 +989,7 @@ public Runner build() {
blockchainQueries,
synchronizer,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
@@ -1070,7 +1070,7 @@ public Runner build() {
blockchainQueries,
synchronizer,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
@@ -1111,7 +1111,7 @@ public Runner build() {
blockchainQueries,
synchronizer,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
@@ -1273,7 +1273,7 @@ private Map jsonRpcMethods(
final BlockchainQueries blockchainQueries,
final Synchronizer synchronizer,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final MiningCoordinator miningCoordinator,
final ObservableMetricsSystem metricsSystem,
final Set supportedCapabilities,
@@ -1308,7 +1308,7 @@ private Map jsonRpcMethods(
protocolContext,
filterManager,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
supportedCapabilities,
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
index 886e3d68383..6ecc22cecdb 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
@@ -37,45 +37,43 @@
import org.hyperledger.besu.cli.config.EthNetworkConfig;
import org.hyperledger.besu.cli.config.NetworkName;
import org.hyperledger.besu.cli.config.ProfilesCompletionCandidates;
-import org.hyperledger.besu.cli.converter.MetricCategoryConverter;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
import org.hyperledger.besu.cli.error.BesuExecutionExceptionHandler;
import org.hyperledger.besu.cli.error.BesuParameterExceptionHandler;
+import org.hyperledger.besu.cli.options.ApiConfigurationOptions;
+import org.hyperledger.besu.cli.options.ChainPruningOptions;
+import org.hyperledger.besu.cli.options.DnsOptions;
+import org.hyperledger.besu.cli.options.EngineRPCConfiguration;
+import org.hyperledger.besu.cli.options.EngineRPCOptions;
+import org.hyperledger.besu.cli.options.EthProtocolOptions;
+import org.hyperledger.besu.cli.options.EthstatsOptions;
+import org.hyperledger.besu.cli.options.EvmOptions;
+import org.hyperledger.besu.cli.options.GraphQlOptions;
+import org.hyperledger.besu.cli.options.InProcessRpcOptions;
+import org.hyperledger.besu.cli.options.IpcOptions;
+import org.hyperledger.besu.cli.options.JsonRpcHttpOptions;
+import org.hyperledger.besu.cli.options.LoggingLevelOption;
+import org.hyperledger.besu.cli.options.MetricsOptions;
import org.hyperledger.besu.cli.options.MiningOptions;
+import org.hyperledger.besu.cli.options.NatOptions;
+import org.hyperledger.besu.cli.options.NativeLibraryOptions;
+import org.hyperledger.besu.cli.options.NetworkingOptions;
+import org.hyperledger.besu.cli.options.NodePrivateKeyFileOption;
+import org.hyperledger.besu.cli.options.P2PDiscoveryOptions;
+import org.hyperledger.besu.cli.options.P2PTLSConfigOptions;
+import org.hyperledger.besu.cli.options.PermissionsOptions;
+import org.hyperledger.besu.cli.options.PluginsConfigurationOptions;
+import org.hyperledger.besu.cli.options.PrivacyPluginOptions;
+import org.hyperledger.besu.cli.options.RPCOptions;
+import org.hyperledger.besu.cli.options.RpcWebsocketOptions;
+import org.hyperledger.besu.cli.options.SynchronizerOptions;
import org.hyperledger.besu.cli.options.TransactionPoolOptions;
-import org.hyperledger.besu.cli.options.stable.ApiConfigurationOptions;
-import org.hyperledger.besu.cli.options.stable.EngineRPCConfiguration;
-import org.hyperledger.besu.cli.options.stable.EngineRPCOptions;
-import org.hyperledger.besu.cli.options.stable.EthstatsOptions;
-import org.hyperledger.besu.cli.options.stable.GraphQlOptions;
-import org.hyperledger.besu.cli.options.stable.JsonRpcHttpOptions;
-import org.hyperledger.besu.cli.options.stable.LoggingLevelOption;
-import org.hyperledger.besu.cli.options.stable.MetricsOptions;
-import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption;
-import org.hyperledger.besu.cli.options.stable.P2PDiscoveryOptions;
-import org.hyperledger.besu.cli.options.stable.PermissionsOptions;
-import org.hyperledger.besu.cli.options.stable.PluginsConfigurationOptions;
-import org.hyperledger.besu.cli.options.stable.RpcWebsocketOptions;
import org.hyperledger.besu.cli.options.storage.DataStorageOptions;
import org.hyperledger.besu.cli.options.storage.DiffBasedSubStorageOptions;
-import org.hyperledger.besu.cli.options.unstable.ChainPruningOptions;
-import org.hyperledger.besu.cli.options.unstable.DnsOptions;
-import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
-import org.hyperledger.besu.cli.options.unstable.EvmOptions;
-import org.hyperledger.besu.cli.options.unstable.InProcessRpcOptions;
-import org.hyperledger.besu.cli.options.unstable.IpcOptions;
-import org.hyperledger.besu.cli.options.unstable.NatOptions;
-import org.hyperledger.besu.cli.options.unstable.NativeLibraryOptions;
-import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
-import org.hyperledger.besu.cli.options.unstable.P2PTLSConfigOptions;
-import org.hyperledger.besu.cli.options.unstable.PrivacyPluginOptions;
-import org.hyperledger.besu.cli.options.unstable.RPCOptions;
-import org.hyperledger.besu.cli.options.unstable.SynchronizerOptions;
import org.hyperledger.besu.cli.presynctasks.PreSynchronizationTaskRunner;
import org.hyperledger.besu.cli.presynctasks.PrivateDatabaseMigrationPreSyncTask;
import org.hyperledger.besu.cli.subcommands.PasswordSubCommand;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand;
-import org.hyperledger.besu.cli.subcommands.RetestethSubCommand;
import org.hyperledger.besu.cli.subcommands.TxParseSubCommand;
import org.hyperledger.besu.cli.subcommands.ValidateConfigSubCommand;
import org.hyperledger.besu.cli.subcommands.blocks.BlocksSubCommand;
@@ -115,7 +113,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.Blockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MiningParametersMetrics;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.VersionMetadata;
@@ -170,7 +168,6 @@
import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.plugin.services.TransactionSimulationService;
import org.hyperledger.besu.plugin.services.exception.StorageException;
-import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry;
import org.hyperledger.besu.plugin.services.p2p.P2PService;
import org.hyperledger.besu.plugin.services.rlp.RlpConverterService;
@@ -332,7 +329,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final Map environment;
private final MetricCategoryRegistryImpl metricCategoryRegistry =
new MetricCategoryRegistryImpl();
- private final MetricCategoryConverter metricCategoryConverter = new MetricCategoryConverter();
private final PreSynchronizationTaskRunner preSynchronizationTaskRunner =
new PreSynchronizationTaskRunner();
@@ -342,7 +338,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
Suppliers.memoize(this::readGenesisConfigFile);
private final Supplier genesisConfigOptionsSupplier =
Suppliers.memoize(this::readGenesisConfigOptions);
- private final Supplier miningParametersSupplier =
+ private final Supplier miningParametersSupplier =
Suppliers.memoize(this::getMiningParameters);
private RocksDBPlugin rocksDBPlugin;
@@ -596,14 +592,6 @@ static class PrivacyOptionGroup {
defaultValue = "localhost,127.0.0.1")
private final JsonRPCAllowlistHostsProperty hostsAllowlist = new JsonRPCAllowlistHostsProperty();
- @Option(
- names = {"--host-whitelist"},
- hidden = true,
- paramLabel = "[,...]... or * or all",
- description =
- "Deprecated in favor of --host-allowlist. Comma separated list of hostnames to allow for RPC access, or * to accept any host (default: ${DEFAULT-VALUE})")
- private final JsonRPCAllowlistHostsProperty hostsWhitelist = new JsonRPCAllowlistHostsProperty();
-
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"})
@Option(
names = {"--color-enabled"},
@@ -1108,7 +1096,6 @@ private void addSubCommands(final InputStream in) {
PublicKeySubCommand.COMMAND_NAME, new PublicKeySubCommand(commandLine.getOut()));
commandLine.addSubcommand(
PasswordSubCommand.COMMAND_NAME, new PasswordSubCommand(commandLine.getOut()));
- commandLine.addSubcommand(RetestethSubCommand.COMMAND_NAME, new RetestethSubCommand());
commandLine.addSubcommand(
RLPSubCommand.COMMAND_NAME, new RLPSubCommand(commandLine.getOut(), in));
commandLine.addSubcommand(
@@ -1136,10 +1123,6 @@ private void registerConverters() {
commandLine.registerConverter(Hash.class, Hash::fromHexString);
commandLine.registerConverter(Optional.class, Optional::of);
commandLine.registerConverter(Double.class, Double::parseDouble);
-
- metricCategoryConverter.addCategories(BesuMetricCategory.class);
- metricCategoryConverter.addCategories(StandardMetricCategory.class);
- commandLine.registerConverter(MetricCategory.class, metricCategoryConverter);
}
private void handleStableOptions() {
@@ -1174,6 +1157,9 @@ private void preparePlugins() {
besuPluginContext.addService(PicoCLIOptions.class, new PicoCLIOptionsImpl(commandLine));
besuPluginContext.addService(SecurityModuleService.class, securityModuleService);
besuPluginContext.addService(StorageService.class, storageService);
+
+ metricCategoryRegistry.addCategories(BesuMetricCategory.class);
+ metricCategoryRegistry.addCategories(StandardMetricCategory.class);
besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry);
besuPluginContext.addService(PermissioningService.class, permissioningService);
besuPluginContext.addService(PrivacyPluginService.class, privacyPluginService);
@@ -1191,10 +1177,6 @@ private void preparePlugins() {
rocksDBPlugin.register(besuPluginContext);
new InMemoryStoragePlugin().register(besuPluginContext);
- metricCategoryRegistry
- .getMetricCategories()
- .forEach(metricCategoryConverter::addRegistryCategory);
-
// register default security module
securityModuleService.register(
DEFAULT_SECURITY_MODULE, Suppliers.memoize(this::defaultSecurityModule));
@@ -1891,6 +1873,10 @@ public MetricsConfiguration metricsConfiguration() {
"--metrics-push-interval",
"--metrics-push-prometheus-job"));
+ metricsOptions.setMetricCategoryRegistry(metricCategoryRegistry);
+
+ metricsOptions.validate(commandLine);
+
final MetricsConfiguration.Builder metricsConfigurationBuilder =
metricsOptions.toDomainObject();
metricsConfigurationBuilder
@@ -1903,7 +1889,9 @@ public MetricsConfiguration metricsConfiguration() {
? p2PDiscoveryOptions.autoDiscoverDefaultIP().getHostAddress()
: metricsOptions.getMetricsPushHost())
.hostsAllowlist(hostsAllowlist);
- return metricsConfigurationBuilder.build();
+ final var metricsConfiguration = metricsConfigurationBuilder.build();
+ metricCategoryRegistry.setMetricsConfiguration(metricsConfiguration);
+ return metricsConfiguration;
}
private PrivacyParameters privacyParameters() {
@@ -2121,7 +2109,7 @@ private TransactionPoolConfiguration buildTransactionPoolConfiguration() {
return txPoolConfBuilder.build();
}
- private MiningParameters getMiningParameters() {
+ private MiningConfiguration getMiningParameters() {
miningOptions.setTransactionSelectionService(transactionSelectionServiceImpl);
final var miningParameters = miningOptions.toDomainObject();
getGenesisBlockPeriodSeconds(genesisConfigOptionsSupplier.get())
@@ -2173,8 +2161,8 @@ public DataStorageConfiguration getDataStorageConfiguration() {
return dataStorageConfiguration;
}
- private void initMiningParametersMetrics(final MiningParameters miningParameters) {
- new MiningParametersMetrics(getMetricsSystem(), miningParameters);
+ private void initMiningParametersMetrics(final MiningConfiguration miningConfiguration) {
+ new MiningParametersMetrics(getMetricsSystem(), miningConfiguration);
}
private OptionalInt getGenesisBlockPeriodSeconds(
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java
index b3dfa2a054c..a7b43d0d9e5 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java
@@ -433,14 +433,18 @@ public String build() {
private void detectJemalloc(final List lines) {
Optional.ofNullable(Objects.isNull(environment) ? null : environment.get("BESU_USING_JEMALLOC"))
.ifPresentOrElse(
- t -> {
+ jemallocEnabled -> {
try {
- final String version = PlatformDetector.getJemalloc();
- lines.add("jemalloc: " + version);
+ if (Boolean.parseBoolean(jemallocEnabled)) {
+ final String version = PlatformDetector.getJemalloc();
+ lines.add("jemalloc: " + version);
+ } else {
+ logger.warn(
+ "besu_using_jemalloc is present but is not set to true, jemalloc library not loaded");
+ }
} catch (final Throwable throwable) {
logger.warn(
- "BESU_USING_JEMALLOC is present but we failed to load jemalloc library to get the version",
- throwable);
+ "besu_using_jemalloc is present but we failed to load jemalloc library to get the version");
}
},
() -> {
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java b/besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java
deleted file mode 100644
index 339da86b2d7..00000000000
--- a/besu/src/main/java/org/hyperledger/besu/cli/converter/MetricCategoryConverter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright ConsenSys AG.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package org.hyperledger.besu.cli.converter;
-
-import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import com.google.common.annotations.VisibleForTesting;
-import picocli.CommandLine;
-
-/** The Metric category converter for CLI options. */
-public class MetricCategoryConverter implements CommandLine.ITypeConverter {
-
- private final Map metricCategories = new HashMap<>();
-
- /** Default Constructor. */
- public MetricCategoryConverter() {}
-
- @Override
- public MetricCategory convert(final String value) {
- final MetricCategory category = metricCategories.get(value);
- if (category == null) {
- throw new IllegalArgumentException("Unknown category: " + value);
- }
- return category;
- }
-
- /**
- * Add Metrics categories.
- *
- * @param the type parameter
- * @param categoryEnum the category enum
- */
- public & MetricCategory> void addCategories(final Class categoryEnum) {
- EnumSet.allOf(categoryEnum)
- .forEach(category -> metricCategories.put(category.name(), category));
- }
-
- /**
- * Add registry category.
- *
- * @param metricCategory the metric category
- */
- public void addRegistryCategory(final MetricCategory metricCategory) {
- metricCategories.put(metricCategory.getName().toUpperCase(Locale.ROOT), metricCategory);
- }
-
- /**
- * Gets metric categories.
- *
- * @return the metric categories
- */
- @VisibleForTesting
- Map getMetricCategories() {
- return metricCategories;
- }
-}
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java
similarity index 99%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java
index d6bc17026cd..c5954f50639 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/ApiConfigurationOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/ApiConfigurationOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/ChainPruningOptions.java
similarity index 98%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/ChainPruningOptions.java
index 0a59ef9b04e..3f26b676ceb 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/ChainPruningOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/ChainPruningOptions.java
@@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethereum.chain.ChainPrunerConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/DnsOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/DnsOptions.java
index 9f9670e8e66..9a720bebbb0 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/DnsOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/DnsOptions.java
@@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.ImmutableEnodeDnsConfiguration;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCConfiguration.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCConfiguration.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCConfiguration.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCConfiguration.java
index c0eb9d1be08..ec98204d3bc 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCConfiguration.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCConfiguration.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCOptions.java
index 1aa5b3d3263..e660e6c821d 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EngineRPCOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EngineRPCOptions.java
@@ -12,13 +12,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_ENGINE_JSON_RPC_PORT;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import java.nio.file.Path;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EthProtocolOptions.java
similarity index 97%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/EthProtocolOptions.java
index 1d5434ff022..a20403027d7 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EthProtocolOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EthProtocolOptions.java
@@ -12,10 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
-import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EthstatsOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/EthstatsOptions.java
index a6e939fdf0e..08e8b49c523 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/EthstatsOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EthstatsOptions.java
@@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.ethstats.util.EthStatsConnectOptions;
import java.nio.file.Path;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/EvmOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/EvmOptions.java
index 39d95324df2..6a58d6830a9 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/EvmOptions.java
@@ -12,9 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.util.List;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/GraphQlOptions.java
similarity index 98%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/GraphQlOptions.java
index 6aac24a6fbc..643ca22e005 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/GraphQlOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/GraphQlOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
import static org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_PORT;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/InProcessRpcOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/InProcessRpcOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/InProcessRpcOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/InProcessRpcOptions.java
index 9adeb37db7d..278a55e1870 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/InProcessRpcOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/InProcessRpcOptions.java
@@ -12,12 +12,11 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration.DEFAULT_IN_PROCESS_RPC_APIS;
import static org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration.DEFAULT_IN_PROCESS_RPC_ENABLED;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.api.jsonrpc.ImmutableInProcessRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/IpcOptions.java
similarity index 98%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/IpcOptions.java
index 19ba2941932..689ac4e9b3b 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/IpcOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/IpcOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/JsonRpcHttpOptions.java
similarity index 99%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/JsonRpcHttpOptions.java
index 7d08a6f9aa6..c8c2c733440 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/JsonRpcHttpOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/JsonRpcHttpOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration.DEFAULT_JSON_RPC_HOST;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java b/besu/src/main/java/org/hyperledger/besu/cli/options/LoggingLevelOption.java
similarity index 97%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/LoggingLevelOption.java
index 39b2a2482b8..1a498fd1962 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/LoggingLevelOption.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import java.util.Locale;
import java.util.Set;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/MetricsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/MetricsOptions.java
similarity index 83%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/MetricsOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/MetricsOptions.java
index 4906cf538e4..1f777286bf5 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/MetricsOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/MetricsOptions.java
@@ -12,8 +12,10 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.stream.Collectors.toUnmodifiableSet;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_HOST_FORMAT_HELP;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_INTEGER_FORMAT_HELP;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_PORT_FORMAT_HELP;
@@ -22,8 +24,8 @@
import static org.hyperledger.besu.metrics.prometheus.MetricsConfiguration.DEFAULT_METRICS_PORT;
import static org.hyperledger.besu.metrics.prometheus.MetricsConfiguration.DEFAULT_METRICS_PUSH_PORT;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
+import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl;
import org.hyperledger.besu.metrics.MetricsProtocol;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
@@ -36,6 +38,7 @@
/** Command line options for configuring metrics. */
// TODO: implement CLIOption
public class MetricsOptions implements CLIOptions {
+ private MetricCategoryRegistryImpl metricCategoryRegistry;
/**
* Returns a MetricsConfiguration.Builder because fields are often overridden from other domains,
@@ -77,7 +80,10 @@ public static MetricsOptions fromConfiguration(final MetricsConfiguration config
metricsOptions.metricsHost = config.getHost();
metricsOptions.metricsPort = config.getPort();
metricsOptions.metricsProtocol = config.getProtocol();
- metricsOptions.metricCategories = config.getMetricCategories();
+ metricsOptions.metricCategories =
+ config.getMetricCategories().stream()
+ .map(MetricCategory::getName)
+ .collect(toUnmodifiableSet());
metricsOptions.metricsPrometheusJob = config.getPrometheusJob();
metricsOptions.isMetricsPushEnabled = config.isPushEnabled();
metricsOptions.metricsPushHost = config.getPushHost();
@@ -126,7 +132,8 @@ public List getCLIOptions() {
arity = "1..*",
description =
"Comma separated list of categories to track metrics for (default: ${DEFAULT-VALUE})")
- private Set metricCategories = DEFAULT_METRIC_CATEGORIES;
+ private Set metricCategories =
+ DEFAULT_METRIC_CATEGORIES.stream().map(MetricCategory::getName).collect(toUnmodifiableSet());
@CommandLine.Option(
names = {"--metrics-push-enabled"},
@@ -216,7 +223,13 @@ public Integer getMetricsPort() {
* @return the metric categories
*/
public Set getMetricCategories() {
- return metricCategories;
+ checkState(
+ metricCategoryRegistry != null, "Set metricCategoryRegistry before calling this method");
+
+ final var list =
+ metricCategories.stream().map(metricCategoryRegistry::getMetricCategory).toList();
+
+ return Set.copyOf(list);
}
/**
@@ -264,6 +277,33 @@ public String getMetricsPrometheusJob() {
return metricsPrometheusJob;
}
+ /**
+ * Perform final validation after all the options, and the metric category registry, have been set
+ *
+ * @param commandLine the command line
+ */
+ public void validate(final CommandLine commandLine) {
+ checkState(
+ metricCategoryRegistry != null, "Set metricCategoryRegistry before calling this method");
+ final var unknownCategories =
+ metricCategories.stream()
+ .filter(category -> !metricCategoryRegistry.containsMetricCategory(category))
+ .toList();
+ if (!unknownCategories.isEmpty()) {
+ throw new CommandLine.ParameterException(
+ commandLine, "--metrics-categories contains unknown categories: " + unknownCategories);
+ }
+ }
+
+ /**
+ * Set the metric category registry in order to support verification and conversion
+ *
+ * @param metricCategoryRegistry the metric category registry
+ */
+ public void setMetricCategoryRegistry(final MetricCategoryRegistryImpl metricCategoryRegistry) {
+ this.metricCategoryRegistry = metricCategoryRegistry;
+ }
+
@CommandLine.ArgGroup(validate = false)
private final MetricsOptions.Unstable unstableOptions = new MetricsOptions.Unstable();
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java
index a884edfe334..fa0cf4dc068 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java
@@ -17,27 +17,27 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_EXTRA_DATA;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_PRIORITY_FEE_PER_GAS;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_MAX_OMMERS_DEPTH;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POW_JOB_TTL;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_TTL;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_EXTRA_DATA;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_PRIORITY_FEE_PER_GAS;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_MAX_OMMERS_DEPTH;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POW_JOB_TTL;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_TTL;
import org.hyperledger.besu.cli.converter.PositiveNumberConverter;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.plugin.services.TransactionSelectionService;
import org.hyperledger.besu.util.number.PositiveNumber;
@@ -50,7 +50,7 @@
import picocli.CommandLine.ParameterException;
/** The Mining CLI options. */
-public class MiningOptions implements CLIOptions {
+public class MiningOptions implements CLIOptions {
@Option(
names = {"--miner-enabled"},
@@ -300,43 +300,45 @@ public void validate(
}
}
- static MiningOptions fromConfig(final MiningParameters miningParameters) {
+ static MiningOptions fromConfig(final MiningConfiguration miningConfiguration) {
final MiningOptions miningOptions = MiningOptions.create();
- miningOptions.setTransactionSelectionService(miningParameters.getTransactionSelectionService());
- miningOptions.isMiningEnabled = miningParameters.isMiningEnabled();
- miningOptions.iStratumMiningEnabled = miningParameters.isStratumMiningEnabled();
- miningOptions.stratumNetworkInterface = miningParameters.getStratumNetworkInterface();
- miningOptions.stratumPort = miningParameters.getStratumPort();
- miningOptions.extraData = miningParameters.getExtraData();
- miningOptions.minTransactionGasPrice = miningParameters.getMinTransactionGasPrice();
- miningOptions.minPriorityFeePerGas = miningParameters.getMinPriorityFeePerGas();
- miningOptions.minBlockOccupancyRatio = miningParameters.getMinBlockOccupancyRatio();
+ miningOptions.setTransactionSelectionService(
+ miningConfiguration.getTransactionSelectionService());
+ miningOptions.isMiningEnabled = miningConfiguration.isMiningEnabled();
+ miningOptions.iStratumMiningEnabled = miningConfiguration.isStratumMiningEnabled();
+ miningOptions.stratumNetworkInterface = miningConfiguration.getStratumNetworkInterface();
+ miningOptions.stratumPort = miningConfiguration.getStratumPort();
+ miningOptions.extraData = miningConfiguration.getExtraData();
+ miningOptions.minTransactionGasPrice = miningConfiguration.getMinTransactionGasPrice();
+ miningOptions.minPriorityFeePerGas = miningConfiguration.getMinPriorityFeePerGas();
+ miningOptions.minBlockOccupancyRatio = miningConfiguration.getMinBlockOccupancyRatio();
miningOptions.nonPoaBlockTxsSelectionMaxTime =
- miningParameters.getNonPoaBlockTxsSelectionMaxTime();
- miningOptions.poaBlockTxsSelectionMaxTime = miningParameters.getPoaBlockTxsSelectionMaxTime();
+ miningConfiguration.getNonPoaBlockTxsSelectionMaxTime();
+ miningOptions.poaBlockTxsSelectionMaxTime =
+ miningConfiguration.getPoaBlockTxsSelectionMaxTime();
miningOptions.unstableOptions.remoteSealersLimit =
- miningParameters.getUnstable().getRemoteSealersLimit();
+ miningConfiguration.getUnstable().getRemoteSealersLimit();
miningOptions.unstableOptions.remoteSealersTimeToLive =
- miningParameters.getUnstable().getRemoteSealersTimeToLive();
+ miningConfiguration.getUnstable().getRemoteSealersTimeToLive();
miningOptions.unstableOptions.powJobTimeToLive =
- miningParameters.getUnstable().getPowJobTimeToLive();
+ miningConfiguration.getUnstable().getPowJobTimeToLive();
miningOptions.unstableOptions.maxOmmersDepth =
- miningParameters.getUnstable().getMaxOmmerDepth();
+ miningConfiguration.getUnstable().getMaxOmmerDepth();
miningOptions.unstableOptions.stratumExtranonce =
- miningParameters.getUnstable().getStratumExtranonce();
+ miningConfiguration.getUnstable().getStratumExtranonce();
miningOptions.unstableOptions.posBlockCreationMaxTime =
- miningParameters.getUnstable().getPosBlockCreationMaxTime();
+ miningConfiguration.getUnstable().getPosBlockCreationMaxTime();
miningOptions.unstableOptions.posBlockCreationRepetitionMinDuration =
- miningParameters.getUnstable().getPosBlockCreationRepetitionMinDuration();
+ miningConfiguration.getUnstable().getPosBlockCreationRepetitionMinDuration();
- miningParameters.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase);
- miningParameters.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl);
+ miningConfiguration.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase);
+ miningConfiguration.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl);
return miningOptions;
}
@Override
- public MiningParameters toDomainObject() {
+ public MiningConfiguration toDomainObject() {
checkNotNull(
transactionSelectionService,
"transactionSelectionService must be set before using this object");
@@ -356,7 +358,7 @@ public MiningParameters toDomainObject() {
updatableInitValuesBuilder.coinbase(coinbase);
}
- return ImmutableMiningParameters.builder()
+ return ImmutableMiningConfiguration.builder()
.transactionSelectionService(transactionSelectionService)
.mutableInitValues(updatableInitValuesBuilder.build())
.isStratumMiningEnabled(iStratumMiningEnabled)
@@ -365,7 +367,7 @@ public MiningParameters toDomainObject() {
.nonPoaBlockTxsSelectionMaxTime(nonPoaBlockTxsSelectionMaxTime)
.poaBlockTxsSelectionMaxTime(poaBlockTxsSelectionMaxTime)
.unstable(
- ImmutableMiningParameters.Unstable.builder()
+ ImmutableMiningConfiguration.Unstable.builder()
.remoteSealersLimit(unstableOptions.remoteSealersLimit)
.remoteSealersTimeToLive(unstableOptions.remoteSealersTimeToLive)
.powJobTimeToLive(unstableOptions.powJobTimeToLive)
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NatOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NatOptions.java
similarity index 97%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NatOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/NatOptions.java
index 31716543d51..11e8051d0e3 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NatOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NatOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.nat.kubernetes.KubernetesNatManager.DEFAULT_BESU_SERVICE_NAME_FILTER;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NativeLibraryOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NativeLibraryOptions.java
similarity index 98%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NativeLibraryOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/NativeLibraryOptions.java
index ec7f043b8f1..f3fc9c3ba4a 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NativeLibraryOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NativeLibraryOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import picocli.CommandLine;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NetworkingOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NetworkingOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NetworkingOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/NetworkingOptions.java
index aed7b079d87..dc001d02311 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/NetworkingOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NetworkingOptions.java
@@ -12,10 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
-import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import java.util.Arrays;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java b/besu/src/main/java/org/hyperledger/besu/cli/options/NodePrivateKeyFileOption.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/NodePrivateKeyFileOption.java
index 107ced545d1..781dcb06e8a 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/NodePrivateKeyFileOption.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/NodePrivateKeyFileOption.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.cli.DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PDiscoveryOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PDiscoveryOptions.java
similarity index 98%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PDiscoveryOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/P2PDiscoveryOptions.java
index a15be99dc74..798d246b52b 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/P2PDiscoveryOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PDiscoveryOptions.java
@@ -12,12 +12,11 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.converter.PercentageConverter;
import org.hyperledger.besu.cli.converter.SubnetInfoConverter;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/P2PTLSConfigOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PTLSConfigOptions.java
similarity index 99%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/P2PTLSConfigOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/P2PTLSConfigOptions.java
index 5939eb3d390..ee53a5e96f4 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/P2PTLSConfigOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/P2PTLSConfigOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import static java.util.Arrays.asList;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_KEYSTORE_TYPE;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/PermissionsOptions.java
similarity index 99%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/PermissionsOptions.java
index 4dc693d36ed..b6c744c98f7 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PermissionsOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/PermissionsOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.datatypes.Address;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/PluginsConfigurationOptions.java
similarity index 97%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/PluginsConfigurationOptions.java
index 25893fff895..5a5a0646080 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/PluginsConfigurationOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/PluginsConfigurationOptions.java
@@ -12,14 +12,13 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_CONTINUE_ON_PLUGIN_ERROR_OPTION_NAME;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_EXTERNAL_ENABLED_OPTION_NAME;
import static org.hyperledger.besu.cli.DefaultCommandValues.DEFAULT_PLUGINS_OPTION_NAME;
import org.hyperledger.besu.cli.converter.PluginInfoConverter;
-import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.cli.util.CommandLineUtils;
import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration;
import org.hyperledger.besu.ethereum.core.plugins.PluginInfo;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/PrivacyPluginOptions.java
similarity index 96%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/PrivacyPluginOptions.java
index fe2f4df3fe8..9a8c0348e8b 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/PrivacyPluginOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/PrivacyPluginOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import static picocli.CommandLine.Option;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/RPCOptions.java
similarity index 97%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/RPCOptions.java
index 2dd11f428d6..63759af1c63 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/RPCOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/RPCOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java
similarity index 67%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java
index 40edeecc0da..2dde517ccc7 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/stable/RpcWebsocketOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/RpcWebsocketOptions.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS;
import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.VALID_APIS;
@@ -120,6 +120,71 @@ public class RpcWebsocketOptions {
arity = "1")
private final File rpcWsAuthenticationPublicKeyFile = null;
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-enabled"},
+ description = "Enable SSL/TLS for the WebSocket RPC service")
+ private final Boolean isRpcWsSslEnabled = false;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-keystore-file"},
+ paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP,
+ description = "Path to the keystore file for the WebSocket RPC service")
+ private String rpcWsKeyStoreFile = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-keystore-password"},
+ paramLabel = "",
+ description = "Password for the WebSocket RPC keystore file")
+ private String rpcWsKeyStorePassword = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-key-file"},
+ paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP,
+ description = "Path to the PEM key file for the WebSocket RPC service")
+ private String rpcWsKeyFile = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-cert-file"},
+ paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP,
+ description = "Path to the PEM cert file for the WebSocket RPC service")
+ private String rpcWsCertFile = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-keystore-type"},
+ paramLabel = "",
+ description = "Type of the WebSocket RPC keystore (JKS, PKCS12, PEM)")
+ private String rpcWsKeyStoreType = null;
+
+ // For client authentication (mTLS)
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-client-auth-enabled"},
+ description = "Enable client authentication for the WebSocket RPC service")
+ private final Boolean isRpcWsClientAuthEnabled = false;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-truststore-file"},
+ paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP,
+ description = "Path to the truststore file for the WebSocket RPC service")
+ private String rpcWsTrustStoreFile = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-truststore-password"},
+ paramLabel = "",
+ description = "Password for the WebSocket RPC truststore file")
+ private String rpcWsTrustStorePassword = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-trustcert-file"},
+ paramLabel = DefaultCommandValues.MANDATORY_FILE_FORMAT_HELP,
+ description = "Path to the PEM trustcert file for the WebSocket RPC service")
+ private String rpcWsTrustCertFile = null;
+
+ @CommandLine.Option(
+ names = {"--rpc-ws-ssl-truststore-type"},
+ paramLabel = "",
+ description = "Type of the truststore (JKS, PKCS12, PEM)")
+ private String rpcWsTrustStoreType = null;
+
/** Default Constructor. */
public RpcWebsocketOptions() {}
@@ -184,7 +249,61 @@ private void checkOptionDependencies(final Logger logger, final CommandLine comm
"--rpc-ws-authentication-enabled",
"--rpc-ws-authentication-credentials-file",
"--rpc-ws-authentication-public-key-file",
- "--rpc-ws-authentication-jwt-algorithm"));
+ "--rpc-ws-authentication-jwt-algorithm",
+ "--rpc-ws-ssl-enabled"));
+
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-enabled",
+ !isRpcWsSslEnabled,
+ List.of(
+ "--rpc-ws-ssl-keystore-file",
+ "--rpc-ws-ssl-keystore-type",
+ "--rpc-ws-ssl-client-auth-enabled"));
+
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-client-auth-enabled",
+ !isRpcWsClientAuthEnabled,
+ List.of(
+ "--rpc-ws-ssl-truststore-file",
+ "--rpc-ws-ssl-truststore-type",
+ "--rpc-ws-ssl-trustcert-file"));
+
+ if (isRpcWsSslEnabled) {
+ if ("PEM".equalsIgnoreCase(rpcWsKeyStoreType)) {
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-key-file",
+ rpcWsKeyFile == null,
+ List.of("--rpc-ws-ssl-cert-file"));
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-cert-file",
+ rpcWsCertFile == null,
+ List.of("--rpc-ws-ssl-key-file"));
+ } else {
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-keystore-file",
+ rpcWsKeyStoreFile == null,
+ List.of("--rpc-ws-ssl-keystore-password"));
+ }
+ }
+
+ if (isRpcWsClientAuthEnabled && !"PEM".equalsIgnoreCase(rpcWsTrustStoreType)) {
+ CommandLineUtils.checkOptionDependencies(
+ logger,
+ commandLine,
+ "--rpc-ws-ssl-truststore-file",
+ rpcWsTrustStoreFile == null,
+ List.of("--rpc-ws-ssl-truststore-password"));
+ }
if (isRpcWsAuthenticationEnabled) {
CommandLineUtils.checkOptionDependencies(
@@ -222,6 +341,18 @@ public WebSocketConfiguration webSocketConfiguration(
webSocketConfiguration.setAuthenticationPublicKeyFile(rpcWsAuthenticationPublicKeyFile);
webSocketConfiguration.setAuthenticationAlgorithm(rpcWebsocketsAuthenticationAlgorithm);
webSocketConfiguration.setTimeoutSec(wsTimoutSec);
+ webSocketConfiguration.setSslEnabled(isRpcWsSslEnabled);
+ webSocketConfiguration.setKeyStorePath(rpcWsKeyStoreFile);
+ webSocketConfiguration.setKeyStorePassword(rpcWsKeyStorePassword);
+ webSocketConfiguration.setKeyStoreType(rpcWsKeyStoreType);
+ webSocketConfiguration.setClientAuthEnabled(isRpcWsClientAuthEnabled);
+ webSocketConfiguration.setTrustStorePath(rpcWsTrustStoreFile);
+ webSocketConfiguration.setTrustStorePassword(rpcWsTrustStorePassword);
+ webSocketConfiguration.setTrustStoreType(rpcWsTrustStoreType);
+ webSocketConfiguration.setKeyPath(rpcWsKeyFile);
+ webSocketConfiguration.setCertPath(rpcWsCertFile);
+ webSocketConfiguration.setTrustCertPath(rpcWsTrustCertFile);
+
return webSocketConfiguration;
}
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/SynchronizerOptions.java
similarity index 99%
rename from besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java
rename to besu/src/main/java/org/hyperledger/besu/cli/options/SynchronizerOptions.java
index 816d9df00a1..c7d20c17fb6 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/options/unstable/SynchronizerOptions.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/options/SynchronizerOptions.java
@@ -12,10 +12,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.unstable;
+package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.CLIOptions;
-import org.hyperledger.besu.cli.options.OptionParser;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.ImmutableSnapSyncConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java
index 73916a936ef..593fc6cd778 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PublicKeySubCommand.java
@@ -20,7 +20,7 @@
import org.hyperledger.besu.cli.BesuCommand;
import org.hyperledger.besu.cli.DefaultCommandValues;
-import org.hyperledger.besu.cli.options.stable.NodePrivateKeyFileOption;
+import org.hyperledger.besu.cli.options.NodePrivateKeyFileOption;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.AddressSubCommand;
import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand.ExportSubCommand;
import org.hyperledger.besu.cli.util.VersionProvider;
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java
index 67af49c400e..0074775f459 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java
@@ -80,7 +80,7 @@ public class RetestethSubCommand implements Runnable {
private final Integer rpcHttpPort = RETESTETH_PORT;
@Option(
- names = {"--host-allowlist", "--host-whitelist"},
+ names = {"--host-allowlist"},
paramLabel = "[,...]... or * or all",
description =
"Comma separated list of hostnames to allow for RPC access, or * to accept any host (default: ${DEFAULT-VALUE})",
@@ -147,3 +147,4 @@ public void run() {
}
}
}
+
diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java
index 5bd0aacee28..95617fe8ca1 100644
--- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java
+++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java
@@ -31,9 +31,9 @@
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.IncrementingNonceGenerator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.metrics.MetricsService;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
@@ -265,12 +265,12 @@ private BesuController createController() {
}
}
- private MiningParameters getMiningParameters() {
+ private MiningConfiguration getMiningParameters() {
final Wei minTransactionGasPrice = Wei.ZERO;
// Extradata and coinbase can be configured on a per-block level via the json file
final Address coinbase = Address.ZERO;
final Bytes extraData = Bytes.EMPTY;
- return ImmutableMiningParameters.builder()
+ return ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.nonceGenerator(new IncrementingNonceGenerator(0))
@@ -377,7 +377,7 @@ private BesuController createBesuController() {
return parentCommand
.parentCommand
.setupControllerBuilder()
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.build();
}
diff --git a/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java b/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java
index e757fd62a2b..ce4f00db737 100644
--- a/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java
+++ b/besu/src/main/java/org/hyperledger/besu/components/BesuCommandModule.java
@@ -20,8 +20,8 @@
import org.hyperledger.besu.chainimport.JsonBlockImporter;
import org.hyperledger.besu.chainimport.RlpBlockImporter;
import org.hyperledger.besu.cli.BesuCommand;
-import org.hyperledger.besu.cli.options.stable.P2PDiscoveryOptions;
-import org.hyperledger.besu.cli.options.unstable.RPCOptions;
+import org.hyperledger.besu.cli.options.P2PDiscoveryOptions;
+import org.hyperledger.besu.cli.options.RPCOptions;
import org.hyperledger.besu.controller.BesuController;
import org.hyperledger.besu.ethereum.p2p.discovery.P2PDiscoveryConfiguration;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java
index fb99318905a..238e5c3c1c0 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java
@@ -24,7 +24,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
@@ -71,7 +71,7 @@ public class BesuController implements java.io.Closeable {
private final MiningCoordinator miningCoordinator;
private final PrivacyParameters privacyParameters;
private final List closeables;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
private final PluginServiceFactory additionalPluginServices;
private final SyncState syncState;
private final EthPeers ethPeers;
@@ -91,7 +91,7 @@ public class BesuController implements java.io.Closeable {
* @param transactionPool the transaction pool
* @param miningCoordinator the mining coordinator
* @param privacyParameters the privacy parameters
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param additionalJsonRpcMethodsFactory the additional json rpc methods factory
* @param nodeKey the node key
* @param closeables the closeables
@@ -111,7 +111,7 @@ public class BesuController implements java.io.Closeable {
final TransactionPool transactionPool,
final MiningCoordinator miningCoordinator,
final PrivacyParameters privacyParameters,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final JsonRpcMethods additionalJsonRpcMethodsFactory,
final NodeKey nodeKey,
final List closeables,
@@ -132,7 +132,7 @@ public class BesuController implements java.io.Closeable {
this.miningCoordinator = miningCoordinator;
this.privacyParameters = privacyParameters;
this.closeables = closeables;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
this.additionalPluginServices = additionalPluginServices;
this.ethPeers = ethPeers;
this.storageProvider = storageProvider;
@@ -265,8 +265,8 @@ public PrivacyParameters getPrivacyParameters() {
*
* @return the mining parameters
*/
- public MiningParameters getMiningParameters() {
- return miningParameters;
+ public MiningConfiguration getMiningParameters() {
+ return miningConfiguration;
}
/**
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
index a26bcb9811a..9059d2209bd 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
@@ -43,8 +43,9 @@
import org.hyperledger.besu.ethereum.chain.VariablesStorage;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
+import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.SnapProtocol;
@@ -55,6 +56,8 @@
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter;
import org.hyperledger.besu.ethereum.eth.manager.MonitoredExecutors;
+import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskExecutor;
+import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskRequestSender;
import org.hyperledger.besu.ethereum.eth.manager.snap.SnapProtocolManager;
import org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator;
import org.hyperledger.besu.ethereum.eth.peervalidation.ClassicForkPeerValidator;
@@ -91,6 +94,7 @@
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
+import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive.WorldStateHealer;
import org.hyperledger.besu.ethereum.worldstate.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator;
@@ -111,6 +115,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.OptionalLong;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
import org.slf4j.Logger;
@@ -142,7 +147,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
protected BigInteger networkId;
/** The Mining parameters. */
- protected MiningParameters miningParameters;
+ protected MiningConfiguration miningConfiguration;
/** The Metrics system. */
protected ObservableMetricsSystem metricsSystem;
@@ -294,11 +299,11 @@ public BesuControllerBuilder networkId(final BigInteger networkId) {
/**
* Mining parameters besu controller builder.
*
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @return the besu controller builder
*/
- public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
return this;
}
@@ -541,7 +546,7 @@ public BesuController build() {
checkNotNull(syncConfig, "Missing sync config");
checkNotNull(ethereumWireProtocolConfiguration, "Missing ethereum protocol configuration");
checkNotNull(networkId, "Missing network ID");
- checkNotNull(miningParameters, "Missing mining parameters");
+ checkNotNull(miningConfiguration, "Missing mining parameters");
checkNotNull(metricsSystem, "Missing metrics system");
checkNotNull(privacyParameters, "Missing privacy parameters");
checkNotNull(dataDirectory, "Missing data directory"); // Why do we need this?
@@ -587,9 +592,14 @@ public BesuController build() {
.map(BesuComponent::getCachedMerkleTrieLoader)
.orElseGet(() -> new BonsaiCachedMerkleTrieLoader(metricsSystem));
+ final var worldStateHealerSupplier = new AtomicReference();
+
final WorldStateArchive worldStateArchive =
createWorldStateArchive(
- worldStateStorageCoordinator, blockchain, bonsaiCachedMerkleTrieLoader);
+ worldStateStorageCoordinator,
+ blockchain,
+ bonsaiCachedMerkleTrieLoader,
+ worldStateHealerSupplier::get);
if (maybeStoredGenesisBlockHash.isEmpty()) {
genesisState.writeStateTo(worldStateArchive.getMutable());
@@ -653,6 +663,8 @@ public BesuController build() {
}
final EthContext ethContext = new EthContext(ethPeers, ethMessages, snapMessages, scheduler);
+ final PeerTaskExecutor peerTaskExecutor =
+ new PeerTaskExecutor(ethPeers, new PeerTaskRequestSender(), metricsSystem);
final boolean fullSyncDisabled = !SyncMode.isFullSync(syncConfig.getSyncMode());
final SyncState syncState = new SyncState(blockchain, ethPeers, fullSyncDisabled, checkpoint);
@@ -676,7 +688,7 @@ public BesuController build() {
syncState,
transactionPoolConfiguration,
besuComponent.map(BesuComponent::getBlobCache).orElse(new BlobCache()),
- miningParameters);
+ miningConfiguration);
final List peerValidators = createPeerValidators(protocolSchedule);
@@ -704,10 +716,13 @@ public BesuController build() {
worldStateStorageCoordinator,
protocolContext,
ethContext,
+ peerTaskExecutor,
syncState,
ethProtocolManager,
pivotBlockSelector);
+ worldStateHealerSupplier.set(synchronizer::healWorldState);
+
ethPeers.setTrailingPeerRequirementsSupplier(synchronizer::calculateTrailingPeerRequirements);
if (syncConfig.getSyncMode() == SyncMode.SNAP
@@ -718,18 +733,16 @@ public BesuController build() {
ethPeers.snapServerPeersNeeded(false);
}
- protocolContext.setSynchronizer(synchronizer);
-
final Optional maybeSnapProtocolManager =
createSnapProtocolManager(
- protocolContext, worldStateStorageCoordinator, ethPeers, snapMessages);
+ protocolContext, worldStateStorageCoordinator, ethPeers, snapMessages, synchronizer);
final MiningCoordinator miningCoordinator =
createMiningCoordinator(
protocolSchedule,
protocolContext,
transactionPool,
- miningParameters,
+ miningConfiguration,
syncState,
ethProtocolManager);
@@ -740,7 +753,8 @@ public BesuController build() {
createSubProtocolConfiguration(ethProtocolManager, maybeSnapProtocolManager);
final JsonRpcMethods additionalJsonRpcMethodFactory =
- createAdditionalJsonRpcMethodFactory(protocolContext, protocolSchedule, miningParameters);
+ createAdditionalJsonRpcMethodFactory(
+ protocolContext, protocolSchedule, miningConfiguration);
if (DataStorageFormat.BONSAI.equals(dataStorageConfiguration.getDataStorageFormat())) {
final DiffBasedSubStorageConfiguration subStorageConfiguration =
@@ -774,7 +788,7 @@ public BesuController build() {
transactionPool,
miningCoordinator,
privacyParameters,
- miningParameters,
+ miningConfiguration,
additionalJsonRpcMethodFactory,
nodeKey,
closeables,
@@ -830,6 +844,7 @@ private TrieLogPruner createTrieLogPruner(
* @param worldStateStorageCoordinator the world state storage
* @param protocolContext the protocol context
* @param ethContext the eth context
+ * @param peerTaskExecutor the PeerTaskExecutor
* @param syncState the sync state
* @param ethProtocolManager the eth protocol manager
* @param pivotBlockSelector the pivot block selector
@@ -840,6 +855,7 @@ protected DefaultSynchronizer createSynchronizer(
final WorldStateStorageCoordinator worldStateStorageCoordinator,
final ProtocolContext protocolContext,
final EthContext ethContext,
+ final PeerTaskExecutor peerTaskExecutor,
final SyncState syncState,
final EthProtocolManager ethProtocolManager,
final PivotBlockSelector pivotBlockSelector) {
@@ -851,6 +867,7 @@ protected DefaultSynchronizer createSynchronizer(
worldStateStorageCoordinator,
ethProtocolManager.getBlockBroadcaster(),
ethContext,
+ peerTaskExecutor,
syncState,
dataDirectory,
storageProvider,
@@ -930,13 +947,13 @@ protected void prepForBuild() {}
*
* @param protocolContext the protocol context
* @param protocolSchedule the protocol schedule
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @return the json rpc methods
*/
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
return apis -> Collections.emptyMap();
}
@@ -964,7 +981,7 @@ protected SubProtocolConfiguration createSubProtocolConfiguration(
* @param protocolSchedule the protocol schedule
* @param protocolContext the protocol context
* @param transactionPool the transaction pool
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param syncState the sync state
* @param ethProtocolManager the eth protocol manager
* @return the mining coordinator
@@ -973,7 +990,7 @@ protected abstract MiningCoordinator createMiningCoordinator(
ProtocolSchedule protocolSchedule,
ProtocolContext protocolContext,
TransactionPool transactionPool,
- MiningParameters miningParameters,
+ MiningConfiguration miningConfiguration,
SyncState syncState,
EthProtocolManager ethProtocolManager);
@@ -1079,20 +1096,23 @@ private Optional createSnapProtocolManager(
final ProtocolContext protocolContext,
final WorldStateStorageCoordinator worldStateStorageCoordinator,
final EthPeers ethPeers,
- final EthMessages snapMessages) {
+ final EthMessages snapMessages,
+ final Synchronizer synchronizer) {
return Optional.of(
new SnapProtocolManager(
worldStateStorageCoordinator,
syncConfig.getSnapSyncConfiguration(),
ethPeers,
snapMessages,
- protocolContext));
+ protocolContext,
+ synchronizer));
}
WorldStateArchive createWorldStateArchive(
final WorldStateStorageCoordinator worldStateStorageCoordinator,
final Blockchain blockchain,
- final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader) {
+ final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader,
+ final Supplier worldStateHealerSupplier) {
return switch (dataStorageConfiguration.getDataStorageFormat()) {
case BONSAI -> {
final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage =
@@ -1107,7 +1127,8 @@ yield new BonsaiWorldStateProvider(
.getMaxLayersToLoad()),
bonsaiCachedMerkleTrieLoader,
besuComponent.map(BesuComponent::getBesuPluginContext).orElse(null),
- evmConfiguration);
+ evmConfiguration,
+ worldStateHealerSupplier);
}
case FOREST -> {
final WorldStatePreimageStorage preimageStorage =
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java
index b4ada605498..edb55a11265 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java
@@ -36,7 +36,7 @@
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
@@ -74,8 +74,8 @@ protected void prepForBuild() {
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
- return new CliqueJsonRpcMethods(protocolContext, protocolSchedule, miningParameters);
+ final MiningConfiguration miningConfiguration) {
+ return new CliqueJsonRpcMethods(protocolContext, protocolSchedule, miningConfiguration);
}
@Override
@@ -83,7 +83,7 @@ protected MiningCoordinator createMiningCoordinator(
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
final CliqueMinerExecutor miningExecutor =
@@ -92,7 +92,7 @@ protected MiningCoordinator createMiningCoordinator(
protocolSchedule,
transactionPool,
nodeKey,
- miningParameters,
+ miningConfiguration,
new CliqueBlockScheduler(
clock,
protocolContext.getConsensusContext(CliqueContext.class).getValidatorProvider(),
@@ -113,7 +113,7 @@ protected MiningCoordinator createMiningCoordinator(
.getBlockchain()
.observeBlockAdded(
o ->
- miningParameters.setBlockPeriodSeconds(
+ miningConfiguration.setBlockPeriodSeconds(
forksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue()
@@ -135,7 +135,7 @@ protected ProtocolSchedule createProtocolSchedule() {
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -172,7 +172,7 @@ protected CliqueContext createConsensusContext(
}
@Override
- public MiningParameters getMiningParameterOverrides(final MiningParameters fromCli) {
+ public MiningConfiguration getMiningParameterOverrides(final MiningConfiguration fromCli) {
// Clique mines by default, reflect that with in the mining parameters:
return fromCli.setMiningEnabled(true);
}
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java
index 0d0f8d2fd87..3ecd5a6c413 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java
@@ -33,7 +33,7 @@
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@@ -128,7 +128,7 @@ protected MiningCoordinator createMiningCoordinator(
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
@@ -143,7 +143,7 @@ protected MiningCoordinator createMiningCoordinator(
protocolSchedule,
protocolContext,
transactionPool,
- miningParameters,
+ miningConfiguration,
syncState,
ethProtocolManager)))
.collect(Collectors.toList());
@@ -206,10 +206,11 @@ protected PluginServiceFactory createAdditionalPluginServices(
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
return besuControllerBuilderSchedule
.get(0L)
- .createAdditionalJsonRpcMethodFactory(protocolContext, protocolSchedule, miningParameters);
+ .createAdditionalJsonRpcMethodFactory(
+ protocolContext, protocolSchedule, miningConfiguration);
}
@Override
@@ -297,9 +298,9 @@ public BesuControllerBuilder networkId(final BigInteger networkId) {
}
@Override
- public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) {
- besuControllerBuilderSchedule.values().forEach(b -> b.miningParameters(miningParameters));
- return super.miningParameters(miningParameters);
+ public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) {
+ besuControllerBuilderSchedule.values().forEach(b -> b.miningParameters(miningConfiguration));
+ return super.miningParameters(miningConfiguration);
}
@Override
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
index 738dcfc5963..ae08b11cca4 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
@@ -60,7 +60,7 @@
import org.hyperledger.besu.ethereum.chain.MinedBlockObserver;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.SnapProtocol;
@@ -114,8 +114,8 @@ protected void prepForBuild() {
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
- return new IbftJsonRpcMethods(protocolContext, protocolSchedule, miningParameters);
+ final MiningConfiguration miningConfiguration) {
+ return new IbftJsonRpcMethods(protocolContext, protocolSchedule, miningConfiguration);
}
@Override
@@ -141,7 +141,7 @@ protected MiningCoordinator createMiningCoordinator(
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
final MutableBlockchain blockchain = protocolContext.getBlockchain();
@@ -156,7 +156,7 @@ protected MiningCoordinator createMiningCoordinator(
protocolContext,
bftProtocolSchedule,
forksSchedule,
- miningParameters,
+ miningConfiguration,
localAddress,
bftExtraDataCodec().get(),
ethProtocolManager.ethContext().getScheduler());
@@ -247,7 +247,7 @@ protected MiningCoordinator createMiningCoordinator(
.getBlockchain()
.observeBlockAdded(
o ->
- miningParameters.setBlockPeriodSeconds(
+ miningConfiguration.setBlockPeriodSeconds(
forksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue()
@@ -303,7 +303,7 @@ protected ProtocolSchedule createProtocolSchedule() {
isRevertReasonEnabled,
bftExtraDataCodec().get(),
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java
index e0fbed608ab..a642539ac5d 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java
@@ -21,7 +21,7 @@
import org.hyperledger.besu.ethereum.blockcreation.PoWMinerExecutor;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -31,6 +31,8 @@
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
+import java.util.Optional;
+
/** The Mainnet besu controller builder. */
public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
@@ -44,7 +46,7 @@ protected MiningCoordinator createMiningCoordinator(
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
@@ -53,7 +55,7 @@ protected MiningCoordinator createMiningCoordinator(
protocolContext,
protocolSchedule,
transactionPool,
- miningParameters,
+ miningConfiguration,
new DefaultBlockScheduler(
MainnetBlockHeaderValidator.MINIMUM_SECONDS_SINCE_PARENT,
MainnetBlockHeaderValidator.TIMESTAMP_TOLERANCE_S,
@@ -66,11 +68,11 @@ protected MiningCoordinator createMiningCoordinator(
protocolContext.getBlockchain(),
executor,
syncState,
- miningParameters.getUnstable().getRemoteSealersLimit(),
- miningParameters.getUnstable().getRemoteSealersTimeToLive());
+ miningConfiguration.getUnstable().getRemoteSealersLimit(),
+ miningConfiguration.getUnstable().getRemoteSealersTimeToLive());
miningCoordinator.addMinedBlockObserver(ethProtocolManager);
- miningCoordinator.setStratumMiningEnabled(miningParameters.isStratumMiningEnabled());
- if (miningParameters.isMiningEnabled()) {
+ miningCoordinator.setStratumMiningEnabled(miningConfiguration.isStratumMiningEnabled());
+ if (miningConfiguration.isMiningEnabled()) {
miningCoordinator.enable();
}
@@ -95,10 +97,10 @@ protected PluginServiceFactory createAdditionalPluginServices(
protected ProtocolSchedule createProtocolSchedule() {
return MainnetProtocolSchedule.fromConfig(
genesisConfigOptions,
- privacyParameters,
- isRevertReasonEnabled,
- evmConfiguration,
- miningParameters,
+ Optional.of(privacyParameters),
+ Optional.of(isRevertReasonEnabled),
+ Optional.of(evmConfiguration),
+ super.miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
index f5fc75959e1..e7c1a5c40d8 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
@@ -26,7 +26,7 @@
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthMessages;
@@ -67,14 +67,14 @@ protected MiningCoordinator createMiningCoordinator(
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
return createTransitionMiningCoordinator(
protocolSchedule,
protocolContext,
transactionPool,
- miningParameters,
+ miningConfiguration,
syncState,
new BackwardSyncContext(
protocolContext,
@@ -140,7 +140,7 @@ protected EthProtocolManager createEthProtocolManager(
* @param protocolSchedule the protocol schedule
* @param protocolContext the protocol context
* @param transactionPool the transaction pool
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param syncState the sync state
* @param backwardSyncContext the backward sync context
* @param ethScheduler the scheduler
@@ -150,7 +150,7 @@ protected MiningCoordinator createTransitionMiningCoordinator(
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final BackwardSyncContext backwardSyncContext,
final EthScheduler ethScheduler) {
@@ -165,7 +165,7 @@ protected MiningCoordinator createTransitionMiningCoordinator(
protocolSchedule,
ethScheduler,
transactionPool,
- miningParameters,
+ miningConfiguration,
backwardSyncContext,
depositContractAddress);
}
@@ -176,7 +176,7 @@ protected ProtocolSchedule createProtocolSchedule() {
genesisConfigOptions,
privacyParameters,
isRevertReasonEnabled,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java b/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java
index e4cebc0d648..ae2ae250ba7 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java
@@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.controller;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
/**
* This interface wraps the provided MiningParameters to enable controller-specific parameter
@@ -27,7 +27,7 @@ public interface MiningParameterOverrides {
* @param fromCli The mining parameters that contains original values.
* @return MiningParameters constructed from provided param with additional overridden parameters.
*/
- default MiningParameters getMiningParameterOverrides(final MiningParameters fromCli) {
+ default MiningConfiguration getMiningParameterOverrides(final MiningConfiguration fromCli) {
return fromCli;
}
}
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
index 498435e4afb..75aff308714 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
@@ -69,7 +69,7 @@
import org.hyperledger.besu.ethereum.chain.MinedBlockObserver;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.SnapProtocol;
@@ -130,12 +130,12 @@ protected void prepForBuild() {
protected JsonRpcMethods createAdditionalJsonRpcMethodFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
return new QbftJsonRpcMethods(
protocolContext,
protocolSchedule,
- miningParameters,
+ miningConfiguration,
createReadOnlyValidatorProvider(protocolContext.getBlockchain()),
bftConfigOptions);
}
@@ -181,7 +181,7 @@ protected MiningCoordinator createMiningCoordinator(
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
final MutableBlockchain blockchain = protocolContext.getBlockchain();
@@ -196,7 +196,7 @@ protected MiningCoordinator createMiningCoordinator(
protocolContext,
bftProtocolSchedule,
qbftForksSchedule,
- miningParameters,
+ miningConfiguration,
localAddress,
bftExtraDataCodec().get(),
ethProtocolManager.ethContext().getScheduler());
@@ -289,12 +289,12 @@ protected MiningCoordinator createMiningCoordinator(
.getBlockchain()
.observeBlockAdded(
o -> {
- miningParameters.setBlockPeriodSeconds(
+ miningConfiguration.setBlockPeriodSeconds(
qbftForksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue()
.getBlockPeriodSeconds());
- miningParameters.setEmptyBlockPeriodSeconds(
+ miningConfiguration.setEmptyBlockPeriodSeconds(
qbftForksSchedule
.getFork(o.getBlock().getHeader().getNumber() + 1)
.getValue()
@@ -351,7 +351,7 @@ protected ProtocolSchedule createProtocolSchedule() {
isRevertReasonEnabled,
bftExtraDataCodec().get(),
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java
index ee2611d9c87..3530621fc6a 100644
--- a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java
+++ b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java
@@ -30,8 +30,8 @@
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@@ -40,6 +40,7 @@
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.manager.MergePeerFilter;
+import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTaskExecutor;
import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator;
import org.hyperledger.besu.ethereum.eth.sync.DefaultSynchronizer;
import org.hyperledger.besu.ethereum.eth.sync.PivotBlockSelector;
@@ -101,7 +102,7 @@ protected MiningCoordinator createMiningCoordinator(
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final SyncState syncState,
final EthProtocolManager ethProtocolManager) {
@@ -111,8 +112,8 @@ protected MiningCoordinator createMiningCoordinator(
// PoA consensus mines by default, get consensus-specific mining parameters for
// TransitionCoordinator:
- MiningParameters transitionMiningParameters =
- preMergeBesuControllerBuilder.getMiningParameterOverrides(miningParameters);
+ MiningConfiguration transitionMiningConfiguration =
+ preMergeBesuControllerBuilder.getMiningParameterOverrides(miningConfiguration);
// construct a transition backward sync context
BackwardSyncContext transitionBackwardsSyncContext =
@@ -130,10 +131,10 @@ protected MiningCoordinator createMiningCoordinator(
transitionProtocolSchedule.getPreMergeSchedule(),
protocolContext,
transactionPool,
- ImmutableMiningParameters.builder()
- .from(miningParameters)
+ ImmutableMiningConfiguration.builder()
+ .from(miningConfiguration)
.mutableInitValues(
- ImmutableMiningParameters.MutableInitValues.builder()
+ ImmutableMiningConfiguration.MutableInitValues.builder()
.isMiningEnabled(false)
.build())
.build(),
@@ -143,7 +144,7 @@ protected MiningCoordinator createMiningCoordinator(
transitionProtocolSchedule,
protocolContext,
transactionPool,
- transitionMiningParameters,
+ transitionMiningConfiguration,
syncState,
transitionBackwardsSyncContext,
ethProtocolManager.ethContext().getScheduler()));
@@ -225,6 +226,7 @@ protected DefaultSynchronizer createSynchronizer(
final WorldStateStorageCoordinator worldStateStorageCoordinator,
final ProtocolContext protocolContext,
final EthContext ethContext,
+ final PeerTaskExecutor peerTaskExecutor,
final SyncState syncState,
final EthProtocolManager ethProtocolManager,
final PivotBlockSelector pivotBlockSelector) {
@@ -235,6 +237,7 @@ protected DefaultSynchronizer createSynchronizer(
worldStateStorageCoordinator,
protocolContext,
ethContext,
+ peerTaskExecutor,
syncState,
ethProtocolManager,
pivotBlockSelector);
@@ -326,9 +329,9 @@ public BesuControllerBuilder networkId(final BigInteger networkId) {
}
@Override
- public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) {
- super.miningParameters(miningParameters);
- return propagateConfig(z -> z.miningParameters(miningParameters));
+ public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) {
+ super.miningParameters(miningConfiguration);
+ return propagateConfig(z -> z.miningParameters(miningConfiguration));
}
@Override
diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java
index 0adbda23b74..f2f5fa53dae 100644
--- a/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java
+++ b/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java
@@ -14,9 +14,9 @@
*/
package org.hyperledger.besu.services;
-import org.hyperledger.besu.cli.options.stable.JsonRpcHttpOptions;
+import org.hyperledger.besu.cli.options.JsonRpcHttpOptions;
import org.hyperledger.besu.datatypes.Wei;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.plugin.services.BesuConfiguration;
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
@@ -31,7 +31,7 @@ public class BesuConfigurationImpl implements BesuConfiguration {
private DataStorageConfiguration dataStorageConfiguration;
// defaults
- private MiningParameters miningParameters = MiningParameters.newDefault();
+ private MiningConfiguration miningConfiguration;
private Optional rpcHttpHost = Optional.of("http://localhost");
private Optional rpcHttpPort = Optional.of(8545);
@@ -59,11 +59,11 @@ public BesuConfigurationImpl init(
/**
* Set the mining parameters
*
- * @param miningParameters configured mining parameters
+ * @param miningConfiguration configured mining parameters
* @return BesuConfigurationImpl instance
*/
- public BesuConfigurationImpl withMiningParameters(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public BesuConfigurationImpl withMiningParameters(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
return this;
}
@@ -106,7 +106,7 @@ public DataStorageFormat getDatabaseFormat() {
@Override
public Wei getMinGasPrice() {
- return miningParameters.getMinTransactionGasPrice();
+ return miningConfiguration.getMinTransactionGasPrice();
}
@Override
diff --git a/besu/src/main/java/org/hyperledger/besu/services/TransactionPoolServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/TransactionPoolServiceImpl.java
index 16d033ac9e4..b720b60b7c1 100644
--- a/besu/src/main/java/org/hyperledger/besu/services/TransactionPoolServiceImpl.java
+++ b/besu/src/main/java/org/hyperledger/besu/services/TransactionPoolServiceImpl.java
@@ -14,9 +14,12 @@
*/
package org.hyperledger.besu.services;
+import org.hyperledger.besu.datatypes.PendingTransaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.plugin.services.transactionpool.TransactionPoolService;
+import java.util.Collection;
+
/** Service to enable and disable the transaction pool. */
public class TransactionPoolServiceImpl implements TransactionPoolService {
@@ -40,4 +43,9 @@ public void disableTransactionPool() {
public void enableTransactionPool() {
transactionPool.setEnabled();
}
+
+ @Override
+ public Collection extends PendingTransaction> getPendingTransactions() {
+ return transactionPool.getPendingTransactions();
+ }
}
diff --git a/besu/src/main/scripts/unixStartScript.txt b/besu/src/main/scripts/unixStartScript.txt
index 3302b9c2fe1..9e5c5a300b0 100644
--- a/besu/src/main/scripts/unixStartScript.txt
+++ b/besu/src/main/scripts/unixStartScript.txt
@@ -182,19 +182,19 @@ APP_ARGS=`save "\$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- \$DEFAULT_JVM_OPTS \$JAVA_OPTS \$${optsEnvironmentVar} <% if ( appNameSystemProperty ) { %>"\"-D${appNameSystemProperty}=\$APP_BASE_NAME\"" <% } %>-classpath "\"\$CLASSPATH\"" <% if ( mainClassName.startsWith('--module ') ) { %>--module-path "\"\$MODULE_PATH\"" <% } %>${mainClassName} "\$APP_ARGS"
-unset BESU_USING_JEMALLOC
if [ "\$darwin" = "false" -a "\$msys" = "false" ]; then
- # check if jemalloc is available
- TEST_JEMALLOC=\$(LD_PRELOAD=libjemalloc.so sh -c true 2>&1)
-
- # if jemalloc is available the output is empty, otherwise the output has an error line
- if [ -z "\$TEST_JEMALLOC" ]; then
- export LD_PRELOAD=libjemalloc.so
- export BESU_USING_JEMALLOC=true
- else
- # jemalloc not available, as fallback limit malloc to 2 arenas
- export MALLOC_ARENA_MAX=2
- fi
+ if [ "\$BESU_USING_JEMALLOC" != "FALSE" -a "\$BESU_USING_JEMALLOC" != "false" ]; then
+ # check if jemalloc is available
+ TEST_JEMALLOC=\$(LD_PRELOAD=libjemalloc.so sh -c true 2>&1)
+
+ # if jemalloc is available the output is empty, otherwise the output has an error line
+ if [ -z "\$TEST_JEMALLOC" ]; then
+ export LD_PRELOAD=libjemalloc.so
+ else
+ # jemalloc not available, as fallback limit malloc to 2 arenas
+ export MALLOC_ARENA_MAX=2
+ fi
+ fi
fi
exec "\$JAVACMD" "\$@"
diff --git a/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java
index a246d18d2ff..ff205e87519 100644
--- a/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java
@@ -31,7 +31,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@@ -150,7 +150,7 @@ BesuController provideBesuController(
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.dataStorageConfiguration(dataStorageConfiguration)
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
diff --git a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java
index 5a58091577c..87bab916f23 100644
--- a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java
@@ -31,7 +31,7 @@
import org.hyperledger.besu.ethereum.chain.GenesisState;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.forkid.ForkId;
import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@@ -174,7 +174,7 @@ private static MilestoneStreamingTransitionProtocolSchedule createSchedule(
(DefaultProtocolSchedule)
MainnetProtocolSchedule.fromConfig(
configOptions,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()));
@@ -184,7 +184,7 @@ private static MilestoneStreamingTransitionProtocolSchedule createSchedule(
MergeProtocolSchedule.create(
configOptions,
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()));
diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java
index 6298b70a953..a79b6644587 100644
--- a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java
@@ -47,7 +47,7 @@
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.InMemoryPrivacyStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
@@ -547,7 +547,7 @@ BesuController provideBesuController(
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.dataDirectory(dataDir)
diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java
index 4d488ced3bc..305d786b8bd 100644
--- a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java
@@ -31,7 +31,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@@ -125,7 +125,7 @@ BesuController provideBesuController(
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.dataStorageConfiguration(dataStorageConfiguration)
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
diff --git a/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java
index 7c5579d4711..230de6efd23 100644
--- a/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java
@@ -49,7 +49,7 @@
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@@ -128,7 +128,7 @@ public void setup() {
when(besuController.getProtocolContext()).thenReturn(protocolContext);
when(besuController.getProtocolSchedule()).thenReturn(protocolSchedule);
when(besuController.getNodeKey()).thenReturn(nodeKey);
- when(besuController.getMiningParameters()).thenReturn(mock(MiningParameters.class));
+ when(besuController.getMiningParameters()).thenReturn(mock(MiningConfiguration.class));
when(besuController.getPrivacyParameters()).thenReturn(mock(PrivacyParameters.class));
when(besuController.getTransactionPool())
.thenReturn(mock(TransactionPool.class, RETURNS_DEEP_STUBS));
diff --git a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java
index cbbf9804084..4239cbdc344 100644
--- a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java
@@ -46,7 +46,7 @@
import org.hyperledger.besu.ethereum.core.BlockImporter;
import org.hyperledger.besu.ethereum.core.BlockSyncTestUtils;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@@ -153,7 +153,15 @@ public void fullSyncFromGenesis() 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());
+ syncFromGenesis(SyncMode.FULL, getFastSyncGenesis(), false);
+ }
+
+ @Test
+ public void fullSyncFromGenesisUsingPeerTaskSystem() throws Exception {
+ // set merge flag to false, otherwise this test can fail if a merge test runs first
+ MergeConfiguration.setMergeEnabled(false);
+
+ syncFromGenesis(SyncMode.FULL, getFastSyncGenesis(), true);
}
@Test
@@ -161,10 +169,21 @@ public void fastSyncFromGenesis() 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());
+ syncFromGenesis(SyncMode.FAST, getFastSyncGenesis(), false);
+ }
+
+ @Test
+ public void fastSyncFromGenesisUsingPeerTaskSystem() throws Exception {
+ // set merge flag to false, otherwise this test can fail if a merge test runs first
+ MergeConfiguration.setMergeEnabled(false);
+
+ syncFromGenesis(SyncMode.FAST, getFastSyncGenesis(), true);
}
- private void syncFromGenesis(final SyncMode mode, final GenesisConfigFile genesisConfig)
+ private void syncFromGenesis(
+ final SyncMode mode,
+ final GenesisConfigFile genesisConfig,
+ final boolean isPeerTaskSystemEnabled)
throws Exception {
final Path dataDirAhead = Files.createTempDirectory(temp, "db-ahead");
final Path dbAhead = dataDirAhead.resolve("database");
@@ -172,9 +191,12 @@ private void syncFromGenesis(final SyncMode mode, final GenesisConfigFile genesi
final NodeKey aheadDbNodeKey = NodeKeyUtils.createFrom(KeyPairUtil.loadKeyPair(dataDirAhead));
final NodeKey behindDbNodeKey = NodeKeyUtils.generate();
final SynchronizerConfiguration syncConfigAhead =
- SynchronizerConfiguration.builder().syncMode(SyncMode.FULL).build();
+ SynchronizerConfiguration.builder()
+ .syncMode(SyncMode.FULL)
+ .isPeerTaskSystemEnabled(isPeerTaskSystemEnabled)
+ .build();
final ObservableMetricsSystem noOpMetricsSystem = new NoOpMetricsSystem();
- final var miningParameters = MiningParameters.newDefault();
+ final var miningParameters = MiningConfiguration.newDefault();
final var dataStorageConfiguration = DataStorageConfiguration.DEFAULT_FOREST_CONFIG;
// Setup Runner with blocks
final BesuController controllerAhead =
@@ -393,11 +415,11 @@ private StorageProvider createKeyValueStorageProvider(
final Path dataDir,
final Path dbDir,
final DataStorageConfiguration dataStorageConfiguration,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
final var besuConfiguration = new BesuConfigurationImpl();
besuConfiguration
.init(dataDir, dbDir, dataStorageConfiguration)
- .withMiningParameters(miningParameters);
+ .withMiningParameters(miningConfiguration);
return new KeyValueStorageProviderBuilder()
.withStorageFactory(
new RocksDBKeyValueStorageFactory(
@@ -466,14 +488,14 @@ private BesuController getController(
final NodeKey nodeKey,
final StorageProvider storageProvider,
final ObservableMetricsSystem metricsSystem,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
return new MainnetBesuControllerBuilder()
.genesisConfigFile(genesisConfig)
.synchronizerConfiguration(syncConfig)
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.dataDirectory(dataDir)
.networkId(NETWORK_ID)
- .miningParameters(miningParameters)
+ .miningParameters(miningConfiguration)
.nodeKey(nodeKey)
.storageProvider(storageProvider)
.metricsSystem(metricsSystem)
diff --git a/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java
index bbc7dea1abb..e76c06fe2d4 100644
--- a/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java
@@ -31,7 +31,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@@ -94,7 +94,7 @@ private static BesuController createController(final @TempDir Path dataDir) thro
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT)
diff --git a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java
index 7b1a4bc7d2c..2b534660ed2 100644
--- a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java
@@ -17,9 +17,10 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Mockito.mock;
+import org.hyperledger.besu.components.BesuCommandModule;
import org.hyperledger.besu.components.BesuComponent;
+import org.hyperledger.besu.components.BesuPluginContextModule;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.JsonUtil;
import org.hyperledger.besu.controller.BesuController;
@@ -31,17 +32,21 @@
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Transaction;
+import org.hyperledger.besu.ethereum.core.components.MiningParametersModule;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
+import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
+import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
+import org.hyperledger.besu.metrics.MetricsSystemModule;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@@ -52,9 +57,13 @@
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
+import javax.inject.Singleton;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.io.Resources;
+import dagger.Component;
+import dagger.Module;
+import dagger.Provides;
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -449,7 +458,7 @@ protected BesuController createController(final GenesisConfigFile genesisConfigF
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.valueOf(10))
.miningParameters(
- ImmutableMiningParameters.builder()
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
@@ -465,7 +474,28 @@ protected BesuController createController(final GenesisConfigFile genesisConfigF
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
- .besuComponent(mock(BesuComponent.class))
+ .besuComponent(DaggerJsonBlockImporterTest_JsonBlockImportComponent.builder().build())
.build();
}
+
+ @Module
+ public static class JsonBlockImporterModule {
+
+ @Provides
+ BonsaiCachedMerkleTrieLoader provideCachedMerkleTrieLoaderModule() {
+ return new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem());
+ }
+ }
+
+ @Singleton
+ @Component(
+ modules = {
+ BesuCommandModule.class,
+ MiningParametersModule.class,
+ MetricsSystemModule.class,
+ JsonBlockImporterModule.class,
+ BesuPluginContextModule.class,
+ BlobCacheModule.class
+ })
+ interface JsonBlockImportComponent extends BesuComponent {}
}
diff --git a/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java
index 2d9e587c3fa..9f405d4cb39 100644
--- a/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java
@@ -26,7 +26,7 @@
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
@@ -69,7 +69,7 @@ public void blockImport() throws IOException {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT)
@@ -103,7 +103,7 @@ public void blockImportRejectsBadPow() throws IOException {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT)
@@ -134,7 +134,7 @@ public void blockImportCanSkipPow() throws IOException {
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
.storageProvider(new InMemoryKeyValueStorageProvider())
.networkId(BigInteger.ONE)
- .miningParameters(MiningParameters.newDefault())
+ .miningParameters(MiningConfiguration.newDefault())
.nodeKey(NodeKeyUtils.generate())
.metricsSystem(new NoOpMetricsSystem())
.privacyParameters(PrivacyParameters.DEFAULT)
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
index 019e8d83cd3..eb789478b9a 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
@@ -37,9 +37,11 @@
import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNotNull;
+import static org.mockito.Mockito.argThat;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
import org.hyperledger.besu.BesuInfo;
import org.hyperledger.besu.cli.config.EthNetworkConfig;
@@ -56,7 +58,7 @@
import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
@@ -99,7 +101,6 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
@@ -277,8 +278,8 @@ public void callingBesuCommandWithoutOptionsMustSyncWithDefaultValues() {
verify(mockRunnerBuilder).build();
verify(mockControllerBuilderFactory).fromEthNetworkConfig(ethNetworkArg.capture(), any());
- final ArgumentCaptor miningArg =
- ArgumentCaptor.forClass(MiningParameters.class);
+ final ArgumentCaptor miningArg =
+ ArgumentCaptor.forClass(MiningConfiguration.class);
verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture());
verify(mockControllerBuilder).dataDirectory(isNotNull());
verify(mockControllerBuilder).miningParameters(miningArg.capture());
@@ -566,7 +567,7 @@ public void genesisAndNetworkMustNotBeUsedTogether() throws Exception {
parseCommand("--genesis-file", genesisFile.toString(), "--network", "mainnet");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
@@ -578,7 +579,7 @@ public void nonExistentGenesisGivesError() {
final String nonExistentGenesis = "non-existent-genesis.json";
parseCommand("--genesis-file", nonExistentGenesis);
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).startsWith("Unable to load genesis file");
@@ -1177,7 +1178,7 @@ public void remoteConnectionsPercentageWithInvalidFormatMustFail() {
parseCommand(
"--remote-connections-limit-enabled", "--remote-connections-max-percentage", "invalid");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1190,7 +1191,7 @@ public void remoteConnectionsPercentageWithOutOfRangeMustFail() {
parseCommand(
"--remote-connections-limit-enabled", "--remote-connections-max-percentage", "150");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1225,7 +1226,7 @@ public void syncMode_full_requires_bonsaiLimitTrieLogsToBeDisabled() {
@Test
public void syncMode_invalid() {
parseCommand("--sync-mode", "bogus");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
@@ -1275,7 +1276,7 @@ public void syncMode_snap_by_default() {
public void helpShouldDisplayFastSyncOptions() {
parseCommand("--help");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).contains("--fast-sync-min-peers");
// whitelist is now a hidden option
@@ -1335,7 +1336,7 @@ public void parsesValidSyncMinPeersOption() {
public void parsesInvalidFastSyncMinPeersOptionWrongFormatShouldFail() {
parseCommand("--sync-mode", "FAST", "--fast-sync-min-peers", "ten");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains("Invalid value for option '--fast-sync-min-peers': 'ten' is not an int");
@@ -1358,7 +1359,7 @@ public void netRestrictParsedCorrectly() {
public void netRestrictInvalidShouldFail() {
final String subnet = "127.0.0.1/abc";
parseCommand("--net-restrict", subnet);
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandErrorOutput.toString(UTF_8))
.contains("Invalid value for option '--net-restrict'");
}
@@ -1382,7 +1383,7 @@ public void ethStatsContactOptionIsParsedCorrectly() {
@Test
public void ethStatsContactOptionCannotBeUsedWithoutEthStatsServerProvided() {
parseCommand("--ethstats-contact", "besu-updated");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1435,7 +1436,7 @@ public void bonsaiLimitTrieLogsDisabledWhenFullSyncEnabled() {
public void parsesInvalidWhenFullSyncAndBonsaiLimitTrieLogsExplicitlyTrue() {
parseCommand("--sync-mode=FULL", "--bonsai-limit-trie-logs-enabled=true");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1467,7 +1468,7 @@ public void parsesInvalidBonsaiHistoricalBlockLimitOption() {
parseCommand("--data-storage-format", "BONSAI", "--bonsai-maximum-back-layers-to-load", "ten");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1501,7 +1502,7 @@ public void dnsUpdateEnabledOptionIsParsedCorrectly() {
@Test
public void dnsUpdateEnabledOptionCannotBeUsedWithoutDnsEnabled() {
parseCommand("--Xdns-update-enabled", "true");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
.contains(
@@ -1720,6 +1721,17 @@ public void metricsCategoryPropertyMustBeUsed() {
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
+ @Test
+ public void metricsUnknownCategoryRaiseError() {
+ parseCommand("--metrics-enabled", "--metrics-category", "UNKNOWN_CATEGORY");
+
+ verifyNoInteractions(mockRunnerBuilder);
+
+ assertThat(commandOutput.toString(UTF_8)).isEmpty();
+ assertThat(commandErrorOutput.toString(UTF_8))
+ .startsWith("--metrics-categories contains unknown categories: [UNKNOWN_CATEGORY]");
+ }
+
@Test
public void metricsPushEnabledPropertyMustBeUsed() {
parseCommand("--metrics-push-enabled");
@@ -1799,7 +1811,7 @@ public void metricsPrometheusJobMustBeUsed() {
public void metricsAndMetricsPushMustNotBeUsedTogether() {
parseCommand("--metrics-enabled", "--metrics-push-enabled");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
@@ -2023,7 +2035,7 @@ private void networkValuesCanBeOverridden(final String network) {
public void fullCLIOptionsShown() {
parseCommand("--help");
- Mockito.verifyNoInteractions(mockRunnerBuilder);
+ verifyNoInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString(UTF_8)).contains("--config-file");
assertThat(commandOutput.toString(UTF_8)).contains("--data-path");
@@ -2401,13 +2413,16 @@ public void nativeLibrariesAreEnabledByDefault() {
@Test
public void logsWarningWhenFailToLoadJemalloc() {
assumeTrue(PlatformDetector.getOSType().equals("linux"));
- setEnvironmentVariable("BESU_USING_JEMALLOC", "true");
+ setEnvironmentVariable("BESU_USING_JEMALLOC", "false");
parseCommand();
verify(mockLogger)
.warn(
- eq(
- "BESU_USING_JEMALLOC is present but we failed to load jemalloc library to get the version"),
- any(Throwable.class));
+ argThat(
+ arg ->
+ arg.equals(
+ "besu_using_jemalloc is present but is not set to true, jemalloc library not loaded")
+ || arg.equals(
+ "besu_using_jemalloc is present but we failed to load jemalloc library to get the version")));
}
@Test
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java b/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java
index 4cdd8163d95..c1428388149 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java
@@ -33,7 +33,7 @@
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
@@ -200,7 +200,7 @@ public void envVariableOverridesValueFromConfigFile() {
setEnvironmentVariable("BESU_MINER_COINBASE", expectedCoinbase);
parseCommand("--config-file", configFile);
- final var captMiningParameters = ArgumentCaptor.forClass(MiningParameters.class);
+ final var captMiningParameters = ArgumentCaptor.forClass(MiningConfiguration.class);
verify(mockControllerBuilder).miningParameters(captMiningParameters.capture());
assertThat(captMiningParameters.getValue().getCoinbase())
@@ -219,7 +219,7 @@ public void cliOptionOverridesEnvVariableAndConfig() {
setEnvironmentVariable("BESU_MINER_COINBASE", "0x0000000000000000000000000000000000000004");
parseCommand("--config-file", configFile, "--miner-coinbase", expectedCoinbase);
- final var captMiningParameters = ArgumentCaptor.forClass(MiningParameters.class);
+ final var captMiningParameters = ArgumentCaptor.forClass(MiningConfiguration.class);
verify(mockControllerBuilder).miningParameters(captMiningParameters.capture());
assertThat(captMiningParameters.getValue().getCoinbase())
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
index 5c7bf3ce88a..72396593985 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
@@ -34,13 +34,13 @@
import org.hyperledger.besu.chainimport.JsonBlockImporter;
import org.hyperledger.besu.chainimport.RlpBlockImporter;
import org.hyperledger.besu.cli.config.EthNetworkConfig;
+import org.hyperledger.besu.cli.options.EthProtocolOptions;
+import org.hyperledger.besu.cli.options.EthstatsOptions;
import org.hyperledger.besu.cli.options.MiningOptions;
+import org.hyperledger.besu.cli.options.NetworkingOptions;
+import org.hyperledger.besu.cli.options.SynchronizerOptions;
import org.hyperledger.besu.cli.options.TransactionPoolOptions;
-import org.hyperledger.besu.cli.options.stable.EthstatsOptions;
import org.hyperledger.besu.cli.options.storage.DataStorageOptions;
-import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
-import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
-import org.hyperledger.besu.cli.options.unstable.SynchronizerOptions;
import org.hyperledger.besu.components.BesuComponent;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.controller.BesuController;
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/HostAllowlistOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/HostAllowlistOptionsTest.java
index c1f867f4892..21dd587ce7f 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/HostAllowlistOptionsTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/HostAllowlistOptionsTest.java
@@ -23,24 +23,6 @@
public class HostAllowlistOptionsTest extends CommandTestAbstract {
- /** test deprecated CLI option * */
- @Deprecated
- @Test
- public void rpcHttpHostWhitelistAcceptsSingleArgument() {
- parseCommand("--host-whitelist", "a");
-
- verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
- verify(mockRunnerBuilder).build();
-
- assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(1);
- assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a");
- assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist())
- .doesNotContain("localhost");
-
- assertThat(commandOutput.toString(UTF_8)).isEmpty();
- assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
- }
-
@Test
public void rpcHttpHostAllowlistAcceptsSingleArgument() {
parseCommand("--host-allowlist", "a");
@@ -89,23 +71,6 @@ public void rpcHttpHostAllowlistAcceptsDoubleComma() {
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
- @Deprecated
- @Test
- public void rpcHttpHostWhitelistAllowlistAcceptsMultipleFlags() {
- parseCommand("--host-whitelist=a", "--host-allowlist=b");
-
- verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
- verify(mockRunnerBuilder).build();
-
- assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(2);
- assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a", "b");
- assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist())
- .doesNotContain("*", "localhost");
-
- assertThat(commandOutput.toString(UTF_8)).isEmpty();
- assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
- }
-
@Test
public void rpcHttpHostAllowlistAcceptsMultipleFlags() {
parseCommand("--host-allowlist=a", "--host-allowlist=b");
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java b/besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java
deleted file mode 100644
index 8c78b7fecc2..00000000000
--- a/besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright ConsenSys AG.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package org.hyperledger.besu.cli.converter;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.Mockito.when;
-
-import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-@ExtendWith(MockitoExtension.class)
-public class MetricCategoryConverterTest {
-
- private MetricCategoryConverter metricCategoryConverter;
-
- @Mock MetricCategory metricCategory;
-
- @BeforeEach
- public void setUp() {
- metricCategoryConverter = new MetricCategoryConverter();
- }
-
- @Test
- public void convertShouldFailIfValueNotRegistered() {
- assertThatExceptionOfType(IllegalArgumentException.class)
- .isThrownBy(() -> metricCategoryConverter.convert("notRegistered"));
- }
-
- @Test
- public void addRegistryCategoryShouldUppercaseInputValues() {
- when(metricCategory.getName()).thenReturn("testcat");
- metricCategoryConverter.addRegistryCategory(metricCategory);
- when(metricCategory.getName()).thenReturn("tesTCat2");
- metricCategoryConverter.addRegistryCategory(metricCategory);
-
- final boolean containsLowercase =
- metricCategoryConverter.getMetricCategories().keySet().stream()
- .anyMatch(testString -> testString.chars().anyMatch(Character::isLowerCase));
-
- assertThat(containsLowercase).isFalse();
- assertThat(metricCategoryConverter.getMetricCategories().size()).isEqualTo(2);
- assertThat(metricCategoryConverter.getMetricCategories().keySet())
- .containsExactlyInAnyOrder("TESTCAT", "TESTCAT2");
- }
-}
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java
index 6f7aa637cdd..33c91f2c03f 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java
@@ -18,7 +18,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verifyNoInteractions;
-import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.junit.jupiter.api.Test;
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/LoggingLevelOptionTest.java
similarity index 97%
rename from besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java
rename to besu/src/test/java/org/hyperledger/besu/cli/options/LoggingLevelOptionTest.java
index b1fb3217c28..78c0f694ad1 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/options/LoggingLevelOptionTest.java
@@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.cli.options.stable;
+package org.hyperledger.besu.cli.options;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java
index 992dcc437d4..f68a87643bd 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsOptionsTest.java
@@ -14,15 +14,32 @@
*/
package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.stable.MetricsOptions;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.hyperledger.besu.metrics.BesuMetricCategory;
+import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl;
+import org.hyperledger.besu.metrics.StandardMetricCategory;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
+import java.util.EnumSet;
+import java.util.stream.Collectors;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
public class MetricsOptionsTest
extends AbstractCLIOptionsTest {
+ private MetricCategoryRegistryImpl categoryRegistry;
+
+ @BeforeEach
+ public void setUp() {
+ categoryRegistry = new MetricCategoryRegistryImpl();
+ categoryRegistry.addCategories(BesuMetricCategory.class);
+ categoryRegistry.addCategories(StandardMetricCategory.class);
+ }
@Override
protected MetricsConfiguration.Builder createDefaultDomainObject() {
@@ -39,11 +56,36 @@ protected MetricsConfiguration.Builder createCustomizedDomainObject() {
@Override
protected MetricsOptions optionsFromDomainObject(
final MetricsConfiguration.Builder domainObject) {
- return MetricsOptions.fromConfiguration(domainObject.build());
+ final var options = MetricsOptions.fromConfiguration(domainObject.build());
+ options.setMetricCategoryRegistry(categoryRegistry);
+ return options;
}
@Override
protected MetricsOptions getOptionsFromBesuCommand(final TestBesuCommand besuCommand) {
return besuCommand.getMetricsOptions();
}
+
+ @Override
+ protected String[] getNonOptionFields() {
+ return new String[] {"metricCategoryRegistry"};
+ }
+
+ @Test
+ public void enableRocksDbCategories() {
+ final var rocksDbMetricsCategories =
+ EnumSet.of(
+ BesuMetricCategory.KVSTORE_ROCKSDB,
+ BesuMetricCategory.KVSTORE_ROCKSDB_STATS,
+ BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB,
+ BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB_STATS);
+
+ internalTestSuccess(
+ metricsConfBuilder -> {
+ assertThat(metricsConfBuilder.build().getMetricCategories())
+ .containsExactlyInAnyOrderElementsOf(rocksDbMetricsCategories);
+ },
+ "--metrics-categories",
+ rocksDbMetricsCategories.stream().map(Enum::name).collect(Collectors.joining(",")));
+ }
}
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java
index e32ff0e4630..f94504ea47c 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java
@@ -15,19 +15,19 @@
package org.hyperledger.besu.cli.options;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME;
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.verify;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.Unstable;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.Unstable;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.util.number.PositiveNumber;
import java.io.IOException;
@@ -42,7 +42,7 @@
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
-public class MiningOptionsTest extends AbstractCLIOptionsTest {
+public class MiningOptionsTest extends AbstractCLIOptionsTest {
@Test
public void besuDoesNotStartInMiningModeIfCoinbaseNotSet() {
@@ -390,13 +390,13 @@ public void poaBlockTxsSelectionMaxTimeOnlyCompatibleWithPoaNetworks() {
}
@Override
- protected MiningParameters createDefaultDomainObject() {
- return MiningParameters.newDefault();
+ protected MiningConfiguration createDefaultDomainObject() {
+ return MiningConfiguration.newDefault();
}
@Override
- protected MiningParameters createCustomizedDomainObject() {
- return ImmutableMiningParameters.builder()
+ protected MiningConfiguration createCustomizedDomainObject() {
+ return ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
@@ -410,7 +410,7 @@ protected MiningParameters createCustomizedDomainObject() {
}
@Override
- protected MiningOptions optionsFromDomainObject(final MiningParameters domainObject) {
+ protected MiningOptions optionsFromDomainObject(final MiningConfiguration domainObject) {
return MiningOptions.fromConfig(domainObject);
}
@@ -424,11 +424,11 @@ protected String[] getNonOptionFields() {
return new String[] {"transactionSelectionService"};
}
- private MiningParameters runtimeConfiguration(
- final TestBesuCommand besuCommand, final MiningParameters miningParameters) {
+ private MiningConfiguration runtimeConfiguration(
+ final TestBesuCommand besuCommand, final MiningConfiguration miningConfiguration) {
if (besuCommand.getGenesisConfigOptions().isPoa()) {
- miningParameters.setBlockPeriodSeconds(POA_BLOCK_PERIOD_SECONDS);
+ miningConfiguration.setBlockPeriodSeconds(POA_BLOCK_PERIOD_SECONDS);
}
- return miningParameters;
+ return miningConfiguration;
}
}
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java
index a645f28b548..191b1a82997 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java
@@ -17,7 +17,6 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
-import org.hyperledger.besu.cli.options.unstable.NetworkingOptions;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import java.util.Arrays;
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java
index 0511279c19f..0a257de6da2 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java
@@ -14,7 +14,6 @@
*/
package org.hyperledger.besu.cli.options;
-import org.hyperledger.besu.cli.options.unstable.SynchronizerOptions;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.ImmutableSnapSyncConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration;
diff --git a/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigDefaultValueProviderStrategyTest.java b/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigDefaultValueProviderStrategyTest.java
index 50eadceb3bb..30eb677e88e 100644
--- a/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigDefaultValueProviderStrategyTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigDefaultValueProviderStrategyTest.java
@@ -25,7 +25,7 @@
import static org.mockito.Mockito.when;
import org.hyperledger.besu.cli.error.BesuParameterExceptionHandler;
-import org.hyperledger.besu.cli.options.stable.LoggingLevelOption;
+import org.hyperledger.besu.cli.options.LoggingLevelOption;
import java.io.File;
import java.io.IOException;
diff --git a/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java
index 621ae8a98c7..e17fb04acf0 100644
--- a/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java
@@ -34,7 +34,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
@@ -90,7 +90,7 @@ public abstract class AbstractBftBesuControllerBuilderTest {
TransactionPoolConfiguration.DEFAULT;
private final ObservableMetricsSystem observableMetricsSystem = new NoOpMetricsSystem();
protected final ObjectMapper objectMapper = new ObjectMapper();
- private final MiningParameters miningParameters = MiningParameters.newDefault();
+ private final MiningConfiguration miningConfiguration = MiningConfiguration.newDefault();
@TempDir Path tempDir;
@BeforeEach
@@ -146,7 +146,7 @@ public void setup() throws JsonProcessingException {
.synchronizerConfiguration(synchronizerConfiguration)
.ethProtocolConfiguration(ethProtocolConfiguration)
.networkId(networkId)
- .miningParameters(miningParameters)
+ .miningParameters(miningConfiguration)
.metricsSystem(observableMetricsSystem)
.privacyParameters(privacyParameters)
.dataDirectory(tempDir)
@@ -193,13 +193,14 @@ public void miningParametersBlockPeriodSecondsIsUpdatedOnTransition() {
null,
null,
null,
+ null,
getBlockHeaderFunctions());
final Block block1 = new Block(header1, BlockBody.empty());
protocolContext.getBlockchain().appendBlock(block1, List.of());
- assertThat(miningParameters.getBlockPeriodSeconds()).isNotEmpty().hasValue(2);
- assertThat(miningParameters.getBlockTxsSelectionMaxTime()).isEqualTo(2000 * 75 / 100);
+ assertThat(miningConfiguration.getBlockPeriodSeconds()).isNotEmpty().hasValue(2);
+ assertThat(miningConfiguration.getBlockTxsSelectionMaxTime()).isEqualTo(2000 * 75 / 100);
}
protected abstract BlockHeaderFunctions getBlockHeaderFunctions();
diff --git a/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java
index e9e93de9b9d..32924e29f92 100644
--- a/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java
@@ -37,7 +37,7 @@
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
@@ -95,7 +95,7 @@ public class CliqueBesuControllerBuilderTest {
TransactionPoolConfiguration.DEFAULT;
private final ObservableMetricsSystem observableMetricsSystem = new NoOpMetricsSystem();
private final ObjectMapper objectMapper = new ObjectMapper();
- private final MiningParameters miningParameters = MiningParameters.newDefault();
+ private final MiningConfiguration miningConfiguration = MiningConfiguration.newDefault();
@TempDir Path tempDir;
@@ -179,7 +179,7 @@ public void setup() throws JsonProcessingException {
.synchronizerConfiguration(synchronizerConfiguration)
.ethProtocolConfiguration(ethProtocolConfiguration)
.networkId(networkId)
- .miningParameters(miningParameters)
+ .miningParameters(miningConfiguration)
.metricsSystem(observableMetricsSystem)
.privacyParameters(privacyParameters)
.dataDirectory(tempDir)
@@ -222,12 +222,13 @@ public void miningParametersBlockPeriodSecondsIsUpdatedOnTransition() {
null,
null,
null,
+ null,
new CliqueBlockHeaderFunctions());
final Block block1 = new Block(header1, BlockBody.empty());
protocolContext.getBlockchain().appendBlock(block1, List.of());
- assertThat(miningParameters.getBlockPeriodSeconds()).isNotEmpty().hasValue(2);
- assertThat(miningParameters.getBlockTxsSelectionMaxTime()).isEqualTo(2000 * 75 / 100);
+ assertThat(miningConfiguration.getBlockPeriodSeconds()).isNotEmpty().hasValue(2);
+ assertThat(miningConfiguration.getBlockTxsSelectionMaxTime()).isEqualTo(2000 * 75 / 100);
}
}
diff --git a/besu/src/test/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilderTest.java
index 5efeed50b24..aefcda4c231 100644
--- a/besu/src/test/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilderTest.java
@@ -32,7 +32,7 @@
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -135,7 +135,7 @@ public void createsMigratingMiningCoordinator() {
protocolSchedule1,
mockProtocolContext,
mock(TransactionPool.class),
- mock(MiningParameters.class),
+ mock(MiningConfiguration.class),
mock(SyncState.class),
mock(EthProtocolManager.class));
diff --git a/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java
index f8c00b20ea7..47971b6442e 100644
--- a/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java
@@ -41,7 +41,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
@@ -95,7 +95,7 @@ public class MergeBesuControllerBuilderTest {
@Mock CheckpointConfigOptions checkpointConfigOptions;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- MiningParameters miningParameters;
+ MiningConfiguration miningConfiguration;
@Mock PrivacyParameters privacyParameters;
@Mock Clock clock;
@@ -167,7 +167,7 @@ public void setup() {
lenient()
.when(worldStateKeyValueStorage.updater())
.thenReturn(mock(ForestWorldStateKeyValueStorage.Updater.class));
- lenient().when(miningParameters.getTargetGasLimit()).thenReturn(OptionalLong.empty());
+ lenient().when(miningConfiguration.getTargetGasLimit()).thenReturn(OptionalLong.empty());
besuControllerBuilder = visitWithMockConfigs(new MergeBesuControllerBuilder());
}
@@ -179,7 +179,7 @@ MergeBesuControllerBuilder visitWithMockConfigs(final MergeBesuControllerBuilder
.genesisConfigFile(genesisConfigFile)
.synchronizerConfiguration(synchronizerConfiguration)
.ethProtocolConfiguration(ethProtocolConfiguration)
- .miningParameters(miningParameters)
+ .miningParameters(miningConfiguration)
.metricsSystem(observableMetricsSystem)
.privacyParameters(privacyParameters)
.dataDirectory(tempDir)
diff --git a/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java
index 3b88ae258b7..a448b11f406 100644
--- a/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/controller/QbftBesuControllerBuilderTest.java
@@ -32,7 +32,7 @@
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import java.util.List;
@@ -107,7 +107,7 @@ public void missingTransactionValidatorProviderThrowsError() {
assertThatThrownBy(
() ->
bftBesuControllerBuilder.createAdditionalJsonRpcMethodFactory(
- protocolContext, protocolSchedule, MiningParameters.newDefault()))
+ protocolContext, protocolSchedule, MiningConfiguration.newDefault()))
.isInstanceOf(NullPointerException.class)
.hasMessage("transactionValidatorProvider should have been initialised");
}
diff --git a/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java
index 40d72e4ed19..24b0133a0f1 100644
--- a/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java
@@ -35,10 +35,10 @@
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -84,7 +84,7 @@ public class TransitionControllerBuilderTest {
CliqueBesuControllerBuilder cliqueBuilder = new CliqueBesuControllerBuilder();
BesuControllerBuilder powBuilder = new MainnetBesuControllerBuilder();
MergeBesuControllerBuilder postMergeBuilder = new MergeBesuControllerBuilder();
- MiningParameters miningParameters;
+ MiningConfiguration miningConfiguration;
TransitionProtocolSchedule transitionProtocolSchedule;
@@ -118,27 +118,27 @@ public void setup() {
.thenReturn(mergeContext);
when(ethProtocolManager.ethContext().getScheduler())
.thenReturn(new DeterministicEthScheduler());
- miningParameters = MiningParameters.newDefault();
+ miningConfiguration = MiningConfiguration.newDefault();
}
@Test
public void assertCliqueMiningOverridePreMerge() {
- assertThat(miningParameters.isMiningEnabled()).isFalse();
+ assertThat(miningConfiguration.isMiningEnabled()).isFalse();
var transCoordinator = buildTransitionCoordinator(cliqueBuilder, postMergeBuilder);
assertThat(transCoordinator.isMiningBeforeMerge()).isTrue();
}
@Test
public void assertPoWIsNotMiningPreMerge() {
- assertThat(miningParameters.isMiningEnabled()).isFalse();
+ assertThat(miningConfiguration.isMiningEnabled()).isFalse();
var transCoordinator = buildTransitionCoordinator(powBuilder, postMergeBuilder);
assertThat(transCoordinator.isMiningBeforeMerge()).isFalse();
}
@Test
public void assertPowMiningPreMerge() {
- miningParameters =
- ImmutableMiningParameters.builder()
+ miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(MutableInitValues.builder().isMiningEnabled(true).build())
.build();
var transCoordinator = buildTransitionCoordinator(powBuilder, postMergeBuilder);
@@ -273,7 +273,7 @@ TransitionCoordinator buildTransitionCoordinator(
transitionProtocolSchedule,
protocolContext,
transactionPool,
- miningParameters,
+ miningConfiguration,
syncState,
ethProtocolManager);
diff --git a/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java
index 478ce4ebc42..79885115f42 100644
--- a/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java
@@ -36,7 +36,7 @@
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
@@ -173,7 +173,7 @@ public void setUp() {
syncState,
txPoolConfig,
new BlobCache(),
- MiningParameters.newDefault());
+ MiningConfiguration.newDefault());
serviceImpl =
new BesuEventsImpl(
@@ -219,7 +219,7 @@ private void setSyncTarget() {
mock(EthPeer.class),
new org.hyperledger.besu.ethereum.core.BlockHeader(
null, null, null, null, null, null, null, null, 1, 1, 1, 1, null, null, null, 1, null,
- null, null, null, null, null));
+ null, null, null, null, null, null));
}
private void clearSyncTarget() {
diff --git a/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java
index 1e734f62312..bcbf1c2fe70 100644
--- a/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java
+++ b/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java
@@ -31,7 +31,7 @@
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.log.Log;
import org.hyperledger.besu.evm.worldstate.WorldView;
@@ -80,7 +80,7 @@ public void setup() {
blockchainSetupUtil.getProtocolSchedule(),
blockchain,
worldStateArchive,
- MiningParameters.newDefault());
+ MiningConfiguration.newDefault());
traceService =
new TraceServiceImpl(blockchainQueries, blockchainSetupUtil.getProtocolSchedule());
}
diff --git a/besu/src/test/resources/everything_config.toml b/besu/src/test/resources/everything_config.toml
index e89442f7f78..960b2b5772c 100644
--- a/besu/src/test/resources/everything_config.toml
+++ b/besu/src/test/resources/everything_config.toml
@@ -120,6 +120,19 @@ rpc-ws-max-frame-size=65535
rpc-ws-authentication-enabled=false
rpc-ws-authentication-credentials-file="none"
rpc-ws-authentication-jwt-public-key-file="none"
+rpc-ws-ssl-enabled=false
+rpc-ws-ssl-keystore-file="none.pfx"
+rpc-ws-ssl-keystore-password="none.passwd"
+rpc-ws-ssl-keystore-type="none"
+rpc-ws-ssl-client-auth-enabled=false
+rpc-ws-ssl-truststore-file="none.pfx"
+rpc-ws-ssl-truststore-password="none.passwd"
+rpc-ws-ssl-truststore-type="none"
+rpc-ws-ssl-key-file="none.pfx"
+rpc-ws-ssl-cert-file="none.pfx"
+rpc-ws-ssl-trustcert-file="none.pfx"
+
+
# API
api-gas-price-blocks=100
diff --git a/build.gradle b/build.gradle
index 4fe80600c2c..8b6982cd4a0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -417,9 +417,6 @@ configure(allprojects - project(':platform')) {
'-org.hyperledger.besu.ethereum.permissioning.*,' +
// referencetests module
'-org.hyperledger.besu.ethereum.referencetests,' +
- // retesteth module
- '-org.hyperledger.besu.ethereum.retesteth.methods,' +
- '-org.hyperledger.besu.ethereum.retesteth,' +
//rlp module
'-org.hyperledger.besu.ethereum.rlp,' +
// stratum module
diff --git a/config/build.gradle b/config/build.gradle
index a78b9a7105c..e269ce51fc9 100644
--- a/config/build.gradle
+++ b/config/build.gradle
@@ -36,11 +36,13 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.guava:guava'
+ implementation 'com.google.dagger:dagger'
implementation 'info.picocli:picocli'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-units'
implementation "org.immutables:value-annotations"
annotationProcessor "org.immutables:value"
+ annotationProcessor 'com.google.dagger:dagger-compiler'
testImplementation project(':testutil')
diff --git a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java
index 8938e5143c2..eae9bc3d109 100644
--- a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java
+++ b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java
@@ -265,6 +265,17 @@ public String getParentBeaconBlockRoot() {
"0x0000000000000000000000000000000000000000000000000000000000000000");
}
+ /**
+ * Gets target blob count.
+ *
+ * @return the target blob count
+ */
+ public Optional getTargetBlobCount() {
+ // TODO SLD EIP-7742 not sure if we should use a default value here or enforce any
+ // "pragueAtGenesis" genesis file (used in devnets) to have this value
+ return JsonUtil.getValueAsString(genesisRoot, "targetblobcount");
+ }
+
/**
* Gets coinbase.
*
diff --git a/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java b/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java
index 6b42c3c2edf..4ee99f0bd83 100644
--- a/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java
+++ b/config/src/main/java/org/hyperledger/besu/config/GenesisReader.java
@@ -80,7 +80,9 @@ public Stream streamAllocations() {
final var on = normalizeKeys((ObjectNode) entry.getValue());
return new GenesisAccount(
Address.fromHexString(entry.getKey()),
- JsonUtil.getString(on, "nonce").map(ParserUtils::parseUnsignedLong).orElse(0L),
+ JsonUtil.getValueAsString(on, "nonce")
+ .map(ParserUtils::parseUnsignedLong)
+ .orElse(0L),
JsonUtil.getString(on, "balance")
.map(ParserUtils::parseBalance)
.orElse(Wei.ZERO),
diff --git a/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java b/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java
index f8327174a33..eab6dfac734 100644
--- a/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java
+++ b/config/src/test/java/org/hyperledger/besu/config/GenesisReaderTest.java
@@ -17,6 +17,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.config.GenesisReader.ALLOCATION_FIELD;
import static org.hyperledger.besu.config.GenesisReader.CONFIG_FIELD;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
@@ -27,6 +28,7 @@
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -111,4 +113,17 @@ private ObjectNode generateAllocation(final Wei balance) {
entry.put("balance", balance.toShortHexString());
return entry;
}
+
+ @Test
+ void testNonceHandlingAsStringAndInteger() {
+ ObjectNode accountNode = JsonNodeFactory.instance.objectNode();
+
+ accountNode.put("nonce", 10);
+ String nonceAsStringFromInt = JsonUtil.getValueAsString(accountNode, "nonce").orElse("");
+ assertEquals("10", nonceAsStringFromInt, "Nonce should convert integer to string correctly");
+
+ accountNode.put("nonce", "20");
+ String nonceAsStringDirect = JsonUtil.getValueAsString(accountNode, "nonce").orElse("");
+ assertEquals("20", nonceAsStringDirect, "Nonce should keep string as string correctly");
+ }
}
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java
index cd197556386..2ceedb71893 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java
@@ -22,7 +22,7 @@
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
@@ -63,7 +63,7 @@ public class CliqueProtocolSchedule {
* @param privacyParameters the privacy parameters
* @param isRevertReasonEnabled the is revert reason enabled
* @param evmConfiguration the evm configuration
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -77,7 +77,7 @@ public static ProtocolSchedule create(
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -110,12 +110,12 @@ public static ProtocolSchedule create(
return new ProtocolScheduleBuilder(
config,
- DEFAULT_CHAIN_ID,
+ Optional.of(DEFAULT_CHAIN_ID),
specAdapters,
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem)
@@ -130,7 +130,7 @@ public static ProtocolSchedule create(
* @param nodeKey the node key
* @param isRevertReasonEnabled the is revert reason enabled
* @param evmConfiguration the evm configuration
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -144,7 +144,7 @@ public static ProtocolSchedule create(
final NodeKey nodeKey,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -155,7 +155,7 @@ public static ProtocolSchedule create(
PrivacyParameters.DEFAULT,
isRevertReasonEnabled,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java
index ed17529a9ff..18d3449ba8d 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java
@@ -29,7 +29,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.SealableBlockHeader;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -48,7 +48,7 @@ public class CliqueBlockCreator extends AbstractBlockCreator {
/**
* Instantiates a new Clique block creator.
*
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param extraDataCalculator the extra data calculator
* @param transactionPool the pending transactions
* @param protocolContext the protocol context
@@ -58,7 +58,7 @@ public class CliqueBlockCreator extends AbstractBlockCreator {
* @param ethScheduler the scheduler for asynchronous block creation tasks
*/
public CliqueBlockCreator(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final ExtraDataCalculator extraDataCalculator,
final TransactionPool transactionPool,
final ProtocolContext protocolContext,
@@ -67,7 +67,7 @@ public CliqueBlockCreator(
final EpochManager epochManager,
final EthScheduler ethScheduler) {
super(
- miningParameters,
+ miningConfiguration,
__ -> Util.publicKeyToAddress(nodeKey.getPublicKey()),
extraDataCalculator,
transactionPool,
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java
index ef3d58fbffb..998a237e916 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java
@@ -28,7 +28,7 @@
import org.hyperledger.besu.ethereum.chain.MinedBlockObserver;
import org.hyperledger.besu.ethereum.chain.PoWObserver;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -70,7 +70,7 @@ public CliqueMinerExecutor(
final ProtocolSchedule protocolSchedule,
final TransactionPool transactionPool,
final NodeKey nodeKey,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final AbstractBlockScheduler blockScheduler,
final EpochManager epochManager,
final ForksSchedule forksSchedule,
@@ -97,7 +97,7 @@ public CliqueBlockMiner createMiner(
final Function blockCreator =
(header) ->
new CliqueBlockCreator(
- miningParameters,
+ miningConfiguration,
this::calculateExtraData,
transactionPool,
protocolContext,
@@ -119,7 +119,7 @@ public CliqueBlockMiner createMiner(
@Override
public Optional getCoinbase() {
- return miningParameters.getCoinbase();
+ return miningConfiguration.getCoinbase();
}
/**
@@ -134,7 +134,7 @@ Bytes calculateExtraData(final BlockHeader parentHeader) {
final Bytes vanityDataToInsert =
ConsensusHelpers.zeroLeftPad(
- miningParameters.getExtraData(), CliqueExtraData.EXTRA_VANITY_LENGTH);
+ miningConfiguration.getExtraData(), CliqueExtraData.EXTRA_VANITY_LENGTH);
// Building ON TOP of canonical head, if the next block is epoch, include validators.
if (epochManager.isEpochBlock(parentHeader.getNumber() + 1)) {
diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java
index 762cce1c569..4e1e75f54c8 100644
--- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java
+++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java
@@ -31,7 +31,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.ApiGroupJsonRpcMethods;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
@@ -41,22 +41,22 @@
public class CliqueJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final ProtocolContext context;
private final ProtocolSchedule protocolSchedule;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
/**
* Instantiates a new Clique json rpc methods.
*
* @param context the protocol context
* @param protocolSchedule the protocol schedule
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
*/
public CliqueJsonRpcMethods(
final ProtocolContext context,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
this.context = context;
this.protocolSchedule = protocolSchedule;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -69,7 +69,7 @@ protected Map create() {
final MutableBlockchain blockchain = context.getBlockchain();
final WorldStateArchive worldStateArchive = context.getWorldStateArchive();
final BlockchainQueries blockchainQueries =
- new BlockchainQueries(protocolSchedule, blockchain, worldStateArchive, miningParameters);
+ new BlockchainQueries(protocolSchedule, blockchain, worldStateArchive, miningConfiguration);
final ValidatorProvider validatorProvider =
context.getConsensusContext(CliqueContext.class).getValidatorProvider();
diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java
index 5cbdbb6d06e..083604af6f0 100644
--- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java
+++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java
@@ -32,7 +32,7 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
@@ -68,7 +68,7 @@ public void protocolSpecsAreCreatedAtBlockDefinedInJson() {
NODE_KEY,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -94,7 +94,7 @@ public void parametersAlignWithMainnetWithAdjustments() {
NODE_KEY,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
@@ -120,7 +120,7 @@ public void zeroEpochLengthThrowsException() {
NODE_KEY,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()))
@@ -142,7 +142,7 @@ public void negativeEpochLengthThrowsException() {
NODE_KEY,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()))
@@ -168,7 +168,7 @@ public void shouldValidateBaseFeeMarketTransition() {
NODE_KEY,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java
index ca76517c62c..fdc068ddef7 100644
--- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java
+++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java
@@ -49,9 +49,9 @@
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -106,7 +106,7 @@ void setup() {
proposerNodeKey,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -146,11 +146,11 @@ public void proposerAddressCanBeExtractFromAConstructedBlock() {
final Address coinbase = AddressHelpers.ofValue(1);
- final MiningParameters miningParameters = createMiningParameters(extraData, coinbase);
+ final MiningConfiguration miningConfiguration = createMiningParameters(extraData, coinbase);
final CliqueBlockCreator blockCreator =
new CliqueBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> extraData,
createTransactionPool(),
protocolContext,
@@ -175,11 +175,11 @@ public void insertsValidVoteIntoConstructedBlock() {
when(voteProvider.getVoteAfterBlock(any(), any()))
.thenReturn(Optional.of(new ValidatorVote(VoteType.ADD, coinbase, a1)));
- final MiningParameters miningParameters = createMiningParameters(extraData, coinbase);
+ final MiningConfiguration miningConfiguration = createMiningParameters(extraData, coinbase);
final CliqueBlockCreator blockCreator =
new CliqueBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> extraData,
createTransactionPool(),
protocolContext,
@@ -209,11 +209,11 @@ public void insertsNoVoteWhenAtEpoch() {
when(mockVoteProvider.getVoteAfterBlock(any(), any()))
.thenReturn(Optional.of(new ValidatorVote(VoteType.ADD, coinbase, a1)));
- final MiningParameters miningParameters = createMiningParameters(extraData, coinbase);
+ final MiningConfiguration miningConfiguration = createMiningParameters(extraData, coinbase);
final CliqueBlockCreator blockCreator =
new CliqueBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> extraData,
createTransactionPool(),
protocolContext,
@@ -252,10 +252,10 @@ private TransactionPool createTransactionPool() {
return transactionPool;
}
- private static MiningParameters createMiningParameters(
+ private static MiningConfiguration createMiningParameters(
final Bytes extraData, final Address coinbase) {
- final MiningParameters miningParameters =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(extraData)
@@ -264,6 +264,6 @@ private static MiningParameters createMiningParameters(
.coinbase(coinbase)
.build())
.build();
- return miningParameters;
+ return miningConfiguration;
}
}
diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java
index 1aa2d75ef3b..3d6dbd77db9 100644
--- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java
+++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java
@@ -39,9 +39,9 @@
import org.hyperledger.besu.ethereum.core.AddressHelpers;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -105,7 +105,7 @@ public void setup() {
proposerNodeKey,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -117,7 +117,7 @@ public void setup() {
public void extraDataCreatedOnEpochBlocksContainsValidators() {
final Bytes vanityData = generateRandomVanityData();
- final MiningParameters miningParameters = createMiningParameters(vanityData);
+ final MiningConfiguration miningConfiguration = createMiningParameters(vanityData);
final CliqueMinerExecutor executor =
new CliqueMinerExecutor(
@@ -125,7 +125,7 @@ public void extraDataCreatedOnEpochBlocksContainsValidators() {
cliqueProtocolSchedule,
createTransactionPool(),
proposerNodeKey,
- miningParameters,
+ miningConfiguration,
mock(CliqueBlockScheduler.class),
new EpochManager(EPOCH_LENGTH),
null,
@@ -153,7 +153,7 @@ public void extraDataCreatedOnEpochBlocksContainsValidators() {
public void extraDataForNonEpochBlocksDoesNotContainValidaors() {
final Bytes vanityData = generateRandomVanityData();
- final MiningParameters miningParameters = createMiningParameters(vanityData);
+ final MiningConfiguration miningConfiguration = createMiningParameters(vanityData);
final CliqueMinerExecutor executor =
new CliqueMinerExecutor(
@@ -161,7 +161,7 @@ public void extraDataForNonEpochBlocksDoesNotContainValidaors() {
cliqueProtocolSchedule,
createTransactionPool(),
proposerNodeKey,
- miningParameters,
+ miningConfiguration,
mock(CliqueBlockScheduler.class),
new EpochManager(EPOCH_LENGTH),
null,
@@ -189,7 +189,7 @@ public void shouldUseLatestVanityData() {
final Bytes initialVanityData = generateRandomVanityData();
final Bytes modifiedVanityData = generateRandomVanityData();
- final MiningParameters miningParameters = createMiningParameters(initialVanityData);
+ final MiningConfiguration miningConfiguration = createMiningParameters(initialVanityData);
final CliqueMinerExecutor executor =
new CliqueMinerExecutor(
@@ -197,13 +197,13 @@ public void shouldUseLatestVanityData() {
cliqueProtocolSchedule,
createTransactionPool(),
proposerNodeKey,
- miningParameters,
+ miningConfiguration,
mock(CliqueBlockScheduler.class),
new EpochManager(EPOCH_LENGTH),
null,
ethScheduler);
- miningParameters.setExtraData(modifiedVanityData);
+ miningConfiguration.setExtraData(modifiedVanityData);
final Bytes extraDataBytes = executor.calculateExtraData(blockHeaderBuilder.buildHeader());
final CliqueExtraData cliqueExtraData =
@@ -253,8 +253,8 @@ private Bytes generateRandomVanityData() {
return Bytes.wrap(vanityData);
}
- private static MiningParameters createMiningParameters(final Bytes vanityData) {
- return ImmutableMiningParameters.builder()
+ private static MiningConfiguration createMiningParameters(final Bytes vanityData) {
+ return ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(vanityData)
diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java
index 311bf30faef..29ec30d6679 100644
--- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java
+++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java
@@ -19,7 +19,7 @@
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@@ -38,6 +38,7 @@
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
import java.util.function.Function;
/** Defines the protocol behaviours for a blockchain using a BFT consensus mechanism. */
@@ -57,7 +58,7 @@ protected BaseBftProtocolScheduleBuilder() {}
* @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @param metricsSystem metricsSystem A metricSystem instance to be able to expose metrics in the
@@ -71,7 +72,7 @@ public BftProtocolSchedule createProtocolSchedule(
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -90,12 +91,12 @@ public BftProtocolSchedule createProtocolSchedule(
final ProtocolSchedule protocolSchedule =
new ProtocolScheduleBuilder(
config,
- DEFAULT_CHAIN_ID,
+ Optional.of(DEFAULT_CHAIN_ID),
specAdapters,
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem)
diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java
index 6bc0254b691..70d18fc3c93 100644
--- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java
+++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java
@@ -25,7 +25,7 @@
import org.hyperledger.besu.ethereum.blockcreation.AbstractBlockCreator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.SealableBlockHeader;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -46,7 +46,7 @@ public class BftBlockCreator extends AbstractBlockCreator {
/**
* Instantiates a new Bft block creator.
*
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param forksSchedule the forks schedule
* @param localAddress the local address
* @param extraDataCalculator the extra data calculator
@@ -57,7 +57,7 @@ public class BftBlockCreator extends AbstractBlockCreator {
* @param ethScheduler the scheduler for asynchronous block creation tasks
*/
public BftBlockCreator(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final ForksSchedule extends BftConfigOptions> forksSchedule,
final Address localAddress,
final ExtraDataCalculator extraDataCalculator,
@@ -67,7 +67,7 @@ public BftBlockCreator(
final BftExtraDataCodec bftExtraDataCodec,
final EthScheduler ethScheduler) {
super(
- miningParameters.setCoinbase(localAddress),
+ miningConfiguration.setCoinbase(localAddress),
miningBeneficiaryCalculator(localAddress, forksSchedule),
extraDataCalculator,
transactionPool,
diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java
index 7c679763b60..1349bbf4619 100644
--- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java
+++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java
@@ -31,7 +31,7 @@
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.BlockCreator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.AbstractGasLimitSpecification;
@@ -54,7 +54,7 @@ public class BftBlockCreatorFactory {
protected final ForksSchedule forksSchedule;
/** The Mining parameters */
- protected final MiningParameters miningParameters;
+ protected final MiningConfiguration miningConfiguration;
private final TransactionPool transactionPool;
@@ -89,7 +89,7 @@ public BftBlockCreatorFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
final ForksSchedule forksSchedule,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final Address localAddress,
final BftExtraDataCodec bftExtraDataCodec,
final EthScheduler ethScheduler) {
@@ -98,7 +98,7 @@ public BftBlockCreatorFactory(
this.protocolSchedule = protocolSchedule;
this.forksSchedule = forksSchedule;
this.localAddress = localAddress;
- this.miningParameters = miningParams;
+ this.miningConfiguration = miningParams;
this.bftExtraDataCodec = bftExtraDataCodec;
this.ethScheduler = ethScheduler;
}
@@ -111,7 +111,7 @@ public BftBlockCreatorFactory(
*/
public BlockCreator create(final int round) {
return new BftBlockCreator(
- miningParameters,
+ miningConfiguration,
forksSchedule,
localAddress,
ph -> createExtraData(round, ph),
@@ -128,7 +128,7 @@ public BlockCreator create(final int round) {
* @param minTransactionGasPrice the min transaction gas price
*/
public void setMinTransactionGasPrice(final Wei minTransactionGasPrice) {
- miningParameters.setMinTransactionGasPrice(minTransactionGasPrice);
+ miningConfiguration.setMinTransactionGasPrice(minTransactionGasPrice);
}
/**
@@ -137,7 +137,7 @@ public void setMinTransactionGasPrice(final Wei minTransactionGasPrice) {
* @return the min transaction gas price
*/
public Wei getMinTransactionGasPrice() {
- return miningParameters.getMinTransactionGasPrice();
+ return miningConfiguration.getMinTransactionGasPrice();
}
/**
@@ -146,7 +146,7 @@ public Wei getMinTransactionGasPrice() {
* @return min priority fee per gas
*/
public Wei getMinPriorityFeePerGas() {
- return miningParameters.getMinPriorityFeePerGas();
+ return miningConfiguration.getMinPriorityFeePerGas();
}
/**
@@ -171,7 +171,7 @@ public Bytes createExtraData(final int round, final BlockHeader parentHeader) {
final BftExtraData extraData =
new BftExtraData(
ConsensusHelpers.zeroLeftPad(
- miningParameters.getExtraData(), BftExtraDataCodec.EXTRA_VANITY_LENGTH),
+ miningConfiguration.getExtraData(), BftExtraDataCodec.EXTRA_VANITY_LENGTH),
Collections.emptyList(),
toVote(proposal),
round,
@@ -187,7 +187,7 @@ public Bytes createExtraData(final int round, final BlockHeader parentHeader) {
*/
public void changeTargetGasLimit(final Long newTargetGasLimit) {
if (AbstractGasLimitSpecification.isValidTargetGasLimit(newTargetGasLimit)) {
- miningParameters.setTargetGasLimit(newTargetGasLimit);
+ miningConfiguration.setTargetGasLimit(newTargetGasLimit);
} else {
throw new UnsupportedOperationException("Specified target gas limit is invalid");
}
diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java
index 02689d52af1..02da30f5075 100644
--- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java
+++ b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java
@@ -21,7 +21,7 @@
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -172,12 +172,12 @@ private BftProtocolSchedule createProtocolSchedule(
final ProtocolScheduleBuilder protocolScheduleBuilder =
new ProtocolScheduleBuilder(
genesisConfigOptions,
- BigInteger.ONE,
+ Optional.of(BigInteger.ONE),
ProtocolSpecAdapters.create(0, Function.identity()),
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java
index e23664fd8d3..56a0e33986b 100644
--- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java
+++ b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java
@@ -31,7 +31,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@@ -245,7 +245,7 @@ protected BlockHeaderValidator.Builder createBlockHeaderRuleset(
false,
bftExtraDataCodec,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/ibft/build.gradle b/consensus/ibft/build.gradle
index da6304c4e58..e95c8661431 100644
--- a/consensus/ibft/build.gradle
+++ b/consensus/ibft/build.gradle
@@ -76,4 +76,6 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'
+ testImplementation 'com.google.dagger:dagger'
+ testAnnotationProcessor 'com.google.dagger:dagger-compiler'
}
diff --git a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java
index 8896733548d..a5d24ff4dbc 100644
--- a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java
+++ b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java
@@ -78,9 +78,9 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -310,8 +310,8 @@ private static ControllerAndState createControllerAndFinalState(
final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive();
- final MiningParameters miningParams =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningParams =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
@@ -334,7 +334,7 @@ private static ControllerAndState createControllerAndFinalState(
forksSchedule,
IBFT_EXTRA_DATA_ENCODER,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java
index 3adf5718955..adc4698e4d5 100644
--- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java
+++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java
@@ -21,7 +21,7 @@
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
@@ -46,7 +46,7 @@ protected IbftProtocolScheduleBuilder() {}
* @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -60,7 +60,7 @@ public static BftProtocolSchedule create(
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -72,7 +72,7 @@ public static BftProtocolSchedule create(
isRevertReasonEnabled,
bftExtraDataCodec,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -85,7 +85,7 @@ public static BftProtocolSchedule create(
* @param forksSchedule the forks schedule
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -97,7 +97,7 @@ public static BftProtocolSchedule create(
final ForksSchedule forksSchedule,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -108,7 +108,7 @@ public static BftProtocolSchedule create(
false,
bftExtraDataCodec,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java
index 1afe067867d..a777d7d175e 100644
--- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java
+++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java
@@ -32,7 +32,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.ApiGroupJsonRpcMethods;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import java.util.Map;
@@ -42,22 +42,22 @@ public class IbftJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final ProtocolContext context;
private final ProtocolSchedule protocolSchedule;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
/**
* Instantiates a new Ibft json rpc methods.
*
* @param context the protocol context
* @param protocolSchedule the protocol schedule
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
*/
public IbftJsonRpcMethods(
final ProtocolContext context,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
this.context = context;
this.protocolSchedule = protocolSchedule;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -70,7 +70,7 @@ protected Map create() {
final MutableBlockchain blockchain = context.getBlockchain();
final BlockchainQueries blockchainQueries =
new BlockchainQueries(
- protocolSchedule, blockchain, context.getWorldStateArchive(), miningParameters);
+ protocolSchedule, blockchain, context.getWorldStateArchive(), miningConfiguration);
final BftContext bftContext = context.getConsensusContext(BftContext.class);
final BlockInterface blockInterface = bftContext.getBlockInterface();
final ValidatorProvider validatorProvider =
diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java
index e5551ff3f31..9cb760551e0 100644
--- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java
+++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java
@@ -22,7 +22,6 @@
import static org.mockito.Mockito.when;
import org.hyperledger.besu.config.BftConfigOptions;
-import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.JsonGenesisConfigOptions;
import org.hyperledger.besu.config.JsonQbftConfigOptions;
import org.hyperledger.besu.config.JsonUtil;
@@ -40,31 +39,39 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
+import org.hyperledger.besu.ethereum.core.components.EthereumCoreComponent;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import java.math.BigInteger;
-import java.util.Collection;
import java.util.List;
+import javax.inject.Singleton;
+import dagger.Component;
+import dagger.Module;
+import dagger.Provides;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class IbftProtocolScheduleTest {
- private final BftExtraDataCodec bftExtraDataCodec = mock(BftExtraDataCodec.class);
- private final BftExtraData bftExtraData = mock(BftExtraData.class);
- private final NodeKey proposerNodeKey = NodeKeyUtils.generate();
- private final Address proposerAddress = Util.publicKeyToAddress(proposerNodeKey.getPublicKey());
- private final List validators = singletonList(proposerAddress);
+
+ private ProtocolContext protocolContext;
+ private List validators;
+ private NodeKey proposerNodeKey;
+ private TestEthCoreComponent component;
@BeforeEach
public void setup() {
- when(bftExtraDataCodec.decode(any())).thenReturn(bftExtraData);
- when(bftExtraData.getValidators()).thenReturn(validators);
+ TestEthCoreComponent component =
+ DaggerIbftProtocolScheduleTest_TestEthCoreComponent.builder().build();
+ this.component = component;
+ this.protocolContext = component.protocolContext();
+ this.validators = component.validators();
+ this.proposerNodeKey = component.nodeKey();
}
@Test
@@ -81,52 +88,111 @@ public void blockModeTransitionsCreatesBlockModeHeaderValidators() {
.buildHeader();
final BftProtocolSchedule schedule =
- createProtocolSchedule(
- JsonGenesisConfigOptions.fromJsonObject(JsonUtil.createEmptyObjectNode()),
- List.of(
- new ForkSpec<>(0, JsonQbftConfigOptions.DEFAULT),
- new ForkSpec<>(1, arbitraryTransition),
- new ForkSpec<>(2, JsonQbftConfigOptions.DEFAULT)));
+ createProtocolSchedule(component.bftExtraDataCodec(), arbitraryTransition);
assertThat(new MilestoneStreamingProtocolSchedule(schedule).streamMilestoneBlocks().count())
.isEqualTo(3);
- assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 0)).isTrue();
- assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 1)).isTrue();
- assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 2)).isTrue();
+ assertThat(validateHeader(schedule, parentHeader, blockHeader, 0)).isTrue();
+ assertThat(validateHeader(schedule, parentHeader, blockHeader, 1)).isTrue();
+ assertThat(validateHeader(schedule, parentHeader, blockHeader, 2)).isTrue();
+ }
+
+ private boolean validateHeader(
+ final BftProtocolSchedule schedule,
+ final BlockHeader parentHeader,
+ final BlockHeader blockHeader,
+ final int block) {
+ return schedule
+ .getByBlockNumberOrTimestamp(block, blockHeader.getTimestamp())
+ .getBlockHeaderValidator()
+ .validateHeader(
+ blockHeader, parentHeader, this.protocolContext, HeaderValidationMode.LIGHT);
}
private BftProtocolSchedule createProtocolSchedule(
- final GenesisConfigOptions genesisConfig, final List> forks) {
+ final BftExtraDataCodec bftExtraDataCodec,
+ final MutableBftConfigOptions arbitraryTransition) {
+
+ var genesisConfig = JsonGenesisConfigOptions.fromJsonObject(JsonUtil.createEmptyObjectNode());
+ ForksSchedule forkSched =
+ new ForksSchedule<>(
+ List.of(
+ new ForkSpec<>(0, JsonQbftConfigOptions.DEFAULT),
+ new ForkSpec<>(1, arbitraryTransition),
+ new ForkSpec<>(2, JsonQbftConfigOptions.DEFAULT)));
+
return IbftProtocolScheduleBuilder.create(
genesisConfig,
- new ForksSchedule<>(forks),
+ forkSched,
PrivacyParameters.DEFAULT,
false,
bftExtraDataCodec,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
}
- private boolean validateHeader(
- final BftProtocolSchedule schedule,
- final List validators,
- final BlockHeader parentHeader,
- final BlockHeader blockHeader,
- final int block) {
- return schedule
- .getByBlockNumberOrTimestamp(block, blockHeader.getTimestamp())
- .getBlockHeaderValidator()
- .validateHeader(
- blockHeader, parentHeader, protocolContext(validators), HeaderValidationMode.LIGHT);
+ @Module
+ static class IbftProtocolScheduleModule {
+ @Provides
+ @Singleton
+ NodeKey nodeKey() {
+ return NodeKeyUtils.generate();
+ }
+
+ @Provides
+ Address provideProposerAddress(final NodeKey proposerNodeKey) {
+ return Util.publicKeyToAddress(proposerNodeKey.getPublicKey());
+ }
+
+ @Provides
+ List provideValidators(final Address proposerAddress) {
+ return singletonList(proposerAddress);
+ }
+
+ @Provides
+ public BftExtraData mockBftExtraData(final List validators) {
+ BftExtraData bftExtraData = mock(BftExtraData.class);
+ when(bftExtraData.getValidators()).thenReturn(validators);
+ return bftExtraData;
+ }
+
+ @Provides
+ public BftExtraDataCodec mockBftExtraDataCodec(final BftExtraData bftExtraData) {
+ BftExtraDataCodec bftExtraDataCodec = mock(BftExtraDataCodec.class);
+ when(bftExtraDataCodec.decode(any())).thenReturn(bftExtraData);
+ return bftExtraDataCodec;
+ }
+
+ @Provides
+ ProtocolContext protocolContext(
+ final List validators, final BftExtraDataCodec bftExtraDataCodec) {
+ return new ProtocolContext(
+ null,
+ null,
+ setupContextWithBftExtraDataEncoder(BftContext.class, validators, bftExtraDataCodec),
+ new BadBlockManager());
+ }
+ }
+
+ @Singleton
+ @Component(modules = {NoMiningParamters.class, IbftProtocolScheduleModule.class})
+ interface TestEthCoreComponent extends EthereumCoreComponent {
+ ProtocolContext protocolContext();
+
+ List validators();
+
+ NodeKey nodeKey();
+
+ BftExtraDataCodec bftExtraDataCodec();
}
- private ProtocolContext protocolContext(final Collection validators) {
- return new ProtocolContext(
- null,
- null,
- setupContextWithBftExtraDataEncoder(BftContext.class, validators, bftExtraDataCodec),
- new BadBlockManager());
+ @Module
+ static class NoMiningParamters {
+ @Provides
+ MiningConfiguration provideMiningParameters() {
+ return MiningConfiguration.MINING_DISABLED;
+ }
}
}
diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java
index 5469717b13f..df5a313ae77 100644
--- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java
+++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java
@@ -42,9 +42,9 @@
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCache;
@@ -122,7 +122,7 @@ public BlockHeaderValidator.Builder createBlockHeaderRuleset(
false,
bftExtraDataEncoder,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -159,8 +159,8 @@ public BlockHeaderValidator.Builder createBlockHeaderRuleset(
transactionPool.setEnabled();
- final MiningParameters miningParameters =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(
@@ -178,7 +178,7 @@ public BlockHeaderValidator.Builder createBlockHeaderRuleset(
final BftBlockCreator blockCreator =
new BftBlockCreator(
- miningParameters,
+ miningConfiguration,
forksSchedule,
initialValidatorList.get(0),
parent ->
diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java
index b9f57debb6b..79022b7d544 100644
--- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java
+++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java
@@ -70,7 +70,7 @@
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@@ -180,12 +180,12 @@ public void setup() {
final ProtocolScheduleBuilder protocolScheduleBuilder =
new ProtocolScheduleBuilder(
new StubGenesisConfigOptions(),
- BigInteger.ONE,
+ Optional.empty(),
ProtocolSpecAdapters.create(0, Function.identity()),
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java
index abbc3b130aa..a8c84d5a093 100644
--- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java
+++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java
@@ -17,7 +17,7 @@
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -48,7 +48,7 @@ public class MergeProtocolSchedule {
*
* @param config the config
* @param isRevertReasonEnabled the is revert reason enabled
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @return the protocol schedule
@@ -56,7 +56,7 @@ public class MergeProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final boolean isRevertReasonEnabled,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -64,7 +64,7 @@ public static ProtocolSchedule create(
config,
PrivacyParameters.DEFAULT,
isRevertReasonEnabled,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -76,7 +76,7 @@ public static ProtocolSchedule create(
* @param config the config
* @param privacyParameters the privacy parameters
* @param isRevertReasonEnabled the is revert reason enabled
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @return the protocol schedule
@@ -85,7 +85,7 @@ public static ProtocolSchedule create(
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -101,12 +101,12 @@ public static ProtocolSchedule create(
return new ProtocolScheduleBuilder(
config,
- DEFAULT_CHAIN_ID,
+ Optional.of(DEFAULT_CHAIN_ID),
new ProtocolSpecAdapters(postMergeModifications),
privacyParameters,
isRevertReasonEnabled,
EvmConfiguration.DEFAULT,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem)
diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java
index e733cc800ec..44fd5f8edfc 100644
--- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java
+++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java
@@ -20,7 +20,7 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PermissionTransactionFilter;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
@@ -65,21 +65,21 @@ public TransitionProtocolSchedule(
*
* @param genesisConfigOptions {@link GenesisConfigOptions} containing the config options for the
* milestone starting points
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @return an initialised TransitionProtocolSchedule using post-merge defaults
*/
public static TransitionProtocolSchedule fromConfig(
final GenesisConfigOptions genesisConfigOptions,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
ProtocolSchedule preMergeProtocolSchedule =
MainnetProtocolSchedule.fromConfig(
genesisConfigOptions,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -87,7 +87,7 @@ public static TransitionProtocolSchedule fromConfig(
MergeProtocolSchedule.create(
genesisConfigOptions,
false,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java
index c56c62d80db..56c78877a67 100644
--- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java
+++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java
@@ -19,7 +19,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.SealableBlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Withdrawal;
@@ -39,7 +39,7 @@ class MergeBlockCreator extends AbstractBlockCreator {
/**
* Instantiates a new Merge block creator.
*
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param extraDataCalculator the extra data calculator
* @param transactionPool the pending transactions
* @param protocolContext the protocol context
@@ -47,7 +47,7 @@ class MergeBlockCreator extends AbstractBlockCreator {
* @param parentHeader the parent header
*/
public MergeBlockCreator(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final ExtraDataCalculator extraDataCalculator,
final TransactionPool transactionPool,
final ProtocolContext protocolContext,
@@ -55,8 +55,8 @@ public MergeBlockCreator(
final BlockHeader parentHeader,
final EthScheduler ethScheduler) {
super(
- miningParameters,
- __ -> miningParameters.getCoinbase().orElseThrow(),
+ miningConfiguration,
+ __ -> miningConfiguration.getCoinbase().orElseThrow(),
extraDataCalculator,
transactionPool,
protocolContext,
diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java
index 877d7fb9633..7570e97d4d6 100644
--- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java
+++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java
@@ -33,7 +33,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockWithReceipts;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Withdrawal;
@@ -81,7 +81,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene
private static final long DEFAULT_TARGET_GAS_LIMIT = 30000000L;
/** The Mining parameters. */
- protected final MiningParameters miningParameters;
+ protected final MiningConfiguration miningConfiguration;
/** The Merge block creator factory. */
protected final MergeBlockCreatorFactory mergeBlockCreatorFactory;
@@ -120,7 +120,7 @@ public MergeCoordinator(
final ProtocolSchedule protocolSchedule,
final EthScheduler ethScheduler,
final TransactionPool transactionPool,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final BackwardSyncContext backwardSyncContext,
final Optional depositContractAddress) {
this.protocolContext = protocolContext;
@@ -137,14 +137,14 @@ public MergeCoordinator(
}
miningParams.setMinBlockOccupancyRatio(TRY_FILL_BLOCK);
- this.miningParameters = miningParams;
+ this.miningConfiguration = miningParams;
this.mergeBlockCreatorFactory =
(parentHeader, address) -> {
address.ifPresent(miningParams::setCoinbase);
return new MergeBlockCreator(
- miningParameters,
- parent -> miningParameters.getExtraData(),
+ miningConfiguration,
+ parent -> miningConfiguration.getExtraData(),
transactionPool,
protocolContext,
protocolSchedule,
@@ -169,7 +169,7 @@ public MergeCoordinator(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
final EthScheduler ethScheduler,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final BackwardSyncContext backwardSyncContext,
final MergeBlockCreatorFactory mergeBlockCreatorFactory) {
@@ -182,7 +182,7 @@ public MergeCoordinator(
miningParams.setTargetGasLimit(DEFAULT_TARGET_GAS_LIMIT);
}
miningParams.setMinBlockOccupancyRatio(TRY_FILL_BLOCK);
- this.miningParameters = miningParams;
+ this.miningConfiguration = miningParams;
this.mergeBlockCreatorFactory = mergeBlockCreatorFactory;
@@ -215,17 +215,17 @@ public boolean isMining() {
@Override
public Wei getMinTransactionGasPrice() {
- return miningParameters.getMinTransactionGasPrice();
+ return miningConfiguration.getMinTransactionGasPrice();
}
@Override
public Wei getMinPriorityFeePerGas() {
- return miningParameters.getMinPriorityFeePerGas();
+ return miningConfiguration.getMinPriorityFeePerGas();
}
@Override
public Optional getCoinbase() {
- return miningParameters.getCoinbase();
+ return miningConfiguration.getCoinbase();
}
@Override
@@ -244,7 +244,7 @@ public Optional createBlock(final BlockHeader parentHeader, final long ti
@Override
public void changeTargetGasLimit(final Long newTargetGasLimit) {
if (AbstractGasLimitSpecification.isValidTargetGasLimit(newTargetGasLimit)) {
- this.miningParameters.setTargetGasLimit(newTargetGasLimit);
+ this.miningConfiguration.setTargetGasLimit(newTargetGasLimit);
} else {
throw new IllegalArgumentException("Specified target gas limit is invalid");
}
@@ -383,13 +383,13 @@ private void tryToBuildBetterBlock(
LOG.debug(
"Block creation started for payload id {}, remaining time is {}ms",
payloadIdentifier,
- miningParameters.getUnstable().getPosBlockCreationMaxTime());
+ miningConfiguration.getUnstable().getPosBlockCreationMaxTime());
ethScheduler
.scheduleBlockCreationTask(
() -> retryBlockCreationUntilUseful(payloadIdentifier, blockCreator))
.orTimeout(
- miningParameters.getUnstable().getPosBlockCreationMaxTime(), TimeUnit.MILLISECONDS)
+ miningConfiguration.getUnstable().getPosBlockCreationMaxTime(), TimeUnit.MILLISECONDS)
.whenComplete(
(unused, throwable) -> {
if (throwable != null) {
@@ -416,7 +416,7 @@ private Void retryBlockCreationUntilUseful(
final long waitBeforeRepetition =
Math.max(
100,
- miningParameters.getUnstable().getPosBlockCreationRepetitionMinDuration()
+ miningConfiguration.getUnstable().getPosBlockCreationRepetitionMinDuration()
- lastDuration);
LOG.debug("Waiting {}ms before repeating block creation", waitBeforeRepetition);
Thread.sleep(waitBeforeRepetition);
@@ -726,7 +726,7 @@ public CompletableFuture appendNewPayloadToSync(final Block newPayload) {
@Override
public boolean isMiningBeforeMerge() {
- return miningParameters.isMiningEnabled();
+ return miningConfiguration.isMiningEnabled();
}
private Optional findValidAncestor(final Blockchain chain, final Hash parentHash) {
diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java
index 0d4aede3a14..ba83f8aad9c 100644
--- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java
+++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java
@@ -22,7 +22,7 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockProcessor;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
@@ -51,7 +51,7 @@ public void protocolSpecsAreCreatedAtBlockDefinedInJson() {
MergeProtocolSchedule.create(
config,
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -72,7 +72,7 @@ public void mergeSpecificModificationsAreUnappliedForShanghai() {
MergeProtocolSchedule.create(
config,
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -113,7 +113,7 @@ public void mergeSpecificModificationsAreUnappliedForCancun_whenShanghaiNotConfi
MergeProtocolSchedule.create(
config,
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -146,7 +146,7 @@ public void mergeSpecificModificationsAreUnappliedForAllMainnetForksAfterParis()
MergeProtocolSchedule.create(
config,
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -180,7 +180,7 @@ public void parametersAlignWithMainnetWithAdjustments() {
MergeProtocolSchedule.create(
GenesisConfigFile.DEFAULT.getConfigOptions(),
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java
index 4efcdc1e0f0..90c4b6866e4 100644
--- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java
+++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java
@@ -55,11 +55,10 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.Unstable;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
-import org.hyperledger.besu.ethereum.core.Synchronizer;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.Unstable;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -135,8 +134,8 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper {
private final Address coinbase = genesisAllocations(getPosGenesisConfigFile()).findFirst().get();
- private MiningParameters miningParameters =
- ImmutableMiningParameters.builder()
+ private MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(MutableInitValues.builder().coinbase(coinbase).build())
.unstable(
Unstable.builder()
@@ -190,7 +189,6 @@ public void setUp() {
protocolContext =
new ProtocolContext(blockchain, worldStateArchive, mergeContext, badBlockManager);
- protocolContext.setSynchronizer(mock(Synchronizer.class));
var mutable = worldStateArchive.getMutable();
genesisState.writeStateTo(mutable);
mutable.persist(null);
@@ -228,7 +226,7 @@ public void setUp() {
protocolSchedule,
ethScheduler,
transactionPool,
- miningParameters,
+ miningConfiguration,
backwardSyncContext,
Optional.empty());
}
@@ -273,7 +271,7 @@ public void exceptionDuringBuildingBlockShouldNotBeInvalid()
MergeBlockCreator beingSpiedOn =
spy(
new MergeBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> Bytes.EMPTY,
transactionPool,
protocolContext,
@@ -302,7 +300,7 @@ public void exceptionDuringBuildingBlockShouldNotBeInvalid()
protocolContext,
protocolSchedule,
ethScheduler,
- miningParameters,
+ miningConfiguration,
backwardSyncContext,
mergeBlockCreatorFactory));
@@ -543,9 +541,9 @@ public void shouldRetryBlockCreationOnRecoverableError()
@Test
public void shouldStopRetryBlockCreationIfTimeExpired() throws InterruptedException {
final AtomicLong retries = new AtomicLong(0);
- miningParameters =
- ImmutableMiningParameters.builder()
- .from(miningParameters)
+ miningConfiguration =
+ ImmutableMiningConfiguration.builder()
+ .from(miningConfiguration)
.unstable(Unstable.builder().posBlockCreationMaxTime(100).build())
.build();
doAnswer(
@@ -737,8 +735,8 @@ public void shouldCancelPreviousBlockCreationJobIfCalledAgainWithNewPayloadId()
public void shouldUseExtraDataFromMiningParameters() {
final Bytes extraData = Bytes.fromHexString("0x1234");
- miningParameters =
- ImmutableMiningParameters.builder()
+ miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(MutableInitValues.builder().extraData(extraData).build())
.build();
@@ -748,7 +746,7 @@ public void shouldUseExtraDataFromMiningParameters() {
protocolSchedule,
ethScheduler,
transactionPool,
- miningParameters,
+ miningConfiguration,
backwardSyncContext,
Optional.empty());
diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java
index dcfe5f98e34..582c8c5dd55 100644
--- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java
+++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java
@@ -19,7 +19,7 @@
import org.hyperledger.besu.consensus.merge.MergeProtocolSchedule;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -56,7 +56,7 @@ default ProtocolSchedule getMergeProtocolSchedule() {
return MergeProtocolSchedule.create(
getPosGenesisConfigFile().getConfigOptions(),
false,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java
index 7b111268e0f..22153eeceee 100644
--- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java
+++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java
@@ -34,8 +34,8 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.sync.backwardsync.BackwardSyncContext;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -96,7 +96,7 @@ public void setUp() {
mockProtocolSchedule,
ethScheduler,
mockTransactionPool,
- ImmutableMiningParameters.builder()
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(MutableInitValues.builder().coinbase(coinbase).build())
.build(),
mock(BackwardSyncContext.class),
diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
index d90d5a15277..cc7066f17ee 100644
--- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
+++ b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
@@ -91,9 +91,9 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@@ -387,8 +387,8 @@ private static ControllerAndState createControllerAndFinalState(
final boolean useFixedBaseFee,
final List qbftForks) {
- final MiningParameters miningParams =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningParams =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.isMiningEnabled(true)
@@ -438,7 +438,7 @@ private static ControllerAndState createControllerAndFinalState(
forksSchedule,
BFT_EXTRA_DATA_ENCODER,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java
index e1cbc134b6f..473b99332ec 100644
--- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java
+++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java
@@ -24,7 +24,7 @@
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -50,7 +50,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
* @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
- * @param miningParameters The mining parameters
+ * @param miningConfiguration The mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -64,7 +64,7 @@ public static BftProtocolSchedule create(
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -76,7 +76,7 @@ public static BftProtocolSchedule create(
isRevertReasonEnabled,
bftExtraDataCodec,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -89,7 +89,7 @@ public static BftProtocolSchedule create(
* @param qbftForksSchedule the qbft forks schedule
* @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration
- * @param miningParameters The mining parameters
+ * @param miningConfiguration The mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -101,7 +101,7 @@ public static BftProtocolSchedule create(
final ForksSchedule qbftForksSchedule,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -112,7 +112,7 @@ public static BftProtocolSchedule create(
false,
bftExtraDataCodec,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -125,7 +125,7 @@ public static BftProtocolSchedule create(
* @param qbftForksSchedule the qbft forks schedule
* @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec
- * @param miningParameters The mining parameters
+ * @param miningConfiguration The mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
@@ -137,7 +137,7 @@ public static ProtocolSchedule create(
final ForksSchedule qbftForksSchedule,
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -148,7 +148,7 @@ public static ProtocolSchedule create(
isRevertReasonEnabled,
bftExtraDataCodec,
EvmConfiguration.DEFAULT,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java
index 10f61713d9e..fc46b6c32fb 100644
--- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java
+++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java
@@ -23,7 +23,7 @@
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -52,7 +52,7 @@ public QbftBlockCreatorFactory(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
final ForksSchedule forksSchedule,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final Address localAddress,
final BftExtraDataCodec bftExtraDataCodec,
final EthScheduler ethScheduler) {
@@ -74,7 +74,7 @@ public Bytes createExtraData(final int round, final BlockHeader parentHeader) {
final BftExtraData extraData =
new BftExtraData(
ConsensusHelpers.zeroLeftPad(
- miningParameters.getExtraData(), BftExtraDataCodec.EXTRA_VANITY_LENGTH),
+ miningConfiguration.getExtraData(), BftExtraDataCodec.EXTRA_VANITY_LENGTH),
Collections.emptyList(),
Optional.empty(),
round,
diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/QbftJsonRpcMethods.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/QbftJsonRpcMethods.java
index ce8ce388f26..a0aaf3a16db 100644
--- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/QbftJsonRpcMethods.java
+++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/QbftJsonRpcMethods.java
@@ -30,7 +30,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.ApiGroupJsonRpcMethods;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import java.util.Map;
@@ -41,7 +41,7 @@ public class QbftJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final ProtocolContext context;
private final ValidatorProvider readOnlyValidatorProvider;
private final ProtocolSchedule protocolSchedule;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
private final BftConfigOptions bftConfig;
/**
@@ -49,20 +49,20 @@ public class QbftJsonRpcMethods extends ApiGroupJsonRpcMethods {
*
* @param context the protocol context
* @param protocolSchedule the protocol schedule
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param readOnlyValidatorProvider the read only validator provider
* @param bftConfig the BFT config options, containing QBFT-specific settings
*/
public QbftJsonRpcMethods(
final ProtocolContext context,
final ProtocolSchedule protocolSchedule,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final ValidatorProvider readOnlyValidatorProvider,
final BftConfigOptions bftConfig) {
this.context = context;
this.readOnlyValidatorProvider = readOnlyValidatorProvider;
this.protocolSchedule = protocolSchedule;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
this.bftConfig = bftConfig;
}
@@ -78,7 +78,7 @@ protected Map create() {
protocolSchedule,
context.getBlockchain(),
context.getWorldStateArchive(),
- miningParameters);
+ miningConfiguration);
final BftContext bftContext = context.getConsensusContext(BftContext.class);
final BlockInterface blockInterface = bftContext.getBlockInterface();
final ValidatorProvider validatorProvider = bftContext.getValidatorProvider();
diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleTest.java b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleTest.java
index 020d6e0e5ae..01783571dce 100644
--- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleTest.java
+++ b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleTest.java
@@ -36,7 +36,7 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
@@ -138,7 +138,7 @@ private BftProtocolSchedule createProtocolSchedule(
false,
bftExtraDataCodec,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactoryTest.java b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactoryTest.java
index 27c50144531..f3682e2533d 100644
--- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactoryTest.java
+++ b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactoryTest.java
@@ -30,9 +30,9 @@
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.testutil.DeterministicEthScheduler;
@@ -50,8 +50,8 @@ public class QbftBlockCreatorFactoryTest {
@BeforeEach
@SuppressWarnings("unchecked")
public void setUp() {
- final MiningParameters miningParams =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningParams =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(Bytes.wrap("Qbft tests".getBytes(UTF_8)))
diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java
index 190c87e020f..b6adcb73e62 100644
--- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java
+++ b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java
@@ -69,7 +69,7 @@
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@@ -182,12 +182,12 @@ BftContext.class, validators, new QbftExtraDataCodec()),
final ProtocolScheduleBuilder protocolScheduleBuilder =
new ProtocolScheduleBuilder(
new StubGenesisConfigOptions(),
- BigInteger.ONE,
+ Optional.of(BigInteger.ONE),
ProtocolSpecAdapters.create(0, Function.identity()),
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/docs/trace_rpc_apis.md b/docs/trace_rpc_apis.md
index e8db0bcbc5c..7f04d497a7b 100644
--- a/docs/trace_rpc_apis.md
+++ b/docs/trace_rpc_apis.md
@@ -16,7 +16,7 @@ implementations of Besu might track gas refunds separately.
### Returned Memory from Calls
-In the `vmTrace` `ope.ex.mem` fields Besu only reports actual data returned
+In the `vmTrace` `op.ex.mem` fields Besu only reports actual data returned
from a `RETURN` opcode. Other implementations return the contents of the
reserved output space for the call operations. Note two major differences:
diff --git a/enclave/build.gradle b/enclave/build.gradle
index 25aeb466d77..24aa1b2e64d 100644
--- a/enclave/build.gradle
+++ b/enclave/build.gradle
@@ -24,5 +24,4 @@ dependencies {
integrationTestImplementation 'org.awaitility:awaitility'
integrationTestImplementation 'org.junit.jupiter:junit-jupiter-api'
integrationTestImplementation 'org.mockito:mockito-core'
- integrationTestImplementation 'org.testcontainers:testcontainers'
}
diff --git a/ethereum/api/build.gradle b/ethereum/api/build.gradle
index 7f5e3d40a9c..6bbfa531a99 100644
--- a/ethereum/api/build.gradle
+++ b/ethereum/api/build.gradle
@@ -121,7 +121,6 @@ dependencies {
integrationTestImplementation 'org.junit.jupiter:junit-jupiter'
integrationTestImplementation 'org.mockito:mockito-core'
integrationTestImplementation 'org.mockito:mockito-junit-jupiter'
- integrationTestImplementation 'org.testcontainers:testcontainers'
integrationTestRuntimeOnly 'org.junit.jupiter:junit-jupiter'
}
diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java
index 3e261abf6d7..7e1be90e10e 100644
--- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java
+++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java
@@ -19,7 +19,7 @@
import org.hyperledger.besu.ethereum.chain.GenesisState;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
@@ -46,7 +46,7 @@ public BlockchainImporter(final URL blocksUrl, final String genesisJson) throws
protocolSchedule =
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig(genesisJson).getConfigOptions(),
- MiningParameters.newDefault(),
+ MiningConfiguration.newDefault(),
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java
index bf5d12804b9..045b4ad02d3 100644
--- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java
+++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java
@@ -38,5 +38,6 @@ public enum JsonRpcResponseKey {
TRANSACTION_ROOT,
BASEFEE,
WITHDRAWALS_ROOT,
- REQUESTS_HASH
+ REQUESTS_HASH,
+ TARGET_BLOB_COUNT
}
diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java
index d72db974b0a..7e5e08aa7bb 100644
--- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java
+++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java
@@ -63,6 +63,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;
+import org.apache.tuweni.units.bigints.UInt64;
public class JsonRpcResponseUtils {
@@ -106,6 +107,10 @@ public JsonRpcResponse response(
values.containsKey(WITHDRAWALS_ROOT) ? hash(values.get(WITHDRAWALS_ROOT)) : null;
final Hash requestsHash =
values.containsKey(REQUESTS_HASH) ? hash(values.get(REQUESTS_HASH)) : null;
+ final UInt64 targetBlobCount =
+ values.containsKey(JsonRpcResponseKey.TARGET_BLOB_COUNT)
+ ? UInt64.fromHexString(values.get(JsonRpcResponseKey.TARGET_BLOB_COUNT))
+ : null;
final List ommers = new ArrayList<>();
final BlockHeader header =
@@ -131,6 +136,7 @@ public JsonRpcResponse response(
null, // ToDo 4844: set with the value of excess_blob_gas field
null, // TODO 4788: set with the value of the parent beacon block root field
requestsHash,
+ targetBlobCount,
blockHeaderFunctions);
return new JsonRpcSuccessResponse(
diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java
index c7ba5a4f934..902d2b04870 100644
--- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java
+++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java
@@ -33,7 +33,7 @@
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockImporter;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
@@ -94,7 +94,7 @@ public JsonRpcTestMethodsFactory(final BlockchainImporter importer) {
}
this.blockchainQueries =
new BlockchainQueries(
- protocolSchedule, blockchain, stateArchive, MiningParameters.newDefault());
+ protocolSchedule, blockchain, stateArchive, MiningConfiguration.newDefault());
}
public JsonRpcTestMethodsFactory(
@@ -112,7 +112,7 @@ public JsonRpcTestMethodsFactory(
importer.getProtocolSchedule(),
blockchain,
stateArchive,
- MiningParameters.newDefault());
+ MiningConfiguration.newDefault());
this.synchronizer = mock(Synchronizer.class);
}
@@ -133,7 +133,7 @@ public JsonRpcTestMethodsFactory(
importer.getProtocolSchedule(),
blockchain,
stateArchive,
- MiningParameters.newDefault());
+ MiningConfiguration.newDefault());
}
public BlockchainQueries getBlockchainQueries() {
@@ -152,7 +152,7 @@ public Map methods() {
final P2PNetwork peerDiscovery = mock(P2PNetwork.class);
final EthPeers ethPeers = mock(EthPeers.class);
final TransactionPool transactionPool = mock(TransactionPool.class);
- final MiningParameters miningParameters = mock(MiningParameters.class);
+ final MiningConfiguration miningConfiguration = mock(MiningConfiguration.class);
final PoWMiningCoordinator miningCoordinator = mock(PoWMiningCoordinator.class);
final ObservableMetricsSystem metricsSystem = new NoOpMetricsSystem();
final Optional accountWhitelistController =
@@ -198,7 +198,7 @@ public Map methods() {
context,
filterManager,
transactionPool,
- miningParameters,
+ miningConfiguration,
miningCoordinator,
metricsSystem,
new HashSet<>(),
diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java
index d4de405305b..b238259d66f 100644
--- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java
+++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java
@@ -45,7 +45,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@@ -130,7 +130,7 @@ public void setUp() {
executionContext.getProtocolSchedule(),
blockchain,
protocolContext.getWorldStateArchive(),
- MiningParameters.newDefault());
+ MiningConfiguration.newDefault());
filterManager =
new FilterManagerBuilder()
.blockchainQueries(blockchainQueries)
diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthGetFilterChangesIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthGetFilterChangesIntegrationTest.java
index 0c194ad22f2..fc5379f1962 100644
--- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthGetFilterChangesIntegrationTest.java
+++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthGetFilterChangesIntegrationTest.java
@@ -45,7 +45,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
@@ -130,7 +130,7 @@ public void setUp() {
executionContext.getProtocolSchedule(),
blockchain,
protocolContext.getWorldStateArchive(),
- MiningParameters.newDefault());
+ MiningConfiguration.newDefault());
filterManager =
new FilterManagerBuilder()
.blockchainQueries(blockchainQueries)
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/AbstractJsonRpcExecutor.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/AbstractJsonRpcExecutor.java
index 95dc88f6a5d..f73d162fa14 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/AbstractJsonRpcExecutor.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/AbstractJsonRpcExecutor.java
@@ -106,6 +106,7 @@ protected static void handleJsonRpcError(
private static HttpResponseStatus statusCodeFromError(final RpcErrorType error) {
return switch (error) {
case INVALID_REQUEST, PARSE_ERROR -> HttpResponseStatus.BAD_REQUEST;
+ case TIMEOUT_ERROR -> HttpResponseStatus.REQUEST_TIMEOUT;
default -> HttpResponseStatus.OK;
};
}
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandler.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandler.java
index 278a38c5578..83866316959 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandler.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandler.java
@@ -34,6 +34,9 @@
public class JsonRpcExecutorHandler {
private static final Logger LOG = LoggerFactory.getLogger(JsonRpcExecutorHandler.class);
+ // Default timeout for RPC calls in seconds
+ private static final long DEFAULT_TIMEOUT_MILLISECONDS = 30_000L;
+
private JsonRpcExecutorHandler() {}
public static Handler handler(
@@ -49,6 +52,19 @@ public static Handler handler(
final Tracer tracer,
final JsonRpcConfiguration jsonRpcConfiguration) {
return ctx -> {
+ final long timerId =
+ ctx.vertx()
+ .setTimer(
+ DEFAULT_TIMEOUT_MILLISECONDS,
+ id -> {
+ final String method =
+ ctx.get(ContextKey.REQUEST_BODY_AS_JSON_OBJECT.name()).toString();
+ LOG.error("Timeout occurred in JSON-RPC executor for method {}", method);
+ handleErrorAndEndResponse(ctx, null, RpcErrorType.TIMEOUT_ERROR);
+ });
+
+ ctx.put("timerId", timerId);
+
try {
createExecutor(jsonRpcExecutor, tracer, ctx, jsonRpcConfiguration)
.ifPresentOrElse(
@@ -58,18 +74,38 @@ public static Handler handler(
} catch (IOException e) {
final String method = executor.getRpcMethodName(ctx);
LOG.error("{} - Error streaming JSON-RPC response", method, e);
- handleJsonRpcError(ctx, null, RpcErrorType.INTERNAL_ERROR);
+ handleErrorAndEndResponse(ctx, null, RpcErrorType.INTERNAL_ERROR);
+ } finally {
+ cancelTimer(ctx);
}
},
- () -> handleJsonRpcError(ctx, null, RpcErrorType.PARSE_ERROR));
+ () -> {
+ handleErrorAndEndResponse(ctx, null, RpcErrorType.PARSE_ERROR);
+ cancelTimer(ctx);
+ });
} catch (final RuntimeException e) {
- final String method = ctx.get(ContextKey.REQUEST_BODY_AS_JSON_OBJECT.name());
+ final String method = ctx.get(ContextKey.REQUEST_BODY_AS_JSON_OBJECT.name()).toString();
LOG.error("Unhandled exception in JSON-RPC executor for method {}", method, e);
- handleJsonRpcError(ctx, null, RpcErrorType.INTERNAL_ERROR);
+ handleErrorAndEndResponse(ctx, null, RpcErrorType.INTERNAL_ERROR);
+ cancelTimer(ctx);
}
};
}
+ private static void cancelTimer(final RoutingContext ctx) {
+ Long timerId = ctx.get("timerId");
+ if (timerId != null) {
+ ctx.vertx().cancelTimer(timerId);
+ }
+ }
+
+ private static void handleErrorAndEndResponse(
+ final RoutingContext ctx, final Object id, final RpcErrorType errorType) {
+ if (!ctx.response().ended()) {
+ handleJsonRpcError(ctx, id, errorType);
+ }
+ }
+
private static Optional createExecutor(
final JsonRpcExecutor jsonRpcExecutor,
final Tracer tracer,
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/JsonRpcExecutor.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/JsonRpcExecutor.java
index 6fedcc70ca4..b8786eb7a5d 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/JsonRpcExecutor.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/JsonRpcExecutor.java
@@ -104,9 +104,9 @@ public JsonRpcResponse execute(
private Optional validateMethodAvailability(final JsonRpcRequest request) {
final String name = request.getMethod();
- if (LOG.isDebugEnabled()) {
+ if (LOG.isTraceEnabled()) {
final JsonArray params = JsonObject.mapFrom(request).getJsonArray("params");
- LOG.debug("JSON-RPC request -> {} {}", name, params);
+ LOG.trace("JSON-RPC request -> {} {}", name, params);
}
final JsonRpcMethod method = rpcMethods.get(name);
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHead.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHead.java
index 7958f8e7595..c2210f81748 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHead.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHead.java
@@ -21,22 +21,41 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters;
-import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
+import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
+import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
+import org.hyperledger.besu.ethereum.core.BlockHeader;
+import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedWorldStateProvider;
import java.util.Optional;
-public class DebugSetHead extends AbstractBlockParameterMethod {
+import graphql.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DebugSetHead extends AbstractBlockParameterOrBlockHashMethod {
private final ProtocolContext protocolContext;
+ private static final Logger LOG = LoggerFactory.getLogger(DebugSetHead.class);
+ private static final int DEFAULT_MAX_TRIE_LOGS_TO_ROLL_AT_ONCE = 512;
+
+ private final long maxTrieLogsToRollAtOnce;
public DebugSetHead(final BlockchainQueries blockchain, final ProtocolContext protocolContext) {
- super(blockchain);
+ this(blockchain, protocolContext, DEFAULT_MAX_TRIE_LOGS_TO_ROLL_AT_ONCE);
+ }
+ @VisibleForTesting
+ DebugSetHead(
+ final BlockchainQueries blockchain,
+ final ProtocolContext protocolContext,
+ final long maxTrieLogsToRollAtOnce) {
+ super(blockchain);
this.protocolContext = protocolContext;
+ this.maxTrieLogsToRollAtOnce = Math.abs(maxTrieLogsToRollAtOnce);
}
@Override
@@ -45,26 +64,108 @@ public String getName() {
}
@Override
- protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
+ protected BlockParameterOrBlockHash blockParameterOrBlockHash(
+ final JsonRpcRequestContext requestContext) {
try {
- return request.getRequiredParameter(0, BlockParameter.class);
+ return requestContext.getRequiredParameter(0, BlockParameterOrBlockHash.class);
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
- "Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
+ "Invalid block or block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
}
}
@Override
- protected Object resultByBlockNumber(
- final JsonRpcRequestContext request, final long blockNumber) {
- final Optional maybeBlockHash = getBlockchainQueries().getBlockHashByNumber(blockNumber);
+ protected Object resultByBlockHash(final JsonRpcRequestContext request, final Hash blockHash) {
+ var blockchainQueries = getBlockchainQueries();
+ var blockchain = protocolContext.getBlockchain();
+ Optional maybeBlockHeader = blockchainQueries.getBlockHeaderByHash(blockHash);
+ Optional maybeMoveWorldstate = shouldMoveWorldstate(request);
- if (maybeBlockHash.isEmpty()) {
+ if (maybeBlockHeader.isEmpty()) {
return new JsonRpcErrorResponse(request.getRequest().getId(), UNKNOWN_BLOCK);
}
- protocolContext.getBlockchain().rewindToBlock(maybeBlockHash.get());
+ // Optionally move the worldstate to the specified blockhash, if it is present in the chain
+ if (maybeMoveWorldstate.orElse(Boolean.FALSE)) {
+ var archive = blockchainQueries.getWorldStateArchive();
+
+ // Only DiffBasedWorldState's need to be moved:
+ if (archive instanceof DiffBasedWorldStateProvider diffBasedArchive) {
+ if (rollIncrementally(maybeBlockHeader.get(), blockchain, diffBasedArchive)) {
+ return JsonRpcSuccessResponse.SUCCESS_RESULT;
+ }
+ }
+ }
+
+ // If we are not rolling incrementally or if there was an error incrementally rolling,
+ // move the blockchain to the requested hash:
+ blockchain.rewindToBlock(maybeBlockHeader.get().getBlockHash());
return JsonRpcSuccessResponse.SUCCESS_RESULT;
}
+
+ private boolean rollIncrementally(
+ final BlockHeader target,
+ final MutableBlockchain blockchain,
+ final DiffBasedWorldStateProvider archive) {
+
+ try {
+ if (archive.isWorldStateAvailable(target.getStateRoot(), target.getBlockHash())) {
+ // WARNING, this can be dangerous for a DiffBasedWorldstate if a concurrent
+ // process attempts to move or modify the head worldstate.
+ // Ensure no block processing is occuring when using this feature.
+ // No engine-api, block import, sync, mining or other rpc calls should be running.
+
+ Optional currentHead =
+ archive
+ .getWorldStateKeyValueStorage()
+ .getWorldStateBlockHash()
+ .flatMap(blockchain::getBlockHeader);
+
+ while (currentHead.isPresent()
+ && !target.getStateRoot().equals(currentHead.get().getStateRoot())) {
+ long delta = currentHead.get().getNumber() - target.getNumber();
+
+ if (maxTrieLogsToRollAtOnce < Math.abs(delta)) {
+ // do we need to move forward or backward?
+ long distanceToMove = (delta > 0) ? -maxTrieLogsToRollAtOnce : maxTrieLogsToRollAtOnce;
+
+ // Add distanceToMove to the current block number to get the interim target header
+ var interimHead =
+ blockchain.getBlockHeader(currentHead.get().getNumber() + distanceToMove);
+
+ interimHead.ifPresent(
+ it -> {
+ blockchain.rewindToBlock(it.getBlockHash());
+ archive.getMutable(it.getStateRoot(), it.getBlockHash());
+ LOG.info("incrementally rolled worldstate to {}", it.toLogString());
+ });
+ currentHead = interimHead;
+
+ } else {
+ blockchain.rewindToBlock(target.getBlockHash());
+ archive.getMutable(target.getStateRoot(), target.getBlockHash());
+ currentHead = Optional.of(target);
+ LOG.info("finished rolling worldstate to {}", target.toLogString());
+ }
+ }
+ }
+
+ return true;
+ } catch (Exception ex) {
+ LOG.error("Failed to incrementally roll blockchain to " + target.toLogString(), ex);
+ return false;
+ }
+ }
+
+ private Optional shouldMoveWorldstate(final JsonRpcRequestContext request) {
+ try {
+ return request.getOptionalParameter(1, Boolean.class);
+ } catch (JsonRpcParameterException e) {
+ throw new InvalidJsonRpcParameters(
+ "Invalid should move worldstate boolean parameter (index 1)",
+ RpcErrorType.INVALID_PARAMS,
+ e);
+ }
+ }
}
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java
index 308940f16aa..8562e140f56 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java
@@ -279,6 +279,7 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
: BlobGas.fromHexString(blockParam.getExcessBlobGas()),
maybeParentBeaconBlockRoot.orElse(null),
maybeRequests.map(BodyValidation::requestsHash).orElse(null),
+ null, // TODO SLD EIP-7742 wiring in future PR
headerFunctions);
// ensure the block hash matches the blockParam hash
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java
index 00b0f830540..8d6bd7e4333 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java
@@ -61,11 +61,11 @@ protected ValidationResult validateParameters(
final Optional> maybeRequestsParam) {
if (payloadParameter.getBlobGasUsed() != null) {
return ValidationResult.invalid(
- RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field");
+ RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Unexpected blob gas used field present");
}
if (payloadParameter.getExcessBlobGas() != null) {
return ValidationResult.invalid(
- RpcErrorType.INVALID_EXCESS_BLOB_GAS_PARAMS, "Missing excess blob gas field");
+ RpcErrorType.INVALID_EXCESS_BLOB_GAS_PARAMS, "Unexpected excess blob gas field present");
}
return ValidationResult.valid();
}
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraData.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraData.java
index b433ed0b6af..02d7bac98c8 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraData.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraData.java
@@ -19,13 +19,13 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
public class MinerGetExtraData implements JsonRpcMethod {
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
- public MinerGetExtraData(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public MinerGetExtraData(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -36,6 +36,6 @@ public String getName() {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
return new JsonRpcSuccessResponse(
- requestContext.getRequest().getId(), miningParameters.getExtraData().toShortHexString());
+ requestContext.getRequest().getId(), miningConfiguration.getExtraData().toShortHexString());
}
}
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPrice.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPrice.java
index 07e8fdc9b63..353125f84c7 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPrice.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPrice.java
@@ -20,13 +20,13 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
public class MinerGetMinGasPrice implements JsonRpcMethod {
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
- public MinerGetMinGasPrice(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public MinerGetMinGasPrice(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -38,6 +38,6 @@ public String getName() {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
return new JsonRpcSuccessResponse(
requestContext.getRequest().getId(),
- Quantity.create(miningParameters.getMinTransactionGasPrice()));
+ Quantity.create(miningConfiguration.getMinTransactionGasPrice()));
}
}
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFee.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFee.java
index d99d13de2ce..e12810b30fc 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFee.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFee.java
@@ -20,13 +20,13 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
public class MinerGetMinPriorityFee implements JsonRpcMethod {
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
- public MinerGetMinPriorityFee(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public MinerGetMinPriorityFee(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -38,6 +38,6 @@ public String getName() {
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
return new JsonRpcSuccessResponse(
requestContext.getRequest().getId(),
- Quantity.create(miningParameters.getMinPriorityFeePerGas()));
+ Quantity.create(miningConfiguration.getMinPriorityFeePerGas()));
}
}
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraData.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraData.java
index 51395e24f77..7d5fa5b2e01 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraData.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraData.java
@@ -23,7 +23,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import java.nio.charset.StandardCharsets;
@@ -35,10 +35,10 @@
public class MinerSetExtraData implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(MinerSetExtraData.class);
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
- public MinerSetExtraData(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public MinerSetExtraData(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -53,7 +53,7 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
Bytes32.fromHexStringLenient(
rawParam); // done for validation, we want a hex string and max 32 bytes
final var extraData = Bytes.fromHexStringLenient(rawParam);
- miningParameters.setExtraData(extraData);
+ miningConfiguration.setExtraData(extraData);
LOG.atDebug()
.setMessage("set extra data, raw=[{}] parsed=[{}], UTF-8=[{}]")
.addArgument(rawParam)
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPrice.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPrice.java
index 733ed3a8f3c..e932669b00d 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPrice.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPrice.java
@@ -25,7 +25,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,10 +33,10 @@
public class MinerSetMinGasPrice implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(MinerSetMinGasPrice.class);
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
- public MinerSetMinGasPrice(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public MinerSetMinGasPrice(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -49,7 +49,7 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
try {
final Wei minGasPrice =
Wei.fromHexString(requestContext.getRequiredParameter(0, String.class));
- miningParameters.setMinTransactionGasPrice(minGasPrice);
+ miningConfiguration.setMinTransactionGasPrice(minGasPrice);
LOG.debug("min gas price changed to {}", minGasPrice.toHumanReadableString());
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
} catch (final IllegalArgumentException invalidJsonRpcParameters) {
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFee.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFee.java
index b1bf4338f77..d296f28f928 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFee.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFee.java
@@ -24,7 +24,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,10 +32,10 @@
public class MinerSetMinPriorityFee implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(MinerSetMinPriorityFee.class);
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
- public MinerSetMinPriorityFee(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public MinerSetMinPriorityFee(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -48,7 +48,7 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
try {
final Wei minPriorityFeePerGas =
Wei.fromHexString(requestContext.getRequiredParameter(0, String.class));
- miningParameters.setMinPriorityFeePerGas(minPriorityFeePerGas);
+ miningConfiguration.setMinPriorityFeePerGas(minPriorityFeePerGas);
LOG.debug(
"min priority fee per gas changed to {}", minPriorityFeePerGas.toHumanReadableString());
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true);
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResult.java
index ed0b64d742a..25e6763edac 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResult.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResult.java
@@ -88,6 +88,7 @@ public class BlockResult implements JsonRpcResult {
private final String blobGasUsed;
private final String excessBlobGas;
private final String parentBeaconBlockRoot;
+ private final String targetBlobCount;
public BlockResult(
final BlockHeader header,
@@ -138,6 +139,7 @@ public BlockResult(
this.excessBlobGas = header.getExcessBlobGas().map(Quantity::create).orElse(null);
this.parentBeaconBlockRoot =
header.getParentBeaconBlockRoot().map(Bytes32::toHexString).orElse(null);
+ this.targetBlobCount = header.getTargetBlobCount().map(Quantity::create).orElse(null);
}
@JsonGetter(value = "number")
@@ -275,4 +277,9 @@ public String getExcessBlobGas() {
public String getParentBeaconBlockRoot() {
return parentBeaconBlockRoot;
}
+
+ @JsonGetter(value = "targetBlobCount")
+ public String getTargetBlobCount() {
+ return targetBlobCount;
+ }
}
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java
index cdf4440bde9..7be34f02290 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java
@@ -25,7 +25,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
@@ -67,7 +67,7 @@ public Map methods(
final ProtocolContext protocolContext,
final FilterManager filterManager,
final TransactionPool transactionPool,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final MiningCoordinator miningCoordinator,
final ObservableMetricsSystem metricsSystem,
final Set supportedCapabilities,
@@ -139,7 +139,7 @@ public Map methods(
webSocketConfiguration,
metricsConfiguration,
graphQLConfiguration),
- new MinerJsonRpcMethods(miningParameters, miningCoordinator),
+ new MinerJsonRpcMethods(miningConfiguration, miningCoordinator),
new PermJsonRpcMethods(accountsAllowlistController, nodeAllowlistController),
new PrivJsonRpcMethods(
blockchainQueries,
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/MinerJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/MinerJsonRpcMethods.java
index c799c23305b..14e74767eef 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/MinerJsonRpcMethods.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/MinerJsonRpcMethods.java
@@ -28,18 +28,18 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner.MinerStart;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner.MinerStop;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import java.util.Map;
public class MinerJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final MiningCoordinator miningCoordinator;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
public MinerJsonRpcMethods(
- final MiningParameters miningParameters, final MiningCoordinator miningCoordinator) {
- this.miningParameters = miningParameters;
+ final MiningConfiguration miningConfiguration, final MiningCoordinator miningCoordinator) {
+ this.miningConfiguration = miningConfiguration;
this.miningCoordinator = miningCoordinator;
}
@@ -57,11 +57,11 @@ protected Map create() {
minerSetCoinbase,
new MinerSetEtherbase(minerSetCoinbase),
new MinerChangeTargetGasLimit(miningCoordinator),
- new MinerGetMinPriorityFee(miningParameters),
- new MinerSetMinPriorityFee(miningParameters),
- new MinerGetMinGasPrice(miningParameters),
- new MinerSetMinGasPrice(miningParameters),
- new MinerGetExtraData(miningParameters),
- new MinerSetExtraData(miningParameters));
+ new MinerGetMinPriorityFee(miningConfiguration),
+ new MinerSetMinPriorityFee(miningConfiguration),
+ new MinerGetMinGasPrice(miningConfiguration),
+ new MinerSetMinGasPrice(miningConfiguration),
+ new MinerGetExtraData(miningConfiguration),
+ new MinerSetExtraData(miningConfiguration));
}
}
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketConfiguration.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketConfiguration.java
index e27f7f21cec..42905b96a70 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketConfiguration.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketConfiguration.java
@@ -25,6 +25,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import java.util.Optional;
import com.google.common.base.MoreObjects;
@@ -49,6 +50,21 @@ public class WebSocketConfiguration {
private int maxActiveConnections;
private int maxFrameSize;
+ private boolean isSslEnabled = false;
+ private Optional keyStorePath = Optional.empty();
+ private Optional keyStorePassword = Optional.empty();
+ private Optional keyStoreType = Optional.of("JKS"); // Default to JKS
+
+ private boolean clientAuthEnabled = false;
+ private Optional trustStorePath = Optional.empty();
+ private Optional trustStorePassword = Optional.empty();
+ private Optional trustStoreType = Optional.of("JKS"); // Default to JKS
+
+ // For PEM format
+ private Optional keyPath = Optional.empty();
+ private Optional certPath = Optional.empty();
+ private Optional trustCertPath = Optional.empty();
+
public static WebSocketConfiguration createDefault() {
final WebSocketConfiguration config = new WebSocketConfiguration();
config.setEnabled(false);
@@ -159,6 +175,102 @@ public void setTimeoutSec(final long timeoutSec) {
this.timeoutSec = timeoutSec;
}
+ public boolean isSslEnabled() {
+ return isSslEnabled;
+ }
+
+ public void setSslEnabled(final boolean isSslEnabled) {
+ this.isSslEnabled = isSslEnabled;
+ }
+
+ public Optional getKeyStorePath() {
+ return keyStorePath;
+ }
+
+ public void setKeyStorePath(final String keyStorePath) {
+ this.keyStorePath = Optional.ofNullable(keyStorePath);
+ }
+
+ public Optional getKeyStorePassword() {
+ return keyStorePassword;
+ }
+
+ public void setKeyStorePassword(final String keyStorePassword) {
+ this.keyStorePassword = Optional.ofNullable(keyStorePassword);
+ }
+
+ // Keystore Type
+ public Optional getKeyStoreType() {
+ return keyStoreType;
+ }
+
+ public void setKeyStoreType(final String keyStoreType) {
+ this.keyStoreType = Optional.ofNullable(keyStoreType);
+ }
+
+ // Key Path (for PEM)
+ public Optional getKeyPath() {
+ return keyPath;
+ }
+
+ public void setKeyPath(final String keyPath) {
+ this.keyPath = Optional.ofNullable(keyPath);
+ }
+
+ // Cert Path (for PEM)
+ public Optional getCertPath() {
+ return certPath;
+ }
+
+ public void setCertPath(final String certPath) {
+ this.certPath = Optional.ofNullable(certPath);
+ }
+
+ // Client Authentication Enabled
+ public boolean isClientAuthEnabled() {
+ return clientAuthEnabled;
+ }
+
+ public void setClientAuthEnabled(final boolean clientAuthEnabled) {
+ this.clientAuthEnabled = clientAuthEnabled;
+ }
+
+ // Truststore Path
+ public Optional getTrustStorePath() {
+ return trustStorePath;
+ }
+
+ public void setTrustStorePath(final String trustStorePath) {
+ this.trustStorePath = Optional.ofNullable(trustStorePath);
+ }
+
+ // Truststore Password
+ public Optional getTrustStorePassword() {
+ return trustStorePassword;
+ }
+
+ public void setTrustStorePassword(final String trustStorePassword) {
+ this.trustStorePassword = Optional.ofNullable(trustStorePassword);
+ }
+
+ // Truststore Type
+ public Optional getTrustStoreType() {
+ return trustStoreType;
+ }
+
+ public void setTrustStoreType(final String trustStoreType) {
+ this.trustStoreType = Optional.ofNullable(trustStoreType);
+ }
+
+ // Trust Cert Path (for PEM)
+ public Optional getTrustCertPath() {
+ return trustCertPath;
+ }
+
+ public void setTrustCertPath(final String trustCertPath) {
+ this.trustCertPath = Optional.ofNullable(trustCertPath);
+ }
+
@Override
public boolean equals(final Object o) {
if (this == o) {
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java
index 59742836ba8..31c86b18d21 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java
@@ -25,6 +25,7 @@
import org.hyperledger.besu.plugin.services.MetricsSystem;
import java.net.InetSocketAddress;
+import java.util.Locale;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
@@ -34,6 +35,7 @@
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
+import io.vertx.core.http.ClientAuth;
import io.vertx.core.http.HttpConnection;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
@@ -41,6 +43,9 @@
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.http.ServerWebSocket;
import io.vertx.core.net.HostAndPort;
+import io.vertx.core.net.JksOptions;
+import io.vertx.core.net.PemKeyCertOptions;
+import io.vertx.core.net.PemTrustOptions;
import io.vertx.core.net.SocketAddress;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
@@ -103,18 +108,65 @@ public CompletableFuture> start() {
"Starting Websocket service on {}:{}", configuration.getHost(), configuration.getPort());
final CompletableFuture> resultFuture = new CompletableFuture<>();
+ HttpServerOptions serverOptions =
+ new HttpServerOptions()
+ .setHost(configuration.getHost())
+ .setPort(configuration.getPort())
+ .setHandle100ContinueAutomatically(true)
+ .setCompressionSupported(true)
+ .addWebSocketSubProtocol("undefined")
+ .setMaxWebSocketFrameSize(configuration.getMaxFrameSize())
+ .setMaxWebSocketMessageSize(configuration.getMaxFrameSize() * 4)
+ .setRegisterWebSocketWriteHandlers(true);
+
+ // Check if SSL/TLS is enabled in the configuration
+ if (configuration.isSslEnabled()) {
+ serverOptions.setSsl(true);
+
+ String keystorePath = configuration.getKeyStorePath().orElse(null);
+ String keystorePassword = configuration.getKeyStorePassword().orElse(null);
+ String keyPath = configuration.getKeyPath().orElse(null);
+ String certPath = configuration.getCertPath().orElse(null);
+
+ String keystoreType = configuration.getKeyStoreType().orElse("JKS");
+
+ switch (keystoreType.toUpperCase(Locale.getDefault())) {
+ case "PEM":
+ serverOptions.setKeyCertOptions(
+ new PemKeyCertOptions().setKeyPath(keyPath).setCertPath(certPath));
+ break;
+ case "JKS":
+ default:
+ serverOptions.setKeyCertOptions(
+ new JksOptions().setPath(keystorePath).setPassword(keystorePassword));
+ break;
+ }
+ }
+
+ // Set up truststore for client authentication (mTLS)
+ if (configuration.isClientAuthEnabled()) {
+ serverOptions.setClientAuth(ClientAuth.REQUIRED);
+
+ String truststorePath = configuration.getTrustStorePath().orElse(null);
+ String truststorePassword = configuration.getTrustStorePassword().orElse("");
+ String truststoreType = configuration.getTrustStoreType().orElse("JKS");
+ String trustCertPath = configuration.getTrustCertPath().orElse(null);
+
+ switch (truststoreType.toUpperCase(Locale.getDefault())) {
+ case "PEM":
+ serverOptions.setTrustOptions(new PemTrustOptions().addCertPath(trustCertPath));
+ break;
+ case "JKS":
+ default:
+ serverOptions.setTrustOptions(
+ new JksOptions().setPath(truststorePath).setPassword(truststorePassword));
+ break;
+ }
+ }
+
httpServer =
vertx
- .createHttpServer(
- new HttpServerOptions()
- .setHost(configuration.getHost())
- .setPort(configuration.getPort())
- .setHandle100ContinueAutomatically(true)
- .setCompressionSupported(true)
- .addWebSocketSubProtocol("undefined")
- .setMaxWebSocketFrameSize(configuration.getMaxFrameSize())
- .setMaxWebSocketMessageSize(configuration.getMaxFrameSize() * 4)
- .setRegisterWebSocketWriteHandlers(true))
+ .createHttpServer(serverOptions)
.webSocketHandler(websocketHandler())
.connectionHandler(connectionHandler())
.requestHandler(httpHandler())
diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java
index c03bf124c47..7e5a7c6fe04 100644
--- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java
+++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java
@@ -30,7 +30,7 @@
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.LogWithMetadata;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
@@ -77,20 +77,20 @@ public class BlockchainQueries {
private final Optional transactionLogBloomCacher;
private final Optional ethScheduler;
private final ApiConfiguration apiConfig;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
public BlockchainQueries(
final ProtocolSchedule protocolSchedule,
final Blockchain blockchain,
final WorldStateArchive worldStateArchive,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
this(
protocolSchedule,
blockchain,
worldStateArchive,
Optional.empty(),
Optional.empty(),
- miningParameters);
+ miningConfiguration);
}
public BlockchainQueries(
@@ -98,14 +98,14 @@ public BlockchainQueries(
final Blockchain blockchain,
final WorldStateArchive worldStateArchive,
final EthScheduler scheduler,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
this(
protocolSchedule,
blockchain,
worldStateArchive,
Optional.empty(),
Optional.ofNullable(scheduler),
- miningParameters);
+ miningConfiguration);
}
public BlockchainQueries(
@@ -114,7 +114,7 @@ public BlockchainQueries(
final WorldStateArchive worldStateArchive,
final Optional cachePath,
final Optional scheduler,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
this(
protocolSchedule,
blockchain,
@@ -122,7 +122,7 @@ public BlockchainQueries(
cachePath,
scheduler,
ImmutableApiConfiguration.builder().build(),
- miningParameters);
+ miningConfiguration);
}
public BlockchainQueries(
@@ -132,7 +132,7 @@ public BlockchainQueries(
final Optional cachePath,
final Optional scheduler,
final ApiConfiguration apiConfig,
- final MiningParameters miningParameters) {
+ final MiningConfiguration miningConfiguration) {
this.protocolSchedule = protocolSchedule;
this.blockchain = blockchain;
this.worldStateArchive = worldStateArchive;
@@ -144,7 +144,7 @@ public BlockchainQueries(
new TransactionLogBloomCacher(blockchain, cachePath.get(), scheduler.get()))
: Optional.empty();
this.apiConfig = apiConfig;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
}
public Blockchain getBlockchain() {
@@ -1034,7 +1034,7 @@ public Wei gasPriceLowerBound() {
private Wei gasPriceLowerBound(
final BlockHeader chainHeadHeader, final FeeMarket nextBlockFeeMarket) {
- final var minGasPrice = miningParameters.getMinTransactionGasPrice();
+ final var minGasPrice = miningConfiguration.getMinTransactionGasPrice();
if (nextBlockFeeMarket.implementsBaseFee()) {
return UInt256s.max(
@@ -1070,9 +1070,9 @@ public Wei gasPriorityFee() {
.toArray(Wei[]::new);
return gasCollection.length == 0
- ? miningParameters.getMinPriorityFeePerGas()
+ ? miningConfiguration.getMinPriorityFeePerGas()
: UInt256s.max(
- miningParameters.getMinPriorityFeePerGas(),
+ miningConfiguration.getMinPriorityFeePerGas(),
gasCollection[
Math.min(
gasCollection.length - 1,
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java
index 5a1c23d40ee..2b55b42ba2d 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java
@@ -27,7 +27,7 @@
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
import org.hyperledger.besu.ethereum.core.DefaultSyncStatus;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
@@ -119,7 +119,7 @@ public void setupTest() throws Exception {
Optional.empty(),
Optional.empty(),
ImmutableApiConfiguration.builder().build(),
- MiningParameters.newDefault().setMinTransactionGasPrice(Wei.ZERO));
+ MiningConfiguration.newDefault().setMinTransactionGasPrice(Wei.ZERO));
final Set supportedCapabilities = new HashSet<>();
supportedCapabilities.add(EthProtocol.ETH62);
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandlerTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandlerTest.java
new file mode 100644
index 00000000000..ee00e433b2f
--- /dev/null
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandlerTest.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright contributors to Hyperledger Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.ethereum.api.handlers;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.contains;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
+import org.hyperledger.besu.ethereum.api.jsonrpc.context.ContextKey;
+import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor;
+
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.opentelemetry.api.trace.Tracer;
+import io.vertx.core.Handler;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpServerResponse;
+import io.vertx.ext.web.RoutingContext;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+
+class JsonRpcExecutorHandlerTest {
+
+ private JsonRpcExecutor mockExecutor;
+ private Tracer mockTracer;
+ private JsonRpcConfiguration mockConfig;
+ private RoutingContext mockContext;
+ private Vertx mockVertx;
+ private HttpServerResponse mockResponse;
+
+ @BeforeEach
+ void setUp() {
+ mockExecutor = mock(JsonRpcExecutor.class);
+ mockTracer = mock(Tracer.class);
+ mockConfig = mock(JsonRpcConfiguration.class);
+ mockContext = mock(RoutingContext.class);
+ mockVertx = mock(Vertx.class);
+ mockResponse = mock(HttpServerResponse.class);
+
+ when(mockContext.vertx()).thenReturn(mockVertx);
+ when(mockContext.response()).thenReturn(mockResponse);
+ when(mockResponse.ended()).thenReturn(false);
+ when(mockResponse.setStatusCode(anyInt())).thenReturn(mockResponse);
+ }
+
+ @Test
+ void testTimeoutHandling() {
+ // Arrange
+ Handler handler =
+ JsonRpcExecutorHandler.handler(mockExecutor, mockTracer, mockConfig);
+ ArgumentCaptor delayCaptor = ArgumentCaptor.forClass(Long.class);
+ @SuppressWarnings("unchecked")
+ ArgumentCaptor> timerHandlerCaptor = ArgumentCaptor.forClass(Handler.class);
+
+ when(mockContext.get(eq(ContextKey.REQUEST_BODY_AS_JSON_OBJECT.name()))).thenReturn("{}");
+ when(mockVertx.setTimer(delayCaptor.capture(), timerHandlerCaptor.capture())).thenReturn(1L);
+ when(mockContext.get("timerId")).thenReturn(1L);
+
+ // Act
+ handler.handle(mockContext);
+
+ // Assert
+ verify(mockVertx).setTimer(eq(30000L), any());
+
+ // Simulate timeout
+ timerHandlerCaptor.getValue().handle(1L);
+
+ // Verify timeout handling
+ verify(mockResponse, times(1))
+ .setStatusCode(eq(HttpResponseStatus.REQUEST_TIMEOUT.code())); // Expect 408 Request Timeout
+ verify(mockResponse, times(1)).end(contains("Timeout expired"));
+ verify(mockVertx, times(1)).cancelTimer(1L);
+ }
+
+ @Test
+ void testCancelTimerOnSuccessfulExecution() {
+ // Arrange
+ Handler handler =
+ JsonRpcExecutorHandler.handler(mockExecutor, mockTracer, mockConfig);
+ when(mockContext.get(eq(ContextKey.REQUEST_BODY_AS_JSON_OBJECT.name()))).thenReturn("{}");
+ when(mockVertx.setTimer(anyLong(), any())).thenReturn(1L);
+ when(mockContext.get("timerId")).thenReturn(1L);
+
+ // Act
+ handler.handle(mockContext);
+
+ // Assert
+ verify(mockVertx).setTimer(anyLong(), any());
+ verify(mockVertx).cancelTimer(1L);
+ }
+}
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java
index d504e3bb0d4..db896a94856 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java
@@ -35,7 +35,7 @@
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.core.Transaction;
@@ -137,7 +137,7 @@ protected Map getRpcMethods(
final Synchronizer synchronizerMock = mock(Synchronizer.class);
final P2PNetwork peerDiscoveryMock = mock(P2PNetwork.class);
final TransactionPool transactionPoolMock = mock(TransactionPool.class);
- final MiningParameters miningParameters = mock(MiningParameters.class);
+ final MiningConfiguration miningConfiguration = mock(MiningConfiguration.class);
final PoWMiningCoordinator miningCoordinatorMock = mock(PoWMiningCoordinator.class);
when(transactionPoolMock.addTransactionViaApi(any(Transaction.class)))
.thenReturn(ValidationResult.valid());
@@ -151,7 +151,7 @@ protected Map getRpcMethods(
blockchainSetupUtil.getProtocolSchedule(),
blockchainSetupUtil.getBlockchain(),
blockchainSetupUtil.getWorldArchive(),
- miningParameters);
+ miningConfiguration);
final FilterIdGenerator filterIdGenerator = mock(FilterIdGenerator.class);
final FilterRepository filterRepository = new FilterRepository();
when(filterIdGenerator.nextId()).thenReturn("0x1");
@@ -183,7 +183,7 @@ protected Map getRpcMethods(
protocolContext,
filterManager,
transactionPoolMock,
- miningParameters,
+ miningConfiguration,
miningCoordinatorMock,
new NoOpMetricsSystem(),
supportedCapabilities,
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java
index 022aa244220..9113e15a12d 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java
@@ -30,7 +30,7 @@
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
@@ -113,14 +113,14 @@ public void initServerAndClient() throws Exception {
synchronizer,
MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()),
mock(ProtocolContext.class),
mock(FilterManager.class),
mock(TransactionPool.class),
- mock(MiningParameters.class),
+ mock(MiningConfiguration.class),
mock(PoWMiningCoordinator.class),
new NoOpMetricsSystem(),
supportedCapabilities,
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java
index f9dba0bc260..aacf1157965 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java
@@ -37,7 +37,7 @@
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
@@ -144,14 +144,14 @@ public static void initServerAndClient() throws Exception {
synchronizer,
MainnetProtocolSchedule.fromConfig(
genesisConfigOptions,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()),
mock(ProtocolContext.class),
mock(FilterManager.class),
mock(TransactionPool.class),
- mock(MiningParameters.class),
+ mock(MiningConfiguration.class),
mock(PoWMiningCoordinator.class),
new NoOpMetricsSystem(),
supportedCapabilities,
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java
index 63ae1b8bfb2..ae66f2ac760 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java
@@ -36,7 +36,7 @@
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
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.ProtocolScheduleFixture;
import org.hyperledger.besu.ethereum.core.Synchronizer;
@@ -217,7 +217,7 @@ private JsonRpcHttpService createJsonRpcHttpServiceWithRpcApis(final JsonRpcConf
mock(ProtocolContext.class),
mock(FilterManager.class),
mock(TransactionPool.class),
- mock(MiningParameters.class),
+ mock(MiningConfiguration.class),
mock(PoWMiningCoordinator.class),
new NoOpMetricsSystem(),
supportedCapabilities,
@@ -328,7 +328,7 @@ private JsonRpcHttpService createJsonRpcHttpService(
mock(ProtocolContext.class),
mock(FilterManager.class),
mock(TransactionPool.class),
- mock(MiningParameters.class),
+ mock(MiningConfiguration.class),
mock(PoWMiningCoordinator.class),
new NoOpMetricsSystem(),
supportedCapabilities,
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java
index 5a439fa1947..ec4f6c6e2b4 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java
@@ -30,7 +30,7 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.ChainHead;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
@@ -122,14 +122,14 @@ public static void initServerAndClient() throws Exception {
MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()),
mock(ProtocolContext.class),
mock(FilterManager.class),
mock(TransactionPool.class),
- mock(MiningParameters.class),
+ mock(MiningConfiguration.class),
mock(PoWMiningCoordinator.class),
new NoOpMetricsSystem(),
supportedCapabilities,
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java
index 28474d3c536..fa336169b9a 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java
@@ -37,7 +37,7 @@
import org.hyperledger.besu.ethereum.api.tls.TlsConfiguration;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
@@ -127,14 +127,14 @@ public void initServer() throws Exception {
synchronizer,
MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()),
mock(ProtocolContext.class),
mock(FilterManager.class),
mock(TransactionPool.class),
- mock(MiningParameters.class),
+ mock(MiningConfiguration.class),
mock(PoWMiningCoordinator.class),
new NoOpMetricsSystem(),
supportedCapabilities,
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java
index 15df60230b6..b675430c49e 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java
@@ -36,7 +36,7 @@
import org.hyperledger.besu.ethereum.api.tls.TlsConfiguration;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
@@ -115,14 +115,14 @@ public void beforeEach() {
synchronizer,
MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()),
mock(ProtocolContext.class),
mock(FilterManager.class),
mock(TransactionPool.class),
- mock(MiningParameters.class),
+ mock(MiningConfiguration.class),
mock(PoWMiningCoordinator.class),
new NoOpMetricsSystem(),
supportedCapabilities,
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java
index 6f7ce4e1d66..de5683ad5c0 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java
@@ -36,7 +36,7 @@
import org.hyperledger.besu.ethereum.api.tls.TlsConfiguration;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
@@ -116,14 +116,14 @@ public void initServer() throws Exception {
synchronizer,
MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()),
mock(ProtocolContext.class),
mock(FilterManager.class),
mock(TransactionPool.class),
- mock(MiningParameters.class),
+ mock(MiningConfiguration.class),
mock(PoWMiningCoordinator.class),
new NoOpMetricsSystem(),
supportedCapabilities,
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHeadTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHeadTest.java
new file mode 100644
index 00000000000..8d552ee3765
--- /dev/null
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugSetHeadTest.java
@@ -0,0 +1,198 @@
+/*
+ * 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.ethereum.api.jsonrpc.internal.methods;
+
+import static java.lang.Boolean.FALSE;
+import static java.lang.Boolean.TRUE;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+import org.hyperledger.besu.crypto.Hash;
+import org.hyperledger.besu.ethereum.ProtocolContext;
+import org.hyperledger.besu.ethereum.api.jsonrpc.AbstractJsonRpcHttpServiceTest;
+import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
+import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
+import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash;
+import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
+import org.hyperledger.besu.ethereum.chain.Blockchain;
+import org.hyperledger.besu.ethereum.core.BlockHeader;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
+import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
+import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
+import org.hyperledger.besu.plugin.services.rpc.RpcResponseType;
+
+import java.util.Optional;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.tuweni.bytes.Bytes;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+/**
+ * This test only exercises bonsai worldstate since forest is essentially a no-op for moving the
+ * worldstate.
+ */
+public class DebugSetHeadTest extends AbstractJsonRpcHttpServiceTest {
+
+ DebugSetHead debugSetHead;
+ Blockchain blockchain;
+ WorldStateArchive archive;
+ ProtocolContext protocolContext;
+ ProtocolSchedule protocolSchedule;
+
+ @Override
+ @BeforeEach
+ public void setup() throws Exception {
+ setupBonsaiBlockchain();
+ blockchain = blockchainSetupUtil.getBlockchain();
+ protocolContext = blockchainSetupUtil.getProtocolContext();
+ protocolSchedule = blockchainSetupUtil.getProtocolSchedule();
+ ;
+ archive = blockchainSetupUtil.getWorldArchive();
+ debugSetHead =
+ new DebugSetHead(
+ new BlockchainQueries(
+ protocolSchedule, blockchain, archive, MiningConfiguration.MINING_DISABLED),
+ protocolContext,
+ // a value of 2 here exercises all the state rolling code paths
+ 2);
+ startService();
+ }
+
+ @ParameterizedTest
+ @ValueSource(
+ strings = {"0x01", "0x4e9a67b663f9abe03e7e9fd5452c9497998337077122f44ee78a466f6a7358de"})
+ public void assertOnlyChainHeadMovesWorldParameterAbsent(final String blockParam) {
+ var chainTip = blockchain.getChainHead().getBlockHeader();
+ var blockOne = getBlockHeaderForHashOrNumber(blockParam).orElse(null);
+
+ assertThat(blockOne).isNotNull();
+ assertThat(blockOne).isNotEqualTo(chainTip);
+
+ // move the head to param val, number or hash
+ debugSetHead.response(debugSetHead(blockParam, Optional.empty()));
+
+ // get the new chainTip:
+ var newChainTip = blockchain.getChainHead().getBlockHeader();
+
+ // assert the chain moved, and the worldstate did not
+ assertThat(newChainTip).isEqualTo(blockOne);
+ assertThat(archive.getMutable().rootHash()).isEqualTo(chainTip.getStateRoot());
+ }
+
+ @ParameterizedTest
+ @ValueSource(
+ strings = {
+ "0x01",
+ "0x02",
+ "0x3d813a0ffc9cd04436e17e3e9c309f1e80df0407078e50355ce0d570b5424812",
+ "0x4e9a67b663f9abe03e7e9fd5452c9497998337077122f44ee78a466f6a7358de"
+ })
+ public void assertOnlyChainHeadMoves(final String blockParam) {
+ var chainTip = blockchain.getChainHead().getBlockHeader();
+ var blockOne = getBlockHeaderForHashOrNumber(blockParam).orElse(null);
+
+ assertThat(blockOne).isNotNull();
+ assertThat(blockOne).isNotEqualTo(chainTip);
+
+ // move the head to param val, number or hash
+ debugSetHead.response(debugSetHead(blockParam, Optional.of(FALSE)));
+
+ // get the new chainTip:
+ var newChainTip = blockchain.getChainHead().getBlockHeader();
+
+ // assert the chain moved, and the worldstate did not
+ assertThat(newChainTip).isEqualTo(blockOne);
+ assertThat(archive.getMutable().rootHash()).isEqualTo(chainTip.getStateRoot());
+ }
+
+ @ParameterizedTest
+ @ValueSource(
+ strings = {
+ "0x01",
+ "0x02",
+ "0x3d813a0ffc9cd04436e17e3e9c309f1e80df0407078e50355ce0d570b5424812",
+ "0x4e9a67b663f9abe03e7e9fd5452c9497998337077122f44ee78a466f6a7358de"
+ })
+ public void assertBothChainHeadAndWorldStatByNumber(final String blockParam) {
+ var chainTip = blockchain.getChainHead().getBlockHeader();
+ var blockOne = getBlockHeaderForHashOrNumber(blockParam).orElse(null);
+
+ assertThat(blockOne).isNotNull();
+ assertThat(blockOne).isNotEqualTo(chainTip);
+
+ // move the head and worldstate to param val number or hash
+ debugSetHead.response(debugSetHead(blockParam, Optional.of(TRUE)));
+
+ // get the new chainTip:
+ var newChainTip = blockchain.getChainHead().getBlockHeader();
+
+ // assert both the chain and worldstate moved to block one
+ assertThat(newChainTip).isEqualTo(blockOne);
+ assertThat(archive.getMutable().rootHash()).isEqualTo(blockOne.getStateRoot());
+ }
+
+ @Test
+ public void assertNotFound() {
+ var chainTip = blockchain.getChainHead().getBlockHeader();
+
+ // move the head to number just after chain head
+ var resp =
+ debugSetHead.response(debugSetHead("" + chainTip.getNumber() + 1, Optional.of(TRUE)));
+ assertThat(resp.getType()).isEqualTo(RpcResponseType.ERROR);
+
+ // move the head to some arbitrary hash
+ var resp2 =
+ debugSetHead.response(
+ debugSetHead(
+ Hash.keccak256(Bytes.fromHexString("0xdeadbeef")).toHexString(),
+ Optional.of(TRUE)));
+ assertThat(resp2.getType()).isEqualTo(RpcResponseType.ERROR);
+
+ // get the new chainTip:
+ var newChainTip = blockchain.getChainHead().getBlockHeader();
+
+ // assert neither the chain nor the worldstate moved
+ assertThat(newChainTip).isEqualTo(chainTip);
+ assertThat(archive.getMutable().rootHash()).isEqualTo(chainTip.getStateRoot());
+ }
+
+ private JsonRpcRequestContext debugSetHead(
+ final String numberOrHash, final Optional moveWorldState) {
+ if (moveWorldState.isPresent()) {
+ return new JsonRpcRequestContext(
+ new JsonRpcRequest(
+ "2.0", "debug_setHead", new Object[] {numberOrHash, moveWorldState.get()}));
+ } else {
+ return new JsonRpcRequestContext(
+ new JsonRpcRequest("2.0", "debug_setHead", new Object[] {numberOrHash}));
+ }
+ }
+
+ private Optional getBlockHeaderForHashOrNumber(final String input) {
+ try {
+ var param = new BlockParameterOrBlockHash(input);
+ if (param.getHash().isPresent()) {
+ return blockchain.getBlockHeader(param.getHash().get());
+ } else if (param.getNumber().isPresent()) {
+ return blockchain.getBlockHeader(param.getNumber().getAsLong());
+ }
+ } catch (JsonProcessingException ignored) {
+ // meh
+ }
+ return Optional.empty();
+ }
+}
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java
index e4282864447..c55f9b46547 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java
@@ -39,7 +39,7 @@
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
@@ -77,13 +77,13 @@ public class EthGasPriceTest {
@Mock private ProtocolSchedule protocolSchedule;
@Mock private Blockchain blockchain;
private EthGasPrice method;
- private MiningParameters miningParameters;
+ private MiningConfiguration miningConfiguration;
@BeforeEach
public void setUp() {
ApiConfiguration apiConfig = createDefaultApiConfiguration();
- miningParameters =
- MiningParameters.newDefault().setMinTransactionGasPrice(DEFAULT_MIN_GAS_PRICE);
+ miningConfiguration =
+ MiningConfiguration.newDefault().setMinTransactionGasPrice(DEFAULT_MIN_GAS_PRICE);
method = createEthGasPriceMethod(apiConfig);
}
@@ -96,7 +96,7 @@ public void returnsCorrectMethodName() {
public void shouldReturnMinValueWhenNoTransactionsExist() {
final JsonRpcRequestContext request = requestWithParams();
final String expectedWei = "0x4d2"; // minGasPrice > nextBlockBaseFee
- miningParameters.setMinTransactionGasPrice(Wei.fromHexString(expectedWei));
+ miningConfiguration.setMinTransactionGasPrice(Wei.fromHexString(expectedWei));
final JsonRpcResponse expectedResponse =
new JsonRpcSuccessResponse(request.getRequest().getId(), expectedWei);
@@ -117,7 +117,7 @@ public void shouldReturnBaseFeeAsMinValueOnGenesis() {
final JsonRpcRequestContext request = requestWithParams();
final String expectedWei =
DEFAULT_BASE_FEE.toShortHexString(); // nextBlockBaseFee > minGasPrice
- miningParameters.setMinTransactionGasPrice(Wei.fromHexString(expectedWei));
+ miningConfiguration.setMinTransactionGasPrice(Wei.fromHexString(expectedWei));
final JsonRpcResponse expectedResponse =
new JsonRpcSuccessResponse(request.getRequest().getId(), expectedWei);
@@ -234,7 +234,7 @@ private static Stream ethGasPriceAtGenesis() {
@MethodSource("ethGasPriceAtGenesis")
public void ethGasPriceAtGenesis(
final Wei minGasPrice, final Optional maybeGenesisBaseFee, final Wei expectedGasPrice) {
- miningParameters.setMinTransactionGasPrice(minGasPrice);
+ miningConfiguration.setMinTransactionGasPrice(minGasPrice);
if (maybeGenesisBaseFee.isPresent()) {
mockBaseFeeMarket();
@@ -267,7 +267,7 @@ private void verifyGasPriceLimit(
final Long lowerBoundCoefficient,
final Long upperBoundCoefficient,
final long expectedGasPrice) {
- miningParameters.setMinTransactionGasPrice(Wei.of(100));
+ miningConfiguration.setMinTransactionGasPrice(Wei.of(100));
mockBaseFeeMarket();
@@ -372,6 +372,7 @@ private Block createFakeBlock(
null,
null,
null,
+ null,
null),
new BlockBody(
IntStream.range(0, txsNum)
@@ -422,7 +423,7 @@ private EthGasPrice createEthGasPriceMethod(final ApiConfiguration apiConfig) {
Optional.empty(),
Optional.empty(),
apiConfig,
- miningParameters),
+ miningConfiguration),
apiConfig);
}
}
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java
index 254d0fbe9e8..fd92b55ba48 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java
@@ -35,7 +35,7 @@
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -93,7 +93,7 @@ public void setUp() {
blockchainQueries =
spy(
new BlockchainQueries(
- protocolSchedule, blockchain, worldStateArchive, MiningParameters.newDefault()));
+ protocolSchedule, blockchain, worldStateArchive, MiningConfiguration.newDefault()));
method = new EthGetBlockByNumber(blockchainQueries, blockResult, synchronizer);
}
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockReceiptsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockReceiptsTest.java
index 545b43a6e70..f25407c86e6 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockReceiptsTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockReceiptsTest.java
@@ -35,7 +35,7 @@
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -86,7 +86,7 @@ public void setUp() {
blockchainQueries =
spy(
new BlockchainQueries(
- protocolSchedule, blockchain, worldStateArchive, MiningParameters.newDefault()));
+ protocolSchedule, blockchain, worldStateArchive, MiningConfiguration.newDefault()));
protocolSchedule = mock(ProtocolSchedule.class);
method = new EthGetBlockReceipts(blockchainQueries, protocolSchedule);
}
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProofTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProofTest.java
index 06a4b9d0e7c..a346cd827b2 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProofTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProofTest.java
@@ -39,7 +39,7 @@
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.ChainHead;
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.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
@@ -89,7 +89,7 @@ public void setUp() {
blockchainQueries =
spy(
new BlockchainQueries(
- protocolSchedule, blockchain, archive, MiningParameters.newDefault()));
+ protocolSchedule, blockchain, archive, MiningConfiguration.newDefault()));
when(blockchainQueries.getBlockchain()).thenReturn(blockchain);
when(blockchainQueries.headBlockNumber()).thenReturn(14L);
when(blockchain.getChainHead()).thenReturn(chainHead);
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java
index 884cc504d8e..608577f47b7 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java
@@ -42,7 +42,7 @@
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.mainnet.PoWHasher;
@@ -195,7 +195,7 @@ public class EthGetTransactionReceiptTest {
protocolSchedule,
blockchain,
mock(WorldStateArchive.class),
- MiningParameters.newDefault()));
+ MiningConfiguration.newDefault()));
private final EthGetTransactionReceipt ethGetTransactionReceipt =
new EthGetTransactionReceipt(blockchainQueries, protocolSchedule);
private final String receiptString =
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthMaxPriorityFeePerGasTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthMaxPriorityFeePerGasTest.java
index 886c8a1d038..05b5f8cb0d7 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthMaxPriorityFeePerGasTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthMaxPriorityFeePerGasTest.java
@@ -35,7 +35,7 @@
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.feemarket.CancunFeeMarket;
@@ -67,12 +67,12 @@ public class EthMaxPriorityFeePerGasTest {
private EthMaxPriorityFeePerGas method;
@Mock private ProtocolSchedule protocolSchedule;
@Mock private Blockchain blockchain;
- private MiningParameters miningParameters;
+ private MiningConfiguration miningConfiguration;
@BeforeEach
public void setUp() {
- miningParameters =
- MiningParameters.newDefault().setMinPriorityFeePerGas(DEFAULT_MIN_PRIORITY_FEE_PER_GAS);
+ miningConfiguration =
+ MiningConfiguration.newDefault().setMinPriorityFeePerGas(DEFAULT_MIN_PRIORITY_FEE_PER_GAS);
method = createEthMaxPriorityFeePerGasMethod();
}
@@ -85,7 +85,7 @@ public void shouldReturnCorrectMethodName() {
public void whenNoTransactionsExistReturnMinPriorityFeePerGasPrice() {
final JsonRpcRequestContext request = requestWithParams();
final Wei expectedWei = Wei.ONE;
- miningParameters.setMinPriorityFeePerGas(expectedWei);
+ miningConfiguration.setMinPriorityFeePerGas(expectedWei);
final JsonRpcResponse expectedResponse =
new JsonRpcSuccessResponse(request.getRequest().getId(), expectedWei.toShortHexString());
@@ -111,7 +111,7 @@ public void whenTransactionsExistReturnMedianMaxPriorityFeePerGasPrice() {
public void returnMinPriorityFeePerGasWhenMedianValueIsLower() {
final JsonRpcRequestContext request = requestWithParams();
final Wei expectedWei = Wei.of(100_000);
- miningParameters.setMinPriorityFeePerGas(expectedWei);
+ miningConfiguration.setMinPriorityFeePerGas(expectedWei);
mockBlockchain(100, 1);
@@ -128,7 +128,7 @@ public void returnMinPriorityFeePerGasWhenMedianValueIsLower() {
public void atGenesisReturnMinPriorityFeePerGas() {
final JsonRpcRequestContext request = requestWithParams();
final Wei expectedWei = Wei.ONE;
- miningParameters.setMinPriorityFeePerGas(expectedWei);
+ miningConfiguration.setMinPriorityFeePerGas(expectedWei);
final JsonRpcResponse expectedResponse =
new JsonRpcSuccessResponse(request.getRequest().getId(), expectedWei.toShortHexString());
@@ -207,6 +207,7 @@ private Block createFakeBlock(
null,
null,
null,
+ null,
null),
new BlockBody(
IntStream.range(0, txsNum)
@@ -234,6 +235,6 @@ private EthMaxPriorityFeePerGas createEthMaxPriorityFeePerGasMethod() {
Optional.empty(),
Optional.empty(),
ImmutableApiConfiguration.builder().build(),
- miningParameters));
+ miningConfiguration));
}
}
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java
index e793ee8b577..0b81ac111a4 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java
@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
+import static java.util.Collections.emptyList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.ACCEPTED;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID;
@@ -51,7 +52,6 @@
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
@@ -62,7 +62,6 @@
import org.hyperledger.besu.plugin.services.exception.StorageException;
import org.hyperledger.besu.plugin.services.rpc.RpcResponseType;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
@@ -123,12 +122,11 @@ public void shouldReturnValid() {
BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))),
- Optional.empty(),
Optional.empty());
lenient()
.when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
assertValidResponse(mockHeader, resp);
}
@@ -136,12 +134,11 @@ public void shouldReturnValid() {
@Test
public void shouldReturnInvalidOnBlockExecutionError() {
BlockHeader mockHeader =
- setupValidPayload(
- new BlockProcessingResult("error 42"), Optional.empty(), Optional.empty());
+ setupValidPayload(new BlockProcessingResult("error 42"), Optional.empty());
lenient()
.when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash().get()).isEqualTo(mockHash);
@@ -152,14 +149,14 @@ public void shouldReturnInvalidOnBlockExecutionError() {
@Test
public void shouldReturnAcceptedOnLatestValidAncestorEmpty() {
- BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty());
+ BlockHeader mockHeader = createBlockHeader(Optional.empty());
when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty());
when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
when(mergeCoordinator.getLatestValidAncestor(any(BlockHeader.class)))
.thenReturn(Optional.empty());
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash()).isEmpty();
@@ -170,20 +167,19 @@ public void shouldReturnAcceptedOnLatestValidAncestorEmpty() {
@Test
public void shouldReturnSuccessOnAlreadyPresent() {
- BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty());
- Block mockBlock =
- new Block(mockHeader, new BlockBody(Collections.emptyList(), Collections.emptyList()));
+ BlockHeader mockHeader = createBlockHeader(Optional.empty());
+ Block mockBlock = new Block(mockHeader, new BlockBody(emptyList(), emptyList()));
when(blockchain.getBlockByHash(any())).thenReturn(Optional.of(mockBlock));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
assertValidResponse(mockHeader, resp);
}
@Test
public void shouldReturnInvalidWithLatestValidHashIsABadBlock() {
- BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty());
+ BlockHeader mockHeader = createBlockHeader(Optional.empty());
Hash latestValidHash = Hash.hash(Bytes32.fromHexStringLenient("0xcafebabe"));
when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty());
@@ -191,7 +187,7 @@ public void shouldReturnInvalidWithLatestValidHashIsABadBlock() {
when(mergeCoordinator.getLatestValidHashOfBadBlock(mockHeader.getHash()))
.thenReturn(Optional.of(latestValidHash));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash()).isEqualTo(Optional.of(latestValidHash));
@@ -204,12 +200,11 @@ public void shouldNotReturnInvalidOnStorageException() {
BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.empty(), new StorageException("database bedlam")),
- Optional.empty(),
Optional.empty());
lenient()
.when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
fromErrorResp(resp);
verify(engineCallListener, times(1)).executionEngineCalled();
@@ -220,13 +215,12 @@ public void shouldNotReturnInvalidOnHandledMerkleTrieException() {
BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.empty(), new MerkleTrieException("missing leaf")),
- Optional.empty(),
Optional.empty());
lenient()
.when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
verify(engineCallListener, times(1)).executionEngineCalled();
@@ -235,7 +229,7 @@ public void shouldNotReturnInvalidOnHandledMerkleTrieException() {
@Test
public void shouldNotReturnInvalidOnThrownMerkleTrieException() {
- BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty());
+ BlockHeader mockHeader = createBlockHeader(Optional.empty());
when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty());
when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
@@ -243,7 +237,7 @@ public void shouldNotReturnInvalidOnThrownMerkleTrieException() {
.thenReturn(Optional.of(mockHash));
when(mergeCoordinator.rememberBlock(any())).thenThrow(new MerkleTrieException("missing leaf"));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
verify(engineCallListener, times(1)).executionEngineCalled();
@@ -252,7 +246,7 @@ public void shouldNotReturnInvalidOnThrownMerkleTrieException() {
@Test
public void shouldReturnInvalidBlockHashOnBadHashParameter() {
- BlockHeader mockHeader = spy(createBlockHeader(Optional.empty(), Optional.empty()));
+ BlockHeader mockHeader = spy(createBlockHeader(Optional.empty()));
lenient()
.when(mergeCoordinator.getLatestValidAncestor(mockHeader.getBlockHash()))
.thenReturn(Optional.empty());
@@ -260,7 +254,7 @@ public void shouldReturnInvalidBlockHashOnBadHashParameter() {
.when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
lenient().when(mockHeader.getHash()).thenReturn(Hash.fromHexStringLenient("0x1337"));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getStatusAsString()).isEqualTo(getExpectedInvalidBlockHashStatus().name());
@@ -269,11 +263,11 @@ public void shouldReturnInvalidBlockHashOnBadHashParameter() {
@Test
public void shouldCheckBlockValidityBeforeCheckingByHashForExisting() {
- BlockHeader realHeader = createBlockHeader(Optional.empty(), Optional.empty());
+ BlockHeader realHeader = createBlockHeader(Optional.empty());
BlockHeader paramHeader = spy(realHeader);
when(paramHeader.getHash()).thenReturn(Hash.fromHexStringLenient("0x1337"));
- var resp = resp(mockEnginePayload(paramHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(paramHeader, emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash()).isEmpty();
@@ -283,7 +277,7 @@ public void shouldCheckBlockValidityBeforeCheckingByHashForExisting() {
@Test
public void shouldReturnInvalidOnMalformedTransactions() {
- BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty());
+ BlockHeader mockHeader = createBlockHeader(Optional.empty());
when(mergeCoordinator.getLatestValidAncestor(any(Hash.class)))
.thenReturn(Optional.of(mockHash));
@@ -298,9 +292,9 @@ public void shouldReturnInvalidOnMalformedTransactions() {
@Test
public void shouldRespondWithSyncingDuringForwardSync() {
- BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty());
+ BlockHeader mockHeader = createBlockHeader(Optional.empty());
when(mergeContext.isSyncing()).thenReturn(Boolean.TRUE);
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getError()).isNull();
@@ -311,10 +305,10 @@ public void shouldRespondWithSyncingDuringForwardSync() {
@Test
public void shouldRespondWithSyncingDuringBackwardsSync() {
- BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty());
+ BlockHeader mockHeader = createBlockHeader(Optional.empty());
when(mergeCoordinator.appendNewPayloadToSync(any()))
.thenReturn(CompletableFuture.completedFuture(null));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash()).isEmpty();
@@ -325,12 +319,12 @@ public void shouldRespondWithSyncingDuringBackwardsSync() {
@Test
public void shouldRespondWithInvalidIfExtraDataIsNull() {
- BlockHeader realHeader = createBlockHeader(Optional.empty(), Optional.empty());
+ BlockHeader realHeader = createBlockHeader(Optional.empty());
BlockHeader paramHeader = spy(realHeader);
when(paramHeader.getHash()).thenReturn(Hash.fromHexStringLenient("0x1337"));
when(paramHeader.getExtraData().toHexString()).thenReturn(null);
- var resp = resp(mockEnginePayload(paramHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(paramHeader, emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash()).isEmpty();
@@ -342,8 +336,8 @@ public void shouldRespondWithInvalidIfExtraDataIsNull() {
@Test
public void shouldReturnInvalidWhenBadBlock() {
when(mergeCoordinator.isBadBlock(any(Hash.class))).thenReturn(true);
- BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty());
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ BlockHeader mockHeader = createBlockHeader(Optional.empty());
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
when(protocolSpec.getWithdrawalsValidator())
.thenReturn(new WithdrawalsValidator.AllowedWithdrawals());
EnginePayloadStatusResult res = fromSuccessResp(resp);
@@ -359,12 +353,11 @@ public void shouldReturnValidIfProtocolScheduleIsEmpty() {
BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))),
- Optional.empty(),
Optional.empty());
lenient()
.when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
assertValidResponse(mockHeader, resp);
}
@@ -408,11 +401,9 @@ protected EnginePayloadParameter mockEnginePayload(
}
protected BlockHeader setupValidPayload(
- final BlockProcessingResult value,
- final Optional> maybeWithdrawals,
- final Optional> maybeRequests) {
+ final BlockProcessingResult value, final Optional> maybeWithdrawals) {
- BlockHeader mockHeader = createBlockHeader(maybeWithdrawals, maybeRequests);
+ BlockHeader mockHeader = createBlockHeader(maybeWithdrawals);
when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty());
when(mergeCoordinator.getLatestValidAncestor(any(BlockHeader.class)))
.thenReturn(Optional.of(mockHash));
@@ -425,6 +416,11 @@ protected ExecutionEngineJsonRpcMethod.EngineStatus getExpectedInvalidBlockHashS
}
protected EnginePayloadStatusResult fromSuccessResp(final JsonRpcResponse resp) {
+ if (resp.getType().equals(RpcResponseType.ERROR)) {
+ final JsonRpcError jsonRpcError = fromErrorResp(resp);
+ throw new AssertionError(
+ "Expected success but was error with message: " + jsonRpcError.getMessage());
+ }
assertThat(resp.getType()).isEqualTo(RpcResponseType.SUCCESS);
return Optional.of(resp)
.map(JsonRpcSuccessResponse.class::cast)
@@ -441,15 +437,12 @@ protected JsonRpcError fromErrorResp(final JsonRpcResponse resp) {
.get();
}
- protected BlockHeader createBlockHeader(
- final Optional> maybeWithdrawals,
- final Optional> maybeRequests) {
- return createBlockHeaderFixture(maybeWithdrawals, maybeRequests).buildHeader();
+ protected BlockHeader createBlockHeader(final Optional> maybeWithdrawals) {
+ return createBlockHeaderFixture(maybeWithdrawals).buildHeader();
}
protected BlockHeaderTestFixture createBlockHeaderFixture(
- final Optional> maybeWithdrawals,
- final Optional> maybeRequests) {
+ final Optional> maybeWithdrawals) {
BlockHeader parentBlockHeader =
new BlockHeaderTestFixture().baseFeePerGas(Wei.ONE).buildHeader();
return new BlockHeaderTestFixture()
@@ -458,8 +451,7 @@ protected BlockHeaderTestFixture createBlockHeaderFixture(
.number(parentBlockHeader.getNumber() + 1)
.timestamp(parentBlockHeader.getTimestamp() + 1)
.withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null))
- .parentBeaconBlockRoot(maybeParentBeaconBlockRoot)
- .requestsHash(maybeRequests.map(BodyValidation::requestsHash).orElse(null));
+ .parentBeaconBlockRoot(maybeParentBeaconBlockRoot);
}
protected void assertValidResponse(final BlockHeader mockHeader, final JsonRpcResponse resp) {
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java
index f1575f81ab4..4c9dbef7d2d 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java
@@ -254,6 +254,7 @@ private BlockHeader createBlockHeader(final Hash blockHash, final long blockNumb
null,
null,
null,
+ null,
new BlockHeaderFunctions() {
@Override
public Hash hash(final BlockHeader header) {
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java
index abf2c297673..171ee0499f2 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java
@@ -82,8 +82,7 @@ public void shouldReturnValidIfWithdrawalsIsNotNull_WhenWithdrawalsAllowed() {
BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))),
- Optional.of(withdrawals),
- Optional.empty());
+ Optional.of(withdrawals));
lenient()
.when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
@@ -100,7 +99,6 @@ public void shouldReturnValidIfWithdrawalsIsNull_WhenWithdrawalsProhibited() {
BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))),
- Optional.empty(),
Optional.empty());
lenient()
.when(blockchain.getBlockHeader(mockHeader.getParentHash()))
@@ -120,7 +118,7 @@ public void shouldReturnInvalidIfWithdrawalsIsNotNull_WhenWithdrawalsProhibited(
var resp =
resp(
mockEnginePayload(
- createBlockHeader(Optional.of(Collections.emptyList()), Optional.empty()),
+ createBlockHeader(Optional.of(Collections.emptyList())),
Collections.emptyList(),
withdrawals));
@@ -133,14 +131,14 @@ public void shouldReturnInvalidIfWithdrawalsIsNotNull_WhenWithdrawalsProhibited(
public void shouldValidateBlobGasUsedCorrectly() {
// V2 should return error if non-null blobGasUsed
BlockHeader blockHeader =
- createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty())
+ createBlockHeaderFixture(Optional.of(Collections.emptyList()))
.blobGasUsed(100L)
.buildHeader();
var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of()));
final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_BLOB_GAS_USED_PARAMS.getCode());
- assertThat(jsonRpcError.getData()).isEqualTo("Missing blob gas used field");
+ assertThat(jsonRpcError.getData()).isEqualTo("Unexpected blob gas used field present");
verify(engineCallListener, times(1)).executionEngineCalled();
}
@@ -148,7 +146,7 @@ public void shouldValidateBlobGasUsedCorrectly() {
public void shouldValidateExcessBlobGasCorrectly() {
// V2 should return error if non-null ExcessBlobGas
BlockHeader blockHeader =
- createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty())
+ createBlockHeaderFixture(Optional.of(Collections.emptyList()))
.excessBlobGas(BlobGas.MAX_BLOB_GAS)
.buildHeader();
@@ -156,7 +154,7 @@ public void shouldValidateExcessBlobGasCorrectly() {
final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
- assertThat(jsonRpcError.getData()).isEqualTo("Missing excess blob gas field");
+ assertThat(jsonRpcError.getData()).isEqualTo("Unexpected excess blob gas field present");
verify(engineCallListener, times(1)).executionEngineCalled();
}
@@ -169,9 +167,7 @@ public void shouldReturnInvalidIfWithdrawalsIsNull_WhenWithdrawalsAllowed() {
var resp =
resp(
mockEnginePayload(
- createBlockHeader(Optional.empty(), Optional.empty()),
- Collections.emptyList(),
- withdrawals));
+ createBlockHeader(Optional.empty()), Collections.emptyList(), withdrawals));
assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode());
verify(engineCallListener, times(1)).executionEngineCalled();
@@ -182,7 +178,7 @@ public void shouldReturnUnsupportedForkIfBlockTimestampIsAfterCancunMilestone()
// Cancun starte at timestamp 30
final long blockTimestamp = 31L;
BlockHeader blockHeader =
- createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty())
+ createBlockHeaderFixture(Optional.of(Collections.emptyList()))
.timestamp(blockTimestamp)
.buildHeader();
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java
index b79cb587eb3..1810ce94508 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java
@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
+import static java.util.Collections.emptyList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS;
@@ -44,7 +45,6 @@
import org.hyperledger.besu.ethereum.core.BlobTestFixture;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
import org.hyperledger.besu.ethereum.core.Withdrawal;
@@ -56,7 +56,6 @@
import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator;
import java.math.BigInteger;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
@@ -112,8 +111,18 @@ public void shouldInvalidVersionedHash_whenShortVersionedHash() {
when(payload.getExcessBlobGas()).thenReturn("99");
when(payload.getBlobGasUsed()).thenReturn(9l);
+ // TODO locking this as V3 otherwise this breaks the EngineNewPayloadV4Test subclass when method
+ // field is V4
+ final EngineNewPayloadV3 methodV3 =
+ new EngineNewPayloadV3(
+ vertx,
+ protocolSchedule,
+ protocolContext,
+ mergeCoordinator,
+ ethPeers,
+ engineCallListener);
final JsonRpcResponse badParam =
- method.response(
+ methodV3.response(
new JsonRpcRequestContext(
new JsonRpcRequest(
"2.0",
@@ -133,24 +142,20 @@ public void shouldValidVersionedHash_whenListIsEmpty() {
final BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))),
- Optional.empty(),
Optional.empty());
- final EnginePayloadParameter payload =
- mockEnginePayload(mockHeader, Collections.emptyList(), null);
+ final EnginePayloadParameter payload = mockEnginePayload(mockHeader, emptyList(), null);
ValidationResult res =
method.validateParameters(
payload,
Optional.of(List.of()),
Optional.of("0x0000000000000000000000000000000000000000000000000000000000000000"),
- Optional.empty());
+ Optional.of(emptyList()));
assertThat(res.isValid()).isTrue();
}
@Override
- protected BlockHeader createBlockHeader(
- final Optional> maybeWithdrawals,
- final Optional> maybeRequests) {
+ protected BlockHeader createBlockHeader(final Optional> maybeWithdrawals) {
BlockHeader parentBlockHeader =
new BlockHeaderTestFixture()
.baseFeePerGas(Wei.ONE)
@@ -186,12 +191,12 @@ public void shouldReturnValidIfProtocolScheduleIsEmpty() {
public void shouldValidateBlobGasUsedCorrectly() {
// V3 must return error if null blobGasUsed
BlockHeader blockHeader =
- createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty())
+ createBlockHeaderFixture(Optional.of(emptyList()))
.excessBlobGas(BlobGas.MAX_BLOB_GAS)
.blobGasUsed(null)
.buildHeader();
- var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of()));
+ var resp = resp(mockEnginePayload(blockHeader, emptyList(), List.of()));
final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
@@ -204,12 +209,12 @@ public void shouldValidateBlobGasUsedCorrectly() {
public void shouldValidateExcessBlobGasCorrectly() {
// V3 must return error if null excessBlobGas
BlockHeader blockHeader =
- createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty())
+ createBlockHeaderFixture(Optional.of(emptyList()))
.excessBlobGas(null)
.blobGasUsed(100L)
.buildHeader();
- var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of()));
+ var resp = resp(mockEnginePayload(blockHeader, emptyList(), List.of()));
final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
@@ -229,7 +234,6 @@ public void shouldRejectTransactionsWithFullBlobs() {
BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))),
- Optional.empty(),
Optional.empty());
var resp = resp(mockEnginePayload(mockHeader, transactions));
@@ -265,7 +269,7 @@ public void shouldReturnUnsupportedForkIfBlockTimestampIsAfterCancunMilestone()
protected JsonRpcResponse resp(final EnginePayloadParameter payload) {
Object[] params =
maybeParentBeaconBlockRoot
- .map(bytes32 -> new Object[] {payload, Collections.emptyList(), bytes32.toHexString()})
+ .map(bytes32 -> new Object[] {payload, emptyList(), bytes32.toHexString()})
.orElseGet(() -> new Object[] {payload});
return method.response(
new JsonRpcRequestContext(new JsonRpcRequest("2.0", this.method.getName(), params)));
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java
index c8504e7451d..fe7c38917c3 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java
@@ -14,8 +14,10 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
+import static java.util.Collections.emptyList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLError.INVALID_PARAMS;
+import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
@@ -42,7 +44,6 @@
import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestValidator;
import org.hyperledger.besu.evm.gascalculator.PragueGasCalculator;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
@@ -59,14 +60,19 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test {
public EngineNewPayloadV4Test() {}
+ private static final List VALID_REQUESTS =
+ List.of(
+ new Request(RequestType.DEPOSIT, Bytes.of(1)),
+ new Request(RequestType.WITHDRAWAL, Bytes.of(1)),
+ new Request(RequestType.CONSOLIDATION, Bytes.of(1)));
+
@BeforeEach
@Override
public void before() {
super.before();
maybeParentBeaconBlockRoot = Optional.of(Bytes32.ZERO);
- // TODO this should be using NewPayloadV4
this.method =
- new EngineNewPayloadV3(
+ new EngineNewPayloadV4(
vertx,
protocolSchedule,
protocolContext,
@@ -75,95 +81,63 @@ public void before() {
engineCallListener);
lenient().when(protocolSchedule.hardforkFor(any())).thenReturn(Optional.of(pragueHardfork));
lenient().when(protocolSpec.getGasCalculator()).thenReturn(new PragueGasCalculator());
+ mockAllowedRequestsValidator();
}
@Override
public void shouldReturnExpectedMethodName() {
- assertThat(method.getName()).isEqualTo("engine_newPayloadV3");
- }
-
- @Test
- public void shouldReturnValidIfRequestsIsNull_WhenRequestsProhibited() {
- mockProhibitedRequestsValidator();
-
- BlockHeader mockHeader =
- setupValidPayload(
- new BlockProcessingResult(
- Optional.of(new BlockProcessingOutputs(null, List.of(), Optional.empty()))),
- Optional.empty(),
- Optional.empty());
- when(blockchain.getBlockHeader(mockHeader.getParentHash()))
- .thenReturn(Optional.of(mock(BlockHeader.class)));
- when(mergeCoordinator.getLatestValidAncestor(mockHeader))
- .thenReturn(Optional.of(mockHeader.getHash()));
-
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()));
-
- assertValidResponse(mockHeader, resp);
+ assertThat(method.getName()).isEqualTo("engine_newPayloadV4");
}
@Test
public void shouldReturnInvalidIfRequestsIsNull_WhenRequestsAllowed() {
- mockAllowedRequestsValidator();
var resp =
- resp(
- mockEnginePayload(
- createBlockHeader(Optional.empty(), Optional.empty()), Collections.emptyList()));
+ respWithInvalidRequests(
+ mockEnginePayload(createValidBlockHeaderForV4(Optional.empty()), emptyList()));
assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode());
+ assertThat(fromErrorResp(resp).getMessage())
+ .isEqualTo(INVALID_EXECUTION_REQUESTS_PARAMS.getMessage());
verify(engineCallListener, times(1)).executionEngineCalled();
}
@Test
public void shouldReturnValidIfRequestsIsNotNull_WhenRequestsAllowed() {
- final List requests =
- List.of(
- new Request(RequestType.DEPOSIT, Bytes.of(1)),
- new Request(RequestType.WITHDRAWAL, Bytes.of(1)),
- new Request(RequestType.CONSOLIDATION, Bytes.of(1)));
-
- mockAllowedRequestsValidator();
BlockHeader mockHeader =
setupValidPayload(
new BlockProcessingResult(
- Optional.of(new BlockProcessingOutputs(null, List.of(), Optional.of(requests)))),
- Optional.empty(),
+ Optional.of(
+ new BlockProcessingOutputs(null, List.of(), Optional.of(VALID_REQUESTS)))),
Optional.empty());
when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
when(mergeCoordinator.getLatestValidAncestor(mockHeader))
.thenReturn(Optional.of(mockHeader.getHash()));
- var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()), requests);
+ var resp = resp(mockEnginePayload(mockHeader, emptyList()));
assertValidResponse(mockHeader, resp);
}
@Test
public void shouldReturnInvalidIfRequestsIsNotNull_WhenRequestsProhibited() {
- final List requests =
- List.of(
- new Request(RequestType.DEPOSIT, Bytes.of(1)),
- new Request(RequestType.WITHDRAWAL, Bytes.of(1)),
- new Request(RequestType.CONSOLIDATION, Bytes.of(1)));
-
mockProhibitedRequestsValidator();
- var resp =
- resp(
- mockEnginePayload(
- createBlockHeader(Optional.empty(), Optional.of(Collections.emptyList())),
- Collections.emptyList()),
- requests);
+ var resp = resp(mockEnginePayload(createValidBlockHeaderForV4(Optional.empty()), emptyList()));
final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
verify(engineCallListener, times(1)).executionEngineCalled();
}
- @Override
- protected BlockHeader createBlockHeader(
- final Optional> maybeWithdrawals,
- final Optional> maybeRequests) {
+ private BlockHeader createValidBlockHeaderForV4(
+ final Optional> maybeWithdrawals) {
+ return createBlockHeaderFixtureForV3(maybeWithdrawals)
+ .requestsHash(BodyValidation.requestsHash(VALID_REQUESTS))
+ .buildHeader();
+ }
+
+ private BlockHeaderTestFixture createBlockHeaderFixtureForV3(
+ final Optional> maybeWithdrawals) {
BlockHeader parentBlockHeader =
new BlockHeaderTestFixture()
.baseFeePerGas(Wei.ONE)
@@ -172,48 +146,49 @@ protected BlockHeader createBlockHeader(
.blobGasUsed(0L)
.buildHeader();
- BlockHeader mockHeader =
- new BlockHeaderTestFixture()
- .baseFeePerGas(Wei.ONE)
- .parentHash(parentBlockHeader.getParentHash())
- .number(parentBlockHeader.getNumber() + 1)
- .timestamp(parentBlockHeader.getTimestamp() + 1)
- .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null))
- .excessBlobGas(BlobGas.ZERO)
- .blobGasUsed(0L)
- .requestsHash(maybeRequests.map(BodyValidation::requestsHash).orElse(null))
- .parentBeaconBlockRoot(
- maybeParentBeaconBlockRoot.isPresent() ? maybeParentBeaconBlockRoot : null)
- .buildHeader();
- return mockHeader;
+ return new BlockHeaderTestFixture()
+ .baseFeePerGas(Wei.ONE)
+ .parentHash(parentBlockHeader.getParentHash())
+ .number(parentBlockHeader.getNumber() + 1)
+ .timestamp(parentBlockHeader.getTimestamp() + 1)
+ .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null))
+ .excessBlobGas(BlobGas.ZERO)
+ .blobGasUsed(0L)
+ .parentBeaconBlockRoot(
+ maybeParentBeaconBlockRoot.isPresent() ? maybeParentBeaconBlockRoot : null);
+ }
+
+ @Override
+ protected BlockHeader createBlockHeader(final Optional> maybeWithdrawals) {
+ return createValidBlockHeaderForV4(maybeWithdrawals);
}
@Override
protected JsonRpcResponse resp(final EnginePayloadParameter payload) {
+ final List requestsWithoutRequestId =
+ VALID_REQUESTS.stream()
+ .sorted(Comparator.comparing(Request::getType))
+ .map(r -> r.getData().toHexString())
+ .toList();
Object[] params =
maybeParentBeaconBlockRoot
- .map(bytes32 -> new Object[] {payload, Collections.emptyList(), bytes32.toHexString()})
+ .map(
+ bytes32 ->
+ new Object[] {
+ payload, emptyList(), bytes32.toHexString(), requestsWithoutRequestId
+ })
.orElseGet(() -> new Object[] {payload});
return method.response(
new JsonRpcRequestContext(new JsonRpcRequest("2.0", this.method.getName(), params)));
}
- protected JsonRpcResponse resp(
- final EnginePayloadParameter payload, final List requests) {
- final List requestsWithoutRequestId =
- requests.stream()
- .sorted(Comparator.comparing(Request::getType))
- .map(r -> r.getData().toHexString())
- .toList();
+ protected JsonRpcResponse respWithInvalidRequests(final EnginePayloadParameter payload) {
Object[] params =
maybeParentBeaconBlockRoot
.map(
bytes32 ->
- new Object[] {
- payload,
- Collections.emptyList(),
- bytes32.toHexString(),
- requestsWithoutRequestId
+ new Object[] {payload, emptyList(), bytes32.toHexString()
+ // empty requests param is invalid
})
.orElseGet(() -> new Object[] {payload});
return method.response(
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraDataTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraDataTest.java
index ebaf817a477..882a0711101 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraDataTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraDataTest.java
@@ -20,8 +20,8 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;
@@ -30,8 +30,8 @@ public class MinerGetExtraDataTest {
@Test
public void shouldReturnDefaultExtraData() {
- final MiningParameters miningParameters = ImmutableMiningParameters.newDefault();
- final MinerGetExtraData method = new MinerGetExtraData(miningParameters);
+ final MiningConfiguration miningConfiguration = ImmutableMiningConfiguration.newDefault();
+ final MinerGetExtraData method = new MinerGetExtraData(miningConfiguration);
final JsonRpcRequestContext request =
new JsonRpcRequestContext(new JsonRpcRequest("2.0", method.getName(), new Object[] {}));
@@ -43,12 +43,12 @@ public void shouldReturnDefaultExtraData() {
@Test
public void shouldReturnSetAtRuntimeExtraData() {
- final MiningParameters miningParameters = ImmutableMiningParameters.newDefault();
- final MinerGetExtraData method = new MinerGetExtraData(miningParameters);
+ final MiningConfiguration miningConfiguration = ImmutableMiningConfiguration.newDefault();
+ final MinerGetExtraData method = new MinerGetExtraData(miningConfiguration);
final var extraData = "0x123456";
final Bytes extraDataAtRuntime = Bytes.fromHexString(extraData);
- miningParameters.setExtraData(extraDataAtRuntime);
+ miningConfiguration.setExtraData(extraDataAtRuntime);
final JsonRpcRequestContext request =
new JsonRpcRequestContext(new JsonRpcRequest("2.0", method.getName(), new Object[] {}));
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPriceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPriceTest.java
index f73229f0e0f..8e036d822d9 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPriceTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPriceTest.java
@@ -22,8 +22,8 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.junit.jupiter.api.Test;
@@ -31,15 +31,16 @@ public class MinerGetMinGasPriceTest {
@Test
public void shouldReturnDefaultMinGasPrice() {
- final MiningParameters miningParameters = ImmutableMiningParameters.newDefault();
- final MinerGetMinGasPrice method = new MinerGetMinGasPrice(miningParameters);
+ final MiningConfiguration miningConfiguration = ImmutableMiningConfiguration.newDefault();
+ final MinerGetMinGasPrice method = new MinerGetMinGasPrice(miningConfiguration);
final JsonRpcRequestContext request =
new JsonRpcRequestContext(new JsonRpcRequest("2.0", method.getName(), new Object[] {}));
final JsonRpcResponse expected =
new JsonRpcSuccessResponse(
request.getRequest().getId(),
- Quantity.create(MiningParameters.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE));
+ Quantity.create(
+ MiningConfiguration.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE));
final JsonRpcResponse actual = method.response(request);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
@@ -47,12 +48,12 @@ public void shouldReturnDefaultMinGasPrice() {
@Test
public void shouldReturnSetAtRuntimeMinGasPrice() {
- final MiningParameters miningParameters = ImmutableMiningParameters.newDefault();
- final MinerGetMinGasPrice method = new MinerGetMinGasPrice(miningParameters);
+ final MiningConfiguration miningConfiguration = ImmutableMiningConfiguration.newDefault();
+ final MinerGetMinGasPrice method = new MinerGetMinGasPrice(miningConfiguration);
final Wei minGasPriceAtRuntime = Wei.of(2000);
- miningParameters.setMinTransactionGasPrice(minGasPriceAtRuntime);
+ miningConfiguration.setMinTransactionGasPrice(minGasPriceAtRuntime);
final JsonRpcRequestContext request =
new JsonRpcRequestContext(new JsonRpcRequest("2.0", method.getName(), new Object[] {}));
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFeeTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFeeTest.java
index 78fb85b94b7..07e3e5842f4 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFeeTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFeeTest.java
@@ -23,18 +23,18 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class MinerGetMinPriorityFeeTest {
- MiningParameters miningParameters = mock(MiningParameters.class);
+ MiningConfiguration miningConfiguration = mock(MiningConfiguration.class);
private MinerGetMinPriorityFee method;
@BeforeEach
public void setUp() {
- method = new MinerGetMinPriorityFee(miningParameters);
+ method = new MinerGetMinPriorityFee(miningConfiguration);
}
@Test
@@ -44,7 +44,8 @@ public void shouldReturnMinPriorityFee() {
final JsonRpcRequestContext request =
new JsonRpcRequestContext(new JsonRpcRequest("2.0", method.getName(), new Object[] {}));
- when(miningParameters.getMinPriorityFeePerGas()).thenReturn(Wei.fromHexString(minPriorityFee));
+ when(miningConfiguration.getMinPriorityFeePerGas())
+ .thenReturn(Wei.fromHexString(minPriorityFee));
final JsonRpcResponse expected =
new JsonRpcSuccessResponse(request.getRequest().getId(), minPriorityFee);
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraDataTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraDataTest.java
index b3c7b45d076..e197964081d 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraDataTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraDataTest.java
@@ -23,7 +23,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import java.nio.charset.StandardCharsets;
@@ -32,12 +32,12 @@
import org.junit.jupiter.api.Test;
public class MinerSetExtraDataTest {
- MiningParameters miningParameters = MiningParameters.newDefault();
+ MiningConfiguration miningConfiguration = MiningConfiguration.newDefault();
private MinerSetExtraData method;
@BeforeEach
public void setUp() {
- method = new MinerSetExtraData(miningParameters);
+ method = new MinerSetExtraData(miningConfiguration);
}
@Test
@@ -49,7 +49,7 @@ public void shouldChangeExtraData() {
final JsonRpcResponse actual = method.response(request);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
- final var currExtraData = miningParameters.getExtraData();
+ final var currExtraData = miningConfiguration.getExtraData();
assertThat(new String(currExtraData.toArray(), StandardCharsets.UTF_8)).isEqualTo(newExtraData);
}
@@ -67,7 +67,7 @@ public void shouldNotTrimLeadingZeros() {
final JsonRpcResponse actual = method.response(request);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
- final var currExtraData = miningParameters.getExtraData();
+ final var currExtraData = miningConfiguration.getExtraData();
assertThat(new String(currExtraData.toArray(), StandardCharsets.UTF_8))
.isEqualTo(
new String(
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPriceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPriceTest.java
index fb56b573075..860e1967d6c 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPriceTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPriceTest.java
@@ -24,18 +24,18 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class MinerSetMinGasPriceTest {
- MiningParameters miningParameters = MiningParameters.newDefault();
+ MiningConfiguration miningConfiguration = MiningConfiguration.newDefault();
private MinerSetMinGasPrice method;
@BeforeEach
public void setUp() {
- method = new MinerSetMinGasPrice(miningParameters);
+ method = new MinerSetMinGasPrice(miningConfiguration);
}
@Test
@@ -64,7 +64,7 @@ public void shouldChangeMinPriorityFee() {
final JsonRpcResponse actual = method.response(request);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
- assertThat(miningParameters.getMinTransactionGasPrice())
+ assertThat(miningConfiguration.getMinTransactionGasPrice())
.isEqualTo(Wei.fromHexString(newMinGasPrice));
}
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFeeTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFeeTest.java
index 7e564ac4259..fb75788d4b5 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFeeTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFeeTest.java
@@ -24,18 +24,18 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class MinerSetMinPriorityFeeTest {
- MiningParameters miningParameters = MiningParameters.newDefault();
+ MiningConfiguration miningConfiguration = MiningConfiguration.newDefault();
private MinerSetMinPriorityFee method;
@BeforeEach
public void setUp() {
- method = new MinerSetMinPriorityFee(miningParameters);
+ method = new MinerSetMinPriorityFee(miningConfiguration);
}
@Test
@@ -80,7 +80,7 @@ public void shouldReturnTrueWhenChangeMinPriorityFee() {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId(), true);
final JsonRpcResponse actual = method.response(request);
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
- assertThat(miningParameters.getMinPriorityFeePerGas())
+ assertThat(miningConfiguration.getMinPriorityFeePerGas())
.isEqualTo(Wei.fromHexString(newMinPriorityFee));
}
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java
index 47a16135ffd..53785012d09 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java
@@ -44,7 +44,7 @@
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.EthProtocol;
@@ -180,14 +180,14 @@ public void before() throws URISyntaxException {
synchronizer,
MainnetProtocolSchedule.fromConfig(
genesisConfigOptions,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()),
mock(ProtocolContext.class),
mock(FilterManager.class),
mock(TransactionPool.class),
- mock(MiningParameters.class),
+ mock(MiningConfiguration.class),
mock(PoWMiningCoordinator.class),
new NoOpMetricsSystem(),
supportedCapabilities,
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceTLSTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceTLSTest.java
new file mode 100644
index 00000000000..9a227dc4326
--- /dev/null
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceTLSTest.java
@@ -0,0 +1,444 @@
+/*
+ * 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.ethereum.api.jsonrpc.websocket;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+
+import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;
+import org.hyperledger.besu.ethereum.api.jsonrpc.execution.BaseJsonRpcProcessor;
+import org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor;
+import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
+import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.WebSocketMethodsFactory;
+import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.SubscriptionManager;
+import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
+import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.security.KeyStore;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import io.netty.handler.ssl.util.SelfSignedCertificate;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.WebSocketClient;
+import io.vertx.core.http.WebSocketClientOptions;
+import io.vertx.core.net.JksOptions;
+import io.vertx.core.net.PemTrustOptions;
+import io.vertx.junit5.VertxExtension;
+import io.vertx.junit5.VertxTestContext;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(VertxExtension.class)
+public class WebSocketServiceTLSTest {
+
+ private Vertx vertx;
+ private WebSocketConfiguration config;
+ private WebSocketMessageHandler webSocketMessageHandlerSpy;
+
+ @BeforeEach
+ public void setUp() {
+ vertx = Vertx.vertx();
+ config = WebSocketConfiguration.createDefault();
+ Map websocketMethods;
+ config.setPort(0); // Use ephemeral port
+ config.setHost("localhost");
+ websocketMethods =
+ new WebSocketMethodsFactory(
+ new SubscriptionManager(new NoOpMetricsSystem()), new HashMap<>())
+ .methods();
+ webSocketMessageHandlerSpy =
+ spy(
+ new WebSocketMessageHandler(
+ vertx,
+ new JsonRpcExecutor(new BaseJsonRpcProcessor(), websocketMethods),
+ mock(EthScheduler.class),
+ TimeoutOptions.defaultOptions().getTimeoutSeconds()));
+ }
+
+ @Test
+ public void shouldAcceptSecureWebSocketConnection(final VertxTestContext testContext)
+ throws Throwable {
+ // Generate a self-signed certificate
+ SelfSignedCertificate ssc = new SelfSignedCertificate();
+
+ // Create a temporary keystore file
+ File keystoreFile = File.createTempFile("keystore", ".jks");
+ keystoreFile.deleteOnExit();
+
+ // Create a PKCS12 keystore and load the self-signed certificate
+ KeyStore keyStore = KeyStore.getInstance("JKS");
+ keyStore.load(null, null);
+ keyStore.setKeyEntry(
+ "alias",
+ ssc.key(),
+ "password".toCharArray(),
+ new java.security.cert.Certificate[] {ssc.cert()});
+
+ // Save the keystore to the temporary file
+ try (FileOutputStream fos = new FileOutputStream(keystoreFile)) {
+ keyStore.store(fos, "password".toCharArray());
+ }
+
+ // Configure WebSocket with SSL enabled
+ config.setSslEnabled(true);
+ config.setKeyStorePath(keystoreFile.getAbsolutePath());
+ config.setKeyStorePassword("password");
+ config.setKeyStoreType("JKS");
+
+ // Create and start WebSocketService
+ WebSocketService webSocketService =
+ new WebSocketService(vertx, config, webSocketMessageHandlerSpy, new NoOpMetricsSystem());
+ webSocketService.start().join();
+
+ // Get the actual port
+ int port = webSocketService.socketAddress().getPort();
+
+ // Create a temporary truststore file
+ File truststoreFile = File.createTempFile("truststore", ".jks");
+ truststoreFile.deleteOnExit();
+
+ // Create a PKCS12 truststore and load the server's certificate
+ KeyStore trustStore = KeyStore.getInstance("JKS");
+ trustStore.load(null, null);
+ trustStore.setCertificateEntry("alias", ssc.cert());
+
+ // Save the truststore to the temporary file
+ try (FileOutputStream fos = new FileOutputStream(truststoreFile)) {
+ trustStore.store(fos, "password".toCharArray());
+ }
+
+ // Configure the HTTP client with the truststore
+ WebSocketClientOptions clientOptions =
+ new WebSocketClientOptions()
+ .setSsl(true)
+ .setTrustOptions(
+ new JksOptions().setPath(truststoreFile.getAbsolutePath()).setPassword("password"))
+ .setVerifyHost(true);
+
+ WebSocketClient webSocketClient = vertx.createWebSocketClient(clientOptions);
+ webSocketClient
+ .connect(port, "localhost", "/")
+ .onSuccess(
+ ws -> {
+ assertThat(ws.isSsl()).isTrue();
+ ws.close();
+ testContext.completeNow();
+ })
+ .onFailure(testContext::failNow);
+
+ assertThat(testContext.awaitCompletion(5, TimeUnit.SECONDS)).isTrue();
+ if (testContext.failed()) {
+ throw testContext.causeOfFailure();
+ }
+
+ // Stop the WebSocketService after the test
+ webSocketService.stop().join();
+ }
+
+ @Test
+ public void shouldAcceptSecureWebSocketConnectionPEM(final VertxTestContext testContext)
+ throws Throwable {
+ // Generate a self-signed certificate
+ SelfSignedCertificate ssc = new SelfSignedCertificate();
+
+ // Create temporary PEM files for the certificate and key
+ File certFile = File.createTempFile("cert", ".pem");
+ certFile.deleteOnExit();
+ File keyFile = File.createTempFile("key", ".pem");
+ keyFile.deleteOnExit();
+
+ // Write the certificate and key to the PEM files
+ try (FileOutputStream certOut = new FileOutputStream(certFile);
+ FileOutputStream keyOut = new FileOutputStream(keyFile)) {
+ certOut.write("-----BEGIN CERTIFICATE-----\n".getBytes(UTF_8));
+ certOut.write(
+ Base64.getMimeEncoder(64, "\n".getBytes(UTF_8)).encode(ssc.cert().getEncoded()));
+ certOut.write("\n-----END CERTIFICATE-----\n".getBytes(UTF_8));
+
+ keyOut.write("-----BEGIN PRIVATE KEY-----\n".getBytes(UTF_8));
+ keyOut.write(Base64.getMimeEncoder(64, "\n".getBytes(UTF_8)).encode(ssc.key().getEncoded()));
+ keyOut.write("\n-----END PRIVATE KEY-----\n".getBytes(UTF_8));
+ }
+
+ // Configure WebSocket with SSL enabled using PEM files
+ config.setSslEnabled(true);
+ config.setKeyPath(keyFile.getAbsolutePath());
+ config.setCertPath(certFile.getAbsolutePath());
+ config.setKeyStoreType("PEM");
+
+ // Create and start WebSocketService
+ WebSocketService webSocketService =
+ new WebSocketService(vertx, config, webSocketMessageHandlerSpy, new NoOpMetricsSystem());
+ webSocketService.start().join();
+
+ // Get the actual port
+ int port = webSocketService.socketAddress().getPort();
+
+ // Create a temporary PEM file for the trust store
+ File trustCertFile = File.createTempFile("trust-cert", ".pem");
+ trustCertFile.deleteOnExit();
+
+ // Write the server's certificate to the PEM file
+ try (FileOutputStream trustCertOut = new FileOutputStream(trustCertFile)) {
+ trustCertOut.write("-----BEGIN CERTIFICATE-----\n".getBytes(UTF_8));
+ trustCertOut.write(
+ Base64.getMimeEncoder(64, "\n".getBytes(UTF_8)).encode(ssc.cert().getEncoded()));
+ trustCertOut.write("\n-----END CERTIFICATE-----\n".getBytes(UTF_8));
+ }
+
+ // Configure the HTTP client with the trust store using PEM files
+ WebSocketClientOptions clientOptions =
+ new WebSocketClientOptions()
+ .setSsl(true)
+ .setTrustOptions(new PemTrustOptions().addCertPath(trustCertFile.getAbsolutePath()))
+ .setVerifyHost(true);
+
+ WebSocketClient webSocketClient = vertx.createWebSocketClient(clientOptions);
+ webSocketClient
+ .connect(port, "localhost", "/")
+ .onSuccess(
+ ws -> {
+ assertThat(ws.isSsl()).isTrue();
+ ws.close();
+ testContext.completeNow();
+ })
+ .onFailure(testContext::failNow);
+
+ assertThat(testContext.awaitCompletion(5, TimeUnit.SECONDS)).isTrue();
+ if (testContext.failed()) {
+ throw testContext.causeOfFailure();
+ }
+
+ // Stop the WebSocketService after the test
+ webSocketService.stop().join();
+ }
+
+ @Test
+ public void shouldFailConnectionWithWrongCertificateInTrustStore(
+ final VertxTestContext testContext) throws Throwable {
+ // Generate a self-signed certificate for the server
+ SelfSignedCertificate serverCert = new SelfSignedCertificate();
+
+ // Create a temporary keystore file for the server
+ File keystoreFile = File.createTempFile("keystore", ".p12");
+ keystoreFile.deleteOnExit();
+
+ // Create a PKCS12 keystore and load the server's self-signed certificate
+ KeyStore keyStore = KeyStore.getInstance("PKCS12");
+ keyStore.load(null, null);
+ keyStore.setKeyEntry(
+ "alias",
+ serverCert.key(),
+ "password".toCharArray(),
+ new java.security.cert.Certificate[] {serverCert.cert()});
+
+ // Save the keystore to the temporary file
+ try (FileOutputStream fos = new FileOutputStream(keystoreFile)) {
+ keyStore.store(fos, "password".toCharArray());
+ }
+
+ // Configure WebSocket with SSL enabled
+ config.setSslEnabled(true);
+ config.setKeyStorePath(keystoreFile.getAbsolutePath());
+ config.setKeyStorePassword("password");
+ config.setKeyStoreType("PKCS12");
+
+ // Create and start WebSocketService
+ WebSocketService webSocketService =
+ new WebSocketService(vertx, config, webSocketMessageHandlerSpy, new NoOpMetricsSystem());
+ webSocketService.start().join();
+
+ // Get the actual port
+ int port = webSocketService.socketAddress().getPort();
+
+ // Generate a different self-signed certificate for the trust store
+ SelfSignedCertificate wrongCert = new SelfSignedCertificate();
+
+ // Create a temporary truststore file
+ File truststoreFile = File.createTempFile("truststore", ".p12");
+ truststoreFile.deleteOnExit();
+
+ // Create a PKCS12 truststore and load the wrong certificate
+ KeyStore trustStore = KeyStore.getInstance("PKCS12");
+ trustStore.load(null, null);
+ trustStore.setCertificateEntry("alias", wrongCert.cert());
+
+ // Save the truststore to the temporary file
+ try (FileOutputStream fos = new FileOutputStream(truststoreFile)) {
+ trustStore.store(fos, "password".toCharArray());
+ }
+
+ // Configure the HTTP client with the truststore containing the wrong certificate
+ WebSocketClientOptions clientOptions =
+ new WebSocketClientOptions()
+ .setSsl(true)
+ .setTrustOptions(
+ new JksOptions().setPath(truststoreFile.getAbsolutePath()).setPassword("password"))
+ .setVerifyHost(true);
+
+ WebSocketClient webSocketClient = vertx.createWebSocketClient(clientOptions);
+ webSocketClient
+ .connect(port, "localhost", "/")
+ .onSuccess(
+ ws -> {
+ testContext.failNow(new AssertionError("Connection should have been rejected"));
+ })
+ .onFailure(
+ throwable -> {
+ assertThat(throwable).isInstanceOf(Exception.class);
+ testContext.completeNow();
+ });
+
+ assertThat(testContext.awaitCompletion(5, TimeUnit.SECONDS)).isTrue();
+ if (testContext.failed()) {
+ throw testContext.causeOfFailure();
+ }
+
+ // Stop the WebSocketService after the test
+ webSocketService.stop().join();
+ }
+
+ @Test
+ public void shouldAuthenticateClient(final VertxTestContext testContext) throws Throwable {
+ // Generate a self-signed certificate for the server
+ SelfSignedCertificate serverCert = new SelfSignedCertificate();
+
+ // Generate a self-signed certificate for the client
+ SelfSignedCertificate clientCert = new SelfSignedCertificate();
+
+ // Create a temporary keystore file for the server
+ File serverKeystoreFile = File.createTempFile("keystore", ".p12");
+ serverKeystoreFile.deleteOnExit();
+
+ // Create a temporary truststore file for the server
+ File serverTruststoreFile = File.createTempFile("truststore", ".p12");
+ serverTruststoreFile.deleteOnExit();
+
+ // Create a temporary keystore file for the client
+ File clientKeystoreFile = File.createTempFile("client-keystore", ".p12");
+ clientKeystoreFile.deleteOnExit();
+
+ // Create a temporary truststore file for the client
+ File clientTruststoreFile = File.createTempFile("truststore", ".p12");
+ clientTruststoreFile.deleteOnExit();
+
+ // Create a PKCS12 keystore and load the server's self-signed certificate
+ KeyStore serverKeyStore = KeyStore.getInstance("PKCS12");
+ serverKeyStore.load(null, null);
+ serverKeyStore.setKeyEntry(
+ "alias",
+ serverCert.key(),
+ "password".toCharArray(),
+ new java.security.cert.Certificate[] {serverCert.cert()});
+
+ // Save the keystore to the temporary file
+ try (FileOutputStream fos = new FileOutputStream(serverKeystoreFile)) {
+ serverKeyStore.store(fos, "password".toCharArray());
+ }
+
+ // Create a PKCS12 truststore and load the client's self-signed certificate
+ KeyStore serverTrustStore = KeyStore.getInstance("PKCS12");
+ serverTrustStore.load(null, null);
+ serverTrustStore.setCertificateEntry("alias", clientCert.cert());
+
+ // Save the truststore to the temporary file
+ try (FileOutputStream fos = new FileOutputStream(serverTruststoreFile)) {
+ serverTrustStore.store(fos, "password".toCharArray());
+ }
+
+ // Create a PKCS12 keystore and load the client's self-signed certificate
+ KeyStore clientKeyStore = KeyStore.getInstance("PKCS12");
+ clientKeyStore.load(null, null);
+ clientKeyStore.setKeyEntry(
+ "alias",
+ clientCert.key(),
+ "password".toCharArray(),
+ new java.security.cert.Certificate[] {clientCert.cert()});
+
+ // Save the client keystore to the temporary file
+ try (FileOutputStream fos = new FileOutputStream(clientKeystoreFile)) {
+ clientKeyStore.store(fos, "password".toCharArray());
+ }
+
+ // Create a PKCS12 truststore and load the server's self-signed certificate
+ KeyStore clientTrustStore = KeyStore.getInstance("PKCS12");
+ clientTrustStore.load(null, null);
+ clientTrustStore.setCertificateEntry("alias", serverCert.cert());
+
+ // Save the truststore to the temporary file
+ try (FileOutputStream fos = new FileOutputStream(clientTruststoreFile)) {
+ clientTrustStore.store(fos, "password".toCharArray());
+ }
+
+ // Configure WebSocket with SSL and client authentication enabled
+ config.setSslEnabled(true);
+ config.setKeyStorePath(serverKeystoreFile.getAbsolutePath());
+ config.setKeyStorePassword("password");
+ config.setKeyStoreType("PKCS12");
+ config.setClientAuthEnabled(true);
+ config.setTrustStorePath(serverTruststoreFile.getAbsolutePath());
+ config.setTrustStorePassword("password");
+ config.setTrustStoreType("PKCS12");
+
+ // Create and start WebSocketService
+ WebSocketService webSocketService =
+ new WebSocketService(vertx, config, webSocketMessageHandlerSpy, new NoOpMetricsSystem());
+ webSocketService.start().join();
+
+ // Get the actual port
+ int port = webSocketService.socketAddress().getPort();
+
+ // Configure the HTTP client with the client certificate
+ WebSocketClientOptions clientOptions =
+ new WebSocketClientOptions()
+ .setSsl(true)
+ .setKeyStoreOptions(
+ new JksOptions()
+ .setPath(clientKeystoreFile.getAbsolutePath())
+ .setPassword("password"))
+ .setTrustOptions(
+ new JksOptions()
+ .setPath(clientTruststoreFile.getAbsolutePath())
+ .setPassword("password"))
+ .setVerifyHost(true);
+
+ WebSocketClient webSocketClient = vertx.createWebSocketClient(clientOptions);
+ webSocketClient
+ .connect(port, "localhost", "/")
+ .onSuccess(
+ ws -> {
+ assertThat(ws.isSsl()).isTrue();
+ ws.close();
+ testContext.completeNow();
+ })
+ .onFailure(testContext::failNow);
+
+ assertThat(testContext.awaitCompletion(5, TimeUnit.SECONDS)).isTrue();
+ if (testContext.failed()) {
+ throw testContext.causeOfFailure();
+ }
+
+ // Stop the WebSocketService after the test
+ webSocketService.stop().join();
+ }
+}
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/blockheaders/NewBlockHeadersSubscriptionServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/blockheaders/NewBlockHeadersSubscriptionServiceTest.java
index 8cb33fa714e..aa69a239cc5 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/blockheaders/NewBlockHeadersSubscriptionServiceTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/blockheaders/NewBlockHeadersSubscriptionServiceTest.java
@@ -32,7 +32,7 @@
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -85,7 +85,7 @@ public class NewBlockHeadersSubscriptionServiceTest {
protocolSchedule,
blockchain,
createInMemoryWorldStateArchive(),
- MiningParameters.newDefault()));
+ MiningConfiguration.newDefault()));
@BeforeEach
public void before() {
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java
index c0420163de8..7b3d50b2d09 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java
@@ -28,7 +28,7 @@
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@@ -120,6 +120,7 @@ public void setup() {
null,
null,
null,
+ null,
new MainnetBlockHeaderFunctions());
testHash = fakeHeader.getHash();
final BlockBody fakeBody = new BlockBody(Collections.emptyList(), Collections.emptyList());
@@ -135,7 +136,7 @@ public void setup() {
worldStateArchive,
Optional.of(cacheDir),
Optional.of(scheduler),
- MiningParameters.newDefault());
+ MiningConfiguration.newDefault());
}
/**
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java
index a49b290e4db..a0213a41a80 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java
@@ -28,7 +28,7 @@
import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.LogWithMetadata;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@@ -599,7 +599,7 @@ private BlockchainWithData(
blockchain,
worldStateArchive,
scheduler,
- MiningParameters.newDefault());
+ MiningConfiguration.newDefault());
}
}
diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacherTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacherTest.java
index 5772a04a49d..293c0b176ea 100644
--- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacherTest.java
+++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacherTest.java
@@ -108,6 +108,7 @@ public void setup() throws IOException {
null,
null,
null,
+ null,
new MainnetBlockHeaderFunctions());
testHash = fakeHeader.getHash();
when(blockchain.getBlockHeader(anyLong())).thenReturn(Optional.of(fakeHeader));
@@ -283,6 +284,7 @@ private BlockHeader createBlock(final long number, final Optional messag
null,
null,
null,
+ null,
new MainnetBlockHeaderFunctions());
testHash = fakeHeader.getHash();
when(blockchain.getBlockHeader(number)).thenReturn(Optional.of(fakeHeader));
diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java
index ad9489daf83..51cde269e05 100644
--- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java
+++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java
@@ -30,7 +30,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.core.Request;
@@ -84,7 +84,7 @@ public interface ExtraDataCalculator {
private final MiningBeneficiaryCalculator miningBeneficiaryCalculator;
private final ExtraDataCalculator extraDataCalculator;
private final TransactionPool transactionPool;
- protected final MiningParameters miningParameters;
+ protected final MiningConfiguration miningConfiguration;
protected final ProtocolContext protocolContext;
protected final ProtocolSchedule protocolSchedule;
protected final BlockHeaderFunctions blockHeaderFunctions;
@@ -92,14 +92,14 @@ public interface ExtraDataCalculator {
private final AtomicBoolean isCancelled = new AtomicBoolean(false);
protected AbstractBlockCreator(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final MiningBeneficiaryCalculator miningBeneficiaryCalculator,
final ExtraDataCalculator extraDataCalculator,
final TransactionPool transactionPool,
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
final EthScheduler ethScheduler) {
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
this.miningBeneficiaryCalculator = miningBeneficiaryCalculator;
this.extraDataCalculator = extraDataCalculator;
this.transactionPool = transactionPool;
@@ -219,7 +219,7 @@ protected BlockCreationResult createBlock(
throwIfStopped();
final PluginTransactionSelector pluginTransactionSelector =
- miningParameters.getTransactionSelectionService().createPluginTransactionSelector();
+ miningConfiguration.getTransactionSelectionService().createPluginTransactionSelector();
final BlockAwareOperationTracer operationTracer =
pluginTransactionSelector.getOperationTracer();
@@ -377,7 +377,7 @@ private TransactionSelectionResults selectTransactions(
final BlockTransactionSelector selector =
new BlockTransactionSelector(
- miningParameters,
+ miningConfiguration,
transactionProcessor,
protocolContext.getBlockchain(),
disposableWorldState,
@@ -433,7 +433,7 @@ private ProcessableBlockHeader createPendingBlockHeader(
.getGasLimitCalculator()
.nextGasLimit(
parentHeader.getGasLimit(),
- miningParameters.getTargetGasLimit().orElse(parentHeader.getGasLimit()),
+ miningConfiguration.getTargetGasLimit().orElse(parentHeader.getGasLimit()),
newBlockNumber);
final DifficultyCalculator difficultyCalculator = protocolSpec.getDifficultyCalculator();
@@ -457,7 +457,7 @@ private ProcessableBlockHeader createPendingBlockHeader(
final Bytes32 parentBeaconBlockRoot = maybeParentBeaconBlockRoot.orElse(null);
return BlockHeaderBuilder.create()
.parentHash(parentHeader.getHash())
- .coinbase(miningParameters.getCoinbase().orElseThrow())
+ .coinbase(miningConfiguration.getCoinbase().orElseThrow())
.difficulty(Difficulty.of(difficulty))
.number(newBlockNumber)
.gasLimit(gasLimit)
diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java
index af71938d1d5..4d2b1274c67 100644
--- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java
+++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java
@@ -20,7 +20,7 @@
import org.hyperledger.besu.ethereum.chain.MinedBlockObserver;
import org.hyperledger.besu.ethereum.chain.PoWObserver;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.AbstractGasLimitSpecification;
@@ -47,7 +47,7 @@ public abstract class AbstractMinerExecutor getCoinbase();
diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/NoopMiningCoordinator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/NoopMiningCoordinator.java
index 6eb4927226c..8b5624f847a 100644
--- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/NoopMiningCoordinator.java
+++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/NoopMiningCoordinator.java
@@ -18,7 +18,7 @@
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Block;
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.Transaction;
import java.util.List;
@@ -26,10 +26,10 @@
public class NoopMiningCoordinator implements MiningCoordinator {
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
- public NoopMiningCoordinator(final MiningParameters miningParameters) {
- this.miningParameters = miningParameters;
+ public NoopMiningCoordinator(final MiningConfiguration miningConfiguration) {
+ this.miningConfiguration = miningConfiguration;
}
@Override
@@ -58,17 +58,17 @@ public boolean isMining() {
@Override
public Wei getMinTransactionGasPrice() {
- return miningParameters.getMinTransactionGasPrice();
+ return miningConfiguration.getMinTransactionGasPrice();
}
@Override
public Wei getMinPriorityFeePerGas() {
- return miningParameters.getMinPriorityFeePerGas();
+ return miningConfiguration.getMinPriorityFeePerGas();
}
@Override
public Optional getCoinbase() {
- return miningParameters.getCoinbase();
+ return miningConfiguration.getCoinbase();
}
@Override
diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreator.java
index d0042a5ad96..173330568fc 100644
--- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreator.java
+++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreator.java
@@ -17,7 +17,7 @@
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.SealableBlockHeader;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@@ -39,7 +39,7 @@ public class PoWBlockCreator extends AbstractBlockCreator {
private final PoWSolver nonceSolver;
public PoWBlockCreator(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final ExtraDataCalculator extraDataCalculator,
final TransactionPool transactionPool,
final ProtocolContext protocolContext,
@@ -47,8 +47,8 @@ public PoWBlockCreator(
final PoWSolver nonceSolver,
final EthScheduler ethScheduler) {
super(
- miningParameters,
- __ -> miningParameters.getCoinbase().orElseThrow(),
+ miningConfiguration,
+ __ -> miningConfiguration.getCoinbase().orElseThrow(),
extraDataCalculator,
transactionPool,
protocolContext,
diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutor.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutor.java
index b14eb193405..f17b7989d2a 100644
--- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutor.java
+++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutor.java
@@ -19,7 +19,7 @@
import org.hyperledger.besu.ethereum.chain.MinedBlockObserver;
import org.hyperledger.besu.ethereum.chain.PoWObserver;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.EpochCalculator;
@@ -40,7 +40,7 @@ public PoWMinerExecutor(
final ProtocolContext protocolContext,
final ProtocolSchedule protocolSchedule,
final TransactionPool transactionPool,
- final MiningParameters miningParams,
+ final MiningConfiguration miningParams,
final AbstractBlockScheduler blockScheduler,
final EpochCalculator epochCalculator,
final EthScheduler ethScheduler) {
@@ -62,7 +62,7 @@ public Optional startAsyncMining(
final Subscribers observers,
final Subscribers ethHashObservers,
final BlockHeader parentHeader) {
- if (miningParameters.getCoinbase().isEmpty()) {
+ if (miningConfiguration.getCoinbase().isEmpty()) {
throw new CoinbaseNotSetException("Unable to start mining without a coinbase.");
}
return super.startAsyncMining(observers, ethHashObservers, parentHeader);
@@ -79,7 +79,7 @@ public PoWBlockMiner createMiner(
protocolSchedule.getForNextBlockHeader(parentHeader, 0);
final PoWSolver solver =
new PoWSolver(
- miningParameters,
+ miningConfiguration,
nextBlockProtocolSpec.getPoWHasher().get(),
stratumMiningEnabled,
ethHashObservers,
@@ -87,8 +87,8 @@ public PoWBlockMiner createMiner(
final Function blockCreator =
(header) ->
new PoWBlockCreator(
- miningParameters,
- parent -> miningParameters.getExtraData(),
+ miningConfiguration,
+ parent -> miningConfiguration.getExtraData(),
transactionPool,
protocolContext,
protocolSchedule,
@@ -103,7 +103,7 @@ public void setCoinbase(final Address coinbase) {
if (coinbase == null) {
throw new IllegalArgumentException("Coinbase cannot be unset.");
} else {
- miningParameters.setCoinbase(Address.wrap(coinbase.copy()));
+ miningConfiguration.setCoinbase(Address.wrap(coinbase.copy()));
}
}
@@ -113,7 +113,7 @@ void setStratumMiningEnabled(final boolean stratumMiningEnabled) {
@Override
public Optional getCoinbase() {
- return miningParameters.getCoinbase();
+ return miningConfiguration.getCoinbase();
}
public EpochCalculator getEpochCalculator() {
diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockSelectionContext.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockSelectionContext.java
index f8bf6d50c5c..99da62ca06e 100644
--- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockSelectionContext.java
+++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockSelectionContext.java
@@ -17,7 +17,7 @@
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.blockhash.BlockHashProcessor;
@@ -25,7 +25,7 @@
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
public record BlockSelectionContext(
- MiningParameters miningParameters,
+ MiningConfiguration miningConfiguration,
GasCalculator gasCalculator,
GasLimitCalculator gasLimitCalculator,
BlockHashProcessor blockHashProcessor,
diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java
index 5370d2ec46c..a9b57a697ae 100644
--- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java
+++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java
@@ -31,7 +31,7 @@
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.PriceTransactionSelector;
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.ProcessingResultTransactionSelector;
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.MutableWorldState;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
@@ -108,7 +108,7 @@ public class BlockTransactionSelector {
private volatile TransactionEvaluationContext currTxEvaluationContext;
public BlockTransactionSelector(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final MainnetTransactionProcessor transactionProcessor,
final Blockchain blockchain,
final MutableWorldState worldState,
@@ -132,7 +132,7 @@ public BlockTransactionSelector(
this.ethScheduler = ethScheduler;
this.blockSelectionContext =
new BlockSelectionContext(
- miningParameters,
+ miningConfiguration,
gasCalculator,
gasLimitCalculator,
blockHashProcessor,
@@ -146,7 +146,7 @@ public BlockTransactionSelector(
this.operationTracer =
new InterruptibleOperationTracer(pluginTransactionSelector.getOperationTracer());
blockWorldStateUpdater = worldState.updater();
- blockTxsSelectionMaxTime = miningParameters.getBlockTxsSelectionMaxTime();
+ blockTxsSelectionMaxTime = miningConfiguration.getBlockTxsSelectionMaxTime();
}
private List createTransactionSelectors(
@@ -315,7 +315,7 @@ private TransactionEvaluationContext createTransactionEvaluationContext(
pendingTransaction,
Stopwatch.createStarted(),
transactionGasPriceInBlock,
- blockSelectionContext.miningParameters().getMinTransactionGasPrice());
+ blockSelectionContext.miningConfiguration().getMinTransactionGasPrice());
}
/**
diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java
index 2877c4ce139..0da2b1386d8 100644
--- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java
+++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java
@@ -112,13 +112,13 @@ private boolean blockOccupancyAboveThreshold(
LOG.trace(
"Min block occupancy ratio {}, gas used {}, available {}, remaining {}, used/available {}",
- context.miningParameters().getMinBlockOccupancyRatio(),
+ context.miningConfiguration().getMinBlockOccupancyRatio(),
gasUsed,
gasAvailable,
gasRemaining,
occupancyRatio);
- return occupancyRatio >= context.miningParameters().getMinBlockOccupancyRatio();
+ return occupancyRatio >= context.miningConfiguration().getMinBlockOccupancyRatio();
}
/**
diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java
index 5783c7e5007..c6dae8a144e 100644
--- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java
+++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java
@@ -69,7 +69,7 @@ private boolean isPriorityFeePriceBelowMinimum(final PendingTransaction pendingT
pendingTransaction
.getTransaction()
.getEffectivePriorityFeePerGas(context.pendingBlockHeader().getBaseFee());
- return priorityFeePerGas.lessThan(context.miningParameters().getMinPriorityFeePerGas());
+ return priorityFeePerGas.lessThan(context.miningConfiguration().getMinPriorityFeePerGas());
}
/**
diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java
index 707b1c48633..d3c3047f688 100644
--- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java
+++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java
@@ -76,7 +76,7 @@ private boolean transactionCurrentPriceBelowMin(
if (!pendingTransaction.hasPriority()) {
if (context
- .miningParameters()
+ .miningConfiguration()
.getMinTransactionGasPrice()
.compareTo(evaluationContext.getTransactionGasPrice())
> 0) {
@@ -86,7 +86,7 @@ private boolean transactionCurrentPriceBelowMin(
.addArgument(pendingTransaction::toTraceLog)
.addArgument(evaluationContext.getTransactionGasPrice()::toHumanReadableString)
.addArgument(
- context.miningParameters().getMinTransactionGasPrice()::toHumanReadableString)
+ context.miningConfiguration().getMinTransactionGasPrice()::toHumanReadableString)
.log();
return true;
}
diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java
index d30349e3d0e..b70c48ad026 100644
--- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java
+++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java
@@ -47,9 +47,9 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.SealableBlockHeader;
@@ -304,12 +304,12 @@ private CreateOn createBlockCreator(final ProtocolSpecAdapters protocolSpecAdapt
.protocolSchedule(
new ProtocolScheduleBuilder(
genesisConfigFile.getConfigOptions(),
- BigInteger.valueOf(42),
+ Optional.of(BigInteger.valueOf(42)),
protocolSpecAdapters,
PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
@@ -342,8 +342,8 @@ private CreateOn createBlockCreator(final ProtocolSpecAdapters protocolSpecAdapt
new BlobCache());
transactionPool.setEnabled();
- final MiningParameters miningParameters =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(Bytes.fromHexString("deadbeef"))
@@ -355,7 +355,7 @@ private CreateOn createBlockCreator(final ProtocolSpecAdapters protocolSpecAdapt
return new CreateOn(
new TestBlockCreator(
- miningParameters,
+ miningConfiguration,
__ -> Address.ZERO,
__ -> Bytes.fromHexString("deadbeef"),
transactionPool,
@@ -368,7 +368,7 @@ private CreateOn createBlockCreator(final ProtocolSpecAdapters protocolSpecAdapt
static class TestBlockCreator extends AbstractBlockCreator {
protected TestBlockCreator(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final MiningBeneficiaryCalculator miningBeneficiaryCalculator,
final ExtraDataCalculator extraDataCalculator,
final TransactionPool transactionPool,
@@ -376,7 +376,7 @@ protected TestBlockCreator(
final ProtocolSchedule protocolSchedule,
final EthScheduler ethScheduler) {
super(
- miningParameters,
+ miningConfiguration,
miningBeneficiaryCalculator,
extraDataCalculator,
transactionPool,
diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java
index 6eb03ece947..2787189ece7 100644
--- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java
+++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java
@@ -18,7 +18,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
import static org.awaitility.Awaitility.await;
-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.transaction.TransactionInvalidReason.EXECUTION_INTERRUPTED;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.NONCE_TOO_LOW;
import static org.hyperledger.besu.plugin.data.TransactionSelectionResult.BLOCK_SELECTION_TIMEOUT;
@@ -55,10 +55,10 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
@@ -138,7 +138,7 @@ public abstract class AbstractBlockTransactionSelectorTest {
protected MutableWorldState worldState;
protected ProtocolSchedule protocolSchedule;
protected TransactionSelectionService transactionSelectionService;
- protected MiningParameters defaultTestMiningParameters;
+ protected MiningConfiguration defaultTestMiningConfiguration;
@Mock protected EthScheduler ethScheduler;
@@ -155,7 +155,7 @@ public void setup() {
genesisConfigFile = getGenesisConfigFile();
protocolSchedule = createProtocolSchedule();
transactionSelectionService = new TransactionSelectionServiceImpl();
- defaultTestMiningParameters =
+ defaultTestMiningConfiguration =
createMiningParameters(
transactionSelectionService,
Wei.ZERO,
@@ -234,7 +234,7 @@ public void emptyPendingTransactionsResultsInEmptyVettingResult() {
FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.fromResource("/dev.json").getConfigOptions(),
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -248,7 +248,7 @@ public void emptyPendingTransactionsResultsInEmptyVettingResult() {
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
mainnetTransactionProcessor,
blockHeader,
miningBeneficiary,
@@ -269,7 +269,7 @@ public void validPendingTransactionIsIncludedInTheBlock() {
final Address miningBeneficiary = AddressHelpers.ofValue(1);
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -296,7 +296,7 @@ public void invalidTransactionsAreSkippedButBlockStillFills() {
final Address miningBeneficiary = AddressHelpers.ofValue(1);
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -336,7 +336,7 @@ public void subsetOfPendingTransactionsIncludedWhenBlockGasLimitHit() {
final Address miningBeneficiary = AddressHelpers.ofValue(1);
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -377,7 +377,7 @@ public void transactionTooLargeForBlockDoesNotPreventMoreBeingAddedIfBlockOccupa
final Address miningBeneficiary = AddressHelpers.ofValue(1);
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -412,7 +412,7 @@ public void transactionSelectionStopsWhenSufficientBlockOccupancyIsReached() {
final Address miningBeneficiary = AddressHelpers.ofValue(1);
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -568,7 +568,7 @@ public void shouldDiscardTransactionsThatFailValidation() {
final Address miningBeneficiary = AddressHelpers.ofValue(1);
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -643,7 +643,7 @@ public TransactionSelectionResult evaluateTransactionPostProcessing(
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -757,7 +757,7 @@ public void transactionSelectionPluginShouldBeNotifiedWhenTransactionSelectionCo
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
transactionProcessor,
createBlock(300_000),
AddressHelpers.ofValue(1),
@@ -793,7 +793,7 @@ public void transactionWithIncorrectNonceRemainsInPoolAndNotSelected() {
final Address miningBeneficiary = AddressHelpers.ofValue(1);
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -824,12 +824,12 @@ public void increaseOfMinGasPriceAtRuntimeExcludeTxFromBeingSelected() {
final Address miningBeneficiary = AddressHelpers.ofValue(1);
- final MiningParameters miningParameters =
- ImmutableMiningParameters.builder().from(defaultTestMiningParameters).build();
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder().from(defaultTestMiningConfiguration).build();
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- miningParameters,
+ miningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -841,7 +841,7 @@ public void increaseOfMinGasPriceAtRuntimeExcludeTxFromBeingSelected() {
ensureTransactionIsValid(transaction, 0, 5);
// raise the minGasPrice at runtime from 1 wei to 10 wei
- miningParameters.setMinTransactionGasPrice(Wei.of(10));
+ miningConfiguration.setMinTransactionGasPrice(Wei.of(10));
final TransactionSelectionResults results = selector.buildTransactionListForBlock();
@@ -857,15 +857,15 @@ public void increaseOfMinGasPriceAtRuntimeExcludeTxFromBeingSelected() {
@Test
public void decreaseOfMinGasPriceAtRuntimeIncludeTxThatWasPreviouslyNotSelected() {
final Transaction transaction = createTransaction(0, Wei.of(7L), 100_000);
- final MiningParameters miningParameters =
- ImmutableMiningParameters.builder().from(defaultTestMiningParameters).build();
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder().from(defaultTestMiningConfiguration).build();
final ProcessableBlockHeader blockHeader = createBlock(500_000);
final Address miningBeneficiary = AddressHelpers.ofValue(1);
final BlockTransactionSelector selector1 =
createBlockSelectorAndSetupTxPool(
- miningParameters,
+ miningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -876,7 +876,7 @@ public void decreaseOfMinGasPriceAtRuntimeIncludeTxThatWasPreviouslyNotSelected(
ensureTransactionIsValid(transaction, 0, 5);
// raise the minGasPrice at runtime from 1 wei to 10 wei
- miningParameters.setMinTransactionGasPrice(Wei.of(10));
+ miningConfiguration.setMinTransactionGasPrice(Wei.of(10));
final TransactionSelectionResults results1 = selector1.buildTransactionListForBlock();
@@ -889,11 +889,11 @@ public void decreaseOfMinGasPriceAtRuntimeIncludeTxThatWasPreviouslyNotSelected(
.containsOnly(transaction);
// decrease the minGasPrice at runtime from 10 wei to 5 wei
- miningParameters.setMinTransactionGasPrice(Wei.of(5));
+ miningConfiguration.setMinTransactionGasPrice(Wei.of(5));
final BlockTransactionSelector selector2 =
createBlockSelector(
- miningParameters,
+ miningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -910,9 +910,9 @@ public void decreaseOfMinGasPriceAtRuntimeIncludeTxThatWasPreviouslyNotSelected(
@Test
public void shouldNotSelectTransactionsWithPriorityFeeLessThanConfig() {
ProcessableBlockHeader blockHeader = createBlock(5_000_000, Wei.ONE);
- final MiningParameters miningParameters =
- ImmutableMiningParameters.builder().from(defaultTestMiningParameters).build();
- miningParameters.setMinPriorityFeePerGas(Wei.of(7));
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder().from(defaultTestMiningConfiguration).build();
+ miningConfiguration.setMinPriorityFeePerGas(Wei.of(7));
final Transaction txSelected = createTransaction(1, Wei.of(8), 100_000);
ensureTransactionIsValid(txSelected);
// transaction txNotSelected should not be selected
@@ -921,7 +921,7 @@ public void shouldNotSelectTransactionsWithPriorityFeeLessThanConfig() {
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- miningParameters,
+ miningConfiguration,
transactionProcessor,
blockHeader,
AddressHelpers.ofValue(1),
@@ -1259,7 +1259,7 @@ private void internalBlockSelectionTimeoutSimulationInvalidTxs(
}
protected BlockTransactionSelector createBlockSelectorAndSetupTxPool(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final MainnetTransactionProcessor transactionProcessor,
final ProcessableBlockHeader blockHeader,
final Address miningBeneficiary,
@@ -1269,7 +1269,7 @@ protected BlockTransactionSelector createBlockSelectorAndSetupTxPool(
transactionPool = createTransactionPool();
return createBlockSelector(
- miningParameters,
+ miningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -1278,7 +1278,7 @@ protected BlockTransactionSelector createBlockSelectorAndSetupTxPool(
}
protected BlockTransactionSelector createBlockSelector(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final MainnetTransactionProcessor transactionProcessor,
final ProcessableBlockHeader blockHeader,
final Address miningBeneficiary,
@@ -1287,7 +1287,7 @@ protected BlockTransactionSelector createBlockSelector(
final BlockTransactionSelector selector =
new BlockTransactionSelector(
- miningParameters,
+ miningConfiguration,
transactionProcessor,
blockchain,
worldState,
@@ -1423,12 +1423,12 @@ private BlockHeader blockHeader(final long number) {
return new BlockHeaderTestFixture().number(number).buildHeader();
}
- protected MiningParameters createMiningParameters(
+ protected MiningConfiguration createMiningParameters(
final TransactionSelectionService transactionSelectionService,
final Wei minGasPrice,
final double minBlockOccupancyRatio,
final PositiveNumber txsSelectionMaxTime) {
- return ImmutableMiningParameters.builder()
+ return ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.minTransactionGasPrice(minGasPrice)
@@ -1439,13 +1439,13 @@ protected MiningParameters createMiningParameters(
.build();
}
- protected MiningParameters createMiningParameters(
+ protected MiningConfiguration createMiningParameters(
final TransactionSelectionService transactionSelectionService,
final Wei minGasPrice,
final double minBlockOccupancyRatio,
final int genesisBlockPeriodSeconds,
final PositiveNumber minBlockTimePercentage) {
- return ImmutableMiningParameters.builder()
+ return ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.minTransactionGasPrice(minGasPrice)
diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java
index 940d076bbc3..327d4bd37d0 100644
--- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java
+++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java
@@ -22,7 +22,7 @@
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCache;
@@ -42,6 +42,7 @@
import org.hyperledger.besu.util.number.Fraction;
import java.time.ZoneId;
+import java.util.Optional;
import java.util.function.Function;
public class LegacyFeeMarketBlockTransactionSelectorTest
@@ -56,12 +57,12 @@ protected GenesisConfigFile getGenesisConfigFile() {
protected ProtocolSchedule createProtocolSchedule() {
return new ProtocolScheduleBuilder(
genesisConfigFile.getConfigOptions(),
- CHAIN_ID,
+ Optional.of(CHAIN_ID),
ProtocolSpecAdapters.create(0, Function.identity()),
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java
index 68d9a71de6f..62eaf713c54 100644
--- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java
+++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java
@@ -16,7 +16,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
-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.mockito.Mockito.mock;
import org.hyperledger.besu.config.GenesisConfigFile;
@@ -26,8 +26,8 @@
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.AddressHelpers;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
@@ -51,6 +51,7 @@
import java.time.ZoneId;
import java.util.List;
+import java.util.Optional;
import java.util.function.Function;
import org.junit.jupiter.api.Test;
@@ -67,12 +68,12 @@ protected GenesisConfigFile getGenesisConfigFile() {
protected ProtocolSchedule createProtocolSchedule() {
return new ProtocolScheduleBuilder(
genesisConfigFile.getConfigOptions(),
- CHAIN_ID,
+ Optional.of(CHAIN_ID),
ProtocolSpecAdapters.create(0, Function.identity()),
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
@@ -221,7 +222,7 @@ public void transactionFromSameSenderWithMixedTypes() {
final Address miningBeneficiary = AddressHelpers.ofValue(1);
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- defaultTestMiningParameters,
+ defaultTestMiningConfiguration,
transactionProcessor,
blockHeader,
miningBeneficiary,
@@ -241,9 +242,9 @@ public void transactionFromSameSenderWithMixedTypes() {
@Override
public void shouldNotSelectTransactionsWithPriorityFeeLessThanConfig() {
ProcessableBlockHeader blockHeader = createBlock(5_000_000, Wei.ONE);
- final MiningParameters miningParameters =
- ImmutableMiningParameters.builder().from(defaultTestMiningParameters).build();
- miningParameters.setMinPriorityFeePerGas(Wei.of(7));
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder().from(defaultTestMiningConfiguration).build();
+ miningConfiguration.setMinPriorityFeePerGas(Wei.of(7));
final Transaction txSelected1 = createEIP1559Transaction(1, Wei.of(8), Wei.of(8), 100_000);
ensureTransactionIsValid(txSelected1);
@@ -262,7 +263,7 @@ public void shouldNotSelectTransactionsWithPriorityFeeLessThanConfig() {
final BlockTransactionSelector selector =
createBlockSelectorAndSetupTxPool(
- miningParameters,
+ miningConfiguration,
transactionProcessor,
blockHeader,
AddressHelpers.ofValue(1),
diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java
index 6f81f4df2c6..29cea9d0893 100644
--- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java
+++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java
@@ -24,7 +24,7 @@
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext;
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.AbstractTransactionSelector;
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.MinPriorityFeePerGasTransactionSelector;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
@@ -46,11 +46,11 @@ public class MinPriorityFeePerGasTransactionSelectorTest {
@BeforeEach
public void initialize() {
- MiningParameters miningParameters =
- MiningParameters.newDefault().setMinPriorityFeePerGas(Wei.of(minPriorityFeeParameter));
+ MiningConfiguration miningConfiguration =
+ MiningConfiguration.newDefault().setMinPriorityFeePerGas(Wei.of(minPriorityFeeParameter));
BlockSelectionContext context =
new BlockSelectionContext(
- miningParameters, null, null, null, pendingBlockHeader, null, null, null, null);
+ miningConfiguration, null, null, null, pendingBlockHeader, null, null, null, null);
transactionSelector = new MinPriorityFeePerGasTransactionSelector(context);
}
diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java
index 509efd7b19b..e8b9baa0a73 100644
--- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java
+++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java
@@ -31,9 +31,9 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
@@ -62,6 +62,7 @@
import java.io.IOException;
import java.math.BigInteger;
import java.util.Collections;
+import java.util.Optional;
import java.util.function.Function;
import com.google.common.collect.Lists;
@@ -86,19 +87,19 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest {
void createMainnetBlock1() throws IOException {
final var genesisConfigFile = GenesisConfigFile.mainnet();
- final MiningParameters miningParameters = createMiningParameters(BLOCK_1_NONCE);
+ final MiningConfiguration miningConfiguration = createMiningParameters(BLOCK_1_NONCE);
final ExecutionContextTestFixture executionContextTestFixture =
ExecutionContextTestFixture.builder(genesisConfigFile)
.protocolSchedule(
new ProtocolScheduleBuilder(
genesisConfigFile.getConfigOptions(),
- BigInteger.valueOf(42),
+ Optional.of(BigInteger.valueOf(42)),
ProtocolSpecAdapters.create(0, Function.identity()),
PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
@@ -107,7 +108,7 @@ void createMainnetBlock1() throws IOException {
final PoWSolver solver =
new PoWSolver(
- miningParameters,
+ miningConfiguration,
PoWHasher.ETHASH_LIGHT,
false,
Subscribers.none(),
@@ -117,7 +118,7 @@ void createMainnetBlock1() throws IOException {
final PoWBlockCreator blockCreator =
new PoWBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> BLOCK_1_EXTRA_DATA,
transactionPool,
executionContextTestFixture.getProtocolContext(),
@@ -145,14 +146,14 @@ void createMainnetBlock1_fixedDifficulty1() {
final var genesisConfigFile =
GenesisConfigFile.fromResource("/block-creation-fixed-difficulty-genesis.json");
- final MiningParameters miningParameters = createMiningParameters(FIXED_DIFFICULTY_NONCE);
+ final MiningConfiguration miningConfiguration = createMiningParameters(FIXED_DIFFICULTY_NONCE);
final ExecutionContextTestFixture executionContextTestFixture =
ExecutionContextTestFixture.builder(genesisConfigFile)
.protocolSchedule(
new ProtocolScheduleBuilder(
genesisConfigFile.getConfigOptions(),
- BigInteger.valueOf(42),
+ Optional.of(BigInteger.valueOf(42)),
ProtocolSpecAdapters.create(
0,
specBuilder ->
@@ -162,7 +163,7 @@ void createMainnetBlock1_fixedDifficulty1() {
PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
@@ -171,7 +172,7 @@ void createMainnetBlock1_fixedDifficulty1() {
final PoWSolver solver =
new PoWSolver(
- miningParameters,
+ miningConfiguration,
PoWHasher.ETHASH_LIGHT,
false,
Subscribers.none(),
@@ -181,7 +182,7 @@ void createMainnetBlock1_fixedDifficulty1() {
final PoWBlockCreator blockCreator =
new PoWBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> BLOCK_1_EXTRA_DATA,
transactionPool,
executionContextTestFixture.getProtocolContext(),
@@ -203,12 +204,12 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsFalse() {
final var genesisConfigFile =
GenesisConfigFile.fromResource("/block-creation-fixed-difficulty-genesis.json");
- final MiningParameters miningParameters = createMiningParameters(FIXED_DIFFICULTY_NONCE);
+ final MiningConfiguration miningConfiguration = createMiningParameters(FIXED_DIFFICULTY_NONCE);
ProtocolSchedule protocolSchedule =
new ProtocolScheduleBuilder(
genesisConfigFile.getConfigOptions(),
- BigInteger.valueOf(42),
+ Optional.of(BigInteger.valueOf(42)),
ProtocolSpecAdapters.create(
0,
specBuilder ->
@@ -218,7 +219,7 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsFalse() {
PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
@@ -230,7 +231,7 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsFalse() {
final PoWSolver solver =
new PoWSolver(
- miningParameters,
+ miningConfiguration,
PoWHasher.ETHASH_LIGHT,
false,
Subscribers.none(),
@@ -240,7 +241,7 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsFalse() {
final PoWBlockCreator blockCreator =
new PoWBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> BLOCK_1_EXTRA_DATA,
transactionPool,
executionContextTestFixture.getProtocolContext(),
@@ -280,12 +281,12 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsTrue() {
final var genesisConfigFile =
GenesisConfigFile.fromResource("/block-creation-fixed-difficulty-genesis.json");
- final MiningParameters miningParameters = createMiningParameters(FIXED_DIFFICULTY_NONCE);
+ final MiningConfiguration miningConfiguration = createMiningParameters(FIXED_DIFFICULTY_NONCE);
ProtocolSchedule protocolSchedule =
new ProtocolScheduleBuilder(
genesisConfigFile.getConfigOptions(),
- BigInteger.valueOf(42),
+ Optional.of(BigInteger.valueOf(42)),
ProtocolSpecAdapters.create(
0,
specBuilder ->
@@ -295,7 +296,7 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsTrue() {
PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
@@ -307,7 +308,7 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsTrue() {
final PoWSolver solver =
new PoWSolver(
- miningParameters,
+ miningConfiguration,
PoWHasher.ETHASH_LIGHT,
false,
Subscribers.none(),
@@ -317,7 +318,7 @@ void rewardBeneficiary_zeroReward_skipZeroRewardsTrue() {
final PoWBlockCreator blockCreator =
new PoWBlockCreator(
- miningParameters,
+ miningConfiguration,
parent -> BLOCK_1_EXTRA_DATA,
transactionPool,
executionContextTestFixture.getProtocolContext(),
@@ -381,8 +382,8 @@ private TransactionPool createTransactionPool(
return transactionPool;
}
- private MiningParameters createMiningParameters(final long nonce) {
- return ImmutableMiningParameters.builder()
+ private MiningConfiguration createMiningParameters(final long nonce) {
+ return ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.nonceGenerator(Lists.newArrayList(nonce))
diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutorTest.java
index 8c1e217d759..14e6b543747 100644
--- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutorTest.java
+++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutorTest.java
@@ -22,7 +22,7 @@
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCache;
@@ -51,7 +51,7 @@ public class PoWMinerExecutorTest {
@Test
public void startingMiningWithoutCoinbaseThrowsException() {
- final MiningParameters miningParameters = MiningParameters.newDefault();
+ final MiningConfiguration miningConfiguration = MiningConfiguration.newDefault();
final TransactionPool transactionPool = createTransactionPool();
@@ -60,7 +60,7 @@ public void startingMiningWithoutCoinbaseThrowsException() {
null,
null,
transactionPool,
- miningParameters,
+ miningConfiguration,
new DefaultBlockScheduler(1L, 10, TestClock.fixed()),
new EpochCalculator.DefaultEpochCalculator(),
ethScheduler);
@@ -72,7 +72,7 @@ public void startingMiningWithoutCoinbaseThrowsException() {
@Test
public void settingCoinbaseToNullThrowsException() {
- final MiningParameters miningParameters = MiningParameters.newDefault();
+ final MiningConfiguration miningConfiguration = MiningConfiguration.newDefault();
final TransactionPool transactionPool = createTransactionPool();
@@ -81,7 +81,7 @@ public void settingCoinbaseToNullThrowsException() {
null,
null,
transactionPool,
- miningParameters,
+ miningConfiguration,
new DefaultBlockScheduler(1, 10, TestClock.fixed()),
new EpochCalculator.DefaultEpochCalculator(),
ethScheduler);
diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinatorTest.java
index 6efd63fbaed..6dd272473fa 100644
--- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinatorTest.java
+++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinatorTest.java
@@ -15,8 +15,8 @@
package org.hyperledger.besu.ethereum.blockcreation;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT;
-import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_TTL;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT;
+import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_TTL;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/ethereum/core/build.gradle b/ethereum/core/build.gradle
index 24c794e298e..c5ab4462669 100644
--- a/ethereum/core/build.gradle
+++ b/ethereum/core/build.gradle
@@ -96,7 +96,6 @@ dependencies {
integrationTestImplementation 'org.assertj:assertj-core'
integrationTestImplementation 'org.junit.jupiter:junit-jupiter-api'
integrationTestImplementation 'org.mockito:mockito-core'
- integrationTestImplementation 'org.testcontainers:testcontainers'
integrationTestImplementation 'io.tmio:tuweni-bytes'
integrationTestRuntimeOnly 'org.junit.jupiter:junit-jupiter'
@@ -108,6 +107,8 @@ dependencies {
testSupportImplementation 'org.junit.jupiter:junit-jupiter'
testSupportImplementation 'org.assertj:assertj-core'
testSupportImplementation 'org.mockito:mockito-core'
+ testSupportImplementation 'com.google.dagger:dagger'
+ testSupportAnnotationProcessor 'com.google.dagger:dagger-compiler'
jmhImplementation project(path: ':config', configuration: 'testSupportArtifacts')
jmhImplementation project(':crypto:algorithms')
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java
index b218982c092..39f5cb0f66f 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java
@@ -181,7 +181,7 @@ public BlockProcessingResult validateAndProcessBlock(
Optional.of(new BlockProcessingOutputs(worldState, receipts, maybeRequests)));
}
} catch (MerkleTrieException ex) {
- context.getSynchronizer().healWorldState(ex.getMaybeAddress(), ex.getLocation());
+ context.getWorldStateArchive().heal(ex.getMaybeAddress(), ex.getLocation());
return new BlockProcessingResult(Optional.empty(), ex);
} catch (StorageException ex) {
var retval = new BlockProcessingResult(Optional.empty(), ex);
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java
index 4ca40bc0a9d..53197ea9c56 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java
@@ -16,7 +16,6 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
-import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
@@ -32,7 +31,6 @@ public class ProtocolContext {
private final WorldStateArchive worldStateArchive;
private final BadBlockManager badBlockManager;
private final ConsensusContext consensusContext;
- private Synchronizer synchronizer;
/**
* Constructs a new ProtocolContext with the given blockchain, world state archive, consensus
@@ -78,24 +76,6 @@ public static ProtocolContext init(
badBlockManager);
}
- /**
- * Gets the synchronizer of the protocol context.
- *
- * @return the synchronizer of the protocol context
- */
- public Synchronizer getSynchronizer() {
- return synchronizer;
- }
-
- /**
- * Sets the synchronizer of the protocol context.
- *
- * @param synchronizer the synchronizer to set
- */
- public void setSynchronizer(final Synchronizer synchronizer) {
- this.synchronizer = synchronizer;
- }
-
/**
* Gets the blockchain of the protocol context.
*
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java
index 2ee997f8ccd..b27023776f6 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java
@@ -48,6 +48,7 @@
import com.google.common.base.MoreObjects;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
+import org.apache.tuweni.units.bigints.UInt64;
public final class GenesisState {
@@ -218,6 +219,12 @@ private static BlockHeader buildHeader(
.parentBeaconBlockRoot(
(isCancunAtGenesis(genesis) ? parseParentBeaconBlockRoot(genesis) : null))
.requestsHash(isPragueAtGenesis(genesis) ? Hash.EMPTY_REQUESTS_HASH : null)
+ .targetBlobCount(
+ isPragueAtGenesis(genesis)
+ // TODO SLD EIP-7742 Currently defaulting to null due to dependency on web3j
+ // BlockHeader in CodeDelegationTransactionAcceptanceTest
+ ? genesis.getTargetBlobCount().map(UInt64::fromHexString).orElse(null)
+ : null)
.buildBlockHeader();
}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolScheduleModule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolScheduleModule.java
new file mode 100644
index 00000000000..98575272c73
--- /dev/null
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolScheduleModule.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright contributors to Hyperledger Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.ethereum.components;
+
+import org.hyperledger.besu.config.GenesisConfigOptions;
+import org.hyperledger.besu.ethereum.chain.BadBlockManager;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
+import org.hyperledger.besu.ethereum.core.PrivacyParameters;
+import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
+import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
+import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
+import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
+import org.hyperledger.besu.evm.internal.EvmConfiguration;
+import org.hyperledger.besu.plugin.services.MetricsSystem;
+
+import java.math.BigInteger;
+import java.util.Optional;
+import javax.inject.Singleton;
+
+import dagger.Module;
+import dagger.Provides;
+
+/** Provides the protocol schedule for the network. */
+@Module
+public class ProtocolScheduleModule {
+
+ /** Default constructor. */
+ public ProtocolScheduleModule() {}
+
+ /**
+ * Provides the protocol schedule builder.
+ *
+ * @param config the genesis config options
+ * @param protocolSpecAdapters the protocol spec adapters
+ * @param privacyParameters the privacy parameters
+ * @param isRevertReasonEnabled whether revert reason is enabled
+ * @param evmConfiguration the EVM configuration
+ * @param badBlockManager the bad block manager
+ * @param isParallelTxProcessingEnabled whether parallel tx processing is enabled
+ * @param metricsSystem the metrics system
+ * @param miningConfiguration the mining parameters
+ * @return the protocol schedule builder
+ */
+ @Singleton
+ @Provides
+ public ProtocolScheduleBuilder provideProtocolScheduleBuilder(
+ final GenesisConfigOptions config,
+ final ProtocolSpecAdapters protocolSpecAdapters,
+ final PrivacyParameters privacyParameters,
+ final boolean isRevertReasonEnabled,
+ final EvmConfiguration evmConfiguration,
+ final BadBlockManager badBlockManager,
+ final boolean isParallelTxProcessingEnabled,
+ final MetricsSystem metricsSystem,
+ final MiningConfiguration miningConfiguration) {
+
+ ProtocolScheduleBuilder builder =
+ new ProtocolScheduleBuilder(
+ config,
+ config.getChainId(),
+ protocolSpecAdapters,
+ privacyParameters,
+ isRevertReasonEnabled,
+ evmConfiguration,
+ miningConfiguration,
+ badBlockManager,
+ isParallelTxProcessingEnabled,
+ metricsSystem);
+
+ return builder;
+ }
+
+ /**
+ * Provides the protocol schedule.
+ *
+ * @param builder the protocol schedule builder
+ * @param config the genesis config options
+ * @return the protocol schedule
+ */
+ @Provides
+ public ProtocolSchedule createProtocolSchedule(
+ final ProtocolScheduleBuilder builder, final GenesisConfigOptions config) {
+ final Optional chainId = config.getChainId().or(() -> builder.getDefaultChainId());
+ DefaultProtocolSchedule protocolSchedule = new DefaultProtocolSchedule(chainId);
+ builder.initSchedule(protocolSchedule, chainId);
+ return protocolSchedule;
+ }
+}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolSpecModule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolSpecModule.java
new file mode 100644
index 00000000000..fe9b0f3fab4
--- /dev/null
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolSpecModule.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright contributors to Hyperledger Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.ethereum.components;
+
+import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSpecs;
+import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
+import org.hyperledger.besu.evm.internal.EvmConfiguration;
+import org.hyperledger.besu.plugin.services.MetricsSystem;
+
+import javax.inject.Named;
+
+import dagger.Module;
+import dagger.Provides;
+
+/** Provides protocol specs for network forks. */
+@Module
+public class ProtocolSpecModule {
+
+ /** Default constructor. */
+ public ProtocolSpecModule() {}
+
+ /**
+ * Provides the protocol spec for the frontier network fork.
+ *
+ * @param evmConfiguration the EVM configuration
+ * @param isParalleltxEnabled whether parallel tx processing is enabled
+ * @param metricsSystem the metrics system
+ * @return the protocol spec for the frontier network fork
+ */
+ @Provides
+ @Named("frontier")
+ public ProtocolSpecBuilder frontierProtocolSpec(
+ final EvmConfiguration evmConfiguration,
+ final boolean isParalleltxEnabled,
+ final MetricsSystem metricsSystem) {
+ return MainnetProtocolSpecs.frontierDefinition(
+ evmConfiguration, isParalleltxEnabled, metricsSystem);
+ }
+}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java
index 6bd1a2aa588..830a80ccceb 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java
@@ -28,6 +28,7 @@
import com.google.common.base.Suppliers;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
+import org.apache.tuweni.units.bigints.UInt64;
/** A mined Ethereum block header. */
public class BlockHeader extends SealableBlockHeader
@@ -65,6 +66,7 @@ public BlockHeader(
final BlobGas excessBlobGas,
final Bytes32 parentBeaconBlockRoot,
final Hash requestsHash,
+ final UInt64 targetBlobCount,
final BlockHeaderFunctions blockHeaderFunctions) {
super(
parentHash,
@@ -86,7 +88,8 @@ public BlockHeader(
blobGasUsed,
excessBlobGas,
parentBeaconBlockRoot,
- requestsHash);
+ requestsHash,
+ targetBlobCount);
this.nonce = nonce;
this.hash = Suppliers.memoize(() -> blockHeaderFunctions.hash(this));
this.parsedExtraData = Suppliers.memoize(() -> blockHeaderFunctions.parseExtraData(this));
@@ -187,6 +190,9 @@ public void writeTo(final RLPOutput out) {
if (requestsHash == null) break;
out.writeBytes(requestsHash);
+
+ if (targetBlobCount == null) break;
+ out.writeUInt64Scalar(targetBlobCount);
} while (false);
out.endList();
}
@@ -219,6 +225,7 @@ public static BlockHeader readFrom(
!input.isEndOfCurrentList() ? BlobGas.of(input.readUInt64Scalar()) : null;
final Bytes32 parentBeaconBlockRoot = !input.isEndOfCurrentList() ? input.readBytes32() : null;
final Hash requestsHash = !input.isEndOfCurrentList() ? Hash.wrap(input.readBytes32()) : null;
+ final UInt64 targetBlobCount = !input.isEndOfCurrentList() ? input.readUInt64Scalar() : null;
input.leaveList();
return new BlockHeader(
parentHash,
@@ -242,6 +249,7 @@ public static BlockHeader readFrom(
excessBlobGas,
parentBeaconBlockRoot,
requestsHash,
+ targetBlobCount,
blockHeaderFunctions);
}
@@ -295,6 +303,9 @@ public String toString() {
if (requestsHash != null) {
sb.append("requestsHash=").append(requestsHash);
}
+ if (targetBlobCount != null) {
+ sb.append("targetBlobCount=").append(targetBlobCount);
+ }
return sb.append("}").toString();
}
@@ -329,6 +340,7 @@ public static org.hyperledger.besu.ethereum.core.BlockHeader convertPluginBlockH
.getRequestsHash()
.map(h -> Hash.fromHexString(h.toHexString()))
.orElse(null),
+ pluginBlockHeader.getTargetBlobCount().orElse(null),
blockHeaderFunctions);
}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java
index a024d53cd2f..b98f8201121 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java
@@ -30,6 +30,7 @@
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
+import org.apache.tuweni.units.bigints.UInt64;
/** A utility class for building block headers. */
public class BlockHeaderBuilder {
@@ -76,6 +77,7 @@ public class BlockHeaderBuilder {
private Long blobGasUsed = null;
private BlobGas excessBlobGas = null;
private Bytes32 parentBeaconBlockRoot = null;
+ private UInt64 targetBlobCount = null;
public static BlockHeaderBuilder create() {
return new BlockHeaderBuilder();
@@ -124,7 +126,8 @@ public static BlockHeaderBuilder fromHeader(final BlockHeader header) {
.blobGasUsed(header.getBlobGasUsed().orElse(null))
.excessBlobGas(header.getExcessBlobGas().orElse(null))
.parentBeaconBlockRoot(header.getParentBeaconBlockRoot().orElse(null))
- .requestsHash(header.getRequestsHash().orElse(null));
+ .requestsHash(header.getRequestsHash().orElse(null))
+ .targetBlobCount(header.getTargetBlobCount().orElse(null));
}
public static BlockHeaderBuilder fromBuilder(final BlockHeaderBuilder fromBuilder) {
@@ -149,6 +152,7 @@ public static BlockHeaderBuilder fromBuilder(final BlockHeaderBuilder fromBuilde
.excessBlobGas(fromBuilder.excessBlobGas)
.parentBeaconBlockRoot(fromBuilder.parentBeaconBlockRoot)
.requestsHash(fromBuilder.requestsHash)
+ .targetBlobCount(fromBuilder.targetBlobCount)
.blockHeaderFunctions(fromBuilder.blockHeaderFunctions);
toBuilder.nonce = fromBuilder.nonce;
return toBuilder;
@@ -179,6 +183,7 @@ public BlockHeader buildBlockHeader() {
excessBlobGas,
parentBeaconBlockRoot,
requestsHash,
+ targetBlobCount,
blockHeaderFunctions);
}
@@ -194,7 +199,8 @@ public ProcessableBlockHeader buildProcessableBlockHeader() {
timestamp,
baseFee,
mixHashOrPrevRandao,
- parentBeaconBlockRoot);
+ parentBeaconBlockRoot,
+ targetBlobCount);
}
public SealableBlockHeader buildSealableBlockHeader() {
@@ -220,7 +226,8 @@ public SealableBlockHeader buildSealableBlockHeader() {
blobGasUsed,
excessBlobGas,
parentBeaconBlockRoot,
- requestsHash);
+ requestsHash,
+ targetBlobCount);
}
private void validateBlockHeader() {
@@ -260,6 +267,7 @@ public BlockHeaderBuilder populateFrom(final ProcessableBlockHeader processableB
baseFee(processableBlockHeader.getBaseFee().orElse(null));
processableBlockHeader.getPrevRandao().ifPresent(this::prevRandao);
processableBlockHeader.getParentBeaconBlockRoot().ifPresent(this::parentBeaconBlockRoot);
+ processableBlockHeader.getTargetBlobCount().ifPresent(this::targetBlobCount);
return this;
}
@@ -285,6 +293,7 @@ public BlockHeaderBuilder populateFrom(final SealableBlockHeader sealableBlockHe
sealableBlockHeader.getExcessBlobGas().ifPresent(this::excessBlobGas);
sealableBlockHeader.getParentBeaconBlockRoot().ifPresent(this::parentBeaconBlockRoot);
requestsHash(sealableBlockHeader.getRequestsHash().orElse(null));
+ sealableBlockHeader.getTargetBlobCount().ifPresent(this::targetBlobCount);
return this;
}
@@ -418,4 +427,9 @@ public BlockHeaderBuilder parentBeaconBlockRoot(final Bytes32 parentBeaconBlockR
this.parentBeaconBlockRoot = parentBeaconBlockRoot;
return this;
}
+
+ public BlockHeaderBuilder targetBlobCount(final UInt64 targetBlobCount) {
+ this.targetBlobCount = targetBlobCount;
+ return this;
+ }
}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParameters.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningConfiguration.java
similarity index 88%
rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParameters.java
rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningConfiguration.java
index 1921b3568b1..fb39d164b75 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParameters.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningConfiguration.java
@@ -34,27 +34,29 @@
@Value.Immutable
@Value.Enclosing
-public abstract class MiningParameters {
+public abstract class MiningConfiguration {
public static final PositiveNumber DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME =
PositiveNumber.fromInt((int) Duration.ofSeconds(5).toMillis());
public static final PositiveNumber DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME =
PositiveNumber.fromInt(75);
- public static final MiningParameters MINING_DISABLED =
- ImmutableMiningParameters.builder()
+ public static final MiningConfiguration MINING_DISABLED =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
- ImmutableMiningParameters.MutableInitValues.builder().isMiningEnabled(false).build())
+ ImmutableMiningConfiguration.MutableInitValues.builder()
+ .isMiningEnabled(false)
+ .build())
.build();
@VisibleForTesting
- public static final MiningParameters newDefault() {
- return ImmutableMiningParameters.builder().build();
+ public static final MiningConfiguration newDefault() {
+ return ImmutableMiningConfiguration.builder().build();
}
public boolean isMiningEnabled() {
return getMutableRuntimeValues().miningEnabled;
}
- public MiningParameters setMiningEnabled(final boolean miningEnabled) {
+ public MiningConfiguration setMiningEnabled(final boolean miningEnabled) {
getMutableRuntimeValues().miningEnabled = miningEnabled;
return this;
}
@@ -63,7 +65,7 @@ public Bytes getExtraData() {
return getMutableRuntimeValues().extraData;
}
- public MiningParameters setExtraData(final Bytes extraData) {
+ public MiningConfiguration setExtraData(final Bytes extraData) {
getMutableRuntimeValues().extraData = extraData;
return this;
}
@@ -72,7 +74,7 @@ public Wei getMinTransactionGasPrice() {
return getMutableRuntimeValues().minTransactionGasPrice;
}
- public MiningParameters setMinTransactionGasPrice(final Wei minTransactionGasPrice) {
+ public MiningConfiguration setMinTransactionGasPrice(final Wei minTransactionGasPrice) {
getMutableRuntimeValues().minTransactionGasPrice = minTransactionGasPrice;
return this;
}
@@ -81,7 +83,7 @@ public Wei getMinPriorityFeePerGas() {
return getMutableRuntimeValues().minPriorityFeePerGas;
}
- public MiningParameters setMinPriorityFeePerGas(final Wei minPriorityFeePerGas) {
+ public MiningConfiguration setMinPriorityFeePerGas(final Wei minPriorityFeePerGas) {
getMutableRuntimeValues().minPriorityFeePerGas = minPriorityFeePerGas;
return this;
}
@@ -90,7 +92,7 @@ public Optional getCoinbase() {
return getMutableRuntimeValues().coinbase;
}
- public MiningParameters setCoinbase(final Address coinbase) {
+ public MiningConfiguration setCoinbase(final Address coinbase) {
getMutableRuntimeValues().coinbase = Optional.of(coinbase);
return this;
}
@@ -99,7 +101,7 @@ public OptionalLong getTargetGasLimit() {
return getMutableRuntimeValues().targetGasLimit;
}
- public MiningParameters setTargetGasLimit(final long targetGasLimit) {
+ public MiningConfiguration setTargetGasLimit(final long targetGasLimit) {
getMutableRuntimeValues().targetGasLimit = OptionalLong.of(targetGasLimit);
return this;
}
@@ -108,7 +110,7 @@ public double getMinBlockOccupancyRatio() {
return getMutableRuntimeValues().minBlockOccupancyRatio;
}
- public MiningParameters setMinBlockOccupancyRatio(final double minBlockOccupancyRatio) {
+ public MiningConfiguration setMinBlockOccupancyRatio(final double minBlockOccupancyRatio) {
getMutableRuntimeValues().minBlockOccupancyRatio = minBlockOccupancyRatio;
return this;
}
@@ -117,7 +119,7 @@ public Optional> getNonceGenerator() {
return getMutableRuntimeValues().nonceGenerator;
}
- public MiningParameters setNonceGenerator(final Iterable nonceGenerator) {
+ public MiningConfiguration setNonceGenerator(final Iterable nonceGenerator) {
getMutableRuntimeValues().nonceGenerator = Optional.of(nonceGenerator);
return this;
}
@@ -126,12 +128,12 @@ public OptionalInt getBlockPeriodSeconds() {
return getMutableRuntimeValues().blockPeriodSeconds;
}
- public MiningParameters setBlockPeriodSeconds(final int blockPeriodSeconds) {
+ public MiningConfiguration setBlockPeriodSeconds(final int blockPeriodSeconds) {
getMutableRuntimeValues().blockPeriodSeconds = OptionalInt.of(blockPeriodSeconds);
return this;
}
- public MiningParameters setEmptyBlockPeriodSeconds(final int emptyBlockPeriodSeconds) {
+ public MiningConfiguration setEmptyBlockPeriodSeconds(final int emptyBlockPeriodSeconds) {
getMutableRuntimeValues().emptyBlockPeriodSeconds = OptionalInt.of(emptyBlockPeriodSeconds);
return this;
}
@@ -207,7 +209,7 @@ public interface MutableInitValues {
Wei DEFAULT_MIN_PRIORITY_FEE_PER_GAS = Wei.ZERO;
double DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO = 0.8;
- MutableInitValues DEFAULT = ImmutableMiningParameters.MutableInitValues.builder().build();
+ MutableInitValues DEFAULT = ImmutableMiningConfiguration.MutableInitValues.builder().build();
@Value.Default
default boolean isMiningEnabled() {
@@ -335,7 +337,7 @@ public interface Unstable {
long DEFAULT_POS_BLOCK_CREATION_MAX_TIME = Duration.ofSeconds(12).toMillis();
long DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION = Duration.ofMillis(500).toMillis();
- MiningParameters.Unstable DEFAULT = ImmutableMiningParameters.Unstable.builder().build();
+ MiningConfiguration.Unstable DEFAULT = ImmutableMiningConfiguration.Unstable.builder().build();
@Value.Default
default int getRemoteSealersLimit() {
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParametersMetrics.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParametersMetrics.java
index 3b3e3a28dcb..8be0b621a33 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParametersMetrics.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParametersMetrics.java
@@ -22,18 +22,18 @@ public class MiningParametersMetrics {
public static final String MIN_PRIORITY_FEE_GAUGE = "min_priority_fee";
public MiningParametersMetrics(
- final MetricsSystem metricsSystem, final MiningParameters miningParameters) {
+ final MetricsSystem metricsSystem, final MiningConfiguration miningConfiguration) {
metricsSystem.createGauge(
BesuMetricCategory.ETHEREUM,
MIN_GAS_PRICE_GAUGE,
"Gauge to measure the runtime value of min-gas-price",
- () -> miningParameters.getMinTransactionGasPrice().toBigInteger().doubleValue());
+ () -> miningConfiguration.getMinTransactionGasPrice().toBigInteger().doubleValue());
metricsSystem.createGauge(
BesuMetricCategory.ETHEREUM,
MIN_PRIORITY_FEE_GAUGE,
"Gauge to measure the runtime value of min-priority-fee",
- () -> miningParameters.getMinPriorityFeePerGas().toBigInteger().doubleValue());
+ () -> miningConfiguration.getMinPriorityFeePerGas().toBigInteger().doubleValue());
}
}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ProcessableBlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ProcessableBlockHeader.java
index 036a33af97a..7e037dff3a7 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ProcessableBlockHeader.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ProcessableBlockHeader.java
@@ -23,6 +23,7 @@
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
+import org.apache.tuweni.units.bigints.UInt64;
/** A block header capable of being processed. */
public class ProcessableBlockHeader
@@ -46,6 +47,8 @@ public class ProcessableBlockHeader
protected final Bytes32 mixHashOrPrevRandao;
// parentBeaconBlockRoot is included for Cancun
protected final Bytes32 parentBeaconBlockRoot;
+ // TODO SLD Quantity or UInt64Value instead?
+ protected final UInt64 targetBlobCount;
protected ProcessableBlockHeader(
final Hash parentHash,
@@ -56,7 +59,8 @@ protected ProcessableBlockHeader(
final long timestamp,
final Wei baseFee,
final Bytes32 mixHashOrPrevRandao,
- final Bytes32 parentBeaconBlockRoot) {
+ final Bytes32 parentBeaconBlockRoot,
+ final UInt64 targetBlobCount) {
this.parentHash = parentHash;
this.coinbase = coinbase;
this.difficulty = difficulty;
@@ -66,6 +70,7 @@ protected ProcessableBlockHeader(
this.baseFee = baseFee;
this.mixHashOrPrevRandao = mixHashOrPrevRandao;
this.parentBeaconBlockRoot = parentBeaconBlockRoot;
+ this.targetBlobCount = targetBlobCount;
}
/**
@@ -178,6 +183,16 @@ public Optional getParentBeaconBlockRoot() {
return Optional.ofNullable(parentBeaconBlockRoot);
}
+ /**
+ * Returns the target blob count if available.
+ *
+ * @return the target blob count if available.
+ */
+ @Override
+ public Optional getTargetBlobCount() {
+ return Optional.ofNullable(targetBlobCount);
+ }
+
public String toLogString() {
return getNumber() + " (time: " + getTimestamp() + ")";
}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java
index 1934c8f8c0e..962178e5041 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java
@@ -24,6 +24,7 @@
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
+import org.apache.tuweni.units.bigints.UInt64;
/** A block header capable of being sealed. */
public class SealableBlockHeader extends ProcessableBlockHeader {
@@ -69,7 +70,8 @@ protected SealableBlockHeader(
final Long blobGasUsed,
final BlobGas excessBlobGas,
final Bytes32 parentBeaconBlockRoot,
- final Hash requestsHash) {
+ final Hash requestsHash,
+ final UInt64 targetBlobCount) {
super(
parentHash,
coinbase,
@@ -79,7 +81,8 @@ protected SealableBlockHeader(
timestamp,
baseFee,
mixHashOrPrevRandao,
- parentBeaconBlockRoot);
+ parentBeaconBlockRoot,
+ targetBlobCount);
this.ommersHash = ommersHash;
this.stateRoot = stateRoot;
this.transactionsRoot = transactionsRoot;
diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethConfiguration.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/CoinbaseModule.java
similarity index 60%
rename from ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethConfiguration.java
rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/CoinbaseModule.java
index bb4fa31a559..bb613b4e17f 100644
--- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethConfiguration.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/CoinbaseModule.java
@@ -1,5 +1,5 @@
/*
- * Copyright ConsenSys AG.
+ * Copyright contributors to Hyperledger Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
@@ -12,19 +12,20 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
-package org.hyperledger.besu.ethereum.retesteth;
+package org.hyperledger.besu.ethereum.core.components;
-import java.nio.file.Path;
+import org.hyperledger.besu.datatypes.Address;
-public class RetestethConfiguration {
+import javax.inject.Named;
- private final Path dataPath;
+import dagger.Module;
+import dagger.Provides;
- public RetestethConfiguration(final Path dataPath) {
- this.dataPath = dataPath;
- }
-
- Path getDataPath() {
- return dataPath;
+@Module
+public class CoinbaseModule {
+ @Provides
+ @Named("emptyCoinbase")
+ Address provideEmptyCoinbase() {
+ return Address.fromHexString(String.format("%020x", 1));
}
}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/EthereumCoreComponent.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/EthereumCoreComponent.java
new file mode 100644
index 00000000000..84de2cef5d6
--- /dev/null
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/EthereumCoreComponent.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright contributors to Hyperledger Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.ethereum.core.components;
+
+import org.hyperledger.besu.ethereum.components.ProtocolScheduleModule;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
+
+import javax.inject.Singleton;
+
+import dagger.Subcomponent;
+
+@Singleton
+@Subcomponent(
+ modules = {
+ MiningParametersModule.class,
+ ProtocolScheduleModule.class,
+ })
+public interface EthereumCoreComponent {
+ MiningConfiguration getMiningParameters();
+}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/MiningParametersModule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/MiningParametersModule.java
new file mode 100644
index 00000000000..7a36e4d81ab
--- /dev/null
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/MiningParametersModule.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright contributors to Hyperledger Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.ethereum.core.components;
+
+import org.hyperledger.besu.datatypes.Address;
+import org.hyperledger.besu.datatypes.Wei;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
+
+import javax.inject.Named;
+
+import dagger.Module;
+import dagger.Provides;
+
+@Module
+public class MiningParametersModule {
+
+ @Provides
+ @Named("defaultMiningParameters")
+ protected MiningConfiguration createImmutableMiningParams() {
+ return ImmutableMiningConfiguration.builder().build();
+ }
+
+ @Provides
+ @Named("noMining")
+ protected MiningConfiguration createNoMining() {
+ return ImmutableMiningConfiguration.builder()
+ .mutableInitValues(
+ ImmutableMiningConfiguration.MutableInitValues.builder().isMiningEnabled(false).build())
+ .build();
+ }
+
+ @Provides
+ @Named("zeroGas")
+ MiningConfiguration createZeroGasMining(final @Named("emptyCoinbase") Address coinbase) {
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
+ .mutableInitValues(
+ ImmutableMiningConfiguration.MutableInitValues.builder()
+ .isMiningEnabled(true)
+ .minTransactionGasPrice(Wei.ZERO)
+ .coinbase(coinbase)
+ .build())
+ .build();
+ return miningConfiguration;
+ }
+
+ @Provides
+ MiningConfiguration provideMiningParameters() {
+ throw new IllegalStateException("unimplemented");
+ }
+}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java
index b86b2b0de22..09ca09ff6a8 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java
@@ -16,7 +16,7 @@
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
@@ -24,7 +24,12 @@
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.plugin.services.MetricsSystem;
-/** A ProtocolSchedule which behaves similarly to MainNet, but with a much reduced difficulty. */
+import java.util.Optional;
+
+/**
+ * A ProtocolSchedule which behaves similarly to pre-merge MainNet, but with a much reduced
+ * difficulty.
+ */
public class FixedDifficultyProtocolSchedule {
public static ProtocolSchedule create(
@@ -32,12 +37,13 @@ public static ProtocolSchedule create(
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
return new ProtocolScheduleBuilder(
config,
+ Optional.empty(),
ProtocolSpecAdapters.create(
0,
builder ->
@@ -45,7 +51,7 @@ public static ProtocolSchedule create(
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem)
@@ -56,7 +62,7 @@ public static ProtocolSchedule create(
final GenesisConfigOptions config,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -65,7 +71,7 @@ public static ProtocolSchedule create(
PrivacyParameters.DEFAULT,
isRevertReasonEnabled,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -74,7 +80,7 @@ public static ProtocolSchedule create(
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -83,7 +89,7 @@ public static ProtocolSchedule create(
PrivacyParameters.DEFAULT,
false,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java
index 88b6a5ae1be..9528e2dfb84 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java
@@ -16,7 +16,7 @@
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyCalculators;
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule;
@@ -24,6 +24,7 @@
import org.hyperledger.besu.plugin.services.MetricsSystem;
import java.math.BigInteger;
+import java.util.Optional;
import java.util.function.Function;
/** Provides {@link ProtocolSpec} lookups for mainnet hard forks. */
@@ -39,7 +40,7 @@ public class MainnetProtocolSchedule {
* @param privacyParameters the parameters set for private transactions
* @param isRevertReasonEnabled whether storing the revert reason is for failed transactions
* @param evmConfiguration how to configure the EVMs jumpdest cache
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
* @param metricsSystem A metricSystem instance to expose metrics in the underlying calls
@@ -47,32 +48,32 @@ public class MainnetProtocolSchedule {
*/
public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config,
- final PrivacyParameters privacyParameters,
- final boolean isRevertReasonEnabled,
- final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final Optional privacyParameters,
+ final Optional isRevertReasonEnabled,
+ final Optional evmConfiguration,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
if (FixedDifficultyCalculators.isFixedDifficultyInConfig(config)) {
return FixedDifficultyProtocolSchedule.create(
config,
- privacyParameters,
- isRevertReasonEnabled,
- evmConfiguration,
- miningParameters,
+ privacyParameters.orElse(PrivacyParameters.DEFAULT),
+ isRevertReasonEnabled.orElse(false),
+ evmConfiguration.orElse(EvmConfiguration.DEFAULT),
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
}
return new ProtocolScheduleBuilder(
config,
- DEFAULT_CHAIN_ID,
+ Optional.of(DEFAULT_CHAIN_ID),
ProtocolSpecAdapters.create(0, Function.identity()),
- privacyParameters,
- isRevertReasonEnabled,
- evmConfiguration,
- miningParameters,
+ privacyParameters.orElse(PrivacyParameters.DEFAULT),
+ isRevertReasonEnabled.orElse(false),
+ evmConfiguration.orElse(EvmConfiguration.DEFAULT),
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem)
@@ -86,7 +87,7 @@ public static ProtocolSchedule fromConfig(
* starting points
* @param isRevertReasonEnabled whether storing the revert reason is for failed transactions
* @param evmConfiguration how to configure the EVMs jumpdest cache
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @return A configured mainnet protocol schedule
@@ -95,16 +96,16 @@ public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
return fromConfig(
config,
- PrivacyParameters.DEFAULT,
- isRevertReasonEnabled,
- evmConfiguration,
- miningParameters,
+ Optional.empty(),
+ Optional.of(isRevertReasonEnabled),
+ Optional.of(evmConfiguration),
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -116,7 +117,7 @@ public static ProtocolSchedule fromConfig(
* @param config {@link GenesisConfigOptions} containing the config options for the milestone
* starting points
* @param evmConfiguration size of
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @return A configured mainnet protocol schedule
@@ -124,16 +125,16 @@ public static ProtocolSchedule fromConfig(
public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
return fromConfig(
config,
- PrivacyParameters.DEFAULT,
- false,
- evmConfiguration,
- miningParameters,
+ Optional.empty(),
+ Optional.empty(),
+ Optional.of(evmConfiguration),
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -144,23 +145,23 @@ public static ProtocolSchedule fromConfig(
*
* @param config {@link GenesisConfigOptions} containing the config options for the milestone
* starting points
- * @param miningParameters the mining parameters
+ * @param miningConfiguration the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
* @return A configured mainnet protocol schedule
*/
public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
return fromConfig(
config,
- PrivacyParameters.DEFAULT,
- false,
- EvmConfiguration.DEFAULT,
- miningParameters,
+ Optional.empty(),
+ Optional.empty(),
+ Optional.empty(),
+ miningConfiguration,
badBlockManager,
isParallelTxProcessingEnabled,
metricsSystem);
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java
index 615a4762518..770175e6462 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java
@@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.config.GenesisConfigOptions;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.plugin.services.MetricsSystem;
@@ -29,7 +29,7 @@ public class MainnetProtocolSpecFactory {
private final boolean isRevertReasonEnabled;
private final OptionalLong ecip1017EraRounds;
private final EvmConfiguration evmConfiguration;
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
private final boolean isParallelTxProcessingEnabled;
private final MetricsSystem metricsSystem;
@@ -38,14 +38,14 @@ public MainnetProtocolSpecFactory(
final boolean isRevertReasonEnabled,
final OptionalLong ecip1017EraRounds,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
this.chainId = chainId;
this.isRevertReasonEnabled = isRevertReasonEnabled;
this.ecip1017EraRounds = ecip1017EraRounds;
this.evmConfiguration = evmConfiguration;
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
this.isParallelTxProcessingEnabled = isParallelTxProcessingEnabled;
this.metricsSystem = metricsSystem;
}
@@ -140,7 +140,7 @@ public ProtocolSpecBuilder londonDefinition(final GenesisConfigOptions genesisCo
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
@@ -152,7 +152,7 @@ public ProtocolSpecBuilder arrowGlacierDefinition(
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
@@ -164,7 +164,7 @@ public ProtocolSpecBuilder grayGlacierDefinition(
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
@@ -175,7 +175,7 @@ public ProtocolSpecBuilder parisDefinition(final GenesisConfigOptions genesisCon
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
@@ -186,7 +186,7 @@ public ProtocolSpecBuilder shanghaiDefinition(final GenesisConfigOptions genesis
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
@@ -197,7 +197,7 @@ public ProtocolSpecBuilder cancunDefinition(final GenesisConfigOptions genesisCo
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
@@ -208,7 +208,7 @@ public ProtocolSpecBuilder cancunEOFDefinition(final GenesisConfigOptions genesi
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
@@ -219,7 +219,7 @@ public ProtocolSpecBuilder pragueDefinition(final GenesisConfigOptions genesisCo
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
@@ -230,7 +230,7 @@ public ProtocolSpecBuilder osakaDefinition(final GenesisConfigOptions genesisCon
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
@@ -252,7 +252,7 @@ public ProtocolSpecBuilder futureEipsDefinition(final GenesisConfigOptions genes
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
@@ -274,7 +274,7 @@ public ProtocolSpecBuilder experimentalEipsDefinition(
isRevertReasonEnabled,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
index 23908664f8c..87396bff3e9 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
@@ -25,7 +25,7 @@
import org.hyperledger.besu.ethereum.MainnetBlockValidator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
@@ -447,7 +447,7 @@ static ProtocolSpecBuilder londonDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
final long londonForkBlockNumber =
@@ -458,7 +458,7 @@ static ProtocolSpecBuilder londonDefinition(
} else if (genesisConfigOptions.isFixedBaseFee()) {
londonFeeMarket =
FeeMarket.fixedBaseFee(
- londonForkBlockNumber, miningParameters.getMinTransactionGasPrice());
+ londonForkBlockNumber, miningConfiguration.getMinTransactionGasPrice());
} else {
londonFeeMarket =
FeeMarket.london(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas());
@@ -533,7 +533,7 @@ static ProtocolSpecBuilder arrowGlacierDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
return londonDefinition(
@@ -541,7 +541,7 @@ static ProtocolSpecBuilder arrowGlacierDefinition(
enableRevertReason,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem)
.difficultyCalculator(MainnetDifficultyCalculators.ARROW_GLACIER)
@@ -553,7 +553,7 @@ static ProtocolSpecBuilder grayGlacierDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
return arrowGlacierDefinition(
@@ -561,7 +561,7 @@ static ProtocolSpecBuilder grayGlacierDefinition(
enableRevertReason,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem)
.difficultyCalculator(MainnetDifficultyCalculators.GRAY_GLACIER)
@@ -573,7 +573,7 @@ static ProtocolSpecBuilder parisDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -582,7 +582,7 @@ static ProtocolSpecBuilder parisDefinition(
enableRevertReason,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem)
.evmBuilder(
@@ -601,7 +601,7 @@ static ProtocolSpecBuilder shanghaiDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
return parisDefinition(
@@ -609,7 +609,7 @@ static ProtocolSpecBuilder shanghaiDefinition(
enableRevertReason,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem)
// gas calculator has new code to support EIP-3860 limit and meter initcode
@@ -660,7 +660,7 @@ static ProtocolSpecBuilder cancunDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
final long londonForkBlockNumber = genesisConfigOptions.getLondonBlockNumber().orElse(0L);
@@ -670,7 +670,7 @@ static ProtocolSpecBuilder cancunDefinition(
} else if (genesisConfigOptions.isFixedBaseFee()) {
cancunFeeMarket =
FeeMarket.fixedBaseFee(
- londonForkBlockNumber, miningParameters.getMinTransactionGasPrice());
+ londonForkBlockNumber, miningConfiguration.getMinTransactionGasPrice());
} else {
cancunFeeMarket =
FeeMarket.cancun(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas());
@@ -681,7 +681,7 @@ static ProtocolSpecBuilder cancunDefinition(
enableRevertReason,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem)
.feeMarket(cancunFeeMarket)
@@ -741,7 +741,7 @@ static ProtocolSpecBuilder cancunEOFDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -751,7 +751,7 @@ static ProtocolSpecBuilder cancunEOFDefinition(
enableRevertReason,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
return addEOF(chainId, evmConfiguration, protocolSpecBuilder).name("CancunEOF");
@@ -762,7 +762,7 @@ static ProtocolSpecBuilder pragueDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -774,7 +774,7 @@ static ProtocolSpecBuilder pragueDefinition(
enableRevertReason,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem)
// EIP-3074 AUTH and AUTCALL gas
@@ -820,7 +820,7 @@ static ProtocolSpecBuilder osakaDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -830,7 +830,7 @@ static ProtocolSpecBuilder osakaDefinition(
enableRevertReason,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
return addEOF(chainId, evmConfiguration, protocolSpecBuilder).name("Osaka");
@@ -863,7 +863,7 @@ static ProtocolSpecBuilder futureEipsDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
return osakaDefinition(
@@ -871,7 +871,7 @@ static ProtocolSpecBuilder futureEipsDefinition(
enableRevertReason,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem)
// Use Future EIP configured EVM
@@ -898,7 +898,7 @@ static ProtocolSpecBuilder experimentalEipsDefinition(
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -907,7 +907,7 @@ static ProtocolSpecBuilder experimentalEipsDefinition(
enableRevertReason,
genesisConfigOptions,
evmConfiguration,
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem)
.evmBuilder(
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java
index 3161490478e..aafc61e71dc 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java
@@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.ethereum.chain.PoWObserver;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.util.Subscribers;
import java.util.Optional;
@@ -34,7 +34,7 @@ public class PoWSolver {
private static final Logger LOG = LoggerFactory.getLogger(PoWSolver.class);
- private final MiningParameters miningParameters;
+ private final MiningConfiguration miningConfiguration;
public static class PoWSolverJob {
@@ -86,12 +86,12 @@ PoWSolution getSolution() throws InterruptedException, ExecutionException {
private final ExpiringMap currentJobs = new ExpiringMap<>();
public PoWSolver(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final PoWHasher poWHasher,
final Boolean stratumMiningEnabled,
final Subscribers ethHashObservers,
final EpochCalculator epochCalculator) {
- this.miningParameters = miningParameters;
+ this.miningConfiguration = miningConfiguration;
this.poWHasher = poWHasher;
this.stratumMiningEnabled = stratumMiningEnabled;
this.ethHashObservers = ethHashObservers;
@@ -105,7 +105,7 @@ public PoWSolution solveFor(final PoWSolverJob job)
currentJobs.put(
job.getInputs().getPrePowHash(),
job,
- System.currentTimeMillis() + miningParameters.getUnstable().getPowJobTimeToLive());
+ System.currentTimeMillis() + miningConfiguration.getUnstable().getPowJobTimeToLive());
if (stratumMiningEnabled) {
LOG.debug(
"solving with stratum miner for {} observers", ethHashObservers.getSubscriberCount());
@@ -121,7 +121,7 @@ private void findValidNonce() {
final Stopwatch operationTimer = Stopwatch.createStarted();
final PoWSolverJob job = currentJob.get();
long hashesExecuted = 0;
- for (final Long n : miningParameters.getNonceGenerator().get()) {
+ for (final Long n : miningConfiguration.getNonceGenerator().get()) {
if (job.isDone()) {
return;
@@ -181,7 +181,7 @@ public boolean submitSolution(final PoWSolution solution) {
solution.getPowHash(),
ommerCandidate.getInputs().getBlockNumber(),
distanceToHead);
- if (distanceToHead <= miningParameters.getUnstable().getMaxOmmerDepth()) {
+ if (distanceToHead <= miningConfiguration.getUnstable().getMaxOmmerDepth()) {
jobToTestWith = ommerCandidate;
} else {
LOG.debug("Discarded ommer solution as too far from head {}", distanceToHead);
@@ -211,6 +211,6 @@ public boolean submitSolution(final PoWSolution solution) {
}
public Iterable getNonceGenerator() {
- return miningParameters.getNonceGenerator().get();
+ return miningConfiguration.getNonceGenerator().get();
}
}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java
index 52003bc96c5..e957394d85f 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java
@@ -18,7 +18,7 @@
import org.hyperledger.besu.datatypes.HardforkId;
import org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
@@ -48,66 +48,19 @@ public class ProtocolScheduleBuilder {
private final PrivacyParameters privacyParameters;
private final boolean isRevertReasonEnabled;
private final EvmConfiguration evmConfiguration;
- private final MiningParameters miningParameters;
private final BadBlockManager badBlockManager;
private final boolean isParallelTxProcessingEnabled;
private final MetricsSystem metricsSystem;
+ private final MiningConfiguration miningConfiguration;
public ProtocolScheduleBuilder(
- final GenesisConfigOptions config,
- final BigInteger defaultChainId,
- final ProtocolSpecAdapters protocolSpecAdapters,
- final PrivacyParameters privacyParameters,
- final boolean isRevertReasonEnabled,
- final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
- final BadBlockManager badBlockManager,
- final boolean isParallelTxProcessingEnabled,
- final MetricsSystem metricsSystem) {
- this(
- config,
- Optional.of(defaultChainId),
- protocolSpecAdapters,
- privacyParameters,
- isRevertReasonEnabled,
- evmConfiguration,
- miningParameters,
- badBlockManager,
- isParallelTxProcessingEnabled,
- metricsSystem);
- }
-
- public ProtocolScheduleBuilder(
- final GenesisConfigOptions config,
- final ProtocolSpecAdapters protocolSpecAdapters,
- final PrivacyParameters privacyParameters,
- final boolean isRevertReasonEnabled,
- final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
- final BadBlockManager badBlockManager,
- final boolean isParallelTxProcessingEnabled,
- final MetricsSystem metricsSystem) {
- this(
- config,
- Optional.empty(),
- protocolSpecAdapters,
- privacyParameters,
- isRevertReasonEnabled,
- evmConfiguration,
- miningParameters,
- badBlockManager,
- isParallelTxProcessingEnabled,
- metricsSystem);
- }
-
- private ProtocolScheduleBuilder(
final GenesisConfigOptions config,
final Optional defaultChainId,
final ProtocolSpecAdapters protocolSpecAdapters,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration,
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final BadBlockManager badBlockManager,
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
@@ -117,10 +70,10 @@ private ProtocolScheduleBuilder(
this.isRevertReasonEnabled = isRevertReasonEnabled;
this.evmConfiguration = evmConfiguration;
this.defaultChainId = defaultChainId;
- this.miningParameters = miningParameters;
this.badBlockManager = badBlockManager;
this.isParallelTxProcessingEnabled = isParallelTxProcessingEnabled;
this.metricsSystem = metricsSystem;
+ this.miningConfiguration = miningConfiguration;
}
public ProtocolSchedule createProtocolSchedule() {
@@ -130,7 +83,7 @@ public ProtocolSchedule createProtocolSchedule() {
return protocolSchedule;
}
- private void initSchedule(
+ public void initSchedule(
final ProtocolSchedule protocolSchedule, final Optional chainId) {
final MainnetProtocolSpecFactory specFactory =
@@ -140,7 +93,7 @@ private void initSchedule(
config.getEcip1017EraRounds(),
evmConfiguration.overrides(
config.getContractSizeLimit(), OptionalInt.empty(), config.getEvmStackSize()),
- miningParameters,
+ miningConfiguration,
isParallelTxProcessingEnabled,
metricsSystem);
@@ -557,4 +510,8 @@ private enum MilestoneType {
TIMESTAMP
}
}
+
+ public Optional getDefaultChainId() {
+ return defaultChainId;
+ }
}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProvider.java
index e4b7ea991f3..96a56da6e20 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProvider.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProvider.java
@@ -34,6 +34,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
+import java.util.function.Supplier;
import com.google.common.annotations.VisibleForTesting;
import org.apache.tuweni.bytes.Bytes;
@@ -44,6 +45,7 @@ public class BonsaiWorldStateProvider extends DiffBasedWorldStateProvider {
private static final Logger LOG = LoggerFactory.getLogger(BonsaiWorldStateProvider.class);
private final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader;
+ private final Supplier worldStateHealerSupplier;
public BonsaiWorldStateProvider(
final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage,
@@ -51,9 +53,11 @@ public BonsaiWorldStateProvider(
final Optional maxLayersToLoad,
final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader,
final BesuContext pluginContext,
- final EvmConfiguration evmConfiguration) {
+ final EvmConfiguration evmConfiguration,
+ final Supplier worldStateHealerSupplier) {
super(worldStateKeyValueStorage, blockchain, maxLayersToLoad, pluginContext);
this.bonsaiCachedMerkleTrieLoader = bonsaiCachedMerkleTrieLoader;
+ this.worldStateHealerSupplier = worldStateHealerSupplier;
provideCachedWorldStorageManager(
new BonsaiCachedWorldStorageManager(
this, worldStateKeyValueStorage, this::cloneBonsaiWorldStateConfig));
@@ -69,9 +73,11 @@ public BonsaiWorldStateProvider(
final BonsaiWorldStateKeyValueStorage worldStateKeyValueStorage,
final Blockchain blockchain,
final BonsaiCachedMerkleTrieLoader bonsaiCachedMerkleTrieLoader,
- final EvmConfiguration evmConfiguration) {
+ final EvmConfiguration evmConfiguration,
+ final Supplier worldStateHealerSupplier) {
super(worldStateKeyValueStorage, blockchain, trieLogManager);
this.bonsaiCachedMerkleTrieLoader = bonsaiCachedMerkleTrieLoader;
+ this.worldStateHealerSupplier = worldStateHealerSupplier;
provideCachedWorldStorageManager(bonsaiCachedWorldStorageManager);
loadPersistedState(
new BonsaiWorldState(
@@ -151,4 +157,9 @@ public void prepareStateHealing(final Address address, final Bytes location) {
private DiffBasedWorldStateConfig cloneBonsaiWorldStateConfig() {
return new DiffBasedWorldStateConfig(defaultWorldStateConfig);
}
+
+ @Override
+ public void heal(final Optional maybeAccountToRepair, final Bytes location) {
+ worldStateHealerSupplier.get().heal(maybeAccountToRepair, location);
+ }
}
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java
index 1cdd079e15a..800d2c98343 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java
@@ -112,6 +112,11 @@ public Optional getAccountProof(
blockHeader.getStateRoot(), accountAddress, accountStorageKeys));
}
+ @Override
+ public void heal(final Optional maybeAccountToRepair, final Bytes location) {
+ // no heal needed for Forest
+ }
+
@Override
public void close() {
// no op
diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java
index 23859ac3961..9856a200b21 100644
--- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java
+++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java
@@ -64,4 +64,24 @@ Optional getAccountProof(
final Address accountAddress,
final List accountStorageKeys,
final Function, ? extends Optional> mapper);
+
+ /**
+ * Heal the world state to fix inconsistency
+ *
+ * @param maybeAccountToRepair the optional account to repair
+ * @param location the location of the inconsistency
+ */
+ void heal(Optional maybeAccountToRepair, Bytes location);
+
+ /** A world state healer */
+ @FunctionalInterface
+ interface WorldStateHealer {
+ /**
+ * Heal the world state to fix inconsistency
+ *
+ * @param maybeAccountToRepair the optional account to repair
+ * @param location the location of the inconsistency
+ */
+ void heal(Optional maybeAccountToRepair, Bytes location);
+ }
}
diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java
index 99cf2407b8d..b0b9aa6497e 100644
--- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java
+++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java
@@ -25,6 +25,7 @@
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
+import org.apache.tuweni.units.bigints.UInt64;
public class BlockHeaderTestFixture {
@@ -55,6 +56,7 @@ public class BlockHeaderTestFixture {
private Optional excessBlobGas = Optional.empty();
private Optional blobGasUsed = Optional.empty();
private Optional parentBeaconBlockRoot = Optional.empty();
+ private Optional targetBlobCount = Optional.empty();
public BlockHeader buildHeader() {
final BlockHeaderBuilder builder = BlockHeaderBuilder.create();
@@ -80,6 +82,7 @@ public BlockHeader buildHeader() {
blobGasUsed.ifPresent(builder::blobGasUsed);
requestsHash.ifPresent(builder::requestsHash);
parentBeaconBlockRoot.ifPresent(builder::parentBeaconBlockRoot);
+ targetBlobCount.ifPresent(builder::targetBlobCount);
builder.blockHeaderFunctions(blockHeaderFunctions);
return builder.buildBlockHeader();
@@ -201,4 +204,9 @@ public BlockHeaderTestFixture parentBeaconBlockRoot(
this.parentBeaconBlockRoot = parentBeaconBlockRoot;
return this;
}
+
+ public BlockHeaderTestFixture targetBlobCount(final UInt64 targetBlobCount) {
+ this.targetBlobCount = Optional.of(targetBlobCount);
+ return this;
+ }
}
diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java
index 7be6ad12c44..b7608bb5de6 100644
--- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java
+++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java
@@ -152,7 +152,7 @@ private static ProtocolSchedule mainnetProtocolScheduleProvider(
return MainnetProtocolSchedule.fromConfig(
genesisConfigFile.getConfigOptions(),
EvmConfiguration.DEFAULT,
- MiningParameters.newDefault(),
+ MiningConfiguration.newDefault(),
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -194,7 +194,6 @@ private static BlockchainSetupUtil create(
genesisState.writeStateTo(worldArchive.getMutable());
final ProtocolContext protocolContext = protocolContextProvider.get(blockchain, worldArchive);
- protocolContext.setSynchronizer(new DummySynchronizer());
final Path blocksPath = Path.of(chainResources.getBlocksURL().toURI());
final List blocks = new ArrayList<>();
diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java
index 511b94d3ae5..b2b979e283c 100644
--- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java
+++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java
@@ -152,12 +152,12 @@ public ExecutionContextTestFixture build() {
protocolSchedule =
new ProtocolScheduleBuilder(
genesisConfigFile.getConfigOptions(),
- BigInteger.valueOf(42),
+ Optional.of(BigInteger.valueOf(42)),
ProtocolSpecAdapters.create(0, Function.identity()),
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem())
diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java
index 9bac9254940..aa32ee2b05f 100644
--- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java
+++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java
@@ -14,6 +14,8 @@
*/
package org.hyperledger.besu.ethereum.core;
+import static org.hyperledger.besu.ethereum.core.WorldStateHealerHelper.throwingWorldStateHealerSupplier;
+
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.DefaultBlockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
@@ -105,7 +107,8 @@ public static BonsaiWorldStateProvider createBonsaiInMemoryWorldStateArchive(
Optional.empty(),
bonsaiCachedMerkleTrieLoader,
null,
- evmConfiguration);
+ evmConfiguration,
+ throwingWorldStateHealerSupplier());
}
public static MutableWorldState createInMemoryWorldState() {
diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java
index e94c6b49fd0..db1114e832b 100644
--- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java
+++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java
@@ -22,10 +22,10 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
-import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import java.io.IOException;
+import java.util.Optional;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
@@ -36,10 +36,10 @@ public class ProtocolScheduleFixture {
public static final ProtocolSchedule MAINNET =
MainnetProtocolSchedule.fromConfig(
getMainnetConfigOptions(),
- PrivacyParameters.DEFAULT,
- false,
- EvmConfiguration.DEFAULT,
- MiningParameters.newDefault(),
+ Optional.empty(),
+ Optional.empty(),
+ Optional.empty(),
+ MiningConfiguration.newDefault(),
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/WorldStateHealerHelper.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/WorldStateHealerHelper.java
new file mode 100644
index 00000000000..a94ce247932
--- /dev/null
+++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/WorldStateHealerHelper.java
@@ -0,0 +1,39 @@
+/*
+ * 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.ethereum.core;
+
+import org.hyperledger.besu.datatypes.Address;
+import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive.WorldStateHealer;
+
+import java.util.Optional;
+import java.util.function.Supplier;
+
+import org.apache.tuweni.bytes.Bytes;
+
+public class WorldStateHealerHelper {
+
+ public static WorldStateHealer throwingHealer(
+ final Optional maybeAccountToRepair, final Bytes location) {
+ throw new RuntimeException(
+ "World state needs to be healed: "
+ + maybeAccountToRepair.map(address -> "account to repair: " + address).orElse("")
+ + " location: "
+ + location.toHexString());
+ }
+
+ public static Supplier throwingWorldStateHealerSupplier() {
+ return () -> WorldStateHealerHelper::throwingHealer;
+ }
+}
diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java
index 013adae51ea..255ea778395 100644
--- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java
+++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java
@@ -31,7 +31,6 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
-import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.mainnet.BlockBodyValidator;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.BlockProcessor;
@@ -91,7 +90,6 @@ public void setup() {
when(protocolContext.getBlockchain()).thenReturn(blockchain);
when(protocolContext.getWorldStateArchive()).thenReturn(worldStateArchive);
- when(protocolContext.getSynchronizer()).thenReturn(mock(Synchronizer.class));
when(worldStateArchive.getMutable(any(BlockHeader.class), anyBoolean()))
.thenReturn(Optional.of(worldState));
when(worldStateArchive.getMutable(any(Hash.class), any(Hash.class)))
diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java
index ba036347085..83c0f1a4c46 100644
--- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java
+++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java
@@ -31,6 +31,7 @@
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;
+import org.apache.tuweni.units.bigints.UInt64;
import org.bouncycastle.util.encoders.Hex;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -287,10 +288,6 @@ void genesisFromPrague(final DataStorageConfiguration dataStorageConfiguration)
GenesisStateTest.class.getResource("genesis_prague.json"),
ProtocolScheduleFixture.MAINNET);
final BlockHeader header = genesisState.getBlock().getHeader();
- assertThat(header.getHash())
- .isEqualTo(
- Hash.fromHexString(
- "0x554807b22674e6d335f734485993857bbad7a9543affb0663a10c14d78135ec7"));
assertThat(header.getGasLimit()).isEqualTo(0x2fefd8);
assertThat(header.getGasUsed()).isZero();
assertThat(header.getNumber()).isZero();
@@ -331,6 +328,13 @@ void genesisFromPrague(final DataStorageConfiguration dataStorageConfiguration)
.isEqualTo(
Hash.fromHexString(
"0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f"));
+ assertThat(header.getTargetBlobCount().isPresent()).isTrue();
+ assertThat(header.getTargetBlobCount().get()).isEqualTo(UInt64.ONE);
+
+ assertThat(header.getHash())
+ .isEqualTo(
+ Hash.fromHexString(
+ "0xdbc64edecb3a432e48cbd270b4a248ffc611b5f3dd666c8a10d546672cae17bd"));
}
@Test
diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java
index 7969ab6824a..02bb41feb90 100644
--- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java
+++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java
@@ -20,7 +20,7 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -36,7 +36,7 @@ public void reportedDifficultyForAllBlocksIsAFixedValue() {
FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.fromResource("/dev.json").getConfigOptions(),
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java
index 2d5dd2cee34..92818e31e72 100644
--- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java
+++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java
@@ -22,7 +22,7 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -56,12 +56,12 @@ public void setup() {
builder =
new ProtocolScheduleBuilder(
config,
- DEFAULT_CHAIN_ID,
+ Optional.of(DEFAULT_CHAIN_ID),
ProtocolSpecAdapters.create(FIRST_TIMESTAMP_FORK, modifier),
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java
index c63a9b5ccbd..9ce20cb6267 100644
--- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java
+++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java
@@ -18,7 +18,7 @@
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -73,7 +73,7 @@ public void shouldOnlyUseFrontierWhenEmptyJsonConfigIsUsed() {
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig("{}").getConfigOptions(),
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -90,7 +90,7 @@ public void createFromConfigWithSettings() {
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig(json).getConfigOptions(),
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -124,7 +124,7 @@ public void outOfOrderConstantinoplesFail() {
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig(json).getConfigOptions(),
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem()));
diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java
index 91553afed33..1f0b7828251 100644
--- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java
+++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java
@@ -21,9 +21,9 @@
import static org.mockito.Mockito.mock;
import org.hyperledger.besu.datatypes.Hash;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.util.Subscribers;
import java.util.Arrays;
@@ -530,12 +530,12 @@ public void rejectsSolutionsForOldBlocks()
powThread1.interrupt();
}
- private MiningParameters createMiningParameters(
+ private MiningConfiguration createMiningParameters(
final List nonceToTry, final int powJobTimeToLive, final int maxOmmerDepth) {
- return ImmutableMiningParameters.builder()
+ return ImmutableMiningConfiguration.builder()
.mutableInitValues(MutableInitValues.builder().nonceGenerator(nonceToTry).build())
.unstable(
- ImmutableMiningParameters.Unstable.builder()
+ ImmutableMiningConfiguration.Unstable.builder()
.maxOmmerDepth(maxOmmerDepth)
.powJobTimeToLive(powJobTimeToLive)
.build())
diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java
index ad261abf472..8046d7e839d 100644
--- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java
+++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java
@@ -31,7 +31,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@@ -62,12 +62,12 @@ public void setup() {
builder =
new ProtocolScheduleBuilder(
configOptions,
- CHAIN_ID,
+ Optional.of(CHAIN_ID),
ProtocolSpecAdapters.create(0, Function.identity()),
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -257,12 +257,12 @@ private MilestoneStreamingProtocolSchedule createScheduleModifiedAt(final int bl
final ProtocolScheduleBuilder builder =
new ProtocolScheduleBuilder(
configOptions,
- CHAIN_ID,
+ Optional.of(CHAIN_ID),
ProtocolSpecAdapters.create(blockNumber, modifier),
new PrivacyParameters(),
false,
EvmConfiguration.DEFAULT,
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java
index dd9257441e8..cfb3094726c 100644
--- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java
+++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java
@@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai;
import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain;
+import static org.hyperledger.besu.ethereum.core.WorldStateHealerHelper.throwingWorldStateHealerSupplier;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -39,9 +40,9 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
-import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
-import org.hyperledger.besu.ethereum.core.MiningParameters;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration;
+import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues;
+import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.SealableBlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
@@ -104,7 +105,7 @@ public abstract class AbstractIsolationTests {
protected final ProtocolSchedule protocolSchedule =
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromResource("/dev.json").getConfigOptions(),
- MiningParameters.MINING_DISABLED,
+ MiningConfiguration.MINING_DISABLED,
new BadBlockManager(),
false,
new NoOpMetricsSystem());
@@ -138,7 +139,7 @@ public abstract class AbstractIsolationTests {
txPoolMetrics,
transactionReplacementTester,
new BlobCache(),
- MiningParameters.newDefault()),
+ MiningConfiguration.newDefault()),
ethScheduler);
protected final List accounts =
@@ -167,7 +168,8 @@ public void createStorage() {
Optional.of(16L),
new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()),
null,
- EvmConfiguration.DEFAULT);
+ EvmConfiguration.DEFAULT,
+ throwingWorldStateHealerSupplier());
var ws = archive.getMutable();
genesisState.writeStateTo(ws);
protocolContext = new ProtocolContext(blockchain, archive, null, new BadBlockManager());
@@ -229,7 +231,7 @@ public DataStorageFormat getDatabaseFormat() {
@Override
public Wei getMinGasPrice() {
- return MiningParameters.newDefault().getMinTransactionGasPrice();
+ return MiningConfiguration.newDefault().getMinTransactionGasPrice();
}
@Override
@@ -254,7 +256,7 @@ public boolean getReceiptCompactionEnabled() {
static class TestBlockCreator extends AbstractBlockCreator {
private TestBlockCreator(
- final MiningParameters miningParameters,
+ final MiningConfiguration miningConfiguration,
final MiningBeneficiaryCalculator miningBeneficiaryCalculator,
final ExtraDataCalculator extraDataCalculator,
final TransactionPool transactionPool,
@@ -262,7 +264,7 @@ private TestBlockCreator(
final ProtocolSchedule protocolSchedule,
final EthScheduler ethScheduler) {
super(
- miningParameters,
+ miningConfiguration,
miningBeneficiaryCalculator,
extraDataCalculator,
transactionPool,
@@ -277,8 +279,8 @@ static TestBlockCreator forHeader(
final TransactionPool transactionPool,
final EthScheduler ethScheduler) {
- final MiningParameters miningParameters =
- ImmutableMiningParameters.builder()
+ final MiningConfiguration miningConfiguration =
+ ImmutableMiningConfiguration.builder()
.mutableInitValues(
MutableInitValues.builder()
.extraData(Bytes.fromHexString("deadbeef"))
@@ -290,7 +292,7 @@ static TestBlockCreator forHeader(
.build();
return new TestBlockCreator(
- miningParameters,
+ miningConfiguration,
__ -> Address.ZERO,
__ -> Bytes.fromHexString("deadbeef"),
transactionPool,
diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProviderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProviderTest.java
index 4ac99377ef0..87cc16c23c3 100644
--- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProviderTest.java
+++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/BonsaiWorldStateProviderTest.java
@@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.trie.diffbased.bonsai;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.hyperledger.besu.ethereum.core.WorldStateHealerHelper.throwingWorldStateHealerSupplier;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.BLOCKCHAIN;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;
import static org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage.WORLD_BLOCK_HASH_KEY;
@@ -111,7 +112,8 @@ void testGetMutableReturnPersistedStateWhenNeeded() {
DataStorageConfiguration.DEFAULT_BONSAI_CONFIG),
blockchain,
new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()),
- EvmConfiguration.DEFAULT);
+ EvmConfiguration.DEFAULT,
+ throwingWorldStateHealerSupplier());
assertThat(bonsaiWorldStateArchive.getMutable(chainHead, true))
.containsInstanceOf(BonsaiWorldState.class);
@@ -129,7 +131,8 @@ void testGetMutableReturnEmptyWhenLoadMoreThanLimitLayersBack() {
Optional.of(512L),
new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()),
null,
- EvmConfiguration.DEFAULT);
+ EvmConfiguration.DEFAULT,
+ throwingWorldStateHealerSupplier());
final BlockHeader blockHeader = blockBuilder.number(0).buildHeader();
final BlockHeader chainHead = blockBuilder.number(512).buildHeader();
when(blockchain.getChainHeadHeader()).thenReturn(chainHead);
@@ -150,7 +153,8 @@ void testGetMutableWhenLoadLessThanLimitLayersBack() {
DataStorageConfiguration.DEFAULT_BONSAI_CONFIG),
blockchain,
new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()),
- EvmConfiguration.DEFAULT);
+ EvmConfiguration.DEFAULT,
+ throwingWorldStateHealerSupplier());
final BlockHeader blockHeader = blockBuilder.number(0).buildHeader();
final BlockHeader chainHead = blockBuilder.number(511).buildHeader();
final BonsaiWorldState mockWorldState = mock(BonsaiWorldState.class);
@@ -185,7 +189,8 @@ void testGetMutableWithStorageInconsistencyRollbackTheState() {
worldStateKeyValueStorage,
blockchain,
new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()),
- EvmConfiguration.DEFAULT));
+ EvmConfiguration.DEFAULT,
+ throwingWorldStateHealerSupplier()));
final BlockHeader blockHeader = blockBuilder.number(0).buildHeader();
when(blockchain.getBlockHeader(blockHeader.getHash())).thenReturn(Optional.of(blockHeader));
@@ -214,7 +219,8 @@ void testGetMutableWithStorageConsistencyNotRollbackTheState() {
worldStateKeyValueStorage,
blockchain,
new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()),
- EvmConfiguration.DEFAULT));
+ EvmConfiguration.DEFAULT,
+ throwingWorldStateHealerSupplier()));
final BlockHeader blockHeader = blockBuilder.number(0).buildHeader();
@@ -254,7 +260,8 @@ void testGetMutableWithStorageConsistencyToRollbackAndRollForwardTheState() {
worldStateKeyValueStorage,
blockchain,
new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()),
- EvmConfiguration.DEFAULT));
+ EvmConfiguration.DEFAULT,
+ throwingWorldStateHealerSupplier()));
// initial persisted state hash key
when(blockchain.getBlockHeader(Hash.ZERO)).thenReturn(Optional.of(blockHeaderChainA));
@@ -297,7 +304,8 @@ void testGetMutableWithRollbackNotOverrideTrieLogLayer() {
DataStorageConfiguration.DEFAULT_BONSAI_CONFIG),
blockchain,
new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()),
- EvmConfiguration.DEFAULT));
+ EvmConfiguration.DEFAULT,
+ throwingWorldStateHealerSupplier()));
// initial persisted state hash key
when(blockchain.getBlockHeader(Hash.ZERO)).thenReturn(Optional.of(blockHeaderChainA));
diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/LogRollingTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/LogRollingTests.java
index e43d464474c..6a70cb20e28 100644
--- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/LogRollingTests.java
+++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/LogRollingTests.java
@@ -99,6 +99,7 @@ class LogRollingTests {
null,
null,
null,
+ null,
new MainnetBlockHeaderFunctions());
private static final BlockHeader headerTwo =
new BlockHeader(
@@ -123,6 +124,7 @@ class LogRollingTests {
null,
null,
null,
+ null,
new MainnetBlockHeaderFunctions());
@BeforeEach
diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/chain/genesis_prague.json b/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/chain/genesis_prague.json
index d99071b328d..f9aa3ff4663 100644
--- a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/chain/genesis_prague.json
+++ b/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/chain/genesis_prague.json
@@ -4073,5 +4073,6 @@
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
- "baseFeePerGas": "0x3b9aca00"
+ "baseFeePerGas": "0x3b9aca00",
+ "targetBlobCount": "0x1"
}
diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java
index 58318f9611e..30cd03c15c3 100644
--- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java
+++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManager.java
@@ -337,7 +337,6 @@ public void processMessage(final Capability cap, final Message message) {
public void handleNewConnection(final PeerConnection connection) {
ethPeers.registerNewConnection(connection, peerValidators);
final EthPeer peer = ethPeers.peer(connection);
-
final Capability cap = connection.capability(getSupportedProtocol());
final ForkId latestForkId =
cap.getVersion() >= 64 ? forkIdManager.getForkIdForChainHead() : null;
diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthScheduler.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthScheduler.java
index 1e2f3eb6abb..8c90993c689 100644
--- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthScheduler.java
+++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthScheduler.java
@@ -145,7 +145,7 @@ public void executeServiceTask(final Runnable command) {
servicesExecutor.execute(command);
}
- public CompletableFuture scheduleServiceTask(final Runnable task) {
+ public CompletableFuture scheduleServiceTask(final Runnable task) {
return CompletableFuture.runAsync(task, servicesExecutor);
}
@@ -156,6 +156,19 @@ public CompletableFuture scheduleServiceTask(final EthTask task) {
return serviceFuture;
}
+ public CompletableFuture scheduleServiceTask(final Supplier> future) {
+ final CompletableFuture promise = new CompletableFuture<>();
+ final Future> workerFuture = servicesExecutor.submit(() -> propagateResult(future, promise));
+ // If returned promise is cancelled, cancel the worker future
+ promise.whenComplete(
+ (r, t) -> {
+ if (t instanceof CancellationException) {
+ workerFuture.cancel(false);
+ }
+ });
+ return promise;
+ }
+
public CompletableFuture startPipeline(final Pipeline> pipeline) {
final CompletableFuture pipelineFuture = pipeline.start(servicesExecutor);
pendingFutures.add(pipelineFuture);
diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTask.java
index 1243846ac3d..fed671d38d2 100644
--- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTask.java
+++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTask.java
@@ -41,13 +41,13 @@ public interface PeerTask {
MessageData getRequestMessage();
/**
- * Parses the MessageData response from the EthPeer
+ * Parses and processes the MessageData response from the EthPeer
*
* @param messageData the response MessageData to be parsed
* @return a T built from the response MessageData
* @throws InvalidPeerTaskResponseException if the response messageData is invalid
*/
- T parseResponse(MessageData messageData) throws InvalidPeerTaskResponseException;
+ T processResponse(MessageData messageData) throws InvalidPeerTaskResponseException;
/**
* Gets the number of times this task may be attempted against other peers
diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java
index 984cedccecb..a2ae0455263 100644
--- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java
+++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/PeerTaskExecutor.java
@@ -133,7 +133,7 @@ public PeerTaskExecutorResult executeAgainstPeer(
MessageData responseMessageData =
requestSender.sendRequest(peerTask.getSubProtocol(), requestMessageData, peer);
- result = peerTask.parseResponse(responseMessageData);
+ result = peerTask.processResponse(responseMessageData);
} finally {
inflightRequestCountForThisTaskClass.decrementAndGet();
}
diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/task/GetReceiptsFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/task/GetReceiptsFromPeerTask.java
new file mode 100644
index 00000000000..7d4b5d585e5
--- /dev/null
+++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/peertask/task/GetReceiptsFromPeerTask.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright contributors to Hyperledger Besu.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.besu.ethereum.eth.manager.peertask.task;
+
+import static java.util.Collections.emptyList;
+
+import org.hyperledger.besu.datatypes.Hash;
+import org.hyperledger.besu.ethereum.core.BlockHeader;
+import org.hyperledger.besu.ethereum.core.TransactionReceipt;
+import org.hyperledger.besu.ethereum.eth.EthProtocol;
+import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
+import org.hyperledger.besu.ethereum.eth.manager.peertask.InvalidPeerTaskResponseException;
+import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerTask;
+import org.hyperledger.besu.ethereum.eth.messages.GetReceiptsMessage;
+import org.hyperledger.besu.ethereum.eth.messages.ReceiptsMessage;
+import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
+import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
+import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
+import org.hyperledger.besu.ethereum.p2p.rlpx.wire.SubProtocol;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Predicate;
+
+public class GetReceiptsFromPeerTask
+ implements PeerTask