Release 23.10.3-RC4 (#6310)

* Increase scope of reference tests (#6287)

Add new forks to transaction tests, add bad rlp to rlp ref tests.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: jflo <justin+github@florentine.us>

* Add trace to web socket JSON/RPC responses (#6285)

* Add trace to web socket JSON/RPC responses

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

* Don't throw runtime exception if we can't parse JSON for trace

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

---------

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: jflo <justin+github@florentine.us>

* [MINOR] Include Enode URL in error message if parsing exception (#6288)

* include the actual Enode URL in the error message if IP can't be resolved

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: jflo <justin+github@florentine.us>

* Execute the terminatedImmediately method only once (#6284)

Signed-off-by: David Lutzardo <jdlutzardo@izertis.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: jflo <justin+github@florentine.us>

* move forest class to a specific package (#6293)

cleaning up the worldstate section, moving and renaming everything that is forest into a specific package in order to clarify the difference between Bonsai and Forest in the code.

---------

Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Signed-off-by: matkt <karim.t2am@gmail.com>
Signed-off-by: jflo <justin+github@florentine.us>

* removed vintage junit dependency (#6296)

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: jflo <justin+github@florentine.us>

* updated cli and chainimport/export tests to junit 5 (#6281)

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: jflo <justin+github@florentine.us>

* [MINOR] CLI Subcommands migrate to junit 5 (#6282)

* updated cli and chainimport/export tests to junit 5

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* subcommands and besucommand test to junit5

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* removed duplicate line

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

* removed vintage junit dep

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: jflo <justin+github@florentine.us>

* [MINOR] add genesis file name to config overview (#6297)

* add genesis file name to config overview

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: jflo <justin+github@florentine.us>

* create trie package for bonsai and forest (#6300)

Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Signed-off-by: matkt <karim.t2am@gmail.com>
Signed-off-by: jflo <justin+github@florentine.us>

* [MINOR] More cli tests to junit 5 (#6283)

* more CLI and services tests to junit5

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: jflo <justin+github@florentine.us>

* Update Gradle plugins and replace unmaintained license plugin (#6275)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: jflo <justin+github@florentine.us>

* Quick fix to avoid a tight loop when processing added blocks in txpool (#6309)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: jflo <justin+github@florentine.us>

* uprev to version 23.10.3-RC4

Signed-off-by: jflo <justin+github@florentine.us>

* mark deleted slot during clear storage step

Signed-off-by: Karim Taam <karim.t2am@gmail.com>

---------

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: jflo <justin+github@florentine.us>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: David Lutzardo <jdlutzardo@izertis.com>
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Signed-off-by: matkt <karim.t2am@gmail.com>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Co-authored-by: Matt Whitehead <matthew1001@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: David Lutzardo <jdlutzardo@izertis.com>
Co-authored-by: Karim TAAM <karim.t2am@gmail.com>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/6333/head
Justin Florentine 11 months ago committed by GitHub
parent 536c444336
commit 47364bfda3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      .github/workflows/checks.yml
  2. 5
      .github/workflows/codeql.yml
  3. 3
      .github/workflows/release.yml
  4. 9
      .github/workflows/sonarcloud.yml
  5. 2
      CHANGELOG.md
  6. 2
      besu/build.gradle
  7. 7
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  8. 16
      besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java
  9. 4
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java
  10. 4
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java
  11. 4
      besu/src/main/java/org/hyperledger/besu/components/BesuComponent.java
  12. 20
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  13. 2
      besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java
  14. 4
      besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java
  15. 77
      besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java
  16. 89
      besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java
  17. 59
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
  18. 8
      besu/src/test/java/org/hyperledger/besu/cli/CommandLineUtilsTest.java
  19. 48
      besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
  20. 3
      besu/src/test/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilderTest.java
  21. 8
      besu/src/test/java/org/hyperledger/besu/cli/EnvironmentVariableDefaultProviderTest.java
  22. 8
      besu/src/test/java/org/hyperledger/besu/cli/PasswordSubCommandTest.java
  23. 16
      besu/src/test/java/org/hyperledger/besu/cli/PublicKeySubCommandTest.java
  24. 43
      besu/src/test/java/org/hyperledger/besu/cli/TomlConfigFileDefaultProviderTest.java
  25. 8
      besu/src/test/java/org/hyperledger/besu/cli/ValidateConfigSubCommandTest.java
  26. 8
      besu/src/test/java/org/hyperledger/besu/cli/config/EthNetworkConfigTest.java
  27. 8
      besu/src/test/java/org/hyperledger/besu/cli/converter/FractionConverterTest.java
  28. 12
      besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java
  29. 8
      besu/src/test/java/org/hyperledger/besu/cli/converter/PercentageConverterTest.java
  30. 8
      besu/src/test/java/org/hyperledger/besu/cli/custom/RpcAuthFileValidatorTest.java
  31. 12
      besu/src/test/java/org/hyperledger/besu/cli/operator/OperatorSubCommandTest.java
  32. 2
      besu/src/test/java/org/hyperledger/besu/cli/options/AbstractCLIOptionsTest.java
  33. 8
      besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java
  34. 6
      besu/src/test/java/org/hyperledger/besu/cli/options/MetricsCLIOptionsTest.java
  35. 8
      besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java
  36. 8
      besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java
  37. 8
      besu/src/test/java/org/hyperledger/besu/cli/options/OptionParserTest.java
  38. 6
      besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java
  39. 8
      besu/src/test/java/org/hyperledger/besu/cli/options/TransactionPoolOptionsTest.java
  40. 2
      besu/src/test/java/org/hyperledger/besu/cli/options/stable/DataStorageOptionsTest.java
  41. 6
      besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java
  42. 54
      besu/src/test/java/org/hyperledger/besu/cli/rlp/RLPSubCommandTest.java
  43. 111
      besu/src/test/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommandTest.java
  44. 8
      besu/src/test/java/org/hyperledger/besu/cli/subcommands/storage/StorageSubCommandTest.java
  45. 12
      besu/src/test/java/org/hyperledger/besu/cli/util/BesuCommandCustomFactoryTest.java
  46. 42
      besu/src/test/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandlerTest.java
  47. 8
      besu/src/test/java/org/hyperledger/besu/cli/util/VersionProviderTest.java
  48. 8
      besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java
  49. 33
      besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java
  50. 12
      besu/src/test/java/org/hyperledger/besu/services/PicoCLIOptionsImplTest.java
  51. 3
      besu/src/test/java/org/hyperledger/besu/util/LocalPermissioningConfigurationValidatorTest.java
  52. 51
      build.gradle
  53. 2
      consensus/clique/build.gradle
  54. 2
      consensus/common/build.gradle
  55. 4
      consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
  56. 2
      crypto/algorithms/build.gradle
  57. 2
      datatypes/build.gradle
  58. 2
      errorprone-checks/build.gradle
  59. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/AccountAdapter.java
  60. 14
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketMessageHandler.java
  61. 15
      ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerIntegrationTest.java
  62. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java
  63. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java
  64. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java
  65. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateMutableWorldStateUpdater.java
  66. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java
  67. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/keyvalue/PrivacyKeyValueStorageProvider.java
  68. 5
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/KeyValueStorageProvider.java
  69. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiAccount.java
  70. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiValue.java
  71. 18
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiWorldStateProvider.java
  72. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedBonsaiWorldView.java
  73. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedMerkleTrieLoader.java
  74. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedMerkleTrieLoaderModule.java
  75. 16
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedWorldStorageManager.java
  76. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiPreImageProxy.java
  77. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiSnapshotWorldStateKeyValueStorage.java
  78. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateKeyValueStorage.java
  79. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateLayerStorage.java
  80. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/FlatDbStrategy.java
  81. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/FullFlatDbStrategy.java
  82. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/PartialFlatDbStrategy.java
  83. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogAddedEvent.java
  84. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogFactoryImpl.java
  85. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogLayer.java
  86. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogManager.java
  87. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogPruner.java
  88. 60
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldState.java
  89. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java
  90. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldView.java
  91. 12
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java
  92. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/MarkSweepPruner.java
  93. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/Pruner.java
  94. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerConfiguration.java
  95. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/storage/ForestWorldStateKeyValueStorage.java
  96. 27
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/worldview/ForestMutableWorldState.java
  97. 22
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java
  98. 14
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryPrivacyStorageProvider.java
  99. 2
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TrieGenerator.java
  100. 6
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -13,9 +13,9 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: adopt
distribution: 'temurin'
java-version: 17
cache: gradle
- name: spotless
@ -27,9 +27,9 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Set up Java 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: adopt
distribution: 'temurin'
java-version: 17
cache: gradle
- name: javadoc (JDK 17)

@ -42,10 +42,11 @@ jobs:
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: adopt
distribution: 'temurin'
java-version: 17
cache: gradle
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL

@ -7,10 +7,11 @@ jobs:
runs-on: [besu-research-ubuntu-16]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
cache: gradle
- name: Login to DockerHub
run: echo '${{ secrets.DOCKER_PASSWORD_RW }}' | docker login -u '${{ secrets.DOCKER_USER_RW }}' --password-stdin
- name: Setup Gradle

@ -19,22 +19,17 @@ jobs:
- name: checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v3
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

@ -11,6 +11,8 @@
- Add error messages on authentication failures with username and password [#6212](https://github.com/hyperledger/besu/pull/6212)
- New `Sequenced` transaction pool. The pool is an evolution of the `legacy` pool and is likely to be more suitable to enterprise or permissioned chains than the `layered` transaction pool. Select to use this pool with `--tx-pool=sequenced`. Supports the same options as the `legacy` pool [#6211](https://github.com/hyperledger/besu/issues/6211)
- Set Ethereum Classic mainnet activation block for Spiral network upgrade [#6267](https://github.com/hyperledger/besu/pull/6267)
- Add custom genesis file name to config overview if specified [#6297](https://github.com/hyperledger/besu/pull/6297)
- Update Gradle plugins and replace unmaintained License Gradle Plugin with the actively maintained Gradle License Report [#6275](https://github.com/hyperledger/besu/pull/6275)
### Bug fixes

@ -99,10 +99,8 @@ 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'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
annotationProcessor 'com.google.dagger:dagger-compiler'
}

@ -146,7 +146,7 @@ import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.evm.precompile.AbstractAltBnPrecompiledContract;
import org.hyperledger.besu.evm.precompile.BigIntegerModularExponentiationPrecompiledContract;
import org.hyperledger.besu.evm.precompile.KZGPointEvalPrecompiledContract;
@ -3246,7 +3246,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
/**
* Besu CLI Paramaters exception handler used by VertX. Visible for testing.
* Besu CLI Parameters exception handler used by VertX. Visible for testing.
*
* @return instance of BesuParameterExceptionHandler
*/
@ -3526,6 +3526,9 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
}
builder.setHasCustomGenesis(genesisFile != null);
if (genesisFile != null) {
builder.setCustomGenesis(genesisFile.getAbsolutePath());
}
builder.setNetworkId(ethNetworkConfig.getNetworkId());
builder

@ -42,6 +42,7 @@ public class ConfigurationOverviewBuilder {
private String network;
private BigInteger networkId;
private boolean hasCustomGenesis;
private String customGenesisFileName;
private String dataStorage;
private String syncMode;
private Integer rpcPort;
@ -98,6 +99,17 @@ public class ConfigurationOverviewBuilder {
return this;
}
/**
* Sets location of custom genesis file specified.
*
* @param customGenesisFileName the filename of the custom genesis file, only set if specified
* @return the builder
*/
public ConfigurationOverviewBuilder setCustomGenesis(final String customGenesisFileName) {
this.customGenesisFileName = customGenesisFileName;
return this;
}
/**
* Sets data storage.
*
@ -269,7 +281,9 @@ public class ConfigurationOverviewBuilder {
}
if (hasCustomGenesis) {
lines.add("Network: Custom genesis file specified");
lines.add("Network: Custom genesis file");
lines.add(
customGenesisFileName == null ? "Custom genesis file is null" : customGenesisFileName);
}
if (networkId != null) {

@ -26,7 +26,7 @@ import org.hyperledger.besu.ethereum.api.query.StateBackupService;
import org.hyperledger.besu.ethereum.api.query.StateBackupService.BackupStatus;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@ -82,7 +82,7 @@ public class BackupState implements Runnable {
final BesuController besuController = createBesuController();
final MutableBlockchain blockchain = besuController.getProtocolContext().getBlockchain();
final WorldStateStorage worldStateStorage =
((DefaultWorldStateArchive) besuController.getProtocolContext().getWorldStateArchive())
((ForestWorldStateArchive) besuController.getProtocolContext().getWorldStateArchive())
.getWorldStateStorage();
final EthScheduler scheduler = new EthScheduler(1, 1, 1, 1, new NoOpMetricsSystem());
try {

@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.trie.Node;
import org.hyperledger.besu.ethereum.trie.PersistVisitor;
import org.hyperledger.besu.ethereum.trie.RestoreVisitor;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.util.io.RollingFileReader;
@ -250,7 +250,7 @@ public class RestoreState implements Runnable {
updater.commit();
}
final WorldStateStorage worldStateStorage =
((DefaultWorldStateArchive) besuController.getProtocolContext().getWorldStateArchive())
((ForestWorldStateArchive) besuController.getProtocolContext().getWorldStateArchive())
.getWorldStateStorage();
updater = worldStateStorage.updater();
}

@ -17,10 +17,10 @@
package org.hyperledger.besu.components;
import org.hyperledger.besu.cli.BesuCommand;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoaderModule;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCache;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoaderModule;
import org.hyperledger.besu.metrics.MetricsSystemModule;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.services.BesuPluginContextImpl;

@ -31,10 +31,6 @@ 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.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogPruner;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.BlockchainStorage;
import org.hyperledger.besu.ethereum.chain.ChainDataPruner;
@ -84,12 +80,16 @@ import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogPruner;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.pruner.MarkSweepPruner;
import org.hyperledger.besu.ethereum.trie.forest.pruner.Pruner;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.MarkSweepPruner;
import org.hyperledger.besu.ethereum.worldstate.Pruner;
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;
@ -657,7 +657,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
Optional.of(
new Pruner(
new MarkSweepPruner(
((DefaultWorldStateArchive) worldStateArchive).getWorldStateStorage(),
((ForestWorldStateArchive) worldStateArchive).getWorldStateStorage(),
blockchain,
storageProvider.getStorageBySegmentIdentifier(
KeyValueSegmentIdentifier.PRUNING_STATE),
@ -1093,7 +1093,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
case FOREST -> {
final WorldStatePreimageStorage preimageStorage =
storageProvider.createWorldStatePreimageStorage();
yield new DefaultWorldStateArchive(worldStateStorage, preimageStorage, evmConfiguration);
yield new ForestWorldStateArchive(worldStateStorage, preimageStorage, evmConfiguration);
}
};
}

@ -56,8 +56,8 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;

@ -52,9 +52,9 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.forest.pruner.Pruner;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.Pruner;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.internal.EvmConfiguration;

@ -46,29 +46,30 @@ import org.hyperledger.besu.testutil.TestClock;
import java.io.File;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.junit.jupiter.MockitoExtension;
/** Tests for {@link BlockExporter}. */
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public final class RlpBlockExporterTest {
@ClassRule public static final TemporaryFolder folder = new TemporaryFolder();
@TempDir public static Path folder;
private static Blockchain blockchain;
private static long chainHead;
private static ProtocolSchedule protocolSchedule;
@BeforeClass
@BeforeAll
public static void setupBlockchain() throws IOException {
final BesuController controller = createController();
final Path blocks = folder.newFile("1000.blocks").toPath();
final BesuController controller =
createController(Files.createTempDirectory(folder, "rlpBlockExporterTestData"));
final Path blocks = Files.createTempFile(folder, "1000", "blocks");
BlockTestUtil.write1000Blocks(blocks);
blockchain = importBlocks(controller, blocks);
chainHead = blockchain.getChainHeadBlockNumber();
@ -83,8 +84,7 @@ public final class RlpBlockExporterTest {
return controller.getProtocolContext().getBlockchain();
}
private static BesuController createController() throws IOException {
final Path dataDir = folder.newFolder().toPath();
private static BesuController createController(final @TempDir Path dataDir) throws IOException {
return new BesuController.Builder()
.fromGenesisConfig(GenesisConfigFile.mainnet(), SyncMode.FAST)
.synchronizerConfiguration(SynchronizerConfiguration.builder().build())
@ -105,13 +105,13 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_noBounds() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_noBounds(final @TempDir Path outputDir) throws IOException {
final Path outputPath = outputDir.resolve("output");
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
exporter.exportBlocks(outputPath, Optional.empty(), Optional.empty());
exporter.exportBlocks(outputPath.toFile(), Optional.empty(), Optional.empty());
// Iterate over blocks and check that they match expectations
final RawBlockIterator blockIterator = getBlockIterator(outputPath.toPath());
final RawBlockIterator blockIterator = getBlockIterator(outputPath);
long currentBlockNumber = 0;
while (blockIterator.hasNext()) {
final Block actual = blockIterator.next();
@ -125,15 +125,15 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_withLowerBound() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_withLowerBound(final @TempDir Path outputDir) throws IOException {
final Path outputPath = outputDir.resolve("output");
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
final long lowerBound = 990;
exporter.exportBlocks(outputPath, Optional.of(lowerBound), Optional.empty());
exporter.exportBlocks(outputPath.toFile(), Optional.of(lowerBound), Optional.empty());
// Iterate over blocks and check that they match expectations
final RawBlockIterator blockIterator = getBlockIterator(outputPath.toPath());
final RawBlockIterator blockIterator = getBlockIterator(outputPath);
long currentBlockNumber = lowerBound;
while (blockIterator.hasNext()) {
final Block actual = blockIterator.next();
@ -147,15 +147,15 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_withUpperBound() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_withUpperBound(final @TempDir Path outputDir) throws IOException {
final Path outputPath = outputDir.resolve("output");
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
final long upperBound = 10;
exporter.exportBlocks(outputPath, Optional.empty(), Optional.of(upperBound));
exporter.exportBlocks(outputPath.toFile(), Optional.empty(), Optional.of(upperBound));
// Iterate over blocks and check that they match expectations
final RawBlockIterator blockIterator = getBlockIterator(outputPath.toPath());
final RawBlockIterator blockIterator = getBlockIterator(outputPath);
long currentBlockNumber = 0;
while (blockIterator.hasNext()) {
final Block actual = blockIterator.next();
@ -169,16 +169,17 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_withUpperAndLowerBounds() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_withUpperAndLowerBounds(final @TempDir Path outputDir)
throws IOException {
final Path outputPath = outputDir.resolve("output");
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
final long lowerBound = 5;
final long upperBound = 10;
exporter.exportBlocks(outputPath, Optional.of(lowerBound), Optional.of(upperBound));
exporter.exportBlocks(outputPath.toFile(), Optional.of(lowerBound), Optional.of(upperBound));
// Iterate over blocks and check that they match expectations
final RawBlockIterator blockIterator = getBlockIterator(outputPath.toPath());
final RawBlockIterator blockIterator = getBlockIterator(outputPath);
long currentBlockNumber = lowerBound;
while (blockIterator.hasNext()) {
final Block actual = blockIterator.next();
@ -192,16 +193,17 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_withRangeBeyondChainHead() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_withRangeBeyondChainHead(final @TempDir Path outputDir)
throws IOException {
final Path outputPath = outputDir.resolve("output");
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
final long lowerBound = chainHead - 10;
final long upperBound = chainHead + 10;
exporter.exportBlocks(outputPath, Optional.of(lowerBound), Optional.of(upperBound));
exporter.exportBlocks(outputPath.toFile(), Optional.of(lowerBound), Optional.of(upperBound));
// Iterate over blocks and check that they match expectations
final RawBlockIterator blockIterator = getBlockIterator(outputPath.toPath());
final RawBlockIterator blockIterator = getBlockIterator(outputPath);
long currentBlockNumber = lowerBound;
while (blockIterator.hasNext()) {
final Block actual = blockIterator.next();
@ -215,8 +217,7 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_negativeStartNumber() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_negativeStartNumber(final @TempDir File outputPath) throws IOException {
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
assertThatThrownBy(() -> exporter.exportBlocks(outputPath, Optional.of(-1L), Optional.empty()))
@ -225,8 +226,7 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_negativeEndNumber() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_negativeEndNumber(final @TempDir File outputPath) throws IOException {
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
assertThatThrownBy(() -> exporter.exportBlocks(outputPath, Optional.empty(), Optional.of(-1L)))
@ -235,8 +235,7 @@ public final class RlpBlockExporterTest {
}
@Test
public void exportBlocks_outOfOrderBounds() throws IOException {
final File outputPath = folder.newFile();
public void exportBlocks_outOfOrderBounds(final @TempDir File outputPath) throws IOException {
final RlpBlockExporter exporter = new RlpBlockExporter(blockchain);
assertThatThrownBy(() -> exporter.exportBlocks(outputPath, Optional.of(10L), Optional.of(2L)))

@ -48,29 +48,28 @@ import java.math.BigInteger;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.io.Resources;
import org.apache.tuweni.bytes.Bytes;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
public abstract class JsonBlockImporterTest {
@Rule public final TemporaryFolder folder = new TemporaryFolder();
@TempDir public Path dataDir;
protected final String consensusEngine;
protected final GenesisConfigFile genesisConfigFile;
protected final boolean isEthash;
protected String consensusEngine;
protected GenesisConfigFile genesisConfigFile;
protected boolean isEthash;
protected JsonBlockImporterTest(final String consensusEngine) throws IOException {
protected void setup(final String consensusEngine) throws IOException {
this.consensusEngine = consensusEngine;
final String genesisData = getFileContents("genesis.json");
this.genesisConfigFile = GenesisConfigFile.fromConfig(genesisData);
@ -78,8 +77,10 @@ public abstract class JsonBlockImporterTest {
}
public static class SingletonTests extends JsonBlockImporterTest {
public SingletonTests() throws IOException {
super("unsupported");
@BeforeEach
public void setup() throws IOException {
super.setup("unsupported");
}
@Test
@ -97,21 +98,23 @@ public abstract class JsonBlockImporterTest {
}
}
@RunWith(Parameterized.class)
public static class ParameterizedTests extends JsonBlockImporterTest {
public ParameterizedTests(final String consensusEngine) throws IOException {
super(consensusEngine);
@Override
public void setup(final String consensusEngine) throws IOException {
super.setup(consensusEngine);
}
@Parameters(name = "Name: {0}")
public static Collection<Object[]> getParameters() {
final Object[][] params = {{"ethash"}, {"clique"}};
return Arrays.asList(params);
public static Stream<Arguments> getParameters() {
return Stream.of(Arguments.of("ethash"), Arguments.of("clique"));
}
@Test
public void importChain_validJson_withBlockNumbers() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_validJson_withBlockNumbers(final String consensusEngine)
throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@ -201,8 +204,12 @@ public abstract class JsonBlockImporterTest {
assertThat(tx.getNonce()).isEqualTo(1L);
}
@Test
public void importChain_validJson_noBlockIdentifiers() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_validJson_noBlockIdentifiers(final String consensusEngine)
throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@ -292,8 +299,12 @@ public abstract class JsonBlockImporterTest {
assertThat(tx.getNonce()).isEqualTo(1L);
}
@Test
public void importChain_validJson_withParentHashes() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_validJson_withParentHashes(final String consensusEngine)
throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@ -343,8 +354,11 @@ public abstract class JsonBlockImporterTest {
assertThat(tx.getNonce()).isEqualTo(2L);
}
@Test
public void importChain_invalidParent() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_invalidParent(final String consensusEngine) throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@ -355,8 +369,11 @@ public abstract class JsonBlockImporterTest {
.hasMessageStartingWith("Unable to locate block parent at 2456");
}
@Test
public void importChain_invalidTransaction() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_invalidTransaction(final String consensusEngine) throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@ -368,8 +385,11 @@ public abstract class JsonBlockImporterTest {
"Unable to create block. 1 transaction(s) were found to be invalid.");
}
@Test
public void importChain_specialFields() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("getParameters")
public void importChain_specialFields(final String consensusEngine) throws IOException {
setup(consensusEngine);
final BesuController controller = createController();
final JsonBlockImporter importer = new JsonBlockImporter(controller);
@ -414,7 +434,6 @@ public abstract class JsonBlockImporterTest {
protected BesuController createController(final GenesisConfigFile genesisConfigFile)
throws IOException {
final Path dataDir = folder.newFolder().toPath();
return new BesuController.Builder()
.fromGenesisConfig(genesisConfigFile, SyncMode.FAST)
.synchronizerConfiguration(SynchronizerConfiguration.builder().build())

@ -83,8 +83,8 @@ import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
import org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
import org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.evm.precompile.AbstractAltBnPrecompiledContract;
import org.hyperledger.besu.evm.precompile.KZGPointEvalPrecompiledContract;
import org.hyperledger.besu.metrics.StandardMetricCategory;
@ -127,19 +127,18 @@ import org.apache.commons.text.StringEscapeUtils;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.toml.Toml;
import org.apache.tuweni.toml.TomlParseResult;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class BesuCommandTest extends CommandTestAbstract {
private static final String ENCLAVE_URI = "http://1.2.3.4:5555";
@ -198,7 +197,7 @@ public class BesuCommandTest extends CommandTestAbstract {
DEFAULT_API_CONFIGURATION = ImmutableApiConfiguration.builder().build();
}
@Before
@BeforeEach
public void setup() {
try {
// optimistically tear down a potential previous loaded trusted setup
@ -210,7 +209,7 @@ public class BesuCommandTest extends CommandTestAbstract {
MergeConfigOptions.setMergeEnabled(false);
}
@After
@AfterEach
public void tearDown() {
MergeConfigOptions.setMergeEnabled(false);
@ -366,10 +365,10 @@ public class BesuCommandTest extends CommandTestAbstract {
}
@Test
public void overrideDefaultValuesIfKeyIsPresentInConfigFile() throws IOException {
public void overrideDefaultValuesIfKeyIsPresentInConfigFile(final @TempDir File dataFolder)
throws IOException {
final URL configFile = this.getClass().getResource("/complete_config.toml");
final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
final File dataFolder = temp.newFolder();
final String updatedConfig =
Resources.toString(configFile, UTF_8)
.replace("/opt/besu/genesis.json", escapeTomlString(genesisFile.toString()))
@ -3745,7 +3744,7 @@ public class BesuCommandTest extends CommandTestAbstract {
});
}
@Ignore
@Disabled
public void pruningIsEnabledIfSyncModeIsFast() {
parseCommand("--sync-mode", "FAST");
@ -3756,7 +3755,7 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Ignore
@Disabled
public void pruningIsDisabledIfSyncModeIsFull() {
parseCommand("--sync-mode", "FULL");
@ -3778,7 +3777,7 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
@Ignore
@Disabled
public void pruningDisabledExplicitly() {
parseCommand("--pruning-enabled=false", "--sync-mode=FAST");
@ -4373,14 +4372,11 @@ public class BesuCommandTest extends CommandTestAbstract {
assertThat(commandOutput.toString(UTF_8)).isEmpty();
}
@Rule public TemporaryFolder testFolder = new TemporaryFolder();
@Test
public void errorIsRaisedIfStaticNodesAreNotAllowed() throws IOException {
final File staticNodesFile = testFolder.newFile("static-nodes.json");
staticNodesFile.deleteOnExit();
final File permissioningConfig = testFolder.newFile("permissioning");
permissioningConfig.deleteOnExit();
public void errorIsRaisedIfStaticNodesAreNotAllowed(final @TempDir Path testFolder)
throws IOException {
final Path staticNodesFile = testFolder.resolve("static-nodes.json");
final Path permissioningConfig = testFolder.resolve("permissioning.json");
final EnodeURL staticNodeURI =
EnodeURLImpl.builder()
@ -4399,17 +4395,16 @@ public class BesuCommandTest extends CommandTestAbstract {
.listeningPort(30304)
.build();
Files.write(staticNodesFile, ("[\"" + staticNodeURI.toString() + "\"]").getBytes(UTF_8));
Files.write(
staticNodesFile.toPath(), ("[\"" + staticNodeURI.toString() + "\"]").getBytes(UTF_8));
Files.write(
permissioningConfig.toPath(),
permissioningConfig,
("nodes-allowlist=[\"" + allowedNode.toString() + "\"]").getBytes(UTF_8));
parseCommand(
"--data-path=" + testFolder.getRoot().getPath(),
"--data-path=" + testFolder,
"--bootnodes",
"--permissions-nodes-config-file-enabled=true",
"--permissions-nodes-config-file=" + permissioningConfig.getPath());
"--permissions-nodes-config-file=" + permissioningConfig);
assertThat(commandErrorOutput.toString(UTF_8))
.contains(staticNodeURI.toString(), "not in nodes-allowlist");
}
@ -4985,12 +4980,10 @@ public class BesuCommandTest extends CommandTestAbstract {
"File containing password to unlock keystore is required when PKI Block Creation is enabled");
}
@Rule public TemporaryFolder pkiTempFolder = new TemporaryFolder();
@Test
public void pkiBlockCreationFullConfig() throws Exception {
public void pkiBlockCreationFullConfig(final @TempDir Path pkiTempFolder) throws Exception {
// Create temp file with password
final File pwdFile = pkiTempFolder.newFile("pwd");
final File pwdFile = pkiTempFolder.resolve("pwd").toFile();
FileUtils.writeStringToFile(pwdFile, "foo", UTF_8);
parseCommand(

@ -35,18 +35,18 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.Logger;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.RunLast;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class CommandLineUtilsTest {
@SuppressWarnings("PrivateStaticFinalLoggers") // @Mocks are inited by JUnit
@Mock

@ -112,22 +112,20 @@ import io.vertx.core.json.JsonObject;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.RunLast;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public abstract class CommandTestAbstract {
private static final Logger TEST_LOGGER = LoggerFactory.getLogger(CommandTestAbstract.class);
protected static final JsonObject VALID_GENESIS_QBFT_POST_LONDON =
@ -156,17 +154,30 @@ public abstract class CommandTestAbstract {
protected static final RpcEndpointServiceImpl rpcEndpointServiceImpl =
new RpcEndpointServiceImpl();
@Mock protected RunnerBuilder mockRunnerBuilder;
@Mock(lenient = true)
protected RunnerBuilder mockRunnerBuilder;
@Mock protected Runner mockRunner;
@Mock protected BesuController.Builder mockControllerBuilderFactory;
@Mock(lenient = true)
protected BesuController.Builder mockControllerBuilderFactory;
@Mock(lenient = true)
protected BesuControllerBuilder mockControllerBuilder;
@Mock(lenient = true)
protected EthProtocolManager mockEthProtocolManager;
@Mock protected BesuControllerBuilder mockControllerBuilder;
@Mock protected EthProtocolManager mockEthProtocolManager;
@Mock protected ProtocolSchedule mockProtocolSchedule;
@Mock protected ProtocolContext mockProtocolContext;
@Mock(lenient = true)
protected ProtocolContext mockProtocolContext;
@Mock protected BlockBroadcaster mockBlockBroadcaster;
@Mock protected BesuController mockController;
@Mock(lenient = true)
protected BesuController mockController;
@Mock protected RlpBlockExporter rlpBlockExporter;
@Mock protected JsonBlockImporter jsonBlockImporter;
@Mock protected RlpBlockImporter rlpBlockImporter;
@ -188,7 +199,8 @@ public abstract class CommandTestAbstract {
@Mock
protected Logger mockLogger;
@Mock protected BesuComponent mockBesuComponent;
@Mock(lenient = true)
protected BesuComponent mockBesuComponent;
@Mock protected PkiBlockCreationConfigurationProvider mockPkiBlockCreationConfigProvider;
@Mock protected PkiBlockCreationConfiguration mockPkiBlockCreationConfiguration;
@ -218,9 +230,7 @@ public abstract class CommandTestAbstract {
@Captor protected ArgumentCaptor<EthstatsOptions> ethstatsOptionsArgumentCaptor;
@Rule public final TemporaryFolder temp = new TemporaryFolder();
@Before
@BeforeEach
public void initMocks() throws Exception {
// doReturn used because of generic BesuController
doReturn(mockControllerBuilder)
@ -353,7 +363,7 @@ public abstract class CommandTestAbstract {
when(mockBesuComponent.getBesuCommandLogger()).thenReturn(mockLogger);
}
@Before
@BeforeEach
public void setUpStreams() {
// reset the global opentelemetry singleton
GlobalOpenTelemetry.resetForTest();
@ -364,7 +374,7 @@ public abstract class CommandTestAbstract {
}
// Display outputs for debug purpose
@After
@AfterEach
public void displayOutput() throws IOException {
TEST_LOGGER.info("Standard output {}", commandOutput.toString(UTF_8));
TEST_LOGGER.info("Standard error {}", commandErrorOutput.toString(UTF_8));

@ -58,8 +58,9 @@ class ConfigurationOverviewBuilderTest {
assertThat(networkSet).contains("Network: foobar");
builder.setHasCustomGenesis(true);
builder.setCustomGenesis("file.name");
final String genesisSet = builder.build();
assertThat(genesisSet).contains("Network: Custom genesis file specified");
assertThat(genesisSet).contains("Network: Custom genesis file");
assertThat(genesisSet).doesNotContain("Network: foobar");
}

@ -21,13 +21,13 @@ import org.hyperledger.besu.cli.util.EnvironmentVariableDefaultProvider;
import java.util.HashMap;
import java.util.Map;
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;
import picocli.CommandLine.Model.OptionSpec;
import picocli.CommandLine.Model.PositionalParamSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class EnvironmentVariableDefaultProviderTest {
private final Map<String, String> environment = new HashMap<>();

@ -19,12 +19,12 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.BesuInfo;
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;
import picocli.CommandLine.Model.CommandSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PasswordSubCommandTest extends CommandTestAbstract {
@Test

@ -35,14 +35,14 @@ import org.apache.tuweni.bytes.Bytes32;
import org.bouncycastle.asn1.sec.SECNamedCurves;
import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.params.ECDomainParameters;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine.Model.CommandSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PublicKeySubCommandTest extends CommandTestAbstract {
private static final String EXPECTED_PUBLIC_KEY_USAGE =
@ -126,13 +126,13 @@ public class PublicKeySubCommandTest extends CommandTestAbstract {
private static final String ALGORITHM = SignatureAlgorithm.ALGORITHM;
private static ECDomainParameters curve;
@BeforeClass
@BeforeAll
public static void setUp() {
final X9ECParameters params = SECNamedCurves.getByName(CURVE_NAME);
curve = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH());
}
@Before
@BeforeEach
public void before() {
SignatureAlgorithmFactory.resetInstance();
}

@ -26,31 +26,29 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Model.OptionSpec;
import picocli.CommandLine.ParameterException;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class TomlConfigFileDefaultProviderTest {
@Mock CommandLine mockCommandLine;
@Mock CommandSpec mockCommandSpec;
@Rule public final TemporaryFolder temp = new TemporaryFolder();
@Test
public void defaultValueForMatchingKey() throws IOException {
public void defaultValueForMatchingKey(final @TempDir Path temp) throws IOException {
when(mockCommandLine.getCommandSpec()).thenReturn(mockCommandSpec);
Map<String, OptionSpec> validOptionsMap = new HashMap<>();
validOptionsMap.put("--a-short-option", null);
@ -58,7 +56,7 @@ public class TomlConfigFileDefaultProviderTest {
validOptionsMap.put("--a-longer-option", null);
when(mockCommandSpec.optionsMap()).thenReturn(validOptionsMap);
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
try (final BufferedWriter fileWriter =
Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8)) {
@ -106,7 +104,7 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void defaultValueForOptionMustMatchType() throws IOException {
public void defaultValueForOptionMustMatchType(final @TempDir Path temp) throws IOException {
when(mockCommandLine.getCommandSpec()).thenReturn(mockCommandSpec);
Map<String, OptionSpec> validOptionsMap = new HashMap<>();
validOptionsMap.put("--a-boolean-option", null);
@ -124,7 +122,7 @@ public class TomlConfigFileDefaultProviderTest {
when(mockCommandSpec.optionsMap()).thenReturn(validOptionsMap);
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
try (final BufferedWriter fileWriter =
Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8)) {
@ -238,9 +236,9 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void invalidConfigMustThrow() throws IOException {
public void invalidConfigMustThrow(final @TempDir Path temp) throws IOException {
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = Files.createTempFile("invalid", "toml").toFile();
final TomlConfigFileDefaultProvider providerUnderTest =
new TomlConfigFileDefaultProvider(mockCommandLine, tempConfigFile);
@ -254,9 +252,9 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void invalidConfigContentMustThrow() throws IOException {
public void invalidConfigContentMustThrow(final @TempDir Path temp) throws IOException {
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
final BufferedWriter fileWriter = Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8);
fileWriter.write("an-invalid-syntax=======....");
@ -276,13 +274,13 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void unknownOptionMustThrow() throws IOException {
public void unknownOptionMustThrow(final @TempDir Path temp) throws IOException {
when(mockCommandLine.getCommandSpec()).thenReturn(mockCommandSpec);
Map<String, OptionSpec> validOptionsMap = new HashMap<>();
when(mockCommandSpec.optionsMap()).thenReturn(validOptionsMap);
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
final BufferedWriter fileWriter = Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8);
fileWriter.write("invalid_option=true");
@ -300,7 +298,7 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void tomlTableHeadingsMustBeIgnored() throws IOException {
public void tomlTableHeadingsMustBeIgnored(final @TempDir Path temp) throws IOException {
when(mockCommandLine.getCommandSpec()).thenReturn(mockCommandSpec);
@ -310,7 +308,7 @@ public class TomlConfigFileDefaultProviderTest {
validOptionsMap.put("--onemore-valid-option", null);
when(mockCommandSpec.optionsMap()).thenReturn(validOptionsMap);
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
final BufferedWriter fileWriter = Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8);
fileWriter.write("a-valid-option=123");
@ -343,7 +341,8 @@ public class TomlConfigFileDefaultProviderTest {
}
@Test
public void tomlTableHeadingsMustNotSkipValidationOfUnknownOptions() throws IOException {
public void tomlTableHeadingsMustNotSkipValidationOfUnknownOptions(final @TempDir Path temp)
throws IOException {
when(mockCommandLine.getCommandSpec()).thenReturn(mockCommandSpec);
@ -351,7 +350,7 @@ public class TomlConfigFileDefaultProviderTest {
validOptionsMap.put("--a-valid-option", null);
when(mockCommandSpec.optionsMap()).thenReturn(validOptionsMap);
final File tempConfigFile = temp.newFile("config.toml");
final File tempConfigFile = temp.resolve("config.toml").toFile();
final BufferedWriter fileWriter = Files.newBufferedWriter(tempConfigFile.toPath(), UTF_8);
fileWriter.write("[ignoreme]");

@ -25,12 +25,12 @@ import java.nio.file.Files;
import java.nio.file.Path;
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;
import picocli.CommandLine.Model.CommandSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ValidateConfigSubCommandTest extends CommandTestAbstract {
private static final String EXPECTED_PUBLIC_KEY_USAGE =

@ -23,11 +23,11 @@ import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfigura
import java.math.BigInteger;
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 EthNetworkConfigTest {
@Test

@ -20,11 +20,11 @@ import static org.assertj.core.api.Assertions.catchThrowable;
import org.hyperledger.besu.cli.converter.exception.FractionConversionException;
import org.hyperledger.besu.util.number.Fraction;
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 FractionConverterTest {
private final FractionConverter fractionConverter = new FractionConverter();

@ -20,20 +20,20 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.plugin.services.metrics.MetricCategory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MetricCategoryConverterTest {
private MetricCategoryConverter metricCategoryConverter;
@Mock MetricCategory metricCategory;
@Before
@BeforeEach
public void setUp() {
metricCategoryConverter = new MetricCategoryConverter();
}

@ -20,11 +20,11 @@ import static org.assertj.core.api.Assertions.catchThrowable;
import org.hyperledger.besu.cli.converter.exception.PercentageConversionException;
import org.hyperledger.besu.util.number.Percentage;
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 PercentageConverterTest {
private final PercentageConverter percentageConverter = new PercentageConverter();

@ -17,14 +17,14 @@ package org.hyperledger.besu.cli.custom;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
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;
import picocli.CommandLine;
import picocli.CommandLine.ParameterException;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
@ExtendWith(MockitoExtension.class)
public class RpcAuthFileValidatorTest {
private static final String CORRECT_TOML = "/rpcauth/auth_correct.toml";

@ -52,13 +52,13 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.json.JsonObject;
import org.apache.tuweni.bytes.Bytes32;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine.Model.CommandSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class OperatorSubCommandTest extends CommandTestAbstract {
private static final String EXPECTED_OPERATOR_USAGE =
@ -80,7 +80,7 @@ public class OperatorSubCommandTest extends CommandTestAbstract {
private Path tmpOutputDirectoryPath;
@Before
@BeforeEach
public void init() throws IOException {
SignatureAlgorithmFactory.resetInstance();
tmpOutputDirectoryPath = createTempDirectory(format("output-%d", currentTimeMillis()));

@ -26,7 +26,7 @@ import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public abstract class AbstractCLIOptionsTest<D, T extends CLIOptions<D>>
extends CommandTestAbstract {

@ -21,11 +21,11 @@ import static org.mockito.Mockito.verifyNoInteractions;
import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
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 EthProtocolOptionsTest
extends AbstractCLIOptionsTest<EthProtocolConfiguration, EthProtocolOptions> {

@ -17,10 +17,10 @@ package org.hyperledger.besu.cli.options;
import org.hyperledger.besu.cli.options.unstable.MetricsCLIOptions;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MetricsCLIOptionsTest
extends AbstractCLIOptionsTest<MetricsConfiguration.Builder, MetricsCLIOptions> {

@ -35,12 +35,12 @@ import java.nio.file.Path;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
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.ArgumentCaptor;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MiningOptionsTest extends AbstractCLIOptionsTest<MiningParameters, MiningOptions> {
@Test

@ -23,11 +23,11 @@ import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import java.util.Arrays;
import java.util.List;
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 NetworkingOptionsTest
extends AbstractCLIOptionsTest<NetworkingConfiguration, NetworkingOptions> {

@ -21,11 +21,11 @@ import java.math.BigInteger;
import com.google.common.collect.Range;
import org.apache.tuweni.units.bigints.UInt256;
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 OptionParserTest {
@Test

@ -23,10 +23,10 @@ import java.util.Arrays;
import java.util.List;
import com.google.common.collect.Range;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class SynchronizerOptionsTest
extends AbstractCLIOptionsTest<SynchronizerConfiguration.Builder, SynchronizerOptions> {

@ -28,11 +28,11 @@ import org.hyperledger.besu.util.number.Percentage;
import java.time.Duration;
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 TransactionPoolOptionsTest
extends AbstractCLIOptionsTest<TransactionPoolConfiguration, TransactionPoolOptions> {

@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class DataStorageOptionsTest
extends AbstractCLIOptionsTest<DataStorageConfiguration, DataStorageOptions> {

@ -21,8 +21,8 @@ import static org.mockito.Answers.RETURNS_DEEP_STUBS;
import java.util.Arrays;
import org.apache.logging.log4j.Level;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.ParameterException;
@ -31,7 +31,7 @@ public class LoggingLevelOptionTest {
private LoggingLevelOption levelOption;
@Before
@BeforeEach
public void setUp() {
levelOption = new LoggingLevelOption();
}

@ -24,11 +24,12 @@ import org.hyperledger.besu.cli.CommandTestAbstract;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import picocli.CommandLine.Model.CommandSpec;
public class RLPSubCommandTest extends CommandTestAbstract {
@ -158,10 +159,10 @@ public class RLPSubCommandTest extends CommandTestAbstract {
}
@Test
public void encodeWithInputFilePathMustReadFromThisFile() throws Exception {
final File tempJsonFile = temp.newFile("test.json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile.toPath(), UTF_8)) {
public void encodeWithInputFilePathMustReadFromThisFile(final @TempDir Path dir)
throws Exception {
final Path tempJsonFile = Files.createTempFile(dir, "input", "json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile, UTF_8)) {
fileWriter.write(
"[\"be068f726a13c8d46c44be6ce9d275600e1735a4\", \"5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193\"]");
@ -169,7 +170,10 @@ public class RLPSubCommandTest extends CommandTestAbstract {
fileWriter.flush();
parseCommand(
RLP_SUBCOMMAND_NAME, RLP_ENCODE_SUBCOMMAND_NAME, "--from", tempJsonFile.getPath());
RLP_SUBCOMMAND_NAME,
RLP_ENCODE_SUBCOMMAND_NAME,
"--from",
tempJsonFile.toFile().getAbsolutePath());
final String expectedRlpString =
"0xf853a00000000000000000000000000000000000000000000000000000000000000000ea94be068f726a13c8d"
@ -180,9 +184,9 @@ public class RLPSubCommandTest extends CommandTestAbstract {
}
@Test
public void canEncodeToQbftExtraData() throws IOException {
final File tempJsonFile = temp.newFile("test.json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile.toPath(), UTF_8)) {
public void canEncodeToQbftExtraData(final @TempDir Path dir) throws Exception {
final Path tempJsonFile = Files.createTempFile(dir, "qbft", "json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile, UTF_8)) {
fileWriter.write(
"[\"be068f726a13c8d46c44be6ce9d275600e1735a4\", \"5ff6f4b66a46a2b2310a6f3a93aaddc0d9a1c193\"]");
@ -193,7 +197,7 @@ public class RLPSubCommandTest extends CommandTestAbstract {
RLP_SUBCOMMAND_NAME,
RLP_ENCODE_SUBCOMMAND_NAME,
"--from",
tempJsonFile.getPath(),
tempJsonFile.toFile().getAbsolutePath(),
"--type",
RLP_QBFT_TYPE);
@ -206,17 +210,19 @@ public class RLPSubCommandTest extends CommandTestAbstract {
}
@Test
public void encodeWithInvalidInputMustRaiseAnError() throws Exception {
final File tempJsonFile = temp.newFile("invalid_test.json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile.toPath(), UTF_8)) {
public void encodeWithInvalidInputMustRaiseAnError(final @TempDir Path dir) throws Exception {
final Path tempJsonFile = Files.createTempFile(dir, "invalid", "json");
try (final BufferedWriter fileWriter = Files.newBufferedWriter(tempJsonFile, UTF_8)) {
fileWriter.write("{\"property\":0}");
fileWriter.flush();
parseCommand(
RLP_SUBCOMMAND_NAME, RLP_ENCODE_SUBCOMMAND_NAME, "--from", tempJsonFile.getPath());
RLP_SUBCOMMAND_NAME,
RLP_ENCODE_SUBCOMMAND_NAME,
"--from",
tempJsonFile.toFile().getAbsolutePath());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
@ -226,11 +232,13 @@ public class RLPSubCommandTest extends CommandTestAbstract {
}
@Test
public void encodeWithEmptyInputMustRaiseAnError() throws Exception {
final File tempJsonFile = temp.newFile("empty.json");
parseCommand(RLP_SUBCOMMAND_NAME, RLP_ENCODE_SUBCOMMAND_NAME, "--from", tempJsonFile.getPath());
public void encodeWithEmptyInputMustRaiseAnError(final @TempDir Path dir) throws Exception {
final Path emptyFile = Files.createTempFile(dir, "empty", "json");
parseCommand(
RLP_SUBCOMMAND_NAME,
RLP_ENCODE_SUBCOMMAND_NAME,
"--from",
emptyFile.toFile().getAbsolutePath());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8))
@ -251,7 +259,7 @@ public class RLPSubCommandTest extends CommandTestAbstract {
.startsWith("An error occurred while trying to read the JSON data.");
}
@After
@AfterEach
public void restoreStdin() {
System.setIn(System.in);
}

@ -36,17 +36,16 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
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.junit.jupiter.api.io.TempDir;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine.Model.CommandSpec;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class BlocksSubCommandTest extends CommandTestAbstract {
@Rule public final TemporaryFolder folder = new TemporaryFolder();
@TempDir public Path folder;
private static final String EXPECTED_BLOCK_USAGE =
"Usage: besu blocks [-hV] [COMMAND]"
@ -187,10 +186,13 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
@Test
public void callingBlockImportSubCommandWithPathMustImportBlocksWithThisPath() throws Exception {
final File fileToImport = temp.newFile("blocks.file");
public void callingBlockImportSubCommandWithPathMustImportBlocksWithThisPath(
final @TempDir File fileToImport) throws Exception {
parseCommand(
BLOCK_SUBCOMMAND_NAME, BLOCK_IMPORT_SUBCOMMAND_NAME, "--from", fileToImport.getPath());
BLOCK_SUBCOMMAND_NAME,
BLOCK_IMPORT_SUBCOMMAND_NAME,
"--from",
fileToImport.getAbsolutePath().toString());
verify(rlpBlockImporter)
.importBlockchain(pathArgumentCaptor.capture(), any(), anyBoolean(), anyLong(), anyLong());
@ -202,8 +204,7 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
@Test
public void blocksImport_rlpFormat() throws Exception {
final File fileToImport = temp.newFile("blocks.file");
public void blocksImport_rlpFormat(final @TempDir File fileToImport) throws Exception {
parseCommand(
BLOCK_SUBCOMMAND_NAME,
BLOCK_IMPORT_SUBCOMMAND_NAME,
@ -222,10 +223,11 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
@Test
public void blocksImport_rlpFormatMultiple() throws Exception {
final File fileToImport = temp.newFile("blocks.file");
final File file2ToImport = temp.newFile("blocks2.file");
final File file3ToImport = temp.newFile("blocks3.file");
public void blocksImport_rlpFormatMultiple(
final @TempDir File fileToImport,
final @TempDir File file2ToImport,
final @TempDir File file3ToImport)
throws Exception {
parseCommand(
BLOCK_SUBCOMMAND_NAME,
BLOCK_IMPORT_SUBCOMMAND_NAME,
@ -247,10 +249,10 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
@Test
public void blocksImport_jsonFormat() throws Exception {
public void blocksImport_jsonFormat(final @TempDir Path dir) throws Exception {
final String fileContent = "test";
final File fileToImport = temp.newFile("blocks.file");
final Writer fileWriter = Files.newBufferedWriter(fileToImport.toPath(), UTF_8);
final Path fileToImport = Files.createTempFile(dir, "tmp", "json");
final Writer fileWriter = Files.newBufferedWriter(fileToImport, UTF_8);
fileWriter.write(fileContent);
fileWriter.close();
@ -260,7 +262,7 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
"--format",
"JSON",
"--from",
fileToImport.getPath());
fileToImport.toFile().getAbsolutePath());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
@ -274,9 +276,7 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
public void blocksExport_missingFileParam() throws IOException {
createDbDirectory(true);
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME);
"--data-path=" + folder.getRoot(), BLOCK_SUBCOMMAND_NAME, BLOCK_EXPORT_SUBCOMMAND_NAME);
final String expectedErrorOutputStart = "Missing required option: '--to=<FILE>'";
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).startsWith(expectedErrorOutputStart);
@ -285,17 +285,17 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
@Test
public void blocksExport_noDbDirectory() throws IOException {
final File outputFile = folder.newFile("blocks.bin");
public void blocksExport_noDbDirectory(final @TempDir Path noDbDir) throws IOException {
final File outputFile = noDbDir.resolve("blocks.bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + noDbDir,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
outputFile.getPath());
outputFile.getAbsolutePath());
final String expectedErrorOutputStart =
"Chain is empty. Unable to export blocks from specified data directory: "
+ folder.getRoot().getAbsolutePath()
+ noDbDir
+ File.separator
+ BesuController.DATABASE_PATH;
assertThat(commandOutput.toString(UTF_8)).isEmpty();
@ -307,16 +307,16 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_emptyDbDirectory() throws IOException {
createDbDirectory(false);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createFile(folder.resolve("empty")).toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
outputFile.getPath());
final String expectedErrorOutputStart =
"Chain is empty. Unable to export blocks from specified data directory: "
+ folder.getRoot().getAbsolutePath()
+ folder
+ File.separator
+ BesuController.DATABASE_PATH;
assertThat(commandOutput.toString(UTF_8)).isEmpty();
@ -328,13 +328,13 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_noStartOrEnd() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
outputFile.getPath());
outputFile.getAbsolutePath());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
@ -344,9 +344,9 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withStartAndNoEnd() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createFile(folder.resolve("blocks.bin")).toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
@ -361,9 +361,9 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withEndAndNoStart() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
@ -378,13 +378,13 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withStartAndEnd() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
outputFile.getPath(),
outputFile.getAbsolutePath(),
"--start-block=1",
"--end-block=10");
assertThat(commandOutput.toString(UTF_8)).isEmpty();
@ -396,13 +396,13 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withOutOfOrderStartAndEnd() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
outputFile.getPath(),
outputFile.getAbsolutePath(),
"--start-block=10",
"--end-block=1");
assertThat(commandErrorOutput.toString(UTF_8))
@ -415,9 +415,9 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withEmptyRange() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder,
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
@ -434,9 +434,9 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withInvalidStart() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder.getRoot(),
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
@ -452,9 +452,9 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
@Test
public void blocksExport_withInvalidEnd() throws IOException {
createDbDirectory(true);
final File outputFile = folder.newFile("blocks.bin");
final File outputFile = Files.createTempFile(folder, "blocks", "bin").toFile();
parseCommand(
"--data-path=" + folder.getRoot().getAbsolutePath(),
"--data-path=" + folder.getRoot(),
BLOCK_SUBCOMMAND_NAME,
BLOCK_EXPORT_SUBCOMMAND_NAME,
"--to",
@ -482,17 +482,18 @@ public class BlocksSubCommandTest extends CommandTestAbstract {
}
private void createDbDirectory(final boolean createDataFiles) throws IOException {
final File dbDir = folder.newFolder(BesuController.DATABASE_PATH);
final Path dbDir = Files.createDirectory(folder.resolve(BesuController.DATABASE_PATH));
if (createDataFiles) {
final Path dataFilePath = Paths.get(dbDir.getAbsolutePath(), "0000001.sst");
final boolean success = new File(dataFilePath.toString()).createNewFile();
final Path dataFilePath = Paths.get(dbDir.toFile().getAbsolutePath(), "0000001.sst");
final boolean success = new File(dataFilePath.toFile().getAbsolutePath()).createNewFile();
assertThat(success).isTrue();
}
}
@Test
public void blocksImportWithNoSyncModeDoesNotRaiseNPE() throws IOException {
final File fileToImport = temp.newFile("blocks.file");
public void blocksImportWithNoSyncModeDoesNotRaiseNPE(final @TempDir File fileToImport)
throws IOException {
parseCommand(
BLOCK_SUBCOMMAND_NAME, BLOCK_IMPORT_SUBCOMMAND_NAME, "--from", fileToImport.getPath());

@ -36,11 +36,11 @@ import org.hyperledger.besu.services.kvstore.SegmentedKeyValueStorageAdapter;
import java.util.List;
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.Silent.class)
@ExtendWith(MockitoExtension.class)
public class StorageSubCommandTest extends CommandTestAbstract {
@Test

@ -22,18 +22,18 @@ import org.hyperledger.besu.plugin.services.PluginVersionsProvider;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class BesuCommandCustomFactoryTest {
@Mock private PluginVersionsProvider pluginVersionsProvider;
@Before
@BeforeEach
public void initMocks() {
when(pluginVersionsProvider.getPluginVersions()).thenReturn(Arrays.asList("v1", "v2"));
}

@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ -28,18 +29,19 @@ import org.hyperledger.besu.cli.options.stable.LoggingLevelOption;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
import picocli.CommandLine.IDefaultValueProvider;
import picocli.CommandLine.IExecutionStrategy;
@ -49,11 +51,11 @@ import picocli.CommandLine.Model.OptionSpec;
import picocli.CommandLine.ParseResult;
import picocli.CommandLine.RunLast;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ConfigOptionSearchAndRunHandlerTest {
private static final String CONFIG_FILE_OPTION_NAME = "--config-file";
@Rule public final TemporaryFolder temp = new TemporaryFolder();
@TempDir public Path temp;
private LoggingLevelOption levelOption;
private final IExecutionStrategy resultHandler = new RunLast();
@ -68,16 +70,18 @@ public class ConfigOptionSearchAndRunHandlerTest {
@Mock IGetter mockConfigOptionGetter;
@Mock BesuParameterExceptionHandler mockParameterExceptionHandler;
@Before
@BeforeEach
public void initMocks() {
when(mockCommandSpec.commandLine()).thenReturn(mockCommandLine);
when(mockParseResult.commandSpec()).thenReturn(mockCommandSpec);
lenient().when(mockCommandSpec.commandLine()).thenReturn(mockCommandLine);
lenient().when(mockParseResult.commandSpec()).thenReturn(mockCommandSpec);
final List<String> originalArgs = new ArrayList<>();
originalArgs.add(CONFIG_FILE_OPTION_NAME);
when(mockParseResult.originalArgs()).thenReturn(originalArgs);
when(mockParseResult.matchedOption(CONFIG_FILE_OPTION_NAME)).thenReturn(mockConfigOptionSpec);
when(mockParseResult.hasMatchedOption(CONFIG_FILE_OPTION_NAME)).thenReturn(true);
when(mockConfigOptionSpec.getter()).thenReturn(mockConfigOptionGetter);
lenient().when(mockParseResult.originalArgs()).thenReturn(originalArgs);
lenient()
.when(mockParseResult.matchedOption(CONFIG_FILE_OPTION_NAME))
.thenReturn(mockConfigOptionSpec);
lenient().when(mockParseResult.hasMatchedOption(CONFIG_FILE_OPTION_NAME)).thenReturn(true);
lenient().when(mockConfigOptionSpec.getter()).thenReturn(mockConfigOptionGetter);
levelOption = new LoggingLevelOption();
levelOption.setLogLevel("INFO");
configParsingHandler =
@ -87,7 +91,7 @@ public class ConfigOptionSearchAndRunHandlerTest {
@Test
public void handleWithCommandLineOption() throws Exception {
when(mockConfigOptionGetter.get()).thenReturn(temp.newFile());
when(mockConfigOptionGetter.get()).thenReturn(Files.createTempFile("tmp", "txt").toFile());
final List<Object> result = configParsingHandler.handle(mockParseResult);
verify(mockCommandLine).setDefaultValueProvider(any(IDefaultValueProvider.class));
verify(mockCommandLine).setExecutionStrategy(eq(resultHandler));
@ -105,7 +109,9 @@ public class ConfigOptionSearchAndRunHandlerTest {
new ConfigOptionSearchAndRunHandler(
resultHandler,
mockParameterExceptionHandler,
singletonMap("BESU_CONFIG_FILE", temp.newFile().getAbsolutePath()));
singletonMap(
"BESU_CONFIG_FILE",
Files.createFile(temp.resolve("tmp")).toFile().getAbsolutePath()));
when(mockParseResult.hasMatchedOption(CONFIG_FILE_OPTION_NAME)).thenReturn(false);
@ -160,7 +166,7 @@ public class ConfigOptionSearchAndRunHandlerTest {
new ConfigOptionSearchAndRunHandler(
resultHandler,
mockParameterExceptionHandler,
singletonMap("BESU_CONFIG_FILE", temp.newFile().getAbsolutePath()));
singletonMap("BESU_CONFIG_FILE", temp.resolve("tmp").toFile().getAbsolutePath()));
when(mockParseResult.hasMatchedOption(CONFIG_FILE_OPTION_NAME)).thenReturn(true);

@ -23,12 +23,12 @@ import org.hyperledger.besu.plugin.services.PluginVersionsProvider;
import java.util.Collections;
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 VersionProviderTest {
@Mock private PluginVersionsProvider pluginVersionsProvider;

@ -30,9 +30,6 @@ import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
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;
@ -45,10 +42,13 @@ import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration;
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;

@ -17,6 +17,7 @@ package org.hyperledger.besu.services;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ -76,15 +77,15 @@ import java.util.stream.Stream;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@SuppressWarnings("unchecked")
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class BesuEventsImplTest {
private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM =
@ -113,7 +114,7 @@ public class BesuEventsImplTest {
private MutableBlockchain blockchain;
private final BlockDataGenerator gen = new BlockDataGenerator();
@Before
@BeforeEach
public void setUp() {
blockchain =
DefaultBlockchain.createMutable(
@ -128,18 +129,22 @@ public class BesuEventsImplTest {
when(mockEthContext.getEthMessages()).thenReturn(mockEthMessages);
when(mockEthContext.getEthPeers()).thenReturn(mockEthPeers);
when(mockEthContext.getScheduler()).thenReturn(mockEthScheduler);
when(mockEthPeers.streamAvailablePeers()).thenAnswer(z -> Stream.empty());
lenient().when(mockEthPeers.streamAvailablePeers()).thenAnswer(z -> Stream.empty());
when(mockProtocolContext.getBlockchain()).thenReturn(blockchain);
when(mockProtocolContext.getWorldStateArchive()).thenReturn(mockWorldStateArchive);
when(mockProtocolSchedule.getByBlockHeader(any())).thenReturn(mockProtocolSpec);
when(mockProtocolSpec.getTransactionValidatorFactory())
lenient().when(mockProtocolContext.getWorldStateArchive()).thenReturn(mockWorldStateArchive);
lenient().when(mockProtocolSchedule.getByBlockHeader(any())).thenReturn(mockProtocolSpec);
lenient()
.when(mockProtocolSpec.getTransactionValidatorFactory())
.thenReturn(mockTransactionValidatorFactory);
when(mockProtocolSpec.getFeeMarket()).thenReturn(FeeMarket.london(0L));
when(mockTransactionValidatorFactory.get().validate(any(), any(Optional.class), any()))
lenient().when(mockProtocolSpec.getFeeMarket()).thenReturn(FeeMarket.london(0L));
lenient()
.when(mockTransactionValidatorFactory.get().validate(any(), any(Optional.class), any()))
.thenReturn(ValidationResult.valid());
when(mockTransactionValidatorFactory.get().validateForSender(any(), any(), any()))
lenient()
.when(mockTransactionValidatorFactory.get().validateForSender(any(), any(), any()))
.thenReturn(ValidationResult.valid());
when(mockWorldStateArchive.getMutable(any(), anyBoolean()))
lenient()
.when(mockWorldStateArchive.getMutable(any(), anyBoolean()))
.thenReturn(Optional.of(mockWorldState));
blockBroadcaster = new BlockBroadcaster(mockEthContext);

@ -17,16 +17,16 @@ package org.hyperledger.besu.services;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.UnmatchedArgumentException;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PicoCLIOptionsImplTest {
@Command
@ -46,7 +46,7 @@ public class PicoCLIOptionsImplTest {
private CommandLine commandLine;
private PicoCLIOptionsImpl serviceImpl;
@Before
@BeforeEach
public void setUp() {
command = new SimpleCommand();
mixin = new MixinOptions();

@ -232,7 +232,6 @@ public class LocalPermissioningConfigurationValidatorTest {
true,
toml.toAbsolutePath().toString()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining(
"Invalid IP address (or DNS query resolved an invalid IP). --Xdns-enabled is true but --Xdns-update-enabled flag is false.");
.hasMessageContaining("Invalid IP address");
}
}

@ -14,6 +14,7 @@
*/
import com.github.jk1.license.filter.LicenseBundleNormalizer
import groovy.transform.CompileStatic
import groovy.transform.Memoized
import net.ltgt.gradle.errorprone.CheckSeverity
@ -22,15 +23,15 @@ import java.text.SimpleDateFormat
import java.util.regex.Pattern
plugins {
id 'com.diffplug.spotless' version '6.12.0'
id 'com.github.ben-manes.versions' version '0.42.0'
id 'com.github.hierynomus.license' version '0.16.1-fix'
id 'com.jfrog.artifactory' version '4.28.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'me.champeau.jmh' version '0.7.0' apply false
id 'net.ltgt.errorprone' version '2.0.2'
id 'com.diffplug.spotless' version '6.23.3'
id 'com.github.ben-manes.versions' version '0.50.0'
id 'com.github.jk1.dependency-license-report' version '2.5'
id 'com.jfrog.artifactory' version '5.1.11'
id 'io.spring.dependency-management' version '1.1.4'
id 'me.champeau.jmh' version '0.7.2' apply false
id 'net.ltgt.errorprone' version '3.0.1'
id 'maven-publish'
id 'org.sonarqube' version '3.4.0.2513'
id 'org.sonarqube' version '4.4.1.3373'
}
sonarqube {
@ -87,13 +88,35 @@ def _strListCmdArg(name) {
return _strListCmdArg(name, null)
}
licenseReport {
// This is for the allowed-licenses-file in checkLicense Task
// Accepts File, URL or String path to local or remote file
allowedLicensesFile = new File("$rootDir/gradle/allowed-licenses.json")
excludes = [
// only used for static analysis, not actually shipped
'com.google.errorprone:javac',
'org.checkerframework:dataflow-shaded',
'org.checkerframework:dataflow-errorprone',
// exclude Kotlin multiplatform dependencies container, they have the same license of what they contain
'com.squareup.okio:okio',
'org.jetbrains.kotlinx:kotlinx-coroutines-core'
]
// If set to true, then all boms will be excluded from the report
excludeBoms = true
filters = [
new LicenseBundleNormalizer(bundlePath: "$rootDir/gradle/license-normalizer-bundle.json")
]
}
allprojects {
apply plugin: 'java-library'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
apply plugin: 'net.ltgt.errorprone'
apply from: "${rootDir}/gradle/versions.gradle"
apply from: "${rootDir}/gradle/check-licenses.gradle"
version = rootProject.version
@ -177,7 +200,7 @@ allprojects {
}
groovyGradle {
target '*.gradle'
greclipse('4.21.0').configFile(rootProject.file('gradle/formatter.properties'))
greclipse('4.21').configFile(rootProject.file('gradle/formatter.properties'))
endWithNewline()
}
// Below this line are currently only license header tasks
@ -323,7 +346,6 @@ allprojects {
options.addStringOption('Xwerror', '-html5')
options.encoding = 'UTF-8'
}
}
task deploy() {}
@ -624,10 +646,10 @@ task autocomplete(type: JavaExec) {
}
}
installDist { dependsOn checkLicenses, untunedStartScripts, evmToolStartScripts }
installDist { dependsOn checkLicense, untunedStartScripts, evmToolStartScripts }
distTar {
dependsOn checkLicenses, autocomplete, untunedStartScripts, evmToolStartScripts
dependsOn checkLicense, autocomplete, untunedStartScripts, evmToolStartScripts
doFirst {
delete fileTree(dir: 'build/distributions', include: '*.tar.gz')
}
@ -636,7 +658,7 @@ distTar {
}
distZip {
dependsOn checkLicenses, autocomplete, untunedStartScripts, evmToolStartScripts
dependsOn checkLicense, autocomplete, untunedStartScripts, evmToolStartScripts
doFirst {
delete fileTree(dir: 'build/distributions', include: '*.zip')
}
@ -958,7 +980,6 @@ task checkSpdxHeader(type: CheckSpdxHeader) {
"(.*${sep}build${sep}.*)",
"(.*${sep}src${sep}[^${sep}]+${sep}generated${sep}.*)"
].join("|")
}
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {

@ -60,6 +60,4 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}

@ -59,8 +59,6 @@ dependencies {
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
testSupportImplementation project( path: ':crypto:services', configuration: 'testSupportArtifacts')
testSupportImplementation project( path: ':ethereum:core', configuration: 'testSupportArtifacts')
testSupportImplementation 'org.mockito:mockito-core'

@ -104,7 +104,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolMetrics;
import org.hyperledger.besu.ethereum.eth.transactions.sorter.GasPricePendingTransactionsSorter;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@ -241,7 +241,7 @@ public class TestContextBuilder {
}
final MutableBlockchain blockChain;
final DefaultWorldStateArchive worldStateArchive = createInMemoryWorldStateArchive();
final ForestWorldStateArchive worldStateArchive = createInMemoryWorldStateArchive();
if (genesisFile.isPresent()) {
try {

@ -42,6 +42,4 @@ dependencies {
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}

@ -39,8 +39,6 @@ dependencies {
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}
configurations { testArtifacts }

@ -38,8 +38,6 @@ dependencies {
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
epJavac 'com.google.errorprone:error_prone_check_api'
}

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.bonsai.BonsaiAccount;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiAccount;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.AccountState;

@ -31,6 +31,7 @@ import java.util.List;
import java.util.Optional;
import com.fasterxml.jackson.core.JsonGenerator.Feature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
@ -46,6 +47,10 @@ import org.slf4j.LoggerFactory;
public class WebSocketMessageHandler {
private static final ObjectMapper jsonObjectMapper =
new ObjectMapper()
.registerModule(new Jdk8Module()); // Handle JDK8 Optionals (de)serialization
private static final Logger LOG = LoggerFactory.getLogger(WebSocketMessageHandler.class);
private static final ObjectWriter JSON_OBJECT_WRITER =
new ObjectMapper()
@ -161,6 +166,7 @@ public class WebSocketMessageHandler {
}
private void replyToClient(final ServerWebSocket websocket, final Object result) {
traceResponse(result);
try {
// underlying output stream lifecycle is managed by the json object writer
JSON_OBJECT_WRITER.writeValue(new JsonResponseStreamer(websocket), result);
@ -172,4 +178,12 @@ public class WebSocketMessageHandler {
private JsonRpcResponse errorResponse(final Object id, final RpcErrorType error) {
return new JsonRpcErrorResponse(id, error);
}
private void traceResponse(final Object response) {
try {
LOG.trace(jsonObjectMapper.writeValueAsString(response));
} catch (JsonProcessingException e) {
LOG.error("Error tracing JSON-RPC response", e);
}
}
}

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.worldstate;
package org.hyperledger.besu.ethereum.trie.forest.pruner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain;
@ -26,11 +26,15 @@ import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.pruner.Pruner.PruningPhase;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.Pruner.PruningPhase;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.worldstate.WorldState;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@ -57,9 +61,10 @@ public class PrunerIntegrationTest {
private final NoOpMetricsSystem metricsSystem = new NoOpMetricsSystem();
private final Map<Bytes, Optional<byte[]>> hashValueStore = new HashMap<>();
private final InMemoryKeyValueStorage stateStorage = new TestInMemoryStorage(hashValueStore);
private final WorldStateStorage worldStateStorage = new WorldStateKeyValueStorage(stateStorage);
private final WorldStateStorage worldStateStorage =
new ForestWorldStateKeyValueStorage(stateStorage);
private final WorldStateArchive worldStateArchive =
new DefaultWorldStateArchive(
new ForestWorldStateArchive(
worldStateStorage,
new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()),
EvmConfiguration.DEFAULT);

@ -32,9 +32,9 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
import org.hyperledger.besu.evm.account.MutableAccount;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.log.LogsBloomFilter;
@ -134,12 +134,12 @@ public final class GenesisState {
}
private static Hash calculateGenesisStateHash(final List<GenesisAccount> genesisAccounts) {
final WorldStateKeyValueStorage stateStorage =
new WorldStateKeyValueStorage(new InMemoryKeyValueStorage());
final ForestWorldStateKeyValueStorage stateStorage =
new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage());
final WorldStatePreimageKeyValueStorage preimageStorage =
new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage());
final MutableWorldState worldState =
new DefaultMutableWorldState(stateStorage, preimageStorage, EvmConfiguration.DEFAULT);
new ForestMutableWorldState(stateStorage, preimageStorage, EvmConfiguration.DEFAULT);
writeAccountsTo(worldState, genesisAccounts, null);
return worldState.rootHash();
}

@ -26,7 +26,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver;
import org.hyperledger.besu.ethereum.privacy.PrivateWorldStateReader;
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
@ -340,7 +340,7 @@ public class PrivacyParameters {
final WorldStatePreimageStorage privatePreimageStorage =
storageProvider.createWorldStatePreimageStorage();
final WorldStateArchive privateWorldStateArchive =
new DefaultWorldStateArchive(
new ForestWorldStateArchive(
privateWorldStateStorage, privatePreimageStorage, EvmConfiguration.DEFAULT);
final PrivateStateStorage privateStateStorage = storageProvider.createPrivateStateStorage();

@ -21,8 +21,6 @@ import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.BlockProcessingOutputs;
import org.hyperledger.besu.ethereum.BlockProcessingResult;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Deposit;
@ -33,6 +31,8 @@ import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
import org.hyperledger.besu.ethereum.vm.CachingBlockHashLookup;
import org.hyperledger.besu.evm.tracing.OperationTracer;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.worldstate;
package org.hyperledger.besu.ethereum.privacy;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
@ -26,12 +26,12 @@ import java.util.Optional;
// This class uses a public WorldUpdater and a private WorldUpdater to provide a
// MutableWorldStateUpdater that can read and write from the private world state and can read from
// the public world state, but cannot write to it.
public class DefaultMutablePrivateWorldStateUpdater implements WorldUpdater {
public class PrivateMutableWorldStateUpdater implements WorldUpdater {
protected final WorldUpdater publicWorldUpdater;
protected final WorldUpdater privateWorldUpdater;
public DefaultMutablePrivateWorldStateUpdater(
public PrivateMutableWorldStateUpdater(
final WorldUpdater publicWorldUpdater, final WorldUpdater privateWorldUpdater) {
this.publicWorldUpdater = publicWorldUpdater;
this.privateWorldUpdater = privateWorldUpdater;

@ -24,7 +24,6 @@ import org.hyperledger.besu.ethereum.mainnet.TransactionValidatorFactory;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.worldstate.DefaultMutablePrivateWorldStateUpdater;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.MutableAccount;
import org.hyperledger.besu.evm.code.CodeV0;
@ -109,7 +108,7 @@ public class PrivateTransactionProcessor {
sender.getNonce());
final WorldUpdater mutablePrivateWorldStateUpdater =
new DefaultMutablePrivateWorldStateUpdater(publicWorldState, privateWorldState);
new PrivateMutableWorldStateUpdater(publicWorldState, privateWorldState);
final MessageFrame.Builder commonMessageFrameBuilder =
MessageFrame.builder()
.maxStackSize(maxStackSize)

@ -19,8 +19,8 @@ import org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage;
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
@ -48,7 +48,7 @@ public class PrivacyKeyValueStorageProvider implements PrivacyStorageProvider {
@Override
public WorldStateStorage createWorldStateStorage() {
return new WorldStateKeyValueStorage(privateWorldStateKeyValueStorage);
return new ForestWorldStateKeyValueStorage(privateWorldStateKeyValueStorage);
}
@Override

@ -14,12 +14,13 @@
*/
package org.hyperledger.besu.ethereum.storage.keyvalue;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.chain.BlockchainStorage;
import org.hyperledger.besu.ethereum.chain.VariablesStorage;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
@ -78,7 +79,7 @@ public class KeyValueStorageProvider implements StorageProvider {
if (dataStorageFormat.equals(DataStorageFormat.BONSAI)) {
return new BonsaiWorldStateKeyValueStorage(this, metricsSystem);
} else {
return new WorldStateKeyValueStorage(
return new ForestWorldStateKeyValueStorage(
getStorageBySegmentIdentifier(KeyValueSegmentIdentifier.WORLD_STATE));
}
}

@ -14,18 +14,18 @@
*
*/
package org.hyperledger.besu.ethereum.bonsai;
package org.hyperledger.besu.ethereum.trie.bonsai;
import org.hyperledger.besu.datatypes.AccountValue;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldView;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldView;
import org.hyperledger.besu.evm.ModificationNotAllowedException;
import org.hyperledger.besu.evm.account.AccountStorageEntry;
import org.hyperledger.besu.evm.account.MutableAccount;

@ -14,7 +14,7 @@
*
*/
package org.hyperledger.besu.ethereum.bonsai;
package org.hyperledger.besu.ethereum.trie.bonsai;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;

@ -14,19 +14,12 @@
*
*/
package org.hyperledger.besu.ethereum.bonsai;
package org.hyperledger.besu.ethereum.trie.bonsai;
import static org.hyperledger.besu.ethereum.bonsai.cache.CachedWorldStorageManager.RETAINED_LAYERS;
import static org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedWorldStorageManager.RETAINED_LAYERS;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedWorldStorageManager;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogManager;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogPruner;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
@ -34,6 +27,13 @@ import org.hyperledger.besu.ethereum.proof.WorldStateProof;
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedWorldStorageManager;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogManager;
import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogPruner;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;

@ -13,17 +13,17 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.cache;
package org.hyperledger.besu.ethereum.trie.bonsai.cache;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CachedBonsaiWorldView implements BonsaiStorageSubscriber {
public class CachedBonsaiWorldView
implements BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber {
private BonsaiWorldStateKeyValueStorage worldStateStorage;
private final BlockHeader blockHeader;
private long worldViewSubscriberId;

@ -13,15 +13,14 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.cache;
package org.hyperledger.besu.ethereum.trie.bonsai.cache;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.StorageSlotKey;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
@ -38,7 +37,8 @@ import io.prometheus.client.guava.cache.CacheMetricsCollector;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
public class CachedMerkleTrieLoader implements BonsaiStorageSubscriber {
public class CachedMerkleTrieLoader
implements BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber {
private static final int ACCOUNT_CACHE_SIZE = 100_000;
private static final int STORAGE_CACHE_SIZE = 200_000;

@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.bonsai.cache;
package org.hyperledger.besu.ethereum.trie.bonsai.cache;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;

@ -12,16 +12,15 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.bonsai.cache;
package org.hyperledger.besu.ethereum.trie.bonsai.cache;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiSnapshotWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateLayerStorage;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiSnapshotWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateLayerStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
@ -37,7 +36,8 @@ import org.apache.tuweni.bytes.Bytes32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CachedWorldStorageManager implements BonsaiStorageSubscriber {
public class CachedWorldStorageManager
implements BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber {
public static final long RETAINED_LAYERS = 512; // at least 256 + typical rollbacks
private static final Logger LOG = LoggerFactory.getLogger(CachedWorldStorageManager.class);
private final BonsaiWorldStateProvider archive;

@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.storage;
package org.hyperledger.besu.ethereum.trie.bonsai.storage;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;

@ -13,11 +13,11 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.storage;
package org.hyperledger.besu.ethereum.trie.bonsai.storage;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.StorageSlotKey;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.plugin.services.exception.StorageException;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.bonsai.storage;
package org.hyperledger.besu.ethereum.trie.bonsai.storage;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;
@ -21,12 +21,12 @@ import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIden
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.StorageSlotKey;
import org.hyperledger.besu.ethereum.bonsai.storage.flat.FlatDbStrategy;
import org.hyperledger.besu.ethereum.bonsai.storage.flat.FullFlatDbStrategy;
import org.hyperledger.besu.ethereum.bonsai.storage.flat.PartialFlatDbStrategy;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.flat.FlatDbStrategy;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.flat.FullFlatDbStrategy;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.flat.PartialFlatDbStrategy;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;

@ -13,9 +13,9 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.storage;
package org.hyperledger.besu.ethereum.trie.bonsai.storage;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber;
import org.hyperledger.besu.ethereum.worldstate.FlatDbMode;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;

@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.storage.flat;
package org.hyperledger.besu.ethereum.trie.bonsai.storage.flat;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;

@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.storage.flat;
package org.hyperledger.besu.ethereum.trie.bonsai.storage.flat;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;

@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.storage.flat;
package org.hyperledger.besu.ethereum.trie.bonsai.storage.flat;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_STORAGE_STORAGE;

@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.trielog;
package org.hyperledger.besu.ethereum.trie.bonsai.trielog;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
import org.hyperledger.besu.plugin.services.trielogs.TrieLogEvent;

@ -13,17 +13,17 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.trielog;
package org.hyperledger.besu.ethereum.trie.bonsai.trielog;
import org.hyperledger.besu.datatypes.AccountValue;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.StorageSlotKey;
import org.hyperledger.besu.ethereum.bonsai.BonsaiValue;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiValue;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.plugin.data.BlockHeader;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;

@ -14,7 +14,7 @@
*
*/
package org.hyperledger.besu.ethereum.bonsai.trielog;
package org.hyperledger.besu.ethereum.trie.bonsai.trielog;
import static com.google.common.base.Preconditions.checkState;
@ -22,7 +22,7 @@ import org.hyperledger.besu.datatypes.AccountValue;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.StorageSlotKey;
import org.hyperledger.besu.ethereum.bonsai.BonsaiValue;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiValue;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;
import java.util.HashMap;

@ -13,14 +13,14 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.bonsai.trielog;
package org.hyperledger.besu.ethereum.trie.bonsai.trielog;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
import org.hyperledger.besu.plugin.BesuContext;
import org.hyperledger.besu.plugin.services.TrieLogService;
import org.hyperledger.besu.plugin.services.trielogs.TrieLog;

@ -13,13 +13,13 @@
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.bonsai.trielog;
package org.hyperledger.besu.ethereum.trie.bonsai.trielog;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import java.util.Comparator;
import java.util.Optional;

@ -14,32 +14,32 @@
*
*/
package org.hyperledger.besu.ethereum.bonsai.worldview;
package org.hyperledger.besu.ethereum.trie.bonsai.worldview;
import static org.hyperledger.besu.ethereum.bonsai.BonsaiAccount.fromRLP;
import static org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage.WORLD_BLOCK_HASH_KEY;
import static org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage.WORLD_ROOT_HASH_KEY;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;
import static org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage.WORLD_BLOCK_HASH_KEY;
import static org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage.WORLD_ROOT_HASH_KEY;
import static org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldView.encodeTrieValue;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.StorageSlotKey;
import org.hyperledger.besu.ethereum.bonsai.BonsaiAccount;
import org.hyperledger.besu.ethereum.bonsai.BonsaiValue;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedWorldStorageManager;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiSnapshotWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateLayerStorage;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogManager;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldStateUpdateAccumulator.StorageConsumingMap;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.trie.NodeLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiAccount;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiValue;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedWorldStorageManager;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiSnapshotWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage.BonsaiStorageSubscriber;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateLayerStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogManager;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldStateUpdateAccumulator.StorageConsumingMap;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.account.Account;
@ -59,6 +59,7 @@ import javax.annotation.Nonnull;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.rlp.RLP;
import org.apache.tuweni.units.bigints.UInt256;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -309,7 +310,7 @@ public class BonsaiWorldState
bonsaiUpdater ->
bonsaiUpdater.putStorageValueBySlotHash(
updatedAddressHash, slotHash, updatedStorage));
storageTrie.put(slotHash, BonsaiWorldView.encodeTrieValue(updatedStorage));
storageTrie.put(slotHash, encodeTrieValue(updatedStorage));
}
} catch (MerkleTrieException e) {
// need to throw to trigger the heal
@ -347,7 +348,8 @@ public class BonsaiWorldState
final BonsaiAccount oldAccount =
worldStateStorage
.getAccount(address.addressHash())
.map(bytes -> fromRLP(BonsaiWorldState.this, address, bytes, true))
.map(
bytes -> BonsaiAccount.fromRLP(BonsaiWorldState.this, address, bytes, true))
.orElse(null);
if (oldAccount == null) {
// This is when an account is both created and deleted within the scope of the same
@ -360,14 +362,24 @@ public class BonsaiWorldState
(location, key) -> getStorageTrieNode(addressHash, location, key),
oldAccount.getStorageRoot());
try {
final StorageConsumingMap<StorageSlotKey, BonsaiValue<UInt256>> storageToDelete =
worldStateUpdater.getStorageToUpdate().get(address);
Map<Bytes32, Bytes> entriesToDelete = storageTrie.entriesFrom(Bytes32.ZERO, 256);
while (!entriesToDelete.isEmpty()) {
entriesToDelete
.keySet()
.forEach(
k ->
bonsaiUpdater.removeStorageValueBySlotHash(
address.addressHash(), Hash.wrap(k)));
entriesToDelete.forEach(
(k, v) -> {
final StorageSlotKey storageSlotKey =
new StorageSlotKey(Hash.wrap(k), Optional.empty());
final UInt256 slotValue =
UInt256.fromBytes(Bytes32.leftPad(RLP.decodeValue(v)));
bonsaiUpdater.removeStorageValueBySlotHash(
address.addressHash(), storageSlotKey.getSlotHash());
storageToDelete
.computeIfAbsent(
storageSlotKey, key -> new BonsaiValue<>(slotValue, null, true))
.setPrior(slotValue);
});
entriesToDelete.keySet().forEach(storageTrie::remove);
if (entriesToDelete.size() == 256) {
entriesToDelete = storageTrie.entriesFrom(Bytes32.ZERO, 256);
@ -537,7 +549,7 @@ public class BonsaiWorldState
public Account get(final Address address) {
return worldStateStorage
.getAccount(address.addressHash())
.map(bytes -> fromRLP(accumulator, address, bytes, true))
.map(bytes -> BonsaiAccount.fromRLP(accumulator, address, bytes, true))
.orElse(null);
}

@ -14,18 +14,18 @@
*
*/
package org.hyperledger.besu.ethereum.bonsai.worldview;
package org.hyperledger.besu.ethereum.trie.bonsai.worldview;
import org.hyperledger.besu.datatypes.AccountValue;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.StorageSlotKey;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.bonsai.BonsaiAccount;
import org.hyperledger.besu.ethereum.bonsai.BonsaiValue;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiAccount;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiValue;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.MutableAccount;
import org.hyperledger.besu.evm.internal.EvmConfiguration;

@ -14,13 +14,13 @@
*
*/
package org.hyperledger.besu.ethereum.bonsai.worldview;
package org.hyperledger.besu.ethereum.trie.bonsai.worldview;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.StorageSlotKey;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
import org.hyperledger.besu.evm.worldstate.WorldView;

@ -13,7 +13,7 @@
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.ethereum.worldstate;
package org.hyperledger.besu.ethereum.trie.forest;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
@ -22,6 +22,10 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
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.evm.worldstate.WorldState;
@ -32,7 +36,7 @@ import java.util.function.Function;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;
public class DefaultWorldStateArchive implements WorldStateArchive {
public class ForestWorldStateArchive implements WorldStateArchive {
private final WorldStateStorage worldStateStorage;
private final WorldStatePreimageStorage preimageStorage;
private final WorldStateProofProvider worldStateProof;
@ -40,7 +44,7 @@ public class DefaultWorldStateArchive implements WorldStateArchive {
private static final Hash EMPTY_ROOT_HASH = Hash.wrap(MerkleTrie.EMPTY_TRIE_NODE_HASH);
public DefaultWorldStateArchive(
public ForestWorldStateArchive(
final WorldStateStorage worldStateStorage,
final WorldStatePreimageStorage preimageStorage,
final EvmConfiguration evmConfiguration) {
@ -72,7 +76,7 @@ public class DefaultWorldStateArchive implements WorldStateArchive {
return Optional.empty();
}
return Optional.of(
new DefaultMutableWorldState(
new ForestMutableWorldState(
rootHash, worldStateStorage, preimageStorage, evmConfiguration));
}

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.worldstate;
package org.hyperledger.besu.ethereum.trie.forest.pruner;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
@ -20,6 +20,8 @@ import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.plugin.services.metrics.Counter;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.worldstate;
package org.hyperledger.besu.ethereum.trie.forest.pruner;
import static com.google.common.base.Preconditions.checkArgument;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.worldstate;
package org.hyperledger.besu.ethereum.trie.forest.pruner;
public class PrunerConfiguration {
public static final int DEFAULT_PRUNING_BLOCKS_RETAINED = 1024;

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.storage.keyvalue;
package org.hyperledger.besu.ethereum.trie.forest.storage;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
@ -35,13 +35,13 @@ import java.util.stream.Stream;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
public class WorldStateKeyValueStorage implements WorldStateStorage {
public class ForestWorldStateKeyValueStorage implements WorldStateStorage {
private final Subscribers<NodesAddedListener> nodeAddedListeners = Subscribers.create();
private final KeyValueStorage keyValueStorage;
private final ReentrantLock lock = new ReentrantLock();
public WorldStateKeyValueStorage(final KeyValueStorage keyValueStorage) {
public ForestWorldStateKeyValueStorage(final KeyValueStorage keyValueStorage) {
this.keyValueStorage = keyValueStorage;
}

@ -12,7 +12,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.worldstate;
package org.hyperledger.besu.ethereum.trie.forest.worldview;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
@ -24,6 +24,9 @@ import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.AccountStorageEntry;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
@ -47,7 +50,7 @@ import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt256;
public class DefaultMutableWorldState implements MutableWorldState {
public class ForestMutableWorldState implements MutableWorldState {
private final EvmConfiguration evmConfiguration;
private final WorldStateStorage worldStateStorage;
@ -59,14 +62,14 @@ public class DefaultMutableWorldState implements MutableWorldState {
private final Map<Bytes32, UInt256> newStorageKeyPreimages = new HashMap<>();
private final Map<Bytes32, Address> newAccountKeyPreimages = new HashMap<>();
public DefaultMutableWorldState(
public ForestMutableWorldState(
final WorldStateStorage storage,
final WorldStatePreimageStorage preimageStorage,
final EvmConfiguration evmConfiguration) {
this(MerkleTrie.EMPTY_TRIE_NODE_HASH, storage, preimageStorage, evmConfiguration);
}
public DefaultMutableWorldState(
public ForestMutableWorldState(
final Bytes32 rootHash,
final WorldStateStorage worldStateStorage,
final WorldStatePreimageStorage preimageStorage,
@ -77,12 +80,12 @@ public class DefaultMutableWorldState implements MutableWorldState {
this.evmConfiguration = evmConfiguration;
}
public DefaultMutableWorldState(
public ForestMutableWorldState(
final WorldState worldState, final EvmConfiguration evmConfiguration) {
// TODO: this is an abstraction leak (and kind of incorrect in that we reuse the underlying
// storage), but the reason for this is that the accounts() method is unimplemented below and
// can't be until NC-754.
if (!(worldState instanceof DefaultMutableWorldState other)) {
if (!(worldState instanceof ForestMutableWorldState other)) {
throw new UnsupportedOperationException();
}
@ -156,7 +159,7 @@ public class DefaultMutableWorldState implements MutableWorldState {
@Override
public final boolean equals(final Object other) {
if (!(other instanceof DefaultMutableWorldState that)) {
if (!(other instanceof ForestMutableWorldState that)) {
return false;
}
@ -288,7 +291,7 @@ public class DefaultMutableWorldState implements MutableWorldState {
public UInt256 getStorageValue(final UInt256 key) {
return storageTrie()
.get(Hash.hash(key))
.map(DefaultMutableWorldState::convertToUInt256)
.map(ForestMutableWorldState::convertToUInt256)
.orElse(UInt256.ZERO);
}
@ -332,16 +335,16 @@ public class DefaultMutableWorldState implements MutableWorldState {
}
protected static class Updater
extends AbstractWorldUpdater<DefaultMutableWorldState, WorldStateAccount> {
extends AbstractWorldUpdater<ForestMutableWorldState, WorldStateAccount> {
protected Updater(
final DefaultMutableWorldState world, final EvmConfiguration evmConfiguration) {
final ForestMutableWorldState world, final EvmConfiguration evmConfiguration) {
super(world, evmConfiguration);
}
@Override
protected WorldStateAccount getForMutation(final Address address) {
final DefaultMutableWorldState wrapped = wrappedWorldView();
final ForestMutableWorldState wrapped = wrappedWorldView();
final Hash addressHash = address.addressHash();
return wrapped
.accountStateTrie
@ -368,7 +371,7 @@ public class DefaultMutableWorldState implements MutableWorldState {
@Override
public void commit() {
final DefaultMutableWorldState wrapped = wrappedWorldView();
final ForestMutableWorldState wrapped = wrappedWorldView();
for (final Address address : getDeletedAccounts()) {
final Hash addressHash = address.addressHash();

@ -14,10 +14,6 @@
*/
package org.hyperledger.besu.ethereum.core;
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.bonsai.trielog.TrieLogPruner;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.DefaultBlockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
@ -28,11 +24,15 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogPruner;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
@ -78,9 +78,9 @@ public class InMemoryKeyValueStorageProvider extends KeyValueStorageProvider {
0);
}
public static DefaultWorldStateArchive createInMemoryWorldStateArchive() {
return new DefaultWorldStateArchive(
new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()),
public static ForestWorldStateArchive createInMemoryWorldStateArchive() {
return new ForestWorldStateArchive(
new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()),
new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()),
EvmConfiguration.DEFAULT);
}
@ -110,7 +110,7 @@ public class InMemoryKeyValueStorageProvider extends KeyValueStorageProvider {
public static MutableWorldState createInMemoryWorldState() {
final InMemoryKeyValueStorageProvider provider = new InMemoryKeyValueStorageProvider();
return new DefaultMutableWorldState(
return new ForestMutableWorldState(
provider.createWorldStateStorage(DataStorageFormat.FOREST),
provider.createWorldStatePreimageStorage(),
EvmConfiguration.DEFAULT);

@ -19,10 +19,10 @@ import org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage;
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
@ -32,15 +32,15 @@ import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
public class InMemoryPrivacyStorageProvider implements PrivacyStorageProvider {
public static WorldStateArchive createInMemoryWorldStateArchive() {
return new DefaultWorldStateArchive(
new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()),
return new ForestWorldStateArchive(
new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()),
new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()),
EvmConfiguration.DEFAULT);
}
public static MutableWorldState createInMemoryWorldState() {
final InMemoryPrivacyStorageProvider provider = new InMemoryPrivacyStorageProvider();
return new DefaultMutableWorldState(
return new ForestMutableWorldState(
provider.createWorldStateStorage(),
provider.createWorldStatePreimageStorage(),
EvmConfiguration.DEFAULT);
@ -48,7 +48,7 @@ public class InMemoryPrivacyStorageProvider implements PrivacyStorageProvider {
@Override
public WorldStateStorage createWorldStateStorage() {
return new WorldStateKeyValueStorage(new InMemoryKeyValueStorage());
return new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage());
}
@Override

@ -16,9 +16,9 @@ package org.hyperledger.besu.ethereum.core;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;

@ -23,9 +23,6 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block;
@ -44,6 +41,9 @@ import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.internal.EvmConfiguration;

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

Loading…
Cancel
Save