merge of 23.1.2 into release-23.1.x (#5323)

Signed-off-by: garyschulte <garyschulte@gmail.com>
pull/5324/head
garyschulte 2 years ago committed by GitHub
parent 7c2d4eb272
commit e24bfdebea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .circleci/config.yml
  2. 1
      .github/issue_template.md
  3. 13
      .github/pull_request_template.md
  4. 5
      .github/workflows/checks.yml
  5. 3
      .github/workflows/codeql.yml
  6. 10
      .github/workflows/dco-merge-group.yml
  7. 3
      .github/workflows/dco.yml
  8. 4
      .github/workflows/gradle-wrapper-validation.yml
  9. 20
      .github/workflows/pr-checklist-on-open.yml
  10. 2
      .github/workflows/release.yml
  11. 3
      .github/workflows/repolinter.yml
  12. 42
      .github/workflows/sonarcloud.yml
  13. 41
      CHANGELOG.md
  14. 0
      ISSUE_TEMPLATE.md
  15. 39
      PULL_REQUEST_TEMPLATE.md
  16. 13
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/TestRpcEndpointServicePlugin.java
  17. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/CreateAccountAcceptanceTest.java
  18. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/GossipTransactionAcceptanceTest.java
  19. 38
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/LoggingTest.java
  20. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/MetricsAcceptanceTest.java
  21. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/OpenTelemetryAcceptanceTest.java
  22. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/RpcApisTogglesAcceptanceTest.java
  23. 2
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/RunHelpTest.java
  24. 5
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/AbstractJsonRpcTest.java
  25. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DeploySmartContractAcceptanceTest.java
  26. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DeployTransactionAcceptanceTest.java
  27. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthGetWorkAcceptanceTest.java
  28. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthSendRawTransactionTest.java
  29. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EventEmitterAcceptanceTest.java
  30. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/JsonRpcHttpAuthenticationAcceptanceTest.java
  31. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/JsonRpcWebsocketAuthenticationAcceptanceTest.java
  32. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/NetServicesAcceptanceTest.java
  33. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/RevertReasonAcceptanceTest.java
  34. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/Web3Sha3AcceptanceTest.java
  35. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/admin/AdminAddPeerAcceptanceTest.java
  36. 14
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BadCLIOptionsPluginTest.java
  37. 8
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/BesuEventsPluginTest.java
  38. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java
  39. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PicoCLIOptionsPluginTest.java
  40. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/RpcEndpointServicePluginTest.java
  41. 5
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyGroupAcceptanceTest.java
  42. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyGroupTest.java
  43. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/contracts/PrivacyProxyTest.java
  44. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/pubsub/NewPendingTransactionAcceptanceTest.java
  45. 1
      besu/build.gradle
  46. 16
      besu/src/main/java/org/hyperledger/besu/Besu.java
  47. 19
      besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
  48. 20
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  49. 10
      besu/src/main/java/org/hyperledger/besu/cli/error/BesuParameterExceptionHandler.java
  50. 9
      besu/src/main/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOption.java
  51. 11
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java
  52. 12
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  53. 5
      besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java
  54. 8
      besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java
  55. 5
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
  56. 4
      besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java
  57. 27
      besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java
  58. 2
      besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java
  59. 4
      besu/src/test/java/org/hyperledger/besu/ethereum/p2p/config/DefaultDiscoveryConfiguration.java
  60. 3
      besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java
  61. 10
      besu/src/test/java/org/hyperledger/besu/util/LocalPermissioningConfigurationValidatorTest.java
  62. 8
      besu/src/test/java/org/hyperledger/besu/util/PrivateStorageMigrationServiceTest.java
  63. 8
      besu/src/test/java/org/hyperledger/besu/util/StringUtilsTest.java
  64. 19
      besu/src/test/resources/invalid_post_merge_checkpoint_total_difficulty_same_as_TTD.json
  65. 19
      besu/src/test/resources/invalid_post_merge_merge_at_genesis.json
  66. 19
      besu/src/test/resources/invalid_post_merge_near_head_checkpoint.json
  67. 19
      besu/src/test/resources/valid_pos_checkpoint_pos_TD_equals_TTD.json
  68. 19
      besu/src/test/resources/valid_post_merge_near_head_checkpoint.json
  69. 15
      build.gradle
  70. 5
      config/src/main/resources/mainnet.json
  71. 6
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactory.java
  72. 17
      consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java
  73. 62
      consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/TransitionProtocolScheduleTest.java
  74. 4
      consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java
  75. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java
  76. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java
  77. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/LogAdapter.java
  78. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/PendingStateAdapter.java
  79. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java
  80. 36
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AbstractTraceByHash.java
  81. 14
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminChangeLogLevel.java
  82. 87
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountAt.java
  83. 20
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountRange.java
  84. 25
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBlockToFile.java
  85. 45
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAt.java
  86. 17
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java
  87. 22
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHash.java
  88. 16
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumber.java
  89. 11
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransaction.java
  90. 9
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProof.java
  91. 31
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceBlock.java
  92. 14
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceCallMany.java
  93. 16
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TraceReplayBlockTransactions.java
  94. 73
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockReplay.java
  95. 24
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java
  96. 101
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/Tracer.java
  97. 45
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java
  98. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugJsonRpcMethods.java
  99. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TraceJsonRpcMethods.java
  100. 28
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -219,7 +219,7 @@ jobs:
- capture_test_results
acceptanceTests:
parallelism: 6
parallelism: 4
executor: xl_machine_executor
steps:
- prepare

@ -32,6 +32,7 @@ As an [Actor], I want [feature] so that [why].
* 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`]

@ -6,16 +6,3 @@
## Fixed Issue(s)
<!-- Please link to fixed issue(s) here using format: fixes #<issue number> -->
<!-- Example: "fixes #2" -->
## Documentation
- [ ] I thought about documentation and added the `doc-change-required` label to this PR if
[updates are required](https://wiki.hyperledger.org/display/BESU/Documentation).
## Acceptance Tests (Non Mainnet)
- [ ] I have considered running `./gradlew acceptanceTestNonMainnet` locally if my PR affects non-mainnet modules.
## Changelog
- [ ] I thought about the changelog and included a [changelog update if required](https://wiki.hyperledger.org/display/BESU/Changelog).

@ -4,10 +4,11 @@ on:
branches: [ main ]
pull_request:
workflow_dispatch:
merge_group:
jobs:
spotless:
runs-on: ubuntu-latest
runs-on: [besu,Linux,self-hosted,X64]
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: Checkout Repo
@ -21,7 +22,7 @@ jobs:
- name: spotless
run: ./gradlew --no-daemon --parallel clean spotlessCheck
javadoc_17:
runs-on: ubuntu-latest
runs-on: [besu,Linux,self-hosted,X64]
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: Checkout Repo

@ -21,10 +21,11 @@ on:
- '**/*.md'
- '**/*.properties'
- '**/*.txt'
merge_group:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: [besu,Linux,self-hosted,X64]
permissions:
actions: read
contents: read

@ -0,0 +1,10 @@
name: dco
on:
merge_group:
jobs:
dco:
runs-on: [besu,Linux,self-hosted]
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- run: echo "This DCO job runs on merge_queue event and doesn't check PR contents"

@ -5,9 +5,10 @@ on:
jobs:
dco:
runs-on: ubuntu-latest
runs-on: [besu,Linux,self-hosted]
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- run: echo "This DCO job runs on pull_request event and workflow_dispatch"
- name: Get PR Commits
id: 'get-pr-commits'
uses: tim-actions/get-pr-commits@v1.2.0

@ -1,11 +1,11 @@
# SPDX-License-Identifier: Apache-2.0
name: "Validate Gradle Wrapper"
on: [push, pull_request]
on: [push, pull_request, merge_group]
jobs:
validation:
name: "Gradle Wrapper Validation"
runs-on: ubuntu-latest
runs-on: [besu,Linux,self-hosted]
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1

@ -0,0 +1,20 @@
name: "comment on pr with checklist"
on:
pull_request_target:
types: [ opened ]
branches: [ main ]
jobs:
checklist:
name: "add checklist as a comment on newly opened PRs"
runs-on: [besu,Linux,self-hosted]
steps:
- uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '- [ ] I thought about documentation and added the `doc-change-required` label to this PR if [updates are required](https://wiki.hyperledger.org/display/BESU/Documentation).\n- [ ] I have considered running `./gradlew acceptanceTestNonMainnet` locally if my PR affects non-mainnet modules.\n- [ ] I thought about the changelog and included a [changelog update if required](https://wiki.hyperledger.org/display/BESU/Changelog).'
})

@ -4,7 +4,7 @@ on:
types: released
jobs:
dockerPromoteX64:
runs-on: ubuntu-latest
runs-on: [besu,Linux,self-hosted]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3

@ -12,10 +12,11 @@ on:
branches:
- master
- main
merge_group:
jobs:
build:
runs-on: ubuntu-latest
runs-on: [besu,Linux,self-hosted,X64]
container: ghcr.io/todogroup/repolinter:v0.10.1
steps:
- name: Checkout Code

@ -0,0 +1,42 @@
name: SonarCloud analysis
on:
schedule:
# * is a special character in YAML so you have to quote this string
# expression evaluates to midnight on Tuesdays UTC
- cron: '0 0 * * 2'
permissions:
pull-requests: read # allows SonarCloud to decorate PRs with analysis results
jobs:
Analysis:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonarqube --info

@ -1,5 +1,23 @@
# Changelog
## 23.1.2
This update is a mainnet-compatible Shanghai/Capella upgrade and is recommended for all Mainnet users.
### Breaking Changes
### Additions and Improvements
- Schedule Shanghai (Shapella) fork for Mainnet [#5230](https://github.com/hyperledger/besu/pull/5230)
- Increase default from 1000 to 5000 for `--rpc-max-logs-range` [#5209](https://github.com/hyperledger/besu/pull/5209)
- Bonsai-safe refactor [#5123](https://github.com/hyperledger/besu/pull/5123)
- Safe tracing [#5197](https://github.com/hyperledger/besu/pull/5197)
### Bug Fixes
- Persist backward sync status to support resuming across restarts [#5182](https://github.com/hyperledger/besu/pull/5182)
### Download Links
https://hyperledger.jfrog.io/hyperledger/besu-binaries/besu/23.1.2/besu-23.1.2.tar.gz / sha256: tba
https://hyperledger.jfrog.io/hyperledger/besu-binaries/besu/23.1.2/besu-23.1.2.zip / sha256: tba
## 23.1.1
This update is required for the Goerli Shanghai/Capella upgrade and recommended for all Mainnet users. If you use Besu on Goerli, update to 23.1.1. If you previously used 23.1.1-RC1, update to test 23.1.1 on Goerli.
@ -16,8 +34,13 @@ This update is required for the Goerli Shanghai/Capella upgrade and recommended
- Goerli configs for shapella [#5151](https://github.com/hyperledger/besu/pull/5151)
### Bug Fixes
- Fix engine_getPayloadV2 block value calculation https://github.com/hyperledger/besu/issues/5040
- Moves check for init code length before balance check https://github.com/hyperledger/besu/pull/5077
- Fix engine_getPayloadV2 block value calculation [#5040](https://github.com/hyperledger/besu/issues/5040)
- Moves check for init code length before balance check [#5077](https://github.com/hyperledger/besu/pull/5077)
- Address concurrency problems with eth_call [#5179](https://github.com/hyperledger/besu/pull/5179)
### Download Links
https://hyperledger.jfrog.io/hyperledger/besu-binaries/besu/23.1.1/besu-23.1.1.tar.gz / sha256: 11c3e5cdbc06df16a690e7ee9f98eefa46848f9fa280824b6e4c896d88f6b975
https://hyperledger.jfrog.io/hyperledger/besu-binaries/besu/23.1.1/besu-23.1.1.zip / sha256: afcf852f193adb8e82d187aa4f02e4669f12cc680270624d37101b94cf37adec
## 23.1.1-RC1
### Sepolia Shanghai Release aka Sepolia Shapella aka Shapolia
@ -33,15 +56,15 @@ Sepolia Shanghai hardfork scheduled for: **Tue Feb 28 2023 04:04:48 UTC**
This release has everything from [23.1.0](https://github.com/hyperledger/besu/releases/tag/23.1.0) and in addition the following:
### Additions and Improvements
* Add support for Shanghai in Sepolia https://github.com/hyperledger/besu/pull/5088
* Add implementation for engine_getPayloadBodiesByRangeV1 and engine_getPayloadBodiesByHashV1 https://github.com/hyperledger/besu/pull/4980
* If a PoS block creation repetition takes less than a configurable duration, then waits before next repetition https://github.com/hyperledger/besu/pull/5048
* Allow other users to read the /opt/besu dir when using docker https://github.com/hyperledger/besu/pull/5092
* Invalid params - add some error detail #5066
- Add support for Shanghai in Sepolia https://github.com/hyperledger/besu/pull/5088
- Add implementation for engine_getPayloadBodiesByRangeV1 and engine_getPayloadBodiesByHashV1 https://github.com/hyperledger/besu/pull/4980
- If a PoS block creation repetition takes less than a configurable duration, then waits before next repetition https://github.com/hyperledger/besu/pull/5048
- Allow other users to read the /opt/besu dir when using docker https://github.com/hyperledger/besu/pull/5092
- Invalid params - add some error detail #5066
### Bug fixes
* Fix engine_getPayloadV2 block value calculation https://github.com/hyperledger/besu/issues/5040
* Moves check for init code length before balance check https://github.com/hyperledger/besu/pull/5077
- Fix engine_getPayloadV2 block value calculation https://github.com/hyperledger/besu/issues/5040
- Moves check for init code length before balance check https://github.com/hyperledger/besu/pull/5077
### Download Links
https://hyperledger.jfrog.io/hyperledger/besu-binaries/besu/23.1.1-RC1/besu-23.1.1-RC1.tar.gz / sha256: 82cff41f3eace02006b0e670605848e0e77e045892f8fa9aad66cbd84a88221e

@ -1,39 +0,0 @@
## Status
**READY/IN DEVELOPMENT/HOLD**
## Description
A few sentences describing the overall goals of the pull request's commits.
## Related PRs
List related PRs against other branches:
branch | PR
------ | ------
other_pr_production | [link]()
other_pr_master | [link]()
## Todos
- [ ] Tests
- [ ] Documentation
## Deploy Notes
Notes regarding deployment the contained body of work. These should note any
db migrations, etc.
## Steps to Test or Reproduce
Outline the steps to test or reproduce the PR here.
```sh
git pull --prune
git checkout <feature_branch>
bundle; script/server
```
1.
## Impacted Areas in Application
List general components of the application that this PR will affect:
*

@ -28,6 +28,8 @@ import com.google.auto.service.AutoService;
@AutoService(BesuPlugin.class)
public class TestRpcEndpointServicePlugin implements BesuPlugin {
private static final String NAMESPACE_ENABLED = "tests";
private static final String NAMESPACE_NOT_ENABLED = "notEnabled";
private final AtomicReference<String> stringStorage = new AtomicReference<>("InitialValue");
private final AtomicReference<Object[]> arrayStorage = new AtomicReference<>();
@ -54,13 +56,14 @@ public class TestRpcEndpointServicePlugin implements BesuPlugin {
.getService(RpcEndpointService.class)
.ifPresent(
rpcEndpointService -> {
rpcEndpointService.registerRPCEndpoint("tests", "getValue", this::getValue);
rpcEndpointService.registerRPCEndpoint("tests", "setValue", this::setValue);
rpcEndpointService.registerRPCEndpoint(NAMESPACE_ENABLED, "getValue", this::getValue);
rpcEndpointService.registerRPCEndpoint(NAMESPACE_ENABLED, "setValue", this::setValue);
rpcEndpointService.registerRPCEndpoint(
"tests", "replaceValueList", this::replaceValueList);
NAMESPACE_ENABLED, "replaceValueList", this::replaceValueList);
rpcEndpointService.registerRPCEndpoint(
"tests", "throwException", this::throwException);
rpcEndpointService.registerRPCEndpoint("notEnabled", "getValue", this::getValue);
NAMESPACE_ENABLED, "throwException", this::throwException);
rpcEndpointService.registerRPCEndpoint(
NAMESPACE_NOT_ENABLED, "getValue", this::getValue);
});
}

@ -19,14 +19,14 @@ 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.Node;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class CreateAccountAcceptanceTest extends AcceptanceTestBase {
private Node minerNode;
@Before
@BeforeEach
public void setUp() throws Exception {
minerNode = besu.createMinerNode("minerNode");
cluster.start(minerNode, besu.createArchiveNode("archiveNode"));

@ -21,14 +21,14 @@ import org.hyperledger.besu.tests.acceptance.dsl.blockchain.Amount;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.account.TransferTransaction;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class GossipTransactionAcceptanceTest extends AcceptanceTestBase {
private Node archiveNode1;
@Before
@BeforeEach
public void setUp() throws Exception {
archiveNode1 = besu.createArchiveNode("archiveNode1");
cluster.start(archiveNode1, besu.createArchiveNode("archiveNode2"));

@ -0,0 +1,38 @@
/*
* 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;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import java.io.IOException;
import org.junit.Test;
public class LoggingTest extends AcceptanceTestBase {
@Test
public void testDefaultLoggingIsAtLeastInfo() throws IOException {
final BesuNode node = besu.createArchiveNode("logger");
cluster.startConsoleCapture();
cluster.runNodeStart(node);
node.verify(net.awaitPeerCount(0));
assertThat(cluster.getConsoleContents()).contains("| INFO |");
}
}

@ -26,15 +26,15 @@ import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class MetricsAcceptanceTest extends AcceptanceTestBase {
private BesuNode metricsNode;
private OkHttpClient client;
@Before
@BeforeEach
public void setUp() throws Exception {
metricsNode =
besu.create(

@ -59,9 +59,9 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class OpenTelemetryAcceptanceTest extends AcceptanceTestBase {
@ -125,7 +125,7 @@ public class OpenTelemetryAcceptanceTest extends AcceptanceTestBase {
private BesuNode metricsNode;
@Before
@BeforeEach
public void setUp() throws Exception {
System.setProperty("root.log.level", "DEBUG");
Server server =
@ -163,7 +163,7 @@ public class OpenTelemetryAcceptanceTest extends AcceptanceTestBase {
cluster.start(metricsNode);
}
@After
@AfterEach
public void tearDown() throws Exception {
closer.close();
}

@ -22,8 +22,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.java_websocket.exceptions.WebsocketNotConnectedException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class RpcApisTogglesAcceptanceTest extends AcceptanceTestBase {
@ -31,7 +31,7 @@ public class RpcApisTogglesAcceptanceTest extends AcceptanceTestBase {
private BesuNode rpcDisabledNode;
private BesuNode ethApiDisabledNode;
@Before
@BeforeEach
public void before() throws Exception {
rpcEnabledNode = besu.createArchiveNode("rpc-enabled");
rpcDisabledNode = besu.createArchiveNodeWithRpcDisabled("rpc-disabled");

@ -22,7 +22,7 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class RunHelpTest extends AcceptanceTestBase {

@ -95,7 +95,10 @@ abstract class AbstractJsonRpcTest {
final ObjectNode actualBody = JsonUtil.objectNodeFromString(response.body().string());
final ObjectNode expectedBody =
JsonUtil.objectNodeFromString(testCase.getResponse().toString());
assertThat(actualBody.toPrettyString()).isEqualTo(expectedBody.toPrettyString());
assertThat(actualBody)
.withFailMessage(
"%s\ndid not equal\n %s", actualBody.toPrettyString(), expectedBody.toPrettyString())
.isEqualTo(expectedBody);
}
private String getRpcUrl(final String rpcMethod) {

@ -18,14 +18,14 @@ import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.hyperledger.besu.tests.web3j.generated.SimpleStorage;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class DeploySmartContractAcceptanceTest extends AcceptanceTestBase {
private BesuNode minerNode;
@Before
@BeforeEach
public void setUp() throws Exception {
minerNode = besu.createMinerNode("miner-node");
cluster.start(minerNode);

@ -19,15 +19,15 @@ 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.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class DeployTransactionAcceptanceTest extends AcceptanceTestBase {
private BesuNode minerNode;
private Account recipient;
@Before
@BeforeEach
public void setUp() throws Exception {
recipient = accounts.createAccount("recipient");
minerNode = besu.createMinerNode("node");

@ -17,16 +17,16 @@ package org.hyperledger.besu.tests.acceptance.jsonrpc;
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class EthGetWorkAcceptanceTest extends AcceptanceTestBase {
private Node minerNode;
private Node fullNode;
@Before
@BeforeEach
public void setUp() throws Exception {
minerNode = besu.createMinerNode("node1");
fullNode = besu.createArchiveNode("node2");
@ -34,7 +34,7 @@ public class EthGetWorkAcceptanceTest extends AcceptanceTestBase {
}
@Test
@Ignore("Genuinely Flakey")
@Disabled("Genuinely Flakey")
public void shouldReturnSuccessResponseWhenMining() {
minerNode.verify(eth.getWork());
}

@ -24,8 +24,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.transaction.account.TransferTra
import java.math.BigInteger;
import java.util.function.UnaryOperator;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class EthSendRawTransactionTest extends AcceptanceTestBase {
private static final long CHAIN_ID = 20211;
@ -36,7 +36,7 @@ public class EthSendRawTransactionTest extends AcceptanceTestBase {
private Node strictNode;
private Node miningNode;
@Before
@BeforeEach
public void setUp() throws Exception {
sender = accounts.getPrimaryBenefactor();

@ -26,8 +26,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
import io.reactivex.Flowable;
import io.reactivex.disposables.Disposable;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
@ -38,7 +38,7 @@ public class EventEmitterAcceptanceTest extends AcceptanceTestBase {
private BesuNode node;
@Before
@BeforeEach
public void setUp() throws Exception {
node = besu.createMinerNode("node1");
cluster.start(node);

@ -25,8 +25,8 @@ import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class JsonRpcHttpAuthenticationAcceptanceTest extends AcceptanceTestBase {
private Cluster authenticatedCluster;
@ -52,7 +52,7 @@ public class JsonRpcHttpAuthenticationAcceptanceTest extends AcceptanceTestBase
private static final List<String> NO_AUTH_API_METHODS = Arrays.asList("net_services");
@Before
@BeforeEach
public void setUp() throws IOException, URISyntaxException {
final ClusterConfiguration clusterConfiguration =

@ -25,8 +25,8 @@ import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class JsonRpcWebsocketAuthenticationAcceptanceTest extends AcceptanceTestBase {
private BesuNode nodeUsingAuthFile;
@ -52,7 +52,7 @@ public class JsonRpcWebsocketAuthenticationAcceptanceTest extends AcceptanceTest
+ "c2lvbnMiOlsibmV0OnBlZXJDb3VudCJdfQ.pWXniN6XQ7G8b1nawy8sviPCMxrfbcI6c7UFzeXm26CMGMUEZxiC"
+ "JjRntB8ueuZcsxnGlEhCHt-KngpFEmx5TA";
@Before
@BeforeEach
public void setUp() throws IOException, URISyntaxException {
final ClusterConfiguration clusterConfiguration =
new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build();

@ -20,9 +20,9 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class NetServicesAcceptanceTest extends AcceptanceTestBase {
@ -31,7 +31,7 @@ public class NetServicesAcceptanceTest extends AcceptanceTestBase {
private Node nodeA;
private Node nodeB;
@Before
@BeforeEach
public void setup() {
final ClusterConfiguration clusterConfiguration =
new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build();
@ -58,7 +58,7 @@ public class NetServicesAcceptanceTest extends AcceptanceTestBase {
nodeB.verify(net.netServicesOnlyJsonRpcEnabled());
}
@After
@AfterEach
public void closeDown() throws Exception {
noDiscoveryCluster.close();
}

@ -21,15 +21,15 @@ import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.hyperledger.besu.tests.web3j.generated.RevertReason;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.protocol.core.methods.response.EthSendTransaction;
public class RevertReasonAcceptanceTest extends AcceptanceTestBase {
private BesuNode minerNode;
@Before
@BeforeEach
public void setUp() throws Exception {
minerNode = besu.createMinerNodeWithRevertReasonEnabled("miner-node-withRevertReason");
cluster.start(minerNode);

@ -17,14 +17,14 @@ package org.hyperledger.besu.tests.acceptance.jsonrpc;
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class Web3Sha3AcceptanceTest extends AcceptanceTestBase {
private Node node;
@Before
@BeforeEach
public void setUp() throws Exception {
node = besu.createArchiveNode("node1");
cluster.start(node);

@ -20,9 +20,9 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration;
import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class AdminAddPeerAcceptanceTest extends AcceptanceTestBase {
private Cluster noDiscoveryCluster;
@ -30,7 +30,7 @@ public class AdminAddPeerAcceptanceTest extends AcceptanceTestBase {
private Node nodeA;
private Node nodeB;
@Before
@BeforeEach
public void setUp() throws Exception {
final ClusterConfiguration clusterConfiguration =
new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build();
@ -40,7 +40,7 @@ public class AdminAddPeerAcceptanceTest extends AcceptanceTestBase {
noDiscoveryCluster.start(nodeA, nodeB);
}
@After
@AfterEach
public void tearDown() {
noDiscoveryCluster.stop();
}

@ -28,15 +28,15 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class BadCLIOptionsPluginTest extends AcceptanceTestBase {
private BesuNode node;
@Before
@BeforeEach
public void setUp() throws Exception {
System.setProperty("TEST_BAD_CLI", "true");
@ -46,7 +46,7 @@ public class BadCLIOptionsPluginTest extends AcceptanceTestBase {
cluster.start(node);
}
@After
@AfterEach
public void tearDown() {
System.setProperty("TEST_BAD_CLI", "false");
}
@ -68,7 +68,7 @@ public class BadCLIOptionsPluginTest extends AcceptanceTestBase {
}
@Test
@Ignore("No way to do a graceful shutdown of Besu at the moment.")
@Disabled("No way to do a graceful shutdown of Besu at the moment.")
public void shouldNotStop() {
cluster.stopNode(node);
waitForFile(node.homeDirectory().resolve("plugins/pluginLifecycle.stopped"));

@ -25,14 +25,14 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.awaitility.Awaitility;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class BesuEventsPluginTest extends AcceptanceTestBase {
private BesuNode pluginNode;
private BesuNode minerNode;
@Before
@BeforeEach
public void setUp() throws Exception {
minerNode = besu.createMinerNode("minerNode");
pluginNode =
@ -42,7 +42,7 @@ public class BesuEventsPluginTest extends AcceptanceTestBase {
}
@Test
public void blockIsAnnounded() {
public void blockIsAnnounced() {
waitForFile(pluginNode.homeDirectory().resolve("plugins/newBlock.2"));
}

@ -25,8 +25,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.transaction.account.TransferTra
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class PermissioningPluginTest extends AcceptanceTestBase {
private BesuNode minerNode;
@ -35,7 +35,7 @@ public class PermissioningPluginTest extends AcceptanceTestBase {
private BesuNode bobNode;
private BesuNode charlieNode;
@Before
@BeforeEach
public void setUp() throws Exception {
final BesuNodeConfigurationBuilder builder =
new BesuNodeConfigurationBuilder()

@ -28,9 +28,9 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.awaitility.Awaitility;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class PicoCLIOptionsPluginTest extends AcceptanceTestBase {
private BesuNode node;
@ -38,7 +38,7 @@ public class PicoCLIOptionsPluginTest extends AcceptanceTestBase {
// context: https://en.wikipedia.org/wiki/The_Magic_Words_are_Squeamish_Ossifrage
private static final String MAGIC_WORDS = "Squemish Ossifrage";
@Before
@BeforeEach
public void setUp() throws Exception {
node =
besu.createPluginsNode(
@ -70,7 +70,7 @@ public class PicoCLIOptionsPluginTest extends AcceptanceTestBase {
}
@Test
@Ignore("No way to do a graceful shutdown of Besu at the moment.")
@Disabled("No way to do a graceful shutdown of Besu at the moment.")
public void shouldStop() {
cluster.stopNode(node);
waitForFile(node.homeDirectory().resolve("plugins/pluginLifecycle.stopped"));

@ -30,8 +30,8 @@ import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class RpcEndpointServicePluginTest extends AcceptanceTestBase {
@ -40,7 +40,7 @@ public class RpcEndpointServicePluginTest extends AcceptanceTestBase {
private OkHttpClient client;
protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
@Before
@BeforeEach
public void setUp() throws Exception {
node = besu.createPluginsNode("node1", List.of("testPlugins"), List.of("--rpc-http-api=TESTS"));
cluster.start(node);

@ -24,7 +24,7 @@ import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyAcceptanceTestBa
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.account.PrivacyAccountResolver;
import org.hyperledger.besu.tests.web3j.generated.EventEmitter;
import org.hyperledger.besu.util.Log4j2ConfiguratorUtil;
import org.hyperledger.besu.util.LogConfigurator;
import org.hyperledger.enclave.testutil.EnclaveEncryptorType;
import org.hyperledger.enclave.testutil.EnclaveType;
@ -34,7 +34,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import org.apache.logging.log4j.Level;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@ -99,7 +98,7 @@ public class PrivacyGroupAcceptanceTest extends PrivacyAcceptanceTestBase {
@Test
public void nodeCanCreatePrivacyGroup() {
Log4j2ConfiguratorUtil.setLevel("", Level.DEBUG);
LogConfigurator.setLevel("", "DEBUG");
final String privacyGroupId =
alice.execute(
privacyTransactions.createPrivacyGroup(

@ -25,8 +25,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.protocol.core.RemoteFunctionCall;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.protocol.exceptions.TransactionException;
@ -55,7 +55,7 @@ public class PrivacyGroupTest extends AcceptanceTestBase {
private BesuNode minerNode;
@Before
@BeforeEach
public void setUp() throws Exception {
minerNode = besu.createMinerNode("node");
cluster.start(minerNode);

@ -27,8 +27,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.exceptions.TransactionException;
@ -55,7 +55,7 @@ public class PrivacyProxyTest extends AcceptanceTestBase {
private DefaultFlexiblePrivacyGroupManagementContract
defaultFlexiblePrivacyGroupManagementContract;
@Before
@BeforeEach
public void setUp() throws Exception {
minerNode = besu.createMinerNode("node");
cluster.start(minerNode);

@ -22,9 +22,9 @@ import org.hyperledger.besu.tests.acceptance.dsl.pubsub.Subscription;
import org.hyperledger.besu.tests.acceptance.dsl.pubsub.WebSocket;
import io.vertx.core.Vertx;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
@ -35,7 +35,7 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
private BesuNode minerNode;
private BesuNode archiveNode;
@Before
@BeforeEach
public void setUp() throws Exception {
vertx = Vertx.vertx();
minerNode = besu.createMinerNode("miner-node1");
@ -46,7 +46,7 @@ public class NewPendingTransactionAcceptanceTest extends AcceptanceTestBase {
archiveWebSocket = new WebSocket(vertx, archiveNode.getConfiguration());
}
@After
@AfterEach
public void tearDown() {
vertx.close();
}

@ -99,6 +99,7 @@ dependencies {
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'
testImplementation 'org.testcontainers:testcontainers'
testImplementation 'tech.pegasys.discovery:discovery'

@ -62,7 +62,13 @@ public final class Besu {
}
private static Logger setupLogging() {
InternalLoggerFactory.setDefaultFactory(Log4J2LoggerFactory.INSTANCE);
try {
InternalLoggerFactory.setDefaultFactory(Log4J2LoggerFactory.INSTANCE);
} catch (Throwable t) {
System.out.printf(
"Could not set netty log4j logger factory: %s - %s%n",
t.getClass().getSimpleName(), t.getMessage());
}
try {
System.setProperty(
"vertx.logger-delegate-factory-class-name",
@ -70,10 +76,10 @@ public final class Besu {
System.setProperty(
"log4j.configurationFactory", BesuLoggingConfigurationFactory.class.getName());
System.setProperty("log4j.skipJansi", String.valueOf(false));
} catch (SecurityException e) {
System.out.println(
"Could not set logging system property as the security manager prevented it:"
+ e.getMessage());
} catch (Throwable t) {
System.out.printf(
"Could not set logging system property: %s - %s%n",
t.getClass().getSimpleName(), t.getMessage());
}
final Logger logger = LoggerFactory.getLogger(Besu.class);
Thread.setDefaultUncaughtExceptionHandler(slf4jExceptionHandler(logger));

@ -67,6 +67,7 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.api.query.PrivacyQueries;
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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
@ -762,11 +763,7 @@ public class RunnerBuilder {
.getBlockchain()
.observeBlockAdded(
blockAddedEvent -> {
if (protocolSchedule
.streamMilestoneBlocks()
.anyMatch(
blockNumber ->
blockNumber == blockAddedEvent.getBlock().getHeader().getNumber())) {
if (protocolSchedule.isOnMilestoneBoundary(blockAddedEvent.getBlock().getHeader())) {
network.updateNodeRecord();
}
});
@ -796,7 +793,8 @@ public class RunnerBuilder {
.build();
vertx.deployVerticle(filterManager);
createPrivateTransactionObserver(filterManager, privacyParameters);
createPrivateTransactionObserver(
filterManager, privacyParameters, context.getBlockchain().getGenesisBlockHeader());
final P2PNetwork peerNetwork = networkRunner.getNetwork();
@ -1032,7 +1030,8 @@ public class RunnerBuilder {
DefaultAuthenticationService.create(vertx, webSocketConfiguration),
metricsSystem));
createPrivateTransactionObserver(subscriptionManager, privacyParameters);
createPrivateTransactionObserver(
subscriptionManager, privacyParameters, context.getBlockchain().getGenesisBlockHeader());
}
final Optional<MetricsService> metricsService =
@ -1344,7 +1343,8 @@ public class RunnerBuilder {
private void createPrivateTransactionObserver(
final PrivateTransactionObserver privateTransactionObserver,
final PrivacyParameters privacyParameters) {
final PrivacyParameters privacyParameters,
final BlockHeader genesisBlockHeader) {
// register privateTransactionObserver as observer of events fired by the flexible precompile.
if (privacyParameters.isFlexiblePrivacyGroupsEnabled()
&& privacyParameters.isMultiTenancyEnabled()) {
@ -1352,9 +1352,10 @@ public class RunnerBuilder {
(FlexiblePrivacyPrecompiledContract)
besuController
.getProtocolSchedule()
.getByBlockNumber(1)
.getByBlockHeader(genesisBlockHeader)
.getPrecompileContractRegistry()
.get(FLEXIBLE_PRIVACY);
flexiblePrivacyPrecompiledContract.addPrivateTransactionObserver(privateTransactionObserver);
}
}

@ -186,7 +186,7 @@ import org.hyperledger.besu.services.SecurityModuleServiceImpl;
import org.hyperledger.besu.services.StorageServiceImpl;
import org.hyperledger.besu.services.kvstore.InMemoryStoragePlugin;
import org.hyperledger.besu.util.InvalidConfigurationException;
import org.hyperledger.besu.util.Log4j2ConfiguratorUtil;
import org.hyperledger.besu.util.LogConfigurator;
import org.hyperledger.besu.util.NetworkUtility;
import org.hyperledger.besu.util.PermissioningConfigurationValidator;
import org.hyperledger.besu.util.number.Fraction;
@ -240,7 +240,6 @@ import net.consensys.quorum.mainnet.launcher.LauncherManager;
import net.consensys.quorum.mainnet.launcher.config.ImmutableLauncherConfig;
import net.consensys.quorum.mainnet.launcher.exception.LauncherException;
import net.consensys.quorum.mainnet.launcher.util.ParseArgsHelper;
import org.apache.logging.log4j.Level;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;
import org.slf4j.Logger;
@ -1313,7 +1312,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
names = {"--rpc-max-logs-range"},
description =
"Specifies the maximum number of blocks to retrieve logs from via RPC. Must be >=0. 0 specifies no limit (default: ${DEFAULT-VALUE})")
private final Long rpcMaxLogsRange = 1000L;
private final Long rpcMaxLogsRange = 5000L;
@Mixin private P2PTLSConfigOptions p2pTLSConfigOptions;
@ -1440,7 +1439,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
* @param args arguments to Besu command
* @return success or failure exit code.
*/
@VisibleForTesting
public int parse(
final IExecutionStrategy resultHandler,
final BesuParameterExceptionHandler parameterExceptionHandler,
@ -1553,7 +1551,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private void registerConverters() {
commandLine.registerConverter(Address.class, Address::fromHexStringStrict);
commandLine.registerConverter(Bytes.class, Bytes::fromHexString);
commandLine.registerConverter(Level.class, Level::valueOf);
commandLine.registerConverter(MetricsProtocol.class, MetricsProtocol::fromString);
commandLine.registerConverter(UInt256.class, (arg) -> UInt256.valueOf(new BigInteger(arg)));
commandLine.registerConverter(Wei.class, (arg) -> Wei.of(Long.parseUnsignedLong(arg)));
@ -1796,14 +1793,14 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
*/
public void configureLogging(final boolean announce) {
// To change the configuration if color was enabled/disabled
Log4j2ConfiguratorUtil.reconfigure();
LogConfigurator.reconfigure();
// set log level per CLI flags
final Level logLevel = loggingLevelOption.getLogLevel();
final String logLevel = loggingLevelOption.getLogLevel();
if (logLevel != null) {
if (announce) {
System.out.println("Setting logging level to " + logLevel.name());
System.out.println("Setting logging level to " + logLevel);
}
Log4j2ConfiguratorUtil.setAllLevels("", logLevel);
LogConfigurator.setLevel("", logLevel);
}
}
@ -3109,7 +3106,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
try {
besuPluginContext.stopPlugins();
runner.close();
Log4j2ConfiguratorUtil.shutdown();
LogConfigurator.shutdown();
} catch (final Exception e) {
logger.error("Failed to stop Besu");
}
@ -3306,7 +3303,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
*
* @return instance of BesuParameterExceptionHandler
*/
@VisibleForTesting
public BesuParameterExceptionHandler parameterExceptionHandler() {
return new BesuParameterExceptionHandler(this::getLogLevel);
}
@ -3454,7 +3450,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
@VisibleForTesting
Level getLogLevel() {
String getLogLevel() {
return loggingLevelOption.getLogLevel();
}

@ -17,21 +17,20 @@ package org.hyperledger.besu.cli.error;
import java.io.PrintWriter;
import java.util.function.Supplier;
import org.apache.logging.log4j.Level;
import picocli.CommandLine;
import picocli.CommandLine.Model.CommandSpec;
/** The custom parameter exception handler for Besu PicoCLI. */
public class BesuParameterExceptionHandler implements CommandLine.IParameterExceptionHandler {
private final Supplier<Level> levelSupplier;
private final Supplier<String> levelSupplier;
/**
* Instantiates a new Besu parameter exception handler.
*
* @param levelSupplier the logging level supplier
*/
public BesuParameterExceptionHandler(final Supplier<Level> levelSupplier) {
public BesuParameterExceptionHandler(final Supplier<String> levelSupplier) {
this.levelSupplier = levelSupplier;
}
@ -39,8 +38,9 @@ public class BesuParameterExceptionHandler implements CommandLine.IParameterExce
public int handleParseException(final CommandLine.ParameterException ex, final String[] args) {
final CommandLine cmd = ex.getCommandLine();
final PrintWriter err = cmd.getErr();
final Level logLevel = levelSupplier.get();
if (logLevel != null && Level.DEBUG.isMoreSpecificThan(logLevel)) {
final String logLevel = levelSupplier.get();
if (logLevel != null
&& (logLevel.equals("DEBUG") || logLevel.equals("TRACE") || logLevel.equals("ALL"))) {
ex.printStackTrace(err);
} else {
err.println(ex.getMessage());

@ -16,7 +16,6 @@ package org.hyperledger.besu.cli.options.stable;
import java.util.Set;
import org.apache.logging.log4j.Level;
import picocli.CommandLine;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Spec;
@ -38,7 +37,7 @@ public class LoggingLevelOption {
/** The Picocli CommandSpec. Visible for testing. Injected by Picocli framework at runtime. */
@Spec CommandSpec spec;
private Level logLevel;
private String logLevel;
/**
* Sets log level.
@ -52,9 +51,9 @@ public class LoggingLevelOption {
public void setLogLevel(final String logLevel) {
if ("FATAL".equalsIgnoreCase(logLevel)) {
System.out.println("FATAL level is deprecated");
this.logLevel = Level.ERROR;
this.logLevel = "ERROR";
} else if (ACCEPTED_VALUES.contains(logLevel.toUpperCase())) {
this.logLevel = Level.getLevel(logLevel.toUpperCase());
this.logLevel = logLevel.toUpperCase();
} else {
throw new CommandLine.ParameterException(
spec.commandLine(), "Unknown logging value: " + logLevel);
@ -66,7 +65,7 @@ public class LoggingLevelOption {
*
* @return the log level
*/
public Level getLogLevel() {
public String getLogLevel() {
return logLevel;
}
}

@ -24,12 +24,11 @@ import org.hyperledger.besu.cli.util.VersionProvider;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.retesteth.RetestethConfiguration;
import org.hyperledger.besu.ethereum.retesteth.RetestethService;
import org.hyperledger.besu.util.Log4j2ConfiguratorUtil;
import org.hyperledger.besu.util.LogConfigurator;
import java.net.InetAddress;
import java.nio.file.Path;
import org.apache.logging.log4j.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine.Command;
@ -106,10 +105,10 @@ public class RetestethSubCommand implements Runnable {
private void prepareLogging() {
// set log level per CLI flags
final Level logLevel = loggingLevelOption.getLogLevel();
final String logLevel = loggingLevelOption.getLogLevel();
if (logLevel != null) {
System.out.println("Setting logging level to " + logLevel.name());
Log4j2ConfiguratorUtil.setAllLevels("", logLevel);
System.out.println("Setting logging level to " + logLevel);
LogConfigurator.setLevel("", logLevel);
}
}
@ -132,7 +131,7 @@ public class RetestethSubCommand implements Runnable {
() -> {
try {
retestethService.close();
Log4j2ConfiguratorUtil.shutdown();
LogConfigurator.shutdown();
} catch (final Exception e) {
LOG.error("Failed to stop Besu Retesteth");
}

@ -30,9 +30,9 @@ import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateArchive;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.BlockchainStorage;
import org.hyperledger.besu.ethereum.chain.ChainDataPruner;
@ -658,6 +658,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
createAdditionalJsonRpcMethodFactory(protocolContext);
final List<Closeable> closeables = new ArrayList<>();
closeables.add(protocolContext.getWorldStateArchive());
closeables.add(storageProvider);
if (privacyParameters.getPrivateStorageProvider() != null) {
closeables.add(privacyParameters.getPrivateStorageProvider());
@ -934,17 +935,16 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
new SnapProtocolManager(peerValidators, ethPeers, snapMessages, worldStateArchive));
}
private WorldStateArchive createWorldStateArchive(
WorldStateArchive createWorldStateArchive(
final WorldStateStorage worldStateStorage,
final Blockchain blockchain,
final CachedMerkleTrieLoader cachedMerkleTrieLoader) {
switch (dataStorageConfiguration.getDataStorageFormat()) {
case BONSAI:
return new BonsaiWorldStateArchive(
return new BonsaiWorldStateProvider(
(BonsaiWorldStateKeyValueStorage) worldStateStorage,
blockchain,
Optional.of(dataStorageConfiguration.getBonsaiMaxLayersToLoad()),
dataStorageConfiguration.useBonsaiSnapshots(),
cachedMerkleTrieLoader);
case FOREST:

@ -118,8 +118,9 @@ public class ForkIdsNetworkConfigTest {
new ForkId(Bytes.ofUnsignedInt(0xeb440f6L), 12965000L),
new ForkId(Bytes.ofUnsignedInt(0xb715077dL), 13773000L),
new ForkId(Bytes.ofUnsignedInt(0x20c327fcL), 15050000L),
new ForkId(Bytes.ofUnsignedInt(0xf0afd0e3L), 0L),
new ForkId(Bytes.ofUnsignedInt(0xf0afd0e3L), 0L))
new ForkId(Bytes.ofUnsignedInt(0xf0afd0e3L), 1681338455L),
new ForkId(Bytes.ofUnsignedInt(0xdce96c2dL), 0L),
new ForkId(Bytes.ofUnsignedInt(0xdce96c2dL), 0L))
},
new Object[] {
NetworkName.MORDOR,

@ -49,6 +49,7 @@ import org.hyperledger.besu.ethereum.chain.DefaultBlockchain;
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.BlockHeader;
import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
@ -63,6 +64,7 @@ import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.nat.NatMethod;
@ -74,7 +76,6 @@ import org.hyperledger.besu.services.RpcEndpointServiceImpl;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.stream.Stream;
import io.vertx.core.Vertx;
import org.apache.tuweni.bytes.Bytes;
@ -97,6 +98,7 @@ public final class RunnerBuilderTest {
@Mock BesuController besuController;
@Mock ProtocolSchedule protocolSchedule;
@Mock ProtocolContext protocolContext;
@Mock WorldStateArchive worldstateArchive;
@Mock Vertx vertx;
private NodeKey nodeKey;
@ -124,7 +126,7 @@ public final class RunnerBuilderTest {
final Block block = mock(Block.class);
when(blockchain.getGenesisBlock()).thenReturn(block);
when(block.getHash()).thenReturn(Hash.ZERO);
when(protocolContext.getWorldStateArchive()).thenReturn(worldstateArchive);
when(besuController.getProtocolManager()).thenReturn(ethProtocolManager);
when(besuController.getSubProtocolConfiguration()).thenReturn(subProtocolConfiguration);
when(besuController.getProtocolContext()).thenReturn(protocolContext);
@ -214,7 +216,7 @@ public final class RunnerBuilderTest {
.build();
runner.startEthereumMainLoop();
when(protocolSchedule.streamMilestoneBlocks()).thenAnswer(__ -> Stream.of(1L, 2L));
when(protocolSchedule.isOnMilestoneBoundary(any(BlockHeader.class))).thenReturn(true);
for (int i = 0; i < 2; ++i) {
final Block block =

@ -123,7 +123,6 @@ import com.google.common.io.Resources;
import io.vertx.core.json.JsonObject;
import org.apache.commons.io.FileUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.logging.log4j.Level;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.toml.Toml;
import org.apache.tuweni.toml.TomlParseResult;
@ -258,7 +257,7 @@ public class BesuCommandTest extends CommandTestAbstract {
verify(mockRunnerBuilder).metricsConfiguration(eq(DEFAULT_METRICS_CONFIGURATION));
verify(mockRunnerBuilder).ethNetworkConfig(ethNetworkArg.capture());
verify(mockRunnerBuilder).autoLogBloomCaching(eq(true));
verify(mockRunnerBuilder).rpcMaxLogsRange(eq(1000L));
verify(mockRunnerBuilder).rpcMaxLogsRange(eq(5000L));
verify(mockRunnerBuilder).build();
verify(mockControllerBuilderFactory)
@ -4979,7 +4978,7 @@ public class BesuCommandTest extends CommandTestAbstract {
public void logLevelIsSetByLoggingOption() {
final TestBesuCommand command = parseCommand("--logging", "WARN");
assertThat(command.getLogLevel()).isEqualTo(Level.WARN);
assertThat(command.getLogLevel()).isEqualTo("WARN");
}
@Test

@ -39,7 +39,7 @@ public class LoggingLevelOptionTest {
@Test
public void fatalLevelEqualsToError() {
levelOption.setLogLevel("fatal");
assertThat(levelOption.getLogLevel()).isEqualTo(Level.ERROR);
assertThat(levelOption.getLogLevel()).isEqualTo("ERROR");
}
@Test
@ -49,7 +49,7 @@ public class LoggingLevelOptionTest {
.forEach(
level -> {
levelOption.setLogLevel(level.name());
assertThat(levelOption.getLogLevel()).isEqualTo(level);
assertThat(levelOption.getLogLevel()).isEqualTo(level.name());
});
}

@ -16,8 +16,10 @@ package org.hyperledger.besu.controller;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ -29,7 +31,10 @@ import org.hyperledger.besu.config.Keccak256ConfigOptions;
import org.hyperledger.besu.crypto.NodeKey;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
@ -43,11 +48,11 @@ import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction;
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
import java.math.BigInteger;
@ -61,6 +66,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
@ -85,6 +91,7 @@ public class BesuControllerBuilderTest {
@Mock StorageProvider storageProvider;
@Mock GasLimitCalculator gasLimitCalculator;
@Mock WorldStateStorage worldStateStorage;
@Mock WorldStateArchive worldStateArchive;
@Mock BonsaiWorldStateKeyValueStorage bonsaiWorldStateStorage;
@Mock WorldStatePreimageStorage worldStatePreimageStorage;
@ -132,14 +139,7 @@ public class BesuControllerBuilderTest {
when(worldStatePreimageStorage.updater())
.thenReturn(mock(WorldStatePreimageStorage.Updater.class));
when(worldStateStorage.updater()).thenReturn(mock(WorldStateStorage.Updater.class));
BonsaiWorldStateKeyValueStorage.BonsaiUpdater bonsaiUpdater =
mock(BonsaiWorldStateKeyValueStorage.BonsaiUpdater.class);
when(bonsaiUpdater.getTrieLogStorageTransaction())
.thenReturn(mock(KeyValueStorageTransaction.class));
when(bonsaiUpdater.getTrieBranchStorageTransaction())
.thenReturn(mock(KeyValueStorageTransaction.class));
when(bonsaiWorldStateStorage.updater()).thenReturn(bonsaiUpdater);
besuControllerBuilder = visitWithMockConfigs(new MainnetBesuControllerBuilder());
besuControllerBuilder = spy(visitWithMockConfigs(new MainnetBesuControllerBuilder()));
}
BesuControllerBuilder visitWithMockConfigs(final BesuControllerBuilder builder) {
@ -162,6 +162,13 @@ public class BesuControllerBuilderTest {
@Test
public void shouldDisablePruningIfBonsaiIsEnabled() {
BonsaiWorldState mockWorldState = mock(BonsaiWorldState.class, Answers.RETURNS_DEEP_STUBS);
doReturn(worldStateArchive)
.when(besuControllerBuilder)
.createWorldStateArchive(
any(WorldStateStorage.class), any(Blockchain.class), any(CachedMerkleTrieLoader.class));
doReturn(mockWorldState).when(worldStateArchive).getMutable();
when(storageProvider.createWorldStateStorage(DataStorageFormat.BONSAI))
.thenReturn(bonsaiWorldStateStorage);
besuControllerBuilder

@ -121,6 +121,8 @@ public class MergeBesuControllerBuilderTest {
.thenReturn(
new KeyValueStoragePrefixedKeyBlockchainStorage(
new InMemoryKeyValueStorage(), new MainnetBlockHeaderFunctions()));
when(storageProvider.getStorageBySegmentIdentifier(any()))
.thenReturn(new InMemoryKeyValueStorage());
when(synchronizerConfiguration.getDownloaderParallelism()).thenReturn(1);
when(synchronizerConfiguration.getTransactionsParallelism()).thenReturn(1);
when(synchronizerConfiguration.getComputationParallelism()).thenReturn(1);

@ -36,10 +36,6 @@ public class DefaultDiscoveryConfiguration {
// Ethereum Foundation Bootnodes
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303", // Singapore AWS
"enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303", // Virginia AWS
"enode://8499da03c47d637b20eee24eec3c356c9a2e6148d6fe25ca195c7949ab8ec2c03e3556126b0d7ed644675e78c4318b08691b7b57de10e5f0d40d05b09238fa0a@52.187.207.27:30303", // Australia Azure
"enode://103858bdb88756c71f15e9b5e09b56dc1be52f0a5021d46301dbbfb7e130029cc9d0d6f73f693bc29b665770fff7da4d34f3c6379fe12721b5d7a0bcb5ca1fc1@191.234.162.198:30303", // Brazil Azure
"enode://715171f50508aba88aecd1250af392a45a330af91d7b90701c436b618c86aaa1589c9184561907bebbb56439b8f8787bc01f49a7c77276c58c1b09822d75e8e8@52.231.165.108:30303", // South Korea Azure
"enode://5d6d7cd20d6da4bb83a1d28cadb5d409b64edf314c0335df658c1a54e32c7c4a7ab7823d57c39b6a757556e68ff1df17c748b698544a55cb488b52479a92b60f@104.42.217.25:30303", // West US Azure
"enode://2b252ab6a1d0f971d9722cb839a42cb81db019ba44c08754628ab4a823487071b5695317c8ccd085219c3a03af063495b2f1da8d18218da2d6a82981b45e6ffc@65.108.70.101:30303", // Helsinki Hetzner
"enode://4aeb4ab6c14b23e2c4cfdce879c04b0748a20d8e9b59e25ded2a08143e265c6c25936e74cbc8e641e3312ca288673d91f2f93f8e277de3cfa444ecdaaf982052@157.90.35.166:30303", // Falkenstein Hetzner

@ -131,8 +131,7 @@ public class BesuEventsImplTest {
.thenReturn(ValidationResult.valid());
when(mockTransactionValidator.validateForSender(any(), any(), any()))
.thenReturn(ValidationResult.valid());
when(mockWorldState.copy()).thenReturn(mockWorldState);
when(mockWorldStateArchive.getMutable(any(), any(), anyBoolean()))
when(mockWorldStateArchive.getMutable(any(), anyBoolean()))
.thenReturn(Optional.of(mockWorldState));
blockBroadcaster = new BlockBroadcaster(mockEthContext);

@ -34,11 +34,11 @@ import java.util.List;
import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class LocalPermissioningConfigurationValidatorTest {
static final String PERMISSIONING_CONFIG_SEPOLIA_BOOTNODES =
@ -50,7 +50,7 @@ public class LocalPermissioningConfigurationValidatorTest {
"/permissioning_config_unknown_hostname.toml";
@Test
public void spoliaWithNodesAllowlistOptionWhichDoesIncludeRopstenBootnodesMustNotError()
public void sepoliaWithNodesAllowlistOptionWhichDoesIncludeRopstenBootnodesMustNotError()
throws Exception {
EthNetworkConfig ethNetworkConfig = EthNetworkConfig.getNetworkConfig(NetworkName.SEPOLIA);

@ -31,12 +31,12 @@ import org.hyperledger.besu.ethereum.privacy.storage.migration.PrivateStorageMig
import org.hyperledger.besu.ethereum.privacy.storage.migration.PrivateStorageMigrationException;
import org.hyperledger.besu.ethereum.privacy.storage.migration.PrivateStorageMigrationService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PrivateStorageMigrationServiceTest {
@Mock private PrivateStateStorage privateStateStorage;

@ -22,11 +22,11 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class StringUtilsTest {
@Test

@ -16,25 +16,6 @@
"terminalTotalDifficulty": 58750000000000000000000,
"ethash": {
},
"discovery": {
"dns": "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net",
"bootnodes": [
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303",
"enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303",
"enode://8499da03c47d637b20eee24eec3c356c9a2e6148d6fe25ca195c7949ab8ec2c03e3556126b0d7ed644675e78c4318b08691b7b57de10e5f0d40d05b09238fa0a@52.187.207.27:30303",
"enode://103858bdb88756c71f15e9b5e09b56dc1be52f0a5021d46301dbbfb7e130029cc9d0d6f73f693bc29b665770fff7da4d34f3c6379fe12721b5d7a0bcb5ca1fc1@191.234.162.198:30303",
"enode://715171f50508aba88aecd1250af392a45a330af91d7b90701c436b618c86aaa1589c9184561907bebbb56439b8f8787bc01f49a7c77276c58c1b09822d75e8e8@52.231.165.108:30303",
"enode://5d6d7cd20d6da4bb83a1d28cadb5d409b64edf314c0335df658c1a54e32c7c4a7ab7823d57c39b6a757556e68ff1df17c748b698544a55cb488b52479a92b60f@104.42.217.25:30303",
"enode://2b252ab6a1d0f971d9722cb839a42cb81db019ba44c08754628ab4a823487071b5695317c8ccd085219c3a03af063495b2f1da8d18218da2d6a82981b45e6ffc@65.108.70.101:30303",
"enode://4aeb4ab6c14b23e2c4cfdce879c04b0748a20d8e9b59e25ded2a08143e265c6c25936e74cbc8e641e3312ca288673d91f2f93f8e277de3cfa444ecdaaf982052@157.90.35.166:30303",
"enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303",
"enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99@13.93.211.84:30303",
"enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d@191.235.84.50:30303",
"enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303",
"enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303",
"enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"
]
},
"checkpoint": {
"hash": "0x186642d6084eb7799cb01c7eb69c1a7f3b2c32cd141e62d309f30081a1ea3c91",
"number": 16015954,

@ -16,25 +16,6 @@
"terminalTotalDifficulty": 0,
"ethash": {
},
"discovery": {
"dns": "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net",
"bootnodes": [
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303",
"enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303",
"enode://8499da03c47d637b20eee24eec3c356c9a2e6148d6fe25ca195c7949ab8ec2c03e3556126b0d7ed644675e78c4318b08691b7b57de10e5f0d40d05b09238fa0a@52.187.207.27:30303",
"enode://103858bdb88756c71f15e9b5e09b56dc1be52f0a5021d46301dbbfb7e130029cc9d0d6f73f693bc29b665770fff7da4d34f3c6379fe12721b5d7a0bcb5ca1fc1@191.234.162.198:30303",
"enode://715171f50508aba88aecd1250af392a45a330af91d7b90701c436b618c86aaa1589c9184561907bebbb56439b8f8787bc01f49a7c77276c58c1b09822d75e8e8@52.231.165.108:30303",
"enode://5d6d7cd20d6da4bb83a1d28cadb5d409b64edf314c0335df658c1a54e32c7c4a7ab7823d57c39b6a757556e68ff1df17c748b698544a55cb488b52479a92b60f@104.42.217.25:30303",
"enode://2b252ab6a1d0f971d9722cb839a42cb81db019ba44c08754628ab4a823487071b5695317c8ccd085219c3a03af063495b2f1da8d18218da2d6a82981b45e6ffc@65.108.70.101:30303",
"enode://4aeb4ab6c14b23e2c4cfdce879c04b0748a20d8e9b59e25ded2a08143e265c6c25936e74cbc8e641e3312ca288673d91f2f93f8e277de3cfa444ecdaaf982052@157.90.35.166:30303",
"enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303",
"enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99@13.93.211.84:30303",
"enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d@191.235.84.50:30303",
"enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303",
"enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303",
"enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"
]
},
"checkpoint": {
"hash": "0x186642d6084eb7799cb01c7eb69c1a7f3b2c32cd141e62d309f30081a1ea3c91",
"number": 1,

@ -15,25 +15,6 @@
"grayGlacierBlock": 15050000,
"ethash": {
},
"discovery": {
"dns": "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net",
"bootnodes": [
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303",
"enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303",
"enode://8499da03c47d637b20eee24eec3c356c9a2e6148d6fe25ca195c7949ab8ec2c03e3556126b0d7ed644675e78c4318b08691b7b57de10e5f0d40d05b09238fa0a@52.187.207.27:30303",
"enode://103858bdb88756c71f15e9b5e09b56dc1be52f0a5021d46301dbbfb7e130029cc9d0d6f73f693bc29b665770fff7da4d34f3c6379fe12721b5d7a0bcb5ca1fc1@191.234.162.198:30303",
"enode://715171f50508aba88aecd1250af392a45a330af91d7b90701c436b618c86aaa1589c9184561907bebbb56439b8f8787bc01f49a7c77276c58c1b09822d75e8e8@52.231.165.108:30303",
"enode://5d6d7cd20d6da4bb83a1d28cadb5d409b64edf314c0335df658c1a54e32c7c4a7ab7823d57c39b6a757556e68ff1df17c748b698544a55cb488b52479a92b60f@104.42.217.25:30303",
"enode://2b252ab6a1d0f971d9722cb839a42cb81db019ba44c08754628ab4a823487071b5695317c8ccd085219c3a03af063495b2f1da8d18218da2d6a82981b45e6ffc@65.108.70.101:30303",
"enode://4aeb4ab6c14b23e2c4cfdce879c04b0748a20d8e9b59e25ded2a08143e265c6c25936e74cbc8e641e3312ca288673d91f2f93f8e277de3cfa444ecdaaf982052@157.90.35.166:30303",
"enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303",
"enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99@13.93.211.84:30303",
"enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d@191.235.84.50:30303",
"enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303",
"enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303",
"enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"
]
},
"checkpoint": {
"hash": "0x186642d6084eb7799cb01c7eb69c1a7f3b2c32cd141e62d309f30081a1ea3c91",
"number": 16015954,

@ -16,25 +16,6 @@
"terminalTotalDifficulty": 10,
"ethash": {
},
"discovery": {
"dns": "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net",
"bootnodes": [
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303",
"enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303",
"enode://8499da03c47d637b20eee24eec3c356c9a2e6148d6fe25ca195c7949ab8ec2c03e3556126b0d7ed644675e78c4318b08691b7b57de10e5f0d40d05b09238fa0a@52.187.207.27:30303",
"enode://103858bdb88756c71f15e9b5e09b56dc1be52f0a5021d46301dbbfb7e130029cc9d0d6f73f693bc29b665770fff7da4d34f3c6379fe12721b5d7a0bcb5ca1fc1@191.234.162.198:30303",
"enode://715171f50508aba88aecd1250af392a45a330af91d7b90701c436b618c86aaa1589c9184561907bebbb56439b8f8787bc01f49a7c77276c58c1b09822d75e8e8@52.231.165.108:30303",
"enode://5d6d7cd20d6da4bb83a1d28cadb5d409b64edf314c0335df658c1a54e32c7c4a7ab7823d57c39b6a757556e68ff1df17c748b698544a55cb488b52479a92b60f@104.42.217.25:30303",
"enode://2b252ab6a1d0f971d9722cb839a42cb81db019ba44c08754628ab4a823487071b5695317c8ccd085219c3a03af063495b2f1da8d18218da2d6a82981b45e6ffc@65.108.70.101:30303",
"enode://4aeb4ab6c14b23e2c4cfdce879c04b0748a20d8e9b59e25ded2a08143e265c6c25936e74cbc8e641e3312ca288673d91f2f93f8e277de3cfa444ecdaaf982052@157.90.35.166:30303",
"enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303",
"enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99@13.93.211.84:30303",
"enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d@191.235.84.50:30303",
"enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303",
"enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303",
"enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"
]
},
"checkpoint": {
"hash": "0x186642d6084eb7799cb01c7eb69c1a7f3b2c32cd141e62d309f30081a1ea3c91",
"number": 3,

@ -16,25 +16,6 @@
"terminalTotalDifficulty": 58750000000000000000000,
"ethash": {
},
"discovery": {
"dns": "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@all.mainnet.ethdisco.net",
"bootnodes": [
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303",
"enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303",
"enode://8499da03c47d637b20eee24eec3c356c9a2e6148d6fe25ca195c7949ab8ec2c03e3556126b0d7ed644675e78c4318b08691b7b57de10e5f0d40d05b09238fa0a@52.187.207.27:30303",
"enode://103858bdb88756c71f15e9b5e09b56dc1be52f0a5021d46301dbbfb7e130029cc9d0d6f73f693bc29b665770fff7da4d34f3c6379fe12721b5d7a0bcb5ca1fc1@191.234.162.198:30303",
"enode://715171f50508aba88aecd1250af392a45a330af91d7b90701c436b618c86aaa1589c9184561907bebbb56439b8f8787bc01f49a7c77276c58c1b09822d75e8e8@52.231.165.108:30303",
"enode://5d6d7cd20d6da4bb83a1d28cadb5d409b64edf314c0335df658c1a54e32c7c4a7ab7823d57c39b6a757556e68ff1df17c748b698544a55cb488b52479a92b60f@104.42.217.25:30303",
"enode://2b252ab6a1d0f971d9722cb839a42cb81db019ba44c08754628ab4a823487071b5695317c8ccd085219c3a03af063495b2f1da8d18218da2d6a82981b45e6ffc@65.108.70.101:30303",
"enode://4aeb4ab6c14b23e2c4cfdce879c04b0748a20d8e9b59e25ded2a08143e265c6c25936e74cbc8e641e3312ca288673d91f2f93f8e277de3cfa444ecdaaf982052@157.90.35.166:30303",
"enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303",
"enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99@13.93.211.84:30303",
"enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d@191.235.84.50:30303",
"enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303",
"enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303",
"enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"
]
},
"checkpoint": {
"hash": "0x186642d6084eb7799cb01c7eb69c1a7f3b2c32cd141e62d309f30081a1ea3c91",
"number": 16015954,

@ -28,8 +28,21 @@ plugins {
id 'me.champeau.jmh' version '0.6.6' apply false
id 'net.ltgt.errorprone' version '2.0.2'
id 'maven-publish'
id 'org.sonarqube' version '3.4.0.2513'
}
sonarqube {
properties {
property "sonar.projectKey", "hyperledger_besu"
property "sonar.organization", "hyperledger"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.coverage.jacoco.xmlReportPaths", "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
property "sonar.coverage.exclusions", "acceptance-tests/**/*"
}
}
project.tasks["sonarqube"].dependsOn "jacocoRootReport"
if (!JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
throw new GradleException("Java 17 or later is required to build Besu.\n" +
" Detected version ${JavaVersion.current()}")
@ -862,7 +875,7 @@ task checkSpdxHeader(type: CheckSpdxHeader) {
"(.*/.idea/.*)",
"(.*/out/.*)",
"(.*/build/.*)",
"(.*/src/[^/]+/generated/.*)",
"(.*/src/[^/]+/generated/.*)"
].join("|")
}

@ -14,6 +14,7 @@
"arrowGlacierBlock": 13773000,
"grayGlacierBlock": 15050000,
"terminalTotalDifficulty": 58750000000000000000000,
"shanghaiTime": 1681338455,
"ethash": {
},
"discovery": {
@ -21,10 +22,6 @@
"bootnodes": [
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303",
"enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303",
"enode://8499da03c47d637b20eee24eec3c356c9a2e6148d6fe25ca195c7949ab8ec2c03e3556126b0d7ed644675e78c4318b08691b7b57de10e5f0d40d05b09238fa0a@52.187.207.27:30303",
"enode://103858bdb88756c71f15e9b5e09b56dc1be52f0a5021d46301dbbfb7e130029cc9d0d6f73f693bc29b665770fff7da4d34f3c6379fe12721b5d7a0bcb5ca1fc1@191.234.162.198:30303",
"enode://715171f50508aba88aecd1250af392a45a330af91d7b90701c436b618c86aaa1589c9184561907bebbb56439b8f8787bc01f49a7c77276c58c1b09822d75e8e8@52.231.165.108:30303",
"enode://5d6d7cd20d6da4bb83a1d28cadb5d409b64edf314c0335df658c1a54e32c7c4a7ab7823d57c39b6a757556e68ff1df17c748b698544a55cb488b52479a92b60f@104.42.217.25:30303",
"enode://2b252ab6a1d0f971d9722cb839a42cb81db019ba44c08754628ab4a823487071b5695317c8ccd085219c3a03af063495b2f1da8d18218da2d6a82981b45e6ffc@65.108.70.101:30303",
"enode://4aeb4ab6c14b23e2c4cfdce879c04b0748a20d8e9b59e25ded2a08143e265c6c25936e74cbc8e641e3312ca288673d91f2f93f8e277de3cfa444ecdaaf982052@157.90.35.166:30303",
"enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303",

@ -49,7 +49,7 @@ public class CombinedProtocolScheduleFactory {
Optional.ofNullable(forkSpecs.higher(spec)).map(ForkSpec::getBlock);
protocolSchedule.getScheduledProtocolSpecs().stream()
.filter(protocolSpecMatchesConsensusBlockRange(spec.getBlock(), endBlock))
.forEach(s -> combinedProtocolSchedule.putMilestone(s.getBlock(), s.getSpec()));
.forEach(s -> combinedProtocolSchedule.putMilestone(s.milestone(), s.spec()));
// When moving to a new consensus mechanism we want to use the last milestone but created by
// our consensus mechanism's BesuControllerBuilder so any additional rules are applied
@ -64,7 +64,7 @@ public class CombinedProtocolScheduleFactory {
private Predicate<ScheduledProtocolSpec> protocolSpecMatchesConsensusBlockRange(
final long startBlock, final Optional<Long> endBlock) {
return scheduledProtocolSpec ->
scheduledProtocolSpec.getBlock() >= startBlock
&& endBlock.map(b -> scheduledProtocolSpec.getBlock() < b).orElse(true);
scheduledProtocolSpec.milestone() >= startBlock
&& endBlock.map(b -> scheduledProtocolSpec.milestone() < b).orElse(true);
}
}

@ -16,6 +16,7 @@ package org.hyperledger.besu.consensus.merge;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
@ -24,11 +25,13 @@ import org.hyperledger.besu.ethereum.mainnet.HeaderBasedProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.TimestampSchedule;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import java.math.BigInteger;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.slf4j.Logger;
@ -211,6 +214,20 @@ public class TransitionProtocolSchedule implements ProtocolSchedule {
return Stream.concat(milestoneBlockNumbers, timestampSchedule.streamMilestoneBlocks());
}
@Override
public boolean anyMatch(final Predicate<ScheduledProtocolSpec> predicate) {
return timestampSchedule.anyMatch(predicate)
|| transitionUtils.dispatchFunctionAccordingToMergeState(
schedule -> schedule.anyMatch(predicate));
}
@Override
public boolean isOnMilestoneBoundary(final BlockHeader blockHeader) {
return timestampSchedule.isOnMilestoneBoundary(blockHeader)
|| transitionUtils.dispatchFunctionAccordingToMergeState(
schedule -> schedule.isOnMilestoneBoundary(blockHeader));
}
/**
* Gets chain id.
*

@ -224,6 +224,68 @@ public class TransitionProtocolScheduleTest {
verifyPostMergeProtocolScheduleReturnedUsingBlockHeader();
}
@Test
public void anyMatch_usesTimestampSchedule() {
when(timestampSchedule.anyMatch(any())).thenReturn(true);
assertThat(transitionProtocolSchedule.anyMatch(__ -> true)).isTrue();
verifyNoInteractions(preMergeProtocolSchedule);
verifyNoInteractions(postMergeProtocolSchedule);
}
@Test
public void anyMatch_delegatesToPreMergeSchedule() {
when(mergeContext.isPostMerge()).thenReturn(false);
when(timestampSchedule.anyMatch(any())).thenReturn(false);
when(preMergeProtocolSchedule.anyMatch(any())).thenReturn(true);
assertThat(transitionProtocolSchedule.anyMatch(__ -> true)).isTrue();
verifyNoInteractions(postMergeProtocolSchedule);
}
@Test
public void anyMatch_delegatesToPostMergeSchedule() {
when(mergeContext.isPostMerge()).thenReturn(true);
when(timestampSchedule.anyMatch(any())).thenReturn(false);
when(postMergeProtocolSchedule.anyMatch(any())).thenReturn(true);
assertThat(transitionProtocolSchedule.anyMatch(__ -> true)).isTrue();
verifyNoInteractions(preMergeProtocolSchedule);
}
@Test
public void isOnMilestoneBoundary_usesTimestampSchedule() {
when(timestampSchedule.isOnMilestoneBoundary(any(BlockHeader.class))).thenReturn(true);
assertThat(transitionProtocolSchedule.isOnMilestoneBoundary(blockHeader)).isTrue();
verifyNoInteractions(preMergeProtocolSchedule);
verifyNoInteractions(postMergeProtocolSchedule);
}
@Test
public void isOnMilestoneBoundary_delegatesToPreMergeSchedule() {
when(mergeContext.isPostMerge()).thenReturn(false);
when(timestampSchedule.isOnMilestoneBoundary(any(BlockHeader.class))).thenReturn(false);
when(preMergeProtocolSchedule.isOnMilestoneBoundary(any(BlockHeader.class))).thenReturn(true);
assertThat(transitionProtocolSchedule.isOnMilestoneBoundary(blockHeader)).isTrue();
verifyNoInteractions(postMergeProtocolSchedule);
}
@Test
public void isOnMilestoneBoundary_delegatesToPostMergeSchedule() {
when(mergeContext.isPostMerge()).thenReturn(true);
when(timestampSchedule.isOnMilestoneBoundary(any(BlockHeader.class))).thenReturn(false);
when(postMergeProtocolSchedule.isOnMilestoneBoundary(any(BlockHeader.class))).thenReturn(true);
assertThat(transitionProtocolSchedule.isOnMilestoneBoundary(blockHeader)).isTrue();
verifyNoInteractions(preMergeProtocolSchedule);
}
private void verifyPreMergeProtocolScheduleReturnedUsingBlockNumber() {
verify(preMergeProtocolSchedule).getByBlockNumber(anyLong());
verifyNoInteractions(postMergeProtocolSchedule);

@ -41,7 +41,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
import org.hyperledger.besu.ethereum.mainnet.feemarket.LondonFeeMarket;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.util.Log4j2ConfiguratorUtil;
import org.hyperledger.besu.util.LogConfigurator;
import java.util.ArrayList;
import java.util.List;
@ -109,7 +109,7 @@ public class MergeReorgTest implements MergeGenesisConfigHelper {
@Test
public void reorgsAcrossTDDToDifferentTargetsWhenNotFinal() {
// Add N blocks to chain from genesis, where total diff is < TTD
Log4j2ConfiguratorUtil.setLevelDebug(BlockHeaderValidator.class.getName());
LogConfigurator.setLevel(BlockHeaderValidator.class.getName(), "DEBUG");
List<Block> endOfWork = subChain(genesisState.getBlock().getHeader(), 10, Difficulty.of(100L));
endOfWork.stream().forEach(this::appendBlock);
assertThat(blockchain.getChainHead().getHeight()).isEqualTo(10L);

@ -224,9 +224,9 @@ public class GraphQLDataFetchers {
ws -> {
final Account account = ws.get(addr);
if (account == null) {
return new EmptyAccountAdapter(addr);
return Optional.of(new EmptyAccountAdapter(addr));
}
return new AccountAdapter(account);
return Optional.of(new AccountAdapter(account));
})
.or(
() -> {
@ -246,9 +246,9 @@ public class GraphQLDataFetchers {
ws -> {
final Account account = ws.get(addr);
if (account == null) {
return new EmptyAccountAdapter(addr);
return Optional.of(new EmptyAccountAdapter(addr));
}
return new AccountAdapter(account);
return Optional.of(new AccountAdapter(account));
});
}
};

@ -96,7 +96,7 @@ public class BlockAdapterBase extends AdapterBase {
}
return query
.getAndMapWorldState(blockNumber, ws -> ws.get(header.getCoinbase()))
.getAndMapWorldState(blockNumber, ws -> Optional.ofNullable(ws.get(header.getCoinbase())))
.map(account -> (AdapterBase) new AccountAdapter(account))
.or(() -> Optional.of(new EmptyAccountAdapter(header.getCoinbase())));
}
@ -150,7 +150,7 @@ public class BlockAdapterBase extends AdapterBase {
bn,
ws -> {
final Address address = environment.getArgument("address");
return new AccountAdapter(ws.get(address));
return Optional.of(new AccountAdapter(ws.get(address)));
});
}

@ -64,6 +64,6 @@ public class LogAdapter extends AdapterBase {
}
return query.getAndMapWorldState(
blockNumber, ws -> new AccountAdapter(ws.get(logWithMetadata.getLogger())));
blockNumber, ws -> Optional.of(new AccountAdapter(ws.get(logWithMetadata.getLogger()))));
}
}

@ -66,7 +66,7 @@ public class PendingStateAdapter extends AdapterBase {
final Long blockNumber = dataFetchingEnvironment.getArgument("blockNumber");
final long latestBlockNumber = blockchainQuery.latestBlock().get().getHeader().getNumber();
return blockchainQuery
.getAndMapWorldState(latestBlockNumber, ws -> ws.get(addr))
.getAndMapWorldState(latestBlockNumber, ws -> Optional.ofNullable(ws.get(addr)))
.map(AccountAdapter::new);
}

@ -85,8 +85,9 @@ public class TransactionAdapter extends AdapterBase {
return query.getAndMapWorldState(
blockNumber,
mutableWorldState ->
new AccountAdapter(
mutableWorldState.get(transactionWithMetadata.getTransaction().getSender())));
Optional.of(
new AccountAdapter(
mutableWorldState.get(transactionWithMetadata.getTransaction().getSender()))));
}
public Optional<AccountAdapter> getTo(final DataFetchingEnvironment environment) {
@ -102,9 +103,7 @@ public class TransactionAdapter extends AdapterBase {
transactionWithMetadata
.getTransaction()
.getTo()
.map(address -> new AccountAdapter(address, ws.get(address)))
// safe because mapWorldState returns Optional.ofNullable
.orElse(null));
.map(address -> new AccountAdapter(address, ws.get(address))));
}
public Optional<Wei> getValue() {
@ -174,7 +173,8 @@ public class TransactionAdapter extends AdapterBase {
return Optional.empty();
}
final long blockNumber = bn.orElseGet(txBlockNumber::get);
return query.getAndMapWorldState(blockNumber, ws -> new AccountAdapter(ws.get(addr.get())));
return query.getAndMapWorldState(
blockNumber, ws -> Optional.of(new AccountAdapter(ws.get(addr.get()))));
}
}
return Optional.empty();

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.flat.FlatTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.flat.FlatTraceGenerator;
@ -28,6 +29,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.vm.DebugOperationTracer;
import java.util.Collections;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Stream;
@ -62,19 +64,33 @@ public abstract class AbstractTraceByHash implements JsonRpcMethod {
if (block == null || block.getBody().getTransactions().isEmpty()) {
return Stream.empty();
}
final TransactionTrace transactionTrace = getTransactionTrace(block, transactionHash);
return getTraceStream(transactionTrace, block);
return Tracer.processTracing(
blockchainQueries,
Optional.of(block.getHeader()),
mutableWorldState -> {
final TransactionTrace transactionTrace = getTransactionTrace(block, transactionHash);
return Optional.ofNullable(getTraceStream(transactionTrace, block));
})
.orElse(Stream.empty());
}
private TransactionTrace getTransactionTrace(final Block block, final Hash transactionHash) {
return blockTracerSupplier
.get()
.trace(block, new DebugOperationTracer(new TraceOptions(false, false, true)))
.map(BlockTrace::getTransactionTraces)
.orElse(Collections.emptyList())
.stream()
.filter(trxTrace -> trxTrace.getTransaction().getHash().equals(transactionHash))
.findFirst()
return Tracer.processTracing(
blockchainQueries,
Optional.of(block.getHeader()),
mutableWorldState -> {
return blockTracerSupplier
.get()
.trace(
mutableWorldState,
block,
new DebugOperationTracer(new TraceOptions(false, false, true)))
.map(BlockTrace::getTransactionTraces)
.orElse(Collections.emptyList())
.stream()
.filter(trxTrace -> trxTrace.getTransaction().getHash().equals(transactionHash))
.findFirst();
})
.orElseThrow();
}

@ -21,13 +21,12 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.util.Log4j2ConfiguratorUtil;
import org.hyperledger.besu.util.LogConfigurator;
import java.util.Arrays;
import java.util.Optional;
import java.util.Set;
import org.apache.logging.log4j.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -45,12 +44,11 @@ public class AdminChangeLogLevel implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
try {
final String rawLogLevel = requestContext.getRequiredParameter(0, String.class);
if (!VALID_PARAMS.contains(rawLogLevel)) {
final String logLevel = requestContext.getRequiredParameter(0, String.class);
if (!VALID_PARAMS.contains(logLevel)) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
}
final Level logLevel = Level.toLevel(rawLogLevel);
final Optional<String[]> optionalLogFilters =
requestContext.getOptionalParameter(1, String[].class);
optionalLogFilters.ifPresentOrElse(
@ -64,8 +62,8 @@ public class AdminChangeLogLevel implements JsonRpcMethod {
}
}
private void setLogLevel(final String logFilter, final Level logLevel) {
LOG.debug("Setting {} logging level to {} ", logFilter, logLevel.name());
Log4j2ConfiguratorUtil.setAllLevels(logFilter, logLevel);
private void setLogLevel(final String logFilter, final String logLevel) {
LOG.debug("Setting {} logging level to {} ", logFilter, logLevel);
LogConfigurator.setLevel(logFilter, logLevel);
}
}

@ -21,6 +21,7 @@ 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.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@ -87,42 +88,56 @@ public class DebugAccountAt extends AbstractBlockParameterOrBlockHashMethod {
requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
}
final Optional<TransactionTrace> transactionTrace =
blockTracerSupplier
.get()
.trace(blockHash, new DebugOperationTracer(new TraceOptions(false, true, true)))
.map(BlockTrace::getTransactionTraces)
.orElse(Collections.emptyList())
.stream()
.filter(
trxTrace ->
trxTrace
.getTransaction()
.getHash()
.equals(transactions.get(txIndex).getTransaction().getHash()))
.findFirst();
if (transactionTrace.isEmpty()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.TRANSACTION_NOT_FOUND);
}
Optional<Account> account =
transactionTrace.get().getTraceFrames().stream()
.map(traceFrame -> traceFrame.getWorldUpdater().get(address))
.filter(Objects::nonNull)
.filter(a -> a.getAddress().equals(address))
.findFirst();
if (account.isEmpty()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NO_ACCOUNT_FOUND);
}
return debugAccountAtResult(
account.get().getCode(),
Quantity.create(account.get().getNonce()),
Quantity.create(account.get().getBalance()),
Quantity.create(account.get().getCodeHash()));
return Tracer.processTracing(
blockchainQueries.get(),
Optional.of(block.get().getHeader()),
mutableWorldState -> {
final Optional<TransactionTrace> transactionTrace =
blockTracerSupplier
.get()
.trace(
mutableWorldState,
blockHash,
new DebugOperationTracer(new TraceOptions(false, true, true)))
.map(BlockTrace::getTransactionTraces)
.orElse(Collections.emptyList())
.stream()
.filter(
trxTrace ->
trxTrace
.getTransaction()
.getHash()
.equals(transactions.get(txIndex).getTransaction().getHash()))
.findFirst();
if (transactionTrace.isEmpty()) {
return Optional.of(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.TRANSACTION_NOT_FOUND));
}
Optional<Account> account =
transactionTrace.get().getTraceFrames().stream()
.map(traceFrame -> traceFrame.getWorldUpdater().get(address))
.filter(Objects::nonNull)
.filter(a -> a.getAddress().equals(address))
.findFirst();
if (account.isEmpty()) {
return Optional.of(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NO_ACCOUNT_FOUND));
}
return Optional.of(
debugAccountAtResult(
account.get().getCode(),
Quantity.create(account.get().getNonce()),
Quantity.create(account.get().getBalance()),
Quantity.create(account.get().getCodeHash())));
})
.orElse(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.WORLD_STATE_UNAVAILABLE));
}
protected ImmutableDebugAccountAtResult debugAccountAtResult(

@ -88,15 +88,17 @@ public class DebugAccountRange implements JsonRpcMethod {
accounts.remove(maxResults);
}
return new JsonRpcSuccessResponse(
requestContext.getRequest().getId(),
new DebugAccountRangeAtResult(
accounts.stream()
.collect(
Collectors.toMap(
account -> account.getAddressHash().toString(),
account -> account.getAddress().orElse(Address.ZERO).toString())),
nextKey.toString()));
return Optional.of(
new JsonRpcSuccessResponse(
requestContext.getRequest().getId(),
new DebugAccountRangeAtResult(
accounts.stream()
.collect(
Collectors.toMap(
account -> account.getAddressHash().toString(),
account ->
account.getAddress().orElse(Address.ZERO).toString())),
nextKey.toString())));
})
.orElse(emptyResponse(requestContext));
}

@ -20,6 +20,7 @@ import org.hyperledger.besu.datatypes.Hash;
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.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@ -29,11 +30,11 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.Block;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Suppliers;
public class DebugStandardTraceBlockToFile implements JsonRpcMethod {
@ -79,14 +80,18 @@ public class DebugStandardTraceBlockToFile implements JsonRpcMethod {
protected List<String> traceBlock(
final Block block, final Optional<TransactionTraceParams> transactionTraceParams) {
return transactionTracerSupplier
.get()
.traceTransactionToFile(
block.getHash(), transactionTraceParams, dataDir.resolve(TRACE_PATH));
}
protected Object emptyResult() {
final ObjectMapper mapper = new ObjectMapper();
return mapper.createArrayNode();
return Tracer.processTracing(
blockchainQueries.get(),
Optional.of(block.getHeader()),
mutableWorldState ->
Optional.of(
transactionTracerSupplier
.get()
.traceTransactionToFile(
mutableWorldState,
block.getHash(),
transactionTraceParams,
dataDir.resolve(TRACE_PATH))))
.orElse(new ArrayList<>());
}
}

@ -20,6 +20,8 @@ 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.parameters.BlockParameterOrBlockHash;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockReplay;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer.TraceableState;
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.DebugStorageRangeAtResult;
@ -29,7 +31,6 @@ import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.AccountStorageEntry;
import org.hyperledger.besu.evm.worldstate.WorldState;
import java.util.Collections;
import java.util.NavigableMap;
@ -85,36 +86,38 @@ public class DebugStorageRangeAt implements JsonRpcMethod {
return emptyResponse(requestContext);
}
final Optional<TransactionWithMetadata> optional =
final Optional<TransactionWithMetadata> maybeTransactionIndex =
blockchainQueries.get().transactionByBlockHashAndIndex(blockHash, transactionIndex);
return optional
.map(
transactionWithMetadata ->
(blockReplay
return Tracer.processTracing(
blockchainQueries.get(),
Optional.of(blockHeaderOptional.get()),
mutableWorldState -> {
if (maybeTransactionIndex.isEmpty()) {
return Optional.of(
extractStorageAt(
requestContext, accountAddress, startKey, limit, mutableWorldState));
} else {
return blockReplay
.get()
.afterTransactionInBlock(
mutableWorldState,
blockHash,
transactionWithMetadata.getTransaction().getHash(),
maybeTransactionIndex.get().getTransaction().getHash(),
(transaction,
blockHeader,
blockchain,
worldState,
transactionProcessor,
protocolSpec) ->
extractStorageAt(
requestContext, accountAddress, startKey, limit, worldState))
.orElseGet(() -> emptyResponse(requestContext))))
.orElseGet(
() ->
blockchainQueries
.get()
.getAndMapWorldState(
blockHeaderOptional.get().getNumber(),
worldState ->
extractStorageAt(
requestContext, accountAddress, startKey, limit, worldState))
.orElseGet(() -> emptyResponse(requestContext)));
requestContext,
accountAddress,
startKey,
limit,
mutableWorldState));
}
})
.orElse(emptyResponse(requestContext));
}
private Optional<Hash> hashFromParameter(final BlockParameterOrBlockHash blockParameter) {
@ -137,7 +140,7 @@ public class DebugStorageRangeAt implements JsonRpcMethod {
final Address accountAddress,
final Hash startKey,
final int limit,
final WorldState worldState) {
final TraceableState worldState) {
final Account account = worldState.get(accountAddress);
final NavigableMap<Bytes32, AccountStorageEntry> entries =
account.storageEntriesFrom(startKey, limit + 1);

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -33,6 +34,7 @@ import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.vm.DebugOperationTracer;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Supplier;
import org.apache.tuweni.bytes.Bytes;
@ -79,11 +81,16 @@ public class DebugTraceBlock implements JsonRpcMethod {
if (this.blockchain.blockByHash(block.getHeader().getParentHash()).isPresent()) {
final Collection<DebugTraceTransactionResult> results =
blockTracerSupplier
.get()
.trace(block, new DebugOperationTracer(traceOptions))
.map(BlockTrace::getTransactionTraces)
.map(DebugTraceTransactionResult::of)
Tracer.processTracing(
blockchain,
Optional.of(block.getHeader()),
mutableWorldState -> {
return blockTracerSupplier
.get()
.trace(mutableWorldState, block, new DebugOperationTracer(traceOptions))
.map(BlockTrace::getTransactionTraces)
.map(DebugTraceTransactionResult::of);
})
.orElse(null);
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), results);
} else {

@ -20,9 +20,11 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
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.DebugTraceTransactionResult;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.debug.TraceOptions;
import org.hyperledger.besu.ethereum.vm.DebugOperationTracer;
@ -32,9 +34,13 @@ import java.util.function.Supplier;
public class DebugTraceBlockByHash implements JsonRpcMethod {
private final Supplier<BlockTracer> blockTracerSupplier;
private final Supplier<BlockchainQueries> blockchainQueries;
public DebugTraceBlockByHash(final Supplier<BlockTracer> blockTracerSupplier) {
public DebugTraceBlockByHash(
final Supplier<BlockTracer> blockTracerSupplier,
final Supplier<BlockchainQueries> blockchainQueriesSupplier) {
this.blockTracerSupplier = blockTracerSupplier;
this.blockchainQueries = blockchainQueriesSupplier;
}
@Override
@ -52,11 +58,15 @@ public class DebugTraceBlockByHash implements JsonRpcMethod {
.orElse(TraceOptions.DEFAULT);
final Collection<DebugTraceTransactionResult> results =
blockTracerSupplier
.get()
.trace(blockHash, new DebugOperationTracer(traceOptions))
.map(BlockTrace::getTransactionTraces)
.map(DebugTraceTransactionResult::of)
Tracer.processTracing(
blockchainQueries.get(),
blockHash,
mutableWorldState ->
blockTracerSupplier
.get()
.trace(mutableWorldState, blockHash, new DebugOperationTracer(traceOptions))
.map(BlockTrace::getTransactionTraces)
.map(DebugTraceTransactionResult::of))
.orElse(null);
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), results);
}

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParame
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.DebugTraceTransactionResult;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.debug.TraceOptions;
@ -62,11 +63,16 @@ public class DebugTraceBlockByNumber extends AbstractBlockParameterMethod {
return blockHash
.flatMap(
hash ->
blockTracerSupplier
.get()
.trace(hash, new DebugOperationTracer(traceOptions))
.map(BlockTrace::getTransactionTraces)
.map(DebugTraceTransactionResult::of))
Tracer.processTracing(
blockchainQueriesSupplier.get(),
hash,
mutableWorldState -> {
return blockTracerSupplier
.get()
.trace(mutableWorldState, hash, new DebugOperationTracer(traceOptions))
.map(BlockTrace::getTransactionTraces)
.map(DebugTraceTransactionResult::of);
}))
.orElse(null);
}
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
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.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
@ -74,9 +75,13 @@ public class DebugTraceTransaction implements JsonRpcMethod {
final DebugOperationTracer execTracer = new DebugOperationTracer(traceOptions);
return transactionTracer
.traceTransaction(blockHash, hash, execTracer)
.map(DebugTraceTransactionResult::new)
return Tracer.processTracing(
blockchain,
blockHash,
mutableWorldState ->
transactionTracer
.traceTransaction(mutableWorldState, blockHash, hash, execTracer)
.map(DebugTraceTransactionResult::new))
.orElse(null);
}
}

@ -72,9 +72,12 @@ public class EthGetProof extends AbstractBlockParameterOrBlockHashMethod {
new JsonRpcSuccessResponse(
requestContext.getRequest().getId(),
GetProofResult.buildGetProofResult(address, proof)))
.orElse(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.NO_ACCOUNT_FOUND));
.or(
() ->
Optional.of(
new JsonRpcErrorResponse(
requestContext.getRequest().getId(),
JsonRpcError.NO_ACCOUNT_FOUND)));
})
.orElse(
new JsonRpcErrorResponse(

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.flat.FlatTraceGenerator;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.flat.RewardTraceGenerator;
@ -89,15 +90,27 @@ public class TraceBlock extends AbstractBlockParameterMethod {
}
final ArrayNodeWrapper resultArrayNode = new ArrayNodeWrapper(MAPPER.createArrayNode());
blockTracerSupplier
.get()
.trace(block, new DebugOperationTracer(new TraceOptions(false, false, true)))
.ifPresent(
blockTrace ->
generateTracesFromTransactionTraceAndBlock(
filterParameter, blockTrace.getTransactionTraces(), block, resultArrayNode));
generateRewardsFromBlock(filterParameter, block, resultArrayNode);
Tracer.processTracing(
blockchainQueriesSupplier.get(),
Optional.of(block.getHeader()),
mutableWorldState -> {
blockTracerSupplier
.get()
.trace(
mutableWorldState,
block,
new DebugOperationTracer(new TraceOptions(false, false, true)))
.ifPresent(
blockTrace ->
generateTracesFromTransactionTraceAndBlock(
filterParameter,
blockTrace.getTransactionTraces(),
block,
resultArrayNode));
generateRewardsFromBlock(filterParameter, block, resultArrayNode);
return Optional.empty();
});
return resultArrayNode;
}

@ -130,20 +130,20 @@ public class TraceCallMany extends TraceCall implements JsonRpcMethod {
});
} catch (final TransactionInvalidException e) {
LOG.error("Invalid transaction simulator result");
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), INTERNAL_ERROR);
return Optional.of(
new JsonRpcErrorResponse(requestContext.getRequest().getId(), INTERNAL_ERROR));
} catch (final EmptySimulatorResultException e) {
LOG.error(
"Empty simulator result, call params: {}, blockHeader: {} ",
JsonCallParameterUtil.validateAndGetCallParams(requestContext),
blockHeader);
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), INTERNAL_ERROR);
return Optional.of(
new JsonRpcErrorResponse(requestContext.getRequest().getId(), INTERNAL_ERROR));
} catch (final Exception e) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), INTERNAL_ERROR);
return Optional.of(
new JsonRpcErrorResponse(requestContext.getRequest().getId(), INTERNAL_ERROR));
}
return traceCallResults;
return Optional.of(traceCallResults);
});
}

@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypePa
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TraceTypeParameter.TraceType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.TraceFormatter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.TraceWriter;
@ -113,11 +114,16 @@ public class TraceReplayBlockTransactions extends AbstractBlockParameterMethod {
final TraceOptions traceOptions =
new TraceOptions(false, false, traceTypes.contains(VM_TRACE) || traceTypes.contains(TRACE));
return blockTracerSupplier
.get()
.trace(block, new DebugOperationTracer(traceOptions))
.map(BlockTrace::getTransactionTraces)
.map((traces) -> generateTracesFromTransactionTrace(traces, block, traceTypes))
return Tracer.processTracing(
blockchainQueriesSupplier.get(),
Optional.of(block.getHeader()),
mutableWorldState -> {
return blockTracerSupplier
.get()
.trace(mutableWorldState, block, new DebugOperationTracer(traceOptions))
.map(BlockTrace::getTransactionTraces)
.map((traces) -> generateTracesFromTransactionTrace(traces, block, traceTypes));
})
.orElse(null);
}

@ -17,11 +17,11 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor;
import org.hyperledger.besu.datatypes.DataGas;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer.TraceableState;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@ -29,7 +29,6 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
import org.hyperledger.besu.ethereum.vm.CachingBlockHashLookup;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import java.util.List;
import java.util.Optional;
@ -38,15 +37,10 @@ public class BlockReplay {
private final ProtocolSchedule protocolSchedule;
private final Blockchain blockchain;
private final WorldStateArchive worldStateArchive;
public BlockReplay(
final ProtocolSchedule protocolSchedule,
final Blockchain blockchain,
final WorldStateArchive worldStateArchive) {
public BlockReplay(final ProtocolSchedule protocolSchedule, final Blockchain blockchain) {
this.protocolSchedule = protocolSchedule;
this.blockchain = blockchain;
this.worldStateArchive = worldStateArchive;
}
public Optional<BlockTrace> block(
@ -54,7 +48,7 @@ public class BlockReplay {
return performActionWithBlock(
block.getHeader(),
block.getBody(),
(body, header, blockchain, mutableWorldState, transactionProcessor, protocolSpec) -> {
(body, header, blockchain, transactionProcessor, protocolSpec) -> {
final Wei dataGasPrice =
protocolSpec
.getFeeMarket()
@ -69,12 +63,7 @@ public class BlockReplay {
.map(
transaction ->
action.performAction(
transaction,
header,
blockchain,
mutableWorldState,
transactionProcessor,
dataGasPrice))
transaction, header, blockchain, transactionProcessor, dataGasPrice))
.toList();
return Optional.of(new BlockTrace(transactionTraces));
});
@ -86,10 +75,13 @@ public class BlockReplay {
}
public <T> Optional<T> beforeTransactionInBlock(
final Hash blockHash, final Hash transactionHash, final TransactionAction<T> action) {
final TraceableState mutableWorldState,
final Hash blockHash,
final Hash transactionHash,
final TransactionAction<T> action) {
return performActionWithBlock(
blockHash,
(body, header, blockchain, mutableWorldState, transactionProcessor, protocolSpec) -> {
(body, header, blockchain, transactionProcessor, protocolSpec) -> {
final BlockHashLookup blockHashLookup = new CachingBlockHashLookup(header, blockchain);
final Wei dataGasPrice =
protocolSpec
@ -104,12 +96,7 @@ public class BlockReplay {
if (transaction.getHash().equals(transactionHash)) {
return Optional.of(
action.performAction(
transaction,
header,
blockchain,
mutableWorldState,
transactionProcessor,
dataGasPrice));
transaction, header, blockchain, transactionProcessor, dataGasPrice));
} else {
transactionProcessor.processTransaction(
blockchain,
@ -128,15 +115,19 @@ public class BlockReplay {
}
public <T> Optional<T> afterTransactionInBlock(
final Hash blockHash, final Hash transactionHash, final TransactionAction<T> action) {
final TraceableState mutableWorldState,
final Hash blockHash,
final Hash transactionHash,
final TransactionAction<T> action) {
return beforeTransactionInBlock(
mutableWorldState,
blockHash,
transactionHash,
(transaction, blockHeader, blockchain, worldState, transactionProcessor, dataGasPrice) -> {
(transaction, blockHeader, blockchain, transactionProcessor, dataGasPrice) -> {
final ProtocolSpec spec = protocolSchedule.getByBlockHeader(blockHeader);
transactionProcessor.processTransaction(
blockchain,
worldState.updater(),
mutableWorldState.updater(),
blockHeader,
transaction,
spec.getMiningBeneficiaryCalculator().calculateBeneficiary(blockHeader),
@ -145,7 +136,7 @@ public class BlockReplay {
TransactionValidationParams.blockReplay(),
dataGasPrice);
return action.performAction(
transaction, blockHeader, blockchain, worldState, transactionProcessor, dataGasPrice);
transaction, blockHeader, blockchain, transactionProcessor, dataGasPrice);
});
}
@ -168,30 +159,8 @@ public class BlockReplay {
}
final ProtocolSpec protocolSpec = protocolSchedule.getByBlockHeader(header);
final MainnetTransactionProcessor transactionProcessor = protocolSpec.getTransactionProcessor();
final BlockHeader previous = blockchain.getBlockHeader(header.getParentHash()).orElse(null);
if (previous == null) {
return Optional.empty();
}
try (final MutableWorldState worldState =
worldStateArchive
.getMutable(previous.getStateRoot(), previous.getBlockHash(), false)
.map(
ws -> {
if (!ws.isPersistable()) {
return ws.copy();
}
return ws;
})
.orElseThrow(
() ->
new IllegalArgumentException(
"Missing worldstate for stateroot "
+ previous.getStateRoot().toShortHexString()))) {
return action.perform(
body, header, blockchain, worldState, transactionProcessor, protocolSpec);
} catch (Exception ex) {
return Optional.empty();
}
return action.perform(body, header, blockchain, transactionProcessor, protocolSpec);
}
private Optional<Block> getBlock(final Hash blockHash) {
@ -217,7 +186,6 @@ public class BlockReplay {
BlockBody body,
BlockHeader blockHeader,
Blockchain blockchain,
MutableWorldState worldState,
MainnetTransactionProcessor transactionProcessor,
ProtocolSpec protocolSpec);
}
@ -228,7 +196,6 @@ public class BlockReplay {
Transaction transaction,
BlockHeader blockHeader,
Blockchain blockchain,
MutableWorldState worldState,
MainnetTransactionProcessor transactionProcessor,
Wei dataGasPrice);
}

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.debug.TraceFrame;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.vm.CachingBlockHashLookup;
@ -37,22 +38,23 @@ public class BlockTracer {
this.blockReplay = blockReplay;
}
public Optional<BlockTrace> trace(final Hash blockHash, final DebugOperationTracer tracer) {
return blockReplay.block(blockHash, prepareReplayAction(tracer));
public Optional<BlockTrace> trace(
final Tracer.TraceableState mutableWorldState,
final Hash blockHash,
final DebugOperationTracer tracer) {
return blockReplay.block(blockHash, prepareReplayAction(mutableWorldState, tracer));
}
public Optional<BlockTrace> trace(final Block block, final DebugOperationTracer tracer) {
return blockReplay.block(block, prepareReplayAction(tracer));
public Optional<BlockTrace> trace(
final Tracer.TraceableState mutableWorldState,
final Block block,
final DebugOperationTracer tracer) {
return blockReplay.block(block, prepareReplayAction(mutableWorldState, tracer));
}
private BlockReplay.TransactionAction<TransactionTrace> prepareReplayAction(
final DebugOperationTracer tracer) {
return (transaction,
header,
blockchain,
mutableWorldState,
transactionProcessor,
dataGasPrice) -> {
final MutableWorldState mutableWorldState, final DebugOperationTracer tracer) {
return (transaction, header, blockchain, transactionProcessor, dataGasPrice) -> {
// if we have no prior updater, it must be the first TX, so use the block's initial state
if (chainedUpdater == null) {
chainedUpdater = mutableWorldState.updater();

@ -0,0 +1,101 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* 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.processor;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Stream;
import org.apache.tuweni.bytes.Bytes32;
public class Tracer {
public static <TRACE> Optional<TRACE> processTracing(
final BlockchainQueries blockchainQueries,
final Hash blockHash,
final Function<TraceableState, ? extends Optional<TRACE>> mapper) {
return processTracing(
blockchainQueries, blockchainQueries.getBlockHeaderByHash(blockHash), mapper);
}
public static <TRACE> Optional<TRACE> processTracing(
final BlockchainQueries blockchainQueries,
final Optional<BlockHeader> blockHeader,
final Function<TraceableState, ? extends Optional<TRACE>> mapper) {
return blockHeader
.map(BlockHeader::getParentHash)
.flatMap(
parentHash ->
blockchainQueries.getAndMapWorldState(
parentHash,
mutableWorldState -> mapper.apply(new TraceableState(mutableWorldState))));
}
/**
* This class force the use of the processTracing method to do tracing. processTracing allows you
* to cleanly manage the worldstate, to close it etc
*/
public static class TraceableState implements MutableWorldState {
private final MutableWorldState mutableWorldState;
private TraceableState(final MutableWorldState mutableWorldState) {
this.mutableWorldState = mutableWorldState;
}
@Override
public void persist(final BlockHeader blockHeader) {
mutableWorldState.persist(blockHeader);
}
@Override
public WorldUpdater updater() {
return mutableWorldState.updater();
}
@Override
public Hash rootHash() {
return mutableWorldState.rootHash();
}
@Override
public Hash frontierRootHash() {
return mutableWorldState.rootHash();
}
@Override
public Stream<StreamableAccount> streamAccounts(final Bytes32 startKeyHash, final int limit) {
return mutableWorldState.streamAccounts(startKeyHash, limit);
}
@Override
public Account get(final Address address) {
return mutableWorldState.get(address);
}
@Override
public void close() throws Exception {
mutableWorldState.close();
}
}
}

@ -22,6 +22,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.debug.TraceOptions;
import org.hyperledger.besu.ethereum.mainnet.ImmutableTransactionValidationParams;
@ -63,25 +64,32 @@ public class TransactionTracer {
}
public Optional<TransactionTrace> traceTransaction(
final Hash blockHash, final Hash transactionHash, final DebugOperationTracer tracer) {
return blockReplay.beforeTransactionInBlock(
blockHash,
transactionHash,
(transaction, header, blockchain, worldState, transactionProcessor, dataGasPrice) -> {
final TransactionProcessingResult result =
processTransaction(
header,
blockchain,
worldState.updater(),
transaction,
transactionProcessor,
tracer,
dataGasPrice);
return new TransactionTrace(transaction, result, tracer.getTraceFrames());
});
final Tracer.TraceableState mutableWorldState,
final Hash blockHash,
final Hash transactionHash,
final DebugOperationTracer tracer) {
Optional<TransactionTrace> transactionTrace =
blockReplay.beforeTransactionInBlock(
mutableWorldState,
blockHash,
transactionHash,
(transaction, header, blockchain, transactionProcessor, dataGasPrice) -> {
final TransactionProcessingResult result =
processTransaction(
header,
blockchain,
mutableWorldState.updater(),
transaction,
transactionProcessor,
tracer,
dataGasPrice);
return new TransactionTrace(transaction, result, tracer.getTraceFrames());
});
return transactionTrace;
}
public List<String> traceTransactionToFile(
final MutableWorldState mutableWorldState,
final Hash blockHash,
final Optional<TransactionTraceParams> transactionTraceParams,
final Path traceDir) {
@ -104,8 +112,8 @@ public class TransactionTracer {
return blockReplay
.performActionWithBlock(
blockHash,
(body, header, blockchain, worldState, transactionProcessor, protocolSpec) -> {
WorldUpdater stackedUpdater = worldState.updater().updater();
(body, header, blockchain, transactionProcessor, protocolSpec) -> {
WorldUpdater stackedUpdater = mutableWorldState.updater().updater();
final List<String> traces = new ArrayList<>();
final Wei dataGasPrice =
protocolSpec
@ -180,7 +188,6 @@ public class TransactionTracer {
final MainnetTransactionProcessor transactionProcessor,
final OperationTracer tracer,
final Wei dataGasPrice) {
return transactionProcessor.processTransaction(
blockchain,
worldUpdater,

@ -85,10 +85,7 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods {
@Override
protected Map<String, JsonRpcMethod> create() {
final BlockReplay blockReplay =
new BlockReplay(
protocolSchedule,
blockchainQueries.getBlockchain(),
blockchainQueries.getWorldStateArchive());
new BlockReplay(protocolSchedule, blockchainQueries.getBlockchain());
return mapOf(
new DebugTraceTransaction(blockchainQueries, new TransactionTracer(blockReplay)),
@ -103,7 +100,7 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods {
new DebugSetHead(blockchainQueries, protocolContext),
new DebugReplayBlock(blockchainQueries, protocolContext, protocolSchedule),
new DebugTraceBlockByNumber(() -> new BlockTracer(blockReplay), blockchainQueries),
new DebugTraceBlockByHash(() -> new BlockTracer(blockReplay)),
new DebugTraceBlockByHash(() -> new BlockTracer(blockReplay), () -> blockchainQueries),
new DebugBatchSendRawTransaction(transactionPool),
new DebugGetBadBlocks(blockchainQueries, protocolSchedule, blockResult),
new DebugStandardTraceBlockToFile(

@ -56,10 +56,7 @@ public class TraceJsonRpcMethods extends ApiGroupJsonRpcMethods {
@Override
protected Map<String, JsonRpcMethod> create() {
final BlockReplay blockReplay =
new BlockReplay(
protocolSchedule,
blockchainQueries.getBlockchain(),
blockchainQueries.getWorldStateArchive());
new BlockReplay(protocolSchedule, blockchainQueries.getBlockchain());
return mapOf(
new TraceReplayBlockTransactions(
() -> new BlockTracer(blockReplay), protocolSchedule, blockchainQueries),

@ -303,7 +303,8 @@ public class BlockchainQueries {
* @return The number of transactions sent from the given address.
*/
public long getTransactionCount(final Address address, final Hash blockHash) {
return getAndMapWorldState(blockHash, worldState -> worldState.get(address))
return getAndMapWorldState(
blockHash, worldState -> Optional.ofNullable(worldState.get(address)))
.map(Account::getNonce)
.orElse(0L);
}
@ -859,24 +860,15 @@ public class BlockchainQueries {
* @return the world state at the block number
*/
public <U> Optional<U> getAndMapWorldState(
final Hash blockHash, final Function<MutableWorldState, ? extends U> mapper) {
final Hash blockHash, final Function<MutableWorldState, ? extends Optional<U>> mapper) {
return blockchain
.getBlockHeader(blockHash)
.flatMap(
blockHeader -> {
try (final var worldState =
worldStateArchive
.getMutable(blockHeader.getStateRoot(), blockHeader.getHash(), false)
.map(
ws -> {
if (!ws.isPersistable()) {
return ws.copy();
}
return ws;
})
.orElse(null)) {
if (worldState != null) {
return Optional.ofNullable(mapper.apply(worldState));
try (var ws = worldStateArchive.getMutable(blockHeader, false).orElse(null)) {
if (ws != null) {
return mapper.apply(ws);
}
} catch (Exception ex) {
LOG.error("failed worldstate query for " + blockHash.toShortHexString(), ex);
@ -894,7 +886,7 @@ public class BlockchainQueries {
* @return the world state at the block number
*/
public <U> Optional<U> getAndMapWorldState(
final long blockNumber, final Function<MutableWorldState, ? extends U> mapper) {
final long blockNumber, final Function<MutableWorldState, ? extends Optional<U>> mapper) {
final Hash blockHash =
getBlockHeaderByNumber(blockNumber).map(BlockHeader::getHash).orElse(Hash.EMPTY);
return getAndMapWorldState(blockHash, mapper);
@ -965,7 +957,9 @@ public class BlockchainQueries {
return getAndMapWorldState(
blockHash,
worldState ->
Optional.ofNullable(worldState.get(address)).map(getter).orElse(noAccountValue));
Optional.ofNullable(worldState.get(address))
.map(getter)
.or(() -> Optional.ofNullable(noAccountValue)));
}
private List<TransactionWithMetadata> formatTransactions(

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

Loading…
Cancel
Save