From 47364bfda3b86ad9f03d50da15bdd1e834a09803 Mon Sep 17 00:00:00 2001 From: Justin Florentine Date: Tue, 19 Dec 2023 08:30:28 -0500 Subject: [PATCH] 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 Signed-off-by: jflo * Add trace to web socket JSON/RPC responses (#6285) * Add trace to web socket JSON/RPC responses Signed-off-by: Matthew Whitehead * Don't throw runtime exception if we can't parse JSON for trace Signed-off-by: Matthew Whitehead --------- Signed-off-by: Matthew Whitehead Signed-off-by: jflo * [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 Signed-off-by: jflo * Execute the terminatedImmediately method only once (#6284) Signed-off-by: David Lutzardo Co-authored-by: Sally MacFarlane Signed-off-by: jflo * 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 Signed-off-by: matkt Signed-off-by: jflo * removed vintage junit dependency (#6296) Signed-off-by: Sally MacFarlane Signed-off-by: jflo * updated cli and chainimport/export tests to junit 5 (#6281) Signed-off-by: Sally MacFarlane Signed-off-by: jflo * [MINOR] CLI Subcommands migrate to junit 5 (#6282) * updated cli and chainimport/export tests to junit 5 Signed-off-by: Sally MacFarlane * subcommands and besucommand test to junit5 Signed-off-by: Sally MacFarlane * removed duplicate line Signed-off-by: Sally MacFarlane * removed vintage junit dep Signed-off-by: Sally MacFarlane --------- Signed-off-by: Sally MacFarlane Co-authored-by: Fabio Di Fabio Signed-off-by: jflo * [MINOR] add genesis file name to config overview (#6297) * add genesis file name to config overview Signed-off-by: Sally MacFarlane --------- Signed-off-by: Sally MacFarlane Signed-off-by: jflo * create trie package for bonsai and forest (#6300) Signed-off-by: Karim Taam Signed-off-by: matkt Signed-off-by: jflo * [MINOR] More cli tests to junit 5 (#6283) * more CLI and services tests to junit5 --------- Signed-off-by: Sally MacFarlane Co-authored-by: Fabio Di Fabio Signed-off-by: jflo * Update Gradle plugins and replace unmaintained license plugin (#6275) Signed-off-by: Fabio Di Fabio Signed-off-by: jflo * Quick fix to avoid a tight loop when processing added blocks in txpool (#6309) Signed-off-by: Fabio Di Fabio Signed-off-by: jflo * uprev to version 23.10.3-RC4 Signed-off-by: jflo * mark deleted slot during clear storage step Signed-off-by: Karim Taam --------- Signed-off-by: Danno Ferrin Signed-off-by: jflo Signed-off-by: Matthew Whitehead Signed-off-by: Sally MacFarlane Signed-off-by: David Lutzardo Signed-off-by: Karim Taam Signed-off-by: matkt Signed-off-by: Fabio Di Fabio Co-authored-by: Danno Ferrin Co-authored-by: Matt Whitehead Co-authored-by: Sally MacFarlane Co-authored-by: David Lutzardo Co-authored-by: Karim TAAM Co-authored-by: Fabio Di Fabio --- .github/workflows/checks.yml | 8 +- .github/workflows/codeql.yml | 5 +- .github/workflows/release.yml | 3 +- .github/workflows/sonarcloud.yml | 9 +- CHANGELOG.md | 2 + besu/build.gradle | 2 - .../org/hyperledger/besu/cli/BesuCommand.java | 7 +- .../cli/ConfigurationOverviewBuilder.java | 16 +- .../cli/subcommands/operator/BackupState.java | 4 +- .../subcommands/operator/RestoreState.java | 4 +- .../besu/components/BesuComponent.java | 4 +- .../controller/BesuControllerBuilder.java | 20 +- ...onsensusScheduleBesuControllerBuilder.java | 2 +- .../TransitionBesuControllerBuilder.java | 4 +- .../chainexport/RlpBlockExporterTest.java | 77 +- .../chainimport/JsonBlockImporterTest.java | 89 +- .../hyperledger/besu/cli/BesuCommandTest.java | 59 +- .../besu/cli/CommandLineUtilsTest.java | 8 +- .../besu/cli/CommandTestAbstract.java | 48 +- .../cli/ConfigurationOverviewBuilderTest.java | 3 +- ...nvironmentVariableDefaultProviderTest.java | 8 +- .../besu/cli/PasswordSubCommandTest.java | 8 +- .../besu/cli/PublicKeySubCommandTest.java | 16 +- .../TomlConfigFileDefaultProviderTest.java | 43 +- .../cli/ValidateConfigSubCommandTest.java | 8 +- .../besu/cli/config/EthNetworkConfigTest.java | 8 +- .../cli/converter/FractionConverterTest.java | 8 +- .../MetricCategoryConverterTest.java | 12 +- .../converter/PercentageConverterTest.java | 8 +- .../cli/custom/RpcAuthFileValidatorTest.java | 8 +- .../cli/operator/OperatorSubCommandTest.java | 12 +- .../cli/options/AbstractCLIOptionsTest.java | 2 +- .../cli/options/EthProtocolOptionsTest.java | 8 +- .../cli/options/MetricsCLIOptionsTest.java | 6 +- .../besu/cli/options/MiningOptionsTest.java | 8 +- .../cli/options/NetworkingOptionsTest.java | 8 +- .../besu/cli/options/OptionParserTest.java | 8 +- .../cli/options/SynchronizerOptionsTest.java | 6 +- .../options/TransactionPoolOptionsTest.java | 8 +- .../stable/DataStorageOptionsTest.java | 2 +- .../stable/LoggingLevelOptionTest.java | 6 +- .../besu/cli/rlp/RLPSubCommandTest.java | 54 +- .../blocks/BlocksSubCommandTest.java | 111 +- .../storage/StorageSubCommandTest.java | 8 +- .../util/BesuCommandCustomFactoryTest.java | 12 +- .../ConfigOptionSearchAndRunHandlerTest.java | 42 +- .../besu/cli/util/VersionProviderTest.java | 8 +- .../controller/BesuControllerBuilderTest.java | 8 +- .../besu/services/BesuEventsImplTest.java | 33 +- .../besu/services/PicoCLIOptionsImplTest.java | 12 +- ...rmissioningConfigurationValidatorTest.java | 3 +- build.gradle | 51 +- consensus/clique/build.gradle | 2 - consensus/common/build.gradle | 2 - .../qbft/support/TestContextBuilder.java | 4 +- crypto/algorithms/build.gradle | 2 - datatypes/build.gradle | 2 - errorprone-checks/build.gradle | 2 - .../internal/pojoadapter/AccountAdapter.java | 2 +- .../websocket/WebSocketMessageHandler.java | 14 + .../forest/pruner}/PrunerIntegrationTest.java | 15 +- .../besu/ethereum/chain/GenesisState.java | 10 +- .../besu/ethereum/core/PrivacyParameters.java | 4 +- .../mainnet/AbstractBlockProcessor.java | 4 +- .../PrivateMutableWorldStateUpdater.java} | 6 +- .../privacy/PrivateTransactionProcessor.java | 3 +- .../PrivacyKeyValueStorageProvider.java | 4 +- .../keyvalue/KeyValueStorageProvider.java | 5 +- .../{ => trie}/bonsai/BonsaiAccount.java | 4 +- .../{ => trie}/bonsai/BonsaiValue.java | 2 +- .../bonsai/BonsaiWorldStateProvider.java | 18 +- .../bonsai/cache/CachedBonsaiWorldView.java | 8 +- .../bonsai/cache/CachedMerkleTrieLoader.java | 8 +- .../cache/CachedMerkleTrieLoaderModule.java | 2 +- .../cache/CachedWorldStorageManager.java | 16 +- .../bonsai/storage/BonsaiPreImageProxy.java | 2 +- ...nsaiSnapshotWorldStateKeyValueStorage.java | 4 +- .../BonsaiWorldStateKeyValueStorage.java | 8 +- .../storage/BonsaiWorldStateLayerStorage.java | 4 +- .../bonsai/storage/flat/FlatDbStrategy.java | 2 +- .../storage/flat/FullFlatDbStrategy.java | 2 +- .../storage/flat/PartialFlatDbStrategy.java | 2 +- .../bonsai/trielog/TrieLogAddedEvent.java | 2 +- .../bonsai/trielog/TrieLogFactoryImpl.java | 4 +- .../bonsai/trielog/TrieLogLayer.java | 4 +- .../bonsai/trielog/TrieLogManager.java | 8 +- .../bonsai/trielog/TrieLogPruner.java | 4 +- .../bonsai/worldview/BonsaiWorldState.java | 60 +- .../BonsaiWorldStateUpdateAccumulator.java | 8 +- .../bonsai/worldview/BonsaiWorldView.java | 4 +- .../forest/ForestWorldStateArchive.java} | 12 +- .../forest/pruner}/MarkSweepPruner.java | 4 +- .../forest/pruner}/Pruner.java | 2 +- .../forest/pruner}/PrunerConfiguration.java | 2 +- .../ForestWorldStateKeyValueStorage.java} | 6 +- .../worldview/ForestMutableWorldState.java} | 27 +- .../core/InMemoryKeyValueStorageProvider.java | 22 +- .../core/InMemoryPrivacyStorageProvider.java | 14 +- .../besu/ethereum/core/TrieGenerator.java | 2 +- .../BlockImportExceptionHandlingTest.java | 6 +- .../proof/WorldStateProofProviderTest.java | 4 +- .../WorldStateRangeProofProviderTest.java | 4 +- .../bonsai/AbstractIsolationTests.java | 8 +- .../bonsai/BonsaiSnapshotIsolationTests.java | 2 +- .../bonsai/BonsaiWorldStateArchiveTest.java | 22 +- .../bonsai/CachedMerkleTrieLoaderTest.java | 6 +- .../{ => trie}/bonsai/LogRollingTests.java | 12 +- .../{ => trie}/bonsai/RollingImport.java | 12 +- .../BonsaiWorldStateKeyValueStorageTest.java | 4 +- .../bonsai/trielog/TrieLogFactoryTests.java | 2 +- .../bonsai/trielog/TrieLogLayerTests.java | 2 +- .../bonsai/trielog/TrieLogManagerTests.java | 10 +- .../bonsai/trielog/TrieLogPrunerTest.java | 4 +- .../forest/pruner}/MarkSweepPrunerTest.java | 12 +- .../forest/pruner}/PrunerTest.java | 2 +- ...KeyValueStorageWorldStateStorageTest.java} | 38 +- .../ForestMutableWorldStateTest.java} | 17 +- .../eth/sync/DefaultSynchronizer.java | 4 +- .../AccountTrieNodeDataRequest.java | 2 +- .../worldstate/FastDownloaderFactory.java | 2 +- .../StorageTrieNodeDataRequest.java | 2 +- .../eth/sync/snapsync/PersistDataStep.java | 2 +- .../snapsync/SnapWorldStateDownloader.java | 2 +- .../request/AccountRangeDataRequest.java | 2 +- .../request/StorageRangeDataRequest.java | 2 +- ...ccountFlatDatabaseHealingRangeRequest.java | 2 +- .../heal/AccountTrieNodeHealingRequest.java | 2 +- ...torageFlatDatabaseHealingRangeRequest.java | 2 +- .../heal/StorageTrieNodeHealingRequest.java | 2 +- .../eth/transactions/TransactionPool.java | 7 + .../FastWorldDownloadStateTest.java | 6 +- .../FastWorldStateDownloaderTest.java | 56 +- .../snapsync/AccountHealingTrackingTest.java | 2 +- .../eth/sync/snapsync/RangeManagerTest.java | 6 +- .../snapsync/SnapWorldDownloadStateTest.java | 6 +- .../eth/sync/snapsync/StackTrieTest.java | 10 +- ...ntFlatDatabaseHealingRangeRequestTest.java | 8 +- ...geFlatDatabaseHealingRangeRequestTest.java | 2 +- .../StorageTrieNodeHealingRequestTest.java | 6 +- ethereum/evmtool/build.gradle | 2 +- .../besu/evmtool/BlockchainModule.java | 10 +- .../besu/ethereum/p2p/peers/EnodeURLImpl.java | 4 +- .../connections/AbstractPeerConnection.java | 23 +- .../BonsaiReferenceTestUpdateAccumulator.java | 10 +- .../BonsaiReferenceTestWorldState.java | 18 +- .../BonsaiReferenceTestWorldStateStorage.java | 10 +- .../DefaultReferenceTestWorldState.java | 8 +- .../ReferenceTestBlockchain.java | 2 +- .../besu/ethereum/core/TransactionTest.java | 33 +- .../core/TransactionTestCaseSpec.java | 5 +- .../besu/ethereum/rlp/RLPRefTest.java | 33 +- .../ethereum/retesteth/RetestethContext.java | 8 +- evm/build.gradle | 2 - gradle.properties | 4 +- gradle/allowed-licenses.json | 65 + gradle/check-licenses.gradle | 216 -- gradle/license-normalizer-bundle.json | 106 + gradle/verification-metadata.xml | 2173 +++++++++++++---- nat/build.gradle | 2 - pki/build.gradle | 2 - settings.gradle | 12 - util/build.gradle | 2 - 162 files changed, 2878 insertions(+), 1439 deletions(-) rename ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/{worldstate => trie/forest/pruner}/PrunerIntegrationTest.java (93%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{worldstate/DefaultMutablePrivateWorldStateUpdater.java => privacy/PrivateMutableWorldStateUpdater.java} (94%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/BonsaiAccount.java (98%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/BonsaiValue.java (97%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/BonsaiWorldStateProvider.java (95%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/cache/CachedBonsaiWorldView.java (88%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/cache/CachedMerkleTrieLoader.java (95%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/cache/CachedMerkleTrieLoaderModule.java (94%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/cache/CachedWorldStorageManager.java (92%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/storage/BonsaiPreImageProxy.java (97%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/storage/BonsaiSnapshotWorldStateKeyValueStorage.java (97%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/storage/BonsaiWorldStateKeyValueStorage.java (98%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/storage/BonsaiWorldStateLayerStorage.java (92%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/storage/flat/FlatDbStrategy.java (99%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/storage/flat/FullFlatDbStrategy.java (98%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/storage/flat/PartialFlatDbStrategy.java (98%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/trielog/TrieLogAddedEvent.java (93%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/trielog/TrieLogFactoryImpl.java (98%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/trielog/TrieLogLayer.java (98%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/trielog/TrieLogManager.java (96%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/trielog/TrieLogPruner.java (97%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/worldview/BonsaiWorldState.java (90%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java (99%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/worldview/BonsaiWorldView.java (93%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{worldstate/DefaultWorldStateArchive.java => trie/forest/ForestWorldStateArchive.java} (88%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{worldstate => trie/forest/pruner}/MarkSweepPruner.java (98%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{worldstate => trie/forest/pruner}/Pruner.java (99%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{worldstate => trie/forest/pruner}/PrunerConfiguration.java (96%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{storage/keyvalue/WorldStateKeyValueStorage.java => trie/forest/storage/ForestWorldStateKeyValueStorage.java} (97%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{worldstate/DefaultMutableWorldState.java => trie/forest/worldview/ForestMutableWorldState.java} (94%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/AbstractIsolationTests.java (97%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/BonsaiSnapshotIsolationTests.java (99%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/BonsaiWorldStateArchiveTest.java (93%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/CachedMerkleTrieLoaderTest.java (97%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/LogRollingTests.java (96%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/RollingImport.java (91%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/storage/BonsaiWorldStateKeyValueStorageTest.java (99%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/trielog/TrieLogFactoryTests.java (97%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/trielog/TrieLogLayerTests.java (98%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/trielog/TrieLogManagerTests.java (85%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{ => trie}/bonsai/trielog/TrieLogPrunerTest.java (98%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{worldstate => trie/forest/pruner}/MarkSweepPrunerTest.java (95%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{worldstate => trie/forest/pruner}/PrunerTest.java (99%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{storage/keyvalue/KeyValueStorageWorldStateStorageTest.java => trie/forest/storage/ForestKeyValueStorageWorldStateStorageTest.java} (82%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/{worldstate/DefaultMutableWorldStateTest.java => trie/forest/worldview/ForestMutableWorldStateTest.java} (97%) create mode 100644 gradle/allowed-licenses.json delete mode 100644 gradle/check-licenses.gradle create mode 100644 gradle/license-normalizer-bundle.json diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 900cc5c977..ee5aa159e9 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -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) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f4ecae04ba..590227e98d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2041368b0..16fd67f94d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 5a2ba5143e..92d9a7713e 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index b3a16d3098..0275bd837a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/besu/build.gradle b/besu/build.gradle index fe5bb45c30..0b31c4a43c 100644 --- a/besu/build.gradle +++ b/besu/build.gradle @@ -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' } diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index b8b7efca3a..07bcabcaa2 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -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 diff --git a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java index 5ed209ca31..4fd870e99c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilder.java @@ -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) { diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java index 0c5c4c0e32..401b824d5e 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java @@ -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 { diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java index 47452b6eb3..a4b36bd5a6 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java @@ -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(); } diff --git a/besu/src/main/java/org/hyperledger/besu/components/BesuComponent.java b/besu/src/main/java/org/hyperledger/besu/components/BesuComponent.java index 0edc5f15e4..f0093243a6 100644 --- a/besu/src/main/java/org/hyperledger/besu/components/BesuComponent.java +++ b/besu/src/main/java/org/hyperledger/besu/components/BesuComponent.java @@ -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; diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index 643aed546c..92cbf320e8 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -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); } }; } diff --git a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java index 921289c66e..1d9356f5c7 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java @@ -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; diff --git a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java index 8231f8e26a..65aadd46c6 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java @@ -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; diff --git a/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java index 89e1b25547..faa6bd34b9 100644 --- a/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java @@ -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))) diff --git a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java index 00ebc61082..4b59491dc1 100644 --- a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java @@ -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 getParameters() { - final Object[][] params = {{"ethash"}, {"clique"}}; - return Arrays.asList(params); + public static Stream 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()) diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index 955c9df7aa..3db626287f 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -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( diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandLineUtilsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandLineUtilsTest.java index f8bc8d8972..726bf38965 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CommandLineUtilsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandLineUtilsTest.java @@ -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 diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java index 8597c0582d..e9d8d55964 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java @@ -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 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)); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilderTest.java index ae00587c04..eee55c3975 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/ConfigurationOverviewBuilderTest.java @@ -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"); } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/EnvironmentVariableDefaultProviderTest.java b/besu/src/test/java/org/hyperledger/besu/cli/EnvironmentVariableDefaultProviderTest.java index af60932734..9953ca519f 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/EnvironmentVariableDefaultProviderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/EnvironmentVariableDefaultProviderTest.java @@ -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 environment = new HashMap<>(); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/PasswordSubCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/PasswordSubCommandTest.java index 62d35830c0..5d661f9203 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/PasswordSubCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/PasswordSubCommandTest.java @@ -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 diff --git a/besu/src/test/java/org/hyperledger/besu/cli/PublicKeySubCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/PublicKeySubCommandTest.java index 3da574e8e3..d2ca00990a 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/PublicKeySubCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/PublicKeySubCommandTest.java @@ -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(); } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/TomlConfigFileDefaultProviderTest.java b/besu/src/test/java/org/hyperledger/besu/cli/TomlConfigFileDefaultProviderTest.java index 1481db9526..5185a4133e 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/TomlConfigFileDefaultProviderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/TomlConfigFileDefaultProviderTest.java @@ -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 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 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 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]"); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/ValidateConfigSubCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/ValidateConfigSubCommandTest.java index dc8d0548e0..ac6efbf405 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/ValidateConfigSubCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/ValidateConfigSubCommandTest.java @@ -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 = diff --git a/besu/src/test/java/org/hyperledger/besu/cli/config/EthNetworkConfigTest.java b/besu/src/test/java/org/hyperledger/besu/cli/config/EthNetworkConfigTest.java index 66e8592b5e..3bddc7724b 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/config/EthNetworkConfigTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/config/EthNetworkConfigTest.java @@ -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 diff --git a/besu/src/test/java/org/hyperledger/besu/cli/converter/FractionConverterTest.java b/besu/src/test/java/org/hyperledger/besu/cli/converter/FractionConverterTest.java index 611109274d..74abdeef5a 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/converter/FractionConverterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/converter/FractionConverterTest.java @@ -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(); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java b/besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java index db34fb9d5e..8c78b7fecc 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/converter/MetricCategoryConverterTest.java @@ -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(); } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/converter/PercentageConverterTest.java b/besu/src/test/java/org/hyperledger/besu/cli/converter/PercentageConverterTest.java index 829a4ef35f..8ee5143c20 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/converter/PercentageConverterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/converter/PercentageConverterTest.java @@ -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(); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/custom/RpcAuthFileValidatorTest.java b/besu/src/test/java/org/hyperledger/besu/cli/custom/RpcAuthFileValidatorTest.java index 714086245a..32db1368af 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/custom/RpcAuthFileValidatorTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/custom/RpcAuthFileValidatorTest.java @@ -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"; diff --git a/besu/src/test/java/org/hyperledger/besu/cli/operator/OperatorSubCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/operator/OperatorSubCommandTest.java index 414412ebb4..ac1ec2e577 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/operator/OperatorSubCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/operator/OperatorSubCommandTest.java @@ -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())); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/AbstractCLIOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/AbstractCLIOptionsTest.java index 09b4e3b136..35dcaa4bae 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/AbstractCLIOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/AbstractCLIOptionsTest.java @@ -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> extends CommandTestAbstract { diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java index 9d1d696ab4..6f7aa637cd 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/EthProtocolOptionsTest.java @@ -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 { diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsCLIOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsCLIOptionsTest.java index 8044770a9b..e88462216f 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsCLIOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/MetricsCLIOptionsTest.java @@ -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 { diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java index 0b7cc5e122..404c021e3b 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java @@ -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 { @Test diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java index a2cbdc5942..4b4601bb9c 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/NetworkingOptionsTest.java @@ -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 { diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/OptionParserTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/OptionParserTest.java index db5e69e174..d57e15d261 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/OptionParserTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/OptionParserTest.java @@ -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 diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java index 0e814a07e2..3b1a9e6839 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/SynchronizerOptionsTest.java @@ -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 { diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/TransactionPoolOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/TransactionPoolOptionsTest.java index d7031eb9a4..00d4efc3b9 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/TransactionPoolOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/TransactionPoolOptionsTest.java @@ -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 { diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/DataStorageOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/stable/DataStorageOptionsTest.java index 5b4e022855..437053afd5 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/DataStorageOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/stable/DataStorageOptionsTest.java @@ -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 { diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java index 4d0a67e75c..18b09434de 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/stable/LoggingLevelOptionTest.java @@ -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(); } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/rlp/RLPSubCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/rlp/RLPSubCommandTest.java index 822c732271..3eca54df25 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/rlp/RLPSubCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/rlp/RLPSubCommandTest.java @@ -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); } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommandTest.java index 5c62076e69..29f519f891 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommandTest.java @@ -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='"; 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()); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/subcommands/storage/StorageSubCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/subcommands/storage/StorageSubCommandTest.java index e3b67d8b43..3ca4f41aaf 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/subcommands/storage/StorageSubCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/subcommands/storage/StorageSubCommandTest.java @@ -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 diff --git a/besu/src/test/java/org/hyperledger/besu/cli/util/BesuCommandCustomFactoryTest.java b/besu/src/test/java/org/hyperledger/besu/cli/util/BesuCommandCustomFactoryTest.java index d83fa43a65..f3494b506b 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/util/BesuCommandCustomFactoryTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/util/BesuCommandCustomFactoryTest.java @@ -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")); } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandlerTest.java b/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandlerTest.java index 0f0c1e696a..bd33703d9c 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandlerTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandlerTest.java @@ -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 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 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); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/util/VersionProviderTest.java b/besu/src/test/java/org/hyperledger/besu/cli/util/VersionProviderTest.java index 6fba9cf66a..57f16c9021 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/util/VersionProviderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/util/VersionProviderTest.java @@ -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; diff --git a/besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java index a24479e861..bb7304d9f7 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java @@ -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; diff --git a/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java index 6245a8a6ba..25db1cb9b4 100644 --- a/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java +++ b/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java @@ -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 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); diff --git a/besu/src/test/java/org/hyperledger/besu/services/PicoCLIOptionsImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/PicoCLIOptionsImplTest.java index ac7e7fb959..52f37f769a 100644 --- a/besu/src/test/java/org/hyperledger/besu/services/PicoCLIOptionsImplTest.java +++ b/besu/src/test/java/org/hyperledger/besu/services/PicoCLIOptionsImplTest.java @@ -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(); diff --git a/besu/src/test/java/org/hyperledger/besu/util/LocalPermissioningConfigurationValidatorTest.java b/besu/src/test/java/org/hyperledger/besu/util/LocalPermissioningConfigurationValidatorTest.java index a5b3bb90d9..84344c2491 100644 --- a/besu/src/test/java/org/hyperledger/besu/util/LocalPermissioningConfigurationValidatorTest.java +++ b/besu/src/test/java/org/hyperledger/besu/util/LocalPermissioningConfigurationValidatorTest.java @@ -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"); } } diff --git a/build.gradle b/build.gradle index 364d969db2..a00ea343db 100644 --- a/build.gradle +++ b/build.gradle @@ -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) { diff --git a/consensus/clique/build.gradle b/consensus/clique/build.gradle index 4c5634f17c..f09e583777 100644 --- a/consensus/clique/build.gradle +++ b/consensus/clique/build.gradle @@ -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' } diff --git a/consensus/common/build.gradle b/consensus/common/build.gradle index 04132ab6d0..0043fe0711 100644 --- a/consensus/common/build.gradle +++ b/consensus/common/build.gradle @@ -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' diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java index 6d8c64a835..58ad24a288 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java +++ b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java @@ -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 { diff --git a/crypto/algorithms/build.gradle b/crypto/algorithms/build.gradle index 190ecae4a2..446a52c371 100644 --- a/crypto/algorithms/build.gradle +++ b/crypto/algorithms/build.gradle @@ -42,6 +42,4 @@ dependencies { testImplementation 'org.assertj:assertj-core' testImplementation 'org.junit.jupiter:junit-jupiter' - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } diff --git a/datatypes/build.gradle b/datatypes/build.gradle index a55bf4e45c..90ba6cc922 100644 --- a/datatypes/build.gradle +++ b/datatypes/build.gradle @@ -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 } diff --git a/errorprone-checks/build.gradle b/errorprone-checks/build.gradle index 1aff3a23b2..a04fa27e47 100644 --- a/errorprone-checks/build.gradle +++ b/errorprone-checks/build.gradle @@ -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' } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/AccountAdapter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/AccountAdapter.java index f9098089e4..13caadab6a 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/AccountAdapter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/AccountAdapter.java @@ -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; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketMessageHandler.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketMessageHandler.java index 3f4995d7ab..d88f6cba8e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketMessageHandler.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketMessageHandler.java @@ -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); + } + } } diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/worldstate/PrunerIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerIntegrationTest.java similarity index 93% rename from ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/worldstate/PrunerIntegrationTest.java rename to ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerIntegrationTest.java index 77f871f100..77ffc461f8 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/worldstate/PrunerIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerIntegrationTest.java @@ -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> 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); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java index a69e920dd2..87d45be818 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java @@ -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 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(); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java index 1d4cfdf6c1..f5e6f05a05 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java @@ -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(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java index 103fb3782d..8f1b01a50c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutablePrivateWorldStateUpdater.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateMutableWorldStateUpdater.java similarity index 94% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutablePrivateWorldStateUpdater.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateMutableWorldStateUpdater.java index e52319463c..fc20db7f81 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutablePrivateWorldStateUpdater.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateMutableWorldStateUpdater.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java index c953ed93d1..9c85fb39fb 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java @@ -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) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/keyvalue/PrivacyKeyValueStorageProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/keyvalue/PrivacyKeyValueStorageProvider.java index d54a4ba164..1596765bfb 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/keyvalue/PrivacyKeyValueStorageProvider.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/keyvalue/PrivacyKeyValueStorageProvider.java @@ -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 diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/KeyValueStorageProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/KeyValueStorageProvider.java index 8a7eef8ee5..dea6b932c3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/KeyValueStorageProvider.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/KeyValueStorageProvider.java @@ -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)); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiAccount.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiAccount.java similarity index 98% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiAccount.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiAccount.java index 476a0ab22e..d93f550caf 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiAccount.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiAccount.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiValue.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiValue.java similarity index 97% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiValue.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiValue.java index 7d862c7fb9..5d14c88275 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiValue.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiValue.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiWorldStateProvider.java similarity index 95% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateProvider.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiWorldStateProvider.java index 5313977c03..4c783888c0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateProvider.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiWorldStateProvider.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedBonsaiWorldView.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedBonsaiWorldView.java similarity index 88% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedBonsaiWorldView.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedBonsaiWorldView.java index 473933b395..6cdfd10cf9 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedBonsaiWorldView.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedBonsaiWorldView.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedMerkleTrieLoader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedMerkleTrieLoader.java similarity index 95% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedMerkleTrieLoader.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedMerkleTrieLoader.java index f53342d631..832ca6f7db 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedMerkleTrieLoader.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedMerkleTrieLoader.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedMerkleTrieLoaderModule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedMerkleTrieLoaderModule.java similarity index 94% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedMerkleTrieLoaderModule.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedMerkleTrieLoaderModule.java index 51cfdd8707..63c8051f25 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedMerkleTrieLoaderModule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedMerkleTrieLoaderModule.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedWorldStorageManager.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedWorldStorageManager.java similarity index 92% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedWorldStorageManager.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedWorldStorageManager.java index bf205f05b7..8a09c136a5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/cache/CachedWorldStorageManager.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/cache/CachedWorldStorageManager.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiPreImageProxy.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiPreImageProxy.java similarity index 97% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiPreImageProxy.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiPreImageProxy.java index 248e5d895f..16cda3104f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiPreImageProxy.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiPreImageProxy.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiSnapshotWorldStateKeyValueStorage.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiSnapshotWorldStateKeyValueStorage.java similarity index 97% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiSnapshotWorldStateKeyValueStorage.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiSnapshotWorldStateKeyValueStorage.java index 80bd2ce86e..69c74ec27c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiSnapshotWorldStateKeyValueStorage.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiSnapshotWorldStateKeyValueStorage.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiWorldStateKeyValueStorage.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateKeyValueStorage.java similarity index 98% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiWorldStateKeyValueStorage.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateKeyValueStorage.java index 28e2c5bd7a..54089c7e21 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiWorldStateKeyValueStorage.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateKeyValueStorage.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiWorldStateLayerStorage.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateLayerStorage.java similarity index 92% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiWorldStateLayerStorage.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateLayerStorage.java index aa96354789..0dd61b8d7a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiWorldStateLayerStorage.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateLayerStorage.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/flat/FlatDbStrategy.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/FlatDbStrategy.java similarity index 99% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/flat/FlatDbStrategy.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/FlatDbStrategy.java index c561dcd860..6c1c918172 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/flat/FlatDbStrategy.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/FlatDbStrategy.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/flat/FullFlatDbStrategy.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/FullFlatDbStrategy.java similarity index 98% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/flat/FullFlatDbStrategy.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/FullFlatDbStrategy.java index de42ba5097..1885069e3d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/flat/FullFlatDbStrategy.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/FullFlatDbStrategy.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/flat/PartialFlatDbStrategy.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/PartialFlatDbStrategy.java similarity index 98% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/flat/PartialFlatDbStrategy.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/PartialFlatDbStrategy.java index 1dc4288b21..632f433f9b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/storage/flat/PartialFlatDbStrategy.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/flat/PartialFlatDbStrategy.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogAddedEvent.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogAddedEvent.java similarity index 93% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogAddedEvent.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogAddedEvent.java index c9df72f004..3e1387997b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogAddedEvent.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogAddedEvent.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogFactoryImpl.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogFactoryImpl.java similarity index 98% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogFactoryImpl.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogFactoryImpl.java index ebac500061..36a6510c91 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogFactoryImpl.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogFactoryImpl.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogLayer.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogLayer.java similarity index 98% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogLayer.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogLayer.java index 7d61e50126..ff1e29c41b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogLayer.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogLayer.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogManager.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogManager.java similarity index 96% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogManager.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogManager.java index 3a874de6b6..ffb4e0bedc 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogManager.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogManager.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogPruner.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogPruner.java similarity index 97% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogPruner.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogPruner.java index 6ba8817074..747a82e162 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogPruner.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogPruner.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldState.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldState.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldState.java index 73717425de..323a9e510e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldState.java @@ -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> storageToDelete = + worldStateUpdater.getStorageToUpdate().get(address); Map 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); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java similarity index 99% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java index f4a0da55c9..1c8cf15916 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldView.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldView.java similarity index 93% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldView.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldView.java index 7a307ec3f4..cd16e7dec8 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldView.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/bonsai/worldview/BonsaiWorldView.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultWorldStateArchive.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java similarity index 88% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultWorldStateArchive.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java index a29bd9b2ff..b04c22a554 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultWorldStateArchive.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/ForestWorldStateArchive.java @@ -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)); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPruner.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/MarkSweepPruner.java similarity index 98% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPruner.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/MarkSweepPruner.java index 136e8b0144..0559400a87 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPruner.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/MarkSweepPruner.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/Pruner.java similarity index 99% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/Pruner.java index 04949b55e1..bad8b2da30 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/Pruner.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/PrunerConfiguration.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerConfiguration.java similarity index 96% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/PrunerConfiguration.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerConfiguration.java index f2336ee9a3..871bdf8f30 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/PrunerConfiguration.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerConfiguration.java @@ -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; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/WorldStateKeyValueStorage.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/storage/ForestWorldStateKeyValueStorage.java similarity index 97% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/WorldStateKeyValueStorage.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/storage/ForestWorldStateKeyValueStorage.java index 74051b5e9b..f53d3e53ce 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/WorldStateKeyValueStorage.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/storage/ForestWorldStateKeyValueStorage.java @@ -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 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; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/worldview/ForestMutableWorldState.java similarity index 94% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldState.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/worldview/ForestMutableWorldState.java index d50f702af3..e9ba94c1a3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/trie/forest/worldview/ForestMutableWorldState.java @@ -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 newStorageKeyPreimages = new HashMap<>(); private final Map 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 { + extends AbstractWorldUpdater { 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(); diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java index fc8bfe77fb..514c882109 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java @@ -14,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); diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryPrivacyStorageProvider.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryPrivacyStorageProvider.java index 91e115cffa..abecd974d8 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryPrivacyStorageProvider.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryPrivacyStorageProvider.java @@ -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 diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TrieGenerator.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TrieGenerator.java index 9ee15e0775..757238a5d8 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TrieGenerator.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TrieGenerator.java @@ -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; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java index a33f6a2b04..f8ac492c93 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java @@ -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; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateProofProviderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateProofProviderTest.java index b6357954f5..e9e4bf9156 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateProofProviderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateProofProviderTest.java @@ -20,8 +20,8 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.MerkleTrie; +import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; @@ -48,7 +48,7 @@ public class WorldStateProofProviderTest { Address.fromHexString("0x1234567890123456789012345678901234567890"); private final WorldStateStorage worldStateStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); private WorldStateProofProvider worldStateProofProvider; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateRangeProofProviderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateRangeProofProviderTest.java index bd4d95321a..2bea39a8e4 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateRangeProofProviderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateRangeProofProviderTest.java @@ -18,10 +18,10 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.TrieGenerator; -import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.RangeStorageEntriesCollector; import org.hyperledger.besu.ethereum.trie.TrieIterator; +import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; @@ -42,7 +42,7 @@ public class WorldStateRangeProofProviderTest { Hash.fromHexString("0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); private static final WorldStateStorage worldStateStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); private static WorldStateProofProvider worldStateProofProvider; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/AbstractIsolationTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/AbstractIsolationTests.java similarity index 97% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/AbstractIsolationTests.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/AbstractIsolationTests.java index 4f40afdb43..a77c51269d 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/AbstractIsolationTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/AbstractIsolationTests.java @@ -13,7 +13,7 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.bonsai; +package org.hyperledger.besu.ethereum.trie.bonsai; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain; import static org.mockito.ArgumentMatchers.any; @@ -32,9 +32,6 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.BlockProcessingResult; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.blockcreation.AbstractBlockCreator; -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.GenesisState; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; @@ -68,6 +65,9 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.storage.StorageProvider; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder; +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.worldstate.DataStorageFormat; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/BonsaiSnapshotIsolationTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiSnapshotIsolationTests.java similarity index 99% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/BonsaiSnapshotIsolationTests.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiSnapshotIsolationTests.java index 03407d2868..20e34bb090 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/BonsaiSnapshotIsolationTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiSnapshotIsolationTests.java @@ -14,7 +14,7 @@ * */ -package org.hyperledger.besu.ethereum.bonsai; +package org.hyperledger.besu.ethereum.trie.bonsai; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchiveTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiWorldStateArchiveTest.java similarity index 93% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchiveTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiWorldStateArchiveTest.java index bfe6954629..6afde3c940 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchiveTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/BonsaiWorldStateArchiveTest.java @@ -13,13 +13,13 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.bonsai; +package org.hyperledger.besu.ethereum.trie.bonsai; import static org.assertj.core.api.Assertions.assertThat; -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.BLOCKCHAIN; 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.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.ArgumentMatchers.eq; @@ -31,19 +31,19 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; 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.TrieLogFactoryImpl; -import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogLayer; -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.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.storage.StorageProvider; +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.TrieLogFactoryImpl; +import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogLayer; +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.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.storage.KeyValueStorage; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/CachedMerkleTrieLoaderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/CachedMerkleTrieLoaderTest.java similarity index 97% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/CachedMerkleTrieLoaderTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/CachedMerkleTrieLoaderTest.java index dfb247ee29..758d708810 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/CachedMerkleTrieLoaderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/CachedMerkleTrieLoaderTest.java @@ -13,21 +13,21 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.bonsai; +package org.hyperledger.besu.ethereum.trie.bonsai; import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.StorageSlotKey; -import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.TrieGenerator; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.storage.StorageProvider; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.TrieIterator; +import org.hyperledger.besu.ethereum.trie.bonsai.cache.CachedMerkleTrieLoader; +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.metrics.noop.NoOpMetricsSystem; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/LogRollingTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/LogRollingTests.java similarity index 96% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/LogRollingTests.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/LogRollingTests.java index 225930fdb7..f2dad3bc6e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/LogRollingTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/LogRollingTests.java @@ -14,7 +14,7 @@ * */ -package org.hyperledger.besu.ethereum.bonsai; +package org.hyperledger.besu.ethereum.trie.bonsai; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -22,11 +22,6 @@ import static org.mockito.Mockito.mock; import org.hyperledger.besu.datatypes.Address; 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.bonsai.trielog.TrieLogFactoryImpl; -import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogLayer; -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.Difficulty; @@ -34,6 +29,11 @@ import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; +import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogFactoryImpl; +import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogLayer; +import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState; +import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldStateUpdateAccumulator; import org.hyperledger.besu.evm.account.MutableAccount; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.log.LogsBloomFilter; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/RollingImport.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/RollingImport.java similarity index 91% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/RollingImport.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/RollingImport.java index 5aa0f68daa..af230e436e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/RollingImport.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/RollingImport.java @@ -14,7 +14,7 @@ * */ -package org.hyperledger.besu.ethereum.bonsai; +package org.hyperledger.besu.ethereum.trie.bonsai; import static com.google.common.base.Preconditions.checkArgument; import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE; @@ -22,14 +22,14 @@ import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIden import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.CODE_STORAGE; import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; -import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogFactoryImpl; -import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogLayer; -import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState; -import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldStateUpdateAccumulator; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; +import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogFactoryImpl; +import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogLayer; +import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldState; +import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldStateUpdateAccumulator; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiWorldStateKeyValueStorageTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateKeyValueStorageTest.java similarity index 99% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiWorldStateKeyValueStorageTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateKeyValueStorageTest.java index 13dbe22a40..f6bb51197b 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/storage/BonsaiWorldStateKeyValueStorageTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/storage/BonsaiWorldStateKeyValueStorageTest.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.bonsai.storage; +package org.hyperledger.besu.ethereum.trie.bonsai.storage; import static org.assertj.core.api.Assertions.assertThat; -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_ROOT_HASH_KEY; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogFactoryTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogFactoryTests.java similarity index 97% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogFactoryTests.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogFactoryTests.java index 78161826ac..c74fc7e180 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogFactoryTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogFactoryTests.java @@ -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 static org.assertj.core.api.AssertionsForClassTypes.assertThat; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogLayerTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogLayerTests.java similarity index 98% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogLayerTests.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogLayerTests.java index cd45bce5d9..d7d49bace0 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogLayerTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogLayerTests.java @@ -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.datatypes.AccountValue; import org.hyperledger.besu.datatypes.Address; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogManagerTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogManagerTests.java similarity index 85% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogManagerTests.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogManagerTests.java index f2fb2224be..a0065e2cb9 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogManagerTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogManagerTests.java @@ -13,19 +13,19 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.bonsai.trielog; +package org.hyperledger.besu.ethereum.trie.bonsai.trielog; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogPruner.noOpTrieLogPruner; +import static org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogPruner.noOpTrieLogPruner; import static org.mockito.Mockito.spy; 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.core.BlockHeaderTestFixture; +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.evm.internal.EvmConfiguration; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogPrunerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogPrunerTest.java similarity index 98% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogPrunerTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogPrunerTest.java index 8538edda37..af5acbf18c 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/trielog/TrieLogPrunerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/trielog/TrieLogPrunerTest.java @@ -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 static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -23,10 +23,10 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; 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.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import java.util.Optional; import java.util.stream.Stream; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPrunerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/pruner/MarkSweepPrunerTest.java similarity index 95% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPrunerTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/pruner/MarkSweepPrunerTest.java index 28997591f7..dffc26e193 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPrunerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/pruner/MarkSweepPrunerTest.java @@ -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; @@ -29,10 +29,14 @@ 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.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie; +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; @@ -63,9 +67,9 @@ class MarkSweepPrunerTest { private final Map> hashValueStore = spy(new HashMap<>()); private final InMemoryKeyValueStorage stateStorage = new TestInMemoryStorage(hashValueStore); private final WorldStateStorage worldStateStorage = - spy(new WorldStateKeyValueStorage(stateStorage)); + spy(new ForestWorldStateKeyValueStorage(stateStorage)); private final WorldStateArchive worldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( worldStateStorage, new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()), EvmConfiguration.DEFAULT); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/PrunerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerTest.java similarity index 99% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/PrunerTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerTest.java index 8f1b34bcca..804c805624 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/PrunerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/pruner/PrunerTest.java @@ -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.assertThatThrownBy; import static org.mockito.ArgumentMatchers.anyLong; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/storage/keyvalue/KeyValueStorageWorldStateStorageTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/storage/ForestKeyValueStorageWorldStateStorageTest.java similarity index 82% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/storage/keyvalue/KeyValueStorageWorldStateStorageTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/storage/ForestKeyValueStorageWorldStateStorageTest.java index 758866fd6f..fa57209a00 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/storage/keyvalue/KeyValueStorageWorldStateStorageTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/storage/ForestKeyValueStorageWorldStateStorageTest.java @@ -12,37 +12,37 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.storage.keyvalue; +package org.hyperledger.besu.ethereum.trie.forest.storage; import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage.Updater; import org.hyperledger.besu.ethereum.trie.MerkleTrie; +import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage.Updater; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; import org.junit.jupiter.api.Test; -public class KeyValueStorageWorldStateStorageTest { +public class ForestKeyValueStorageWorldStateStorageTest { @Test public void getCode_returnsEmpty() { - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); assertThat(storage.getCode(Hash.EMPTY, null)).contains(Bytes.EMPTY); } @Test public void getAccountStateTrieNode_returnsEmptyNode() { - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); assertThat(storage.getAccountStateTrieNode(Bytes.EMPTY, MerkleTrie.EMPTY_TRIE_NODE_HASH)) .contains(MerkleTrie.EMPTY_TRIE_NODE); } @Test public void getAccountStorageTrieNode_returnsEmptyNode() { - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); assertThat( storage.getAccountStorageTrieNode(null, Bytes.EMPTY, MerkleTrie.EMPTY_TRIE_NODE_HASH)) .contains(MerkleTrie.EMPTY_TRIE_NODE); @@ -50,20 +50,20 @@ public class KeyValueStorageWorldStateStorageTest { @Test public void getNodeData_returnsEmptyValue() { - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); assertThat(storage.getNodeData(null, Hash.EMPTY)).contains(Bytes.EMPTY); } @Test public void getNodeData_returnsEmptyNode() { - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); assertThat(storage.getNodeData(Bytes.EMPTY, MerkleTrie.EMPTY_TRIE_NODE_HASH)) .contains(MerkleTrie.EMPTY_TRIE_NODE); } @Test public void getCode_saveAndGetSpecialValues() { - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); storage.updater().putCode(null, MerkleTrie.EMPTY_TRIE_NODE).putCode(null, Bytes.EMPTY).commit(); assertThat(storage.getCode(MerkleTrie.EMPTY_TRIE_NODE_HASH, null)) @@ -74,7 +74,7 @@ public class KeyValueStorageWorldStateStorageTest { @Test public void getCode_saveAndGetRegularValue() { final Bytes bytes = Bytes.fromHexString("0x123456"); - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); storage.updater().putCode(null, bytes).commit(); assertThat(storage.getCode(Hash.hash(bytes), null)).contains(bytes); @@ -82,7 +82,7 @@ public class KeyValueStorageWorldStateStorageTest { @Test public void getAccountStateTrieNode_saveAndGetSpecialValues() { - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); storage .updater() .putAccountStateTrieNode( @@ -98,7 +98,7 @@ public class KeyValueStorageWorldStateStorageTest { @Test public void getAccountStateTrieNode_saveAndGetRegularValue() { final Bytes bytes = Bytes.fromHexString("0x123456"); - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); storage.updater().putAccountStateTrieNode(null, Hash.hash(bytes), bytes).commit(); assertThat(storage.getAccountStateTrieNode(Bytes.EMPTY, Hash.hash(bytes))).contains(bytes); @@ -106,7 +106,7 @@ public class KeyValueStorageWorldStateStorageTest { @Test public void getAccountStorageTrieNode_saveAndGetSpecialValues() { - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); storage .updater() .putAccountStorageTrieNode( @@ -124,7 +124,7 @@ public class KeyValueStorageWorldStateStorageTest { @Test public void getAccountStorageTrieNode_saveAndGetRegularValue() { final Bytes bytes = Bytes.fromHexString("0x123456"); - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); storage.updater().putAccountStorageTrieNode(null, null, Hash.hash(bytes), bytes).commit(); assertThat(storage.getAccountStateTrieNode(Bytes.EMPTY, Hash.hash(bytes))).contains(bytes); @@ -132,7 +132,7 @@ public class KeyValueStorageWorldStateStorageTest { @Test public void getNodeData_saveAndGetSpecialValues() { - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); storage .updater() .putAccountStorageTrieNode( @@ -148,7 +148,7 @@ public class KeyValueStorageWorldStateStorageTest { @Test public void getNodeData_saveAndGetRegularValue() { final Bytes bytes = Bytes.fromHexString("0x123456"); - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); storage.updater().putAccountStorageTrieNode(null, null, Hash.hash(bytes), bytes).commit(); assertThat(storage.getNodeData(null, Hash.hash(bytes))).contains(bytes); @@ -160,7 +160,7 @@ public class KeyValueStorageWorldStateStorageTest { final Bytes bytesB = Bytes.fromHexString("0x1234"); final Bytes bytesC = Bytes.fromHexString("0x123456"); - final WorldStateKeyValueStorage storage = emptyStorage(); + final ForestWorldStateKeyValueStorage storage = emptyStorage(); final Updater updaterA = storage.updater(); final Updater updaterB = storage.updater(); @@ -187,7 +187,7 @@ public class KeyValueStorageWorldStateStorageTest { assertThat(emptyStorage().isWorldStateAvailable(Hash.EMPTY_TRIE_HASH, null)).isTrue(); } - private WorldStateKeyValueStorage emptyStorage() { - return new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + private ForestWorldStateKeyValueStorage emptyStorage() { + return new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldStateTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/worldview/ForestMutableWorldStateTest.java similarity index 97% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldStateTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/worldview/ForestMutableWorldStateTest.java index 4e42356341..dec41cd8d6 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldStateTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/forest/worldview/ForestMutableWorldStateTest.java @@ -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 static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldState; @@ -21,9 +21,9 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.MutableWorldState; -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.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.evm.account.AccountStorageEntry; import org.hyperledger.besu.evm.account.MutableAccount; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -47,17 +47,17 @@ import org.junit.jupiter.api.Test; // TODO: make that an abstract mutable world state test, and create sub-class for all world state // implementations. -class DefaultMutableWorldStateTest { +class ForestMutableWorldStateTest { // The following test cases are loosely derived from the testTransactionToItself // GeneralStateReferenceTest. private static final Address ADDRESS = Address.fromHexString("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"); - private static MutableWorldState createEmpty(final WorldStateKeyValueStorage storage) { + private static MutableWorldState createEmpty(final ForestWorldStateKeyValueStorage storage) { final WorldStatePreimageKeyValueStorage preimageStorage = new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()); - return new DefaultMutableWorldState(storage, preimageStorage, EvmConfiguration.DEFAULT); + return new ForestMutableWorldState(storage, preimageStorage, EvmConfiguration.DEFAULT); } private static MutableWorldState createEmpty() { @@ -243,7 +243,8 @@ class DefaultMutableWorldStateTest { @Test void commitAndPersist() { final KeyValueStorage storage = new InMemoryKeyValueStorage(); - final WorldStateKeyValueStorage kvWorldStateStorage = new WorldStateKeyValueStorage(storage); + final ForestWorldStateKeyValueStorage kvWorldStateStorage = + new ForestWorldStateKeyValueStorage(storage); final MutableWorldState worldState = createEmpty(kvWorldStateStorage); final WorldUpdater updater = worldState.updater(); final Wei newBalance = Wei.of(100000); @@ -274,9 +275,9 @@ class DefaultMutableWorldStateTest { // Create new world state and check that it can access modified address final MutableWorldState newWorldState = - new DefaultMutableWorldState( + new ForestMutableWorldState( expectedRootHash, - new WorldStateKeyValueStorage(storage), + new ForestWorldStateKeyValueStorage(storage), new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()), EvmConfiguration.DEFAULT); assertThat(newWorldState.rootHash()).isEqualTo(expectedRootHash); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java index 2f98c1a831..46595f6bd0 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java @@ -20,7 +20,6 @@ import org.hyperledger.besu.consensus.merge.ForkchoiceEvent; import org.hyperledger.besu.consensus.merge.UnverifiedForkchoiceListener; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.ProtocolContext; -import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateProvider; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.sync.checkpointsync.CheckpointDownloaderFactory; @@ -35,7 +34,8 @@ import org.hyperledger.besu.ethereum.eth.sync.state.PendingBlocksManager; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.storage.StorageProvider; -import org.hyperledger.besu.ethereum.worldstate.Pruner; +import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiWorldStateProvider; +import org.hyperledger.besu.ethereum.trie.forest.pruner.Pruner; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.plugin.data.SyncStatus; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/AccountTrieNodeDataRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/AccountTrieNodeDataRequest.java index 90aa59c045..78af77054d 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/AccountTrieNodeDataRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/AccountTrieNodeDataRequest.java @@ -15,11 +15,11 @@ package org.hyperledger.besu.ethereum.eth.sync.fastsync.worldstate; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.hyperledger.besu.ethereum.trie.CompactEncoding; import org.hyperledger.besu.ethereum.trie.MerkleTrie; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.FlatDbMode; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastDownloaderFactory.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastDownloaderFactory.java index 467dc0a53d..da520d88b5 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastDownloaderFactory.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastDownloaderFactory.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.ethereum.eth.sync.fastsync.worldstate; import org.hyperledger.besu.ethereum.ProtocolContext; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.sync.PivotBlockSelector; @@ -29,6 +28,7 @@ import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.sync.worldstate.WorldStateDownloader; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.plugin.services.MetricsSystem; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/StorageTrieNodeDataRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/StorageTrieNodeDataRequest.java index a46faa06a6..1a78eede60 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/StorageTrieNodeDataRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/StorageTrieNodeDataRequest.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.ethereum.eth.sync.fastsync.worldstate; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.hyperledger.besu.ethereum.trie.CompactEncoding; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.FlatDbMode; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage.Updater; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/PersistDataStep.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/PersistDataStep.java index df3696ccdf..9b72d05604 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/PersistDataStep.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/PersistDataStep.java @@ -18,9 +18,9 @@ import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.can import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.errorCountAtThreshold; import static org.hyperledger.besu.ethereum.eth.sync.StorageExceptionManager.getRetryableErrorCounter; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest; import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.heal.TrieNodeHealingRequest; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.plugin.services.exception.StorageException; import org.hyperledger.besu.services.tasks.Task; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java index 91bdd83a0f..313d5a3770 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java @@ -19,7 +19,6 @@ import static org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRe import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.ProtocolContext; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.sync.fastsync.FastSyncActions; @@ -28,6 +27,7 @@ import org.hyperledger.besu.ethereum.eth.sync.snapsync.context.SnapSyncStatePers import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.AccountRangeDataRequest; import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest; import org.hyperledger.besu.ethereum.eth.sync.worldstate.WorldStateDownloader; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.metrics.BesuMetricCategory; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/AccountRangeDataRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/AccountRangeDataRequest.java index 06181fd09f..ea5c25ec0d 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/AccountRangeDataRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/AccountRangeDataRequest.java @@ -22,7 +22,6 @@ import static org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapsyncMetricsMan import static org.hyperledger.besu.ethereum.eth.sync.snapsync.StackTrie.FlatDatabaseUpdater.noop; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncProcessState; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapWorldDownloadState; @@ -31,6 +30,7 @@ import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.trie.NodeUpdater; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.FlatDbMode; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/StorageRangeDataRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/StorageRangeDataRequest.java index 14839f0ad6..9829b4ba90 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/StorageRangeDataRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/StorageRangeDataRequest.java @@ -22,7 +22,6 @@ import static org.hyperledger.besu.ethereum.eth.sync.snapsync.RequestType.STORAG import static org.hyperledger.besu.ethereum.eth.sync.snapsync.StackTrie.FlatDatabaseUpdater.noop; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncProcessState; @@ -31,6 +30,7 @@ import org.hyperledger.besu.ethereum.eth.sync.snapsync.StackTrie; import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; import org.hyperledger.besu.ethereum.trie.CompactEncoding; import org.hyperledger.besu.ethereum.trie.NodeUpdater; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.FlatDbMode; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage.Updater; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequest.java index a40a4fb11a..7de7760745 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequest.java @@ -19,7 +19,6 @@ import static org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager.MIN_R import static org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapsyncMetricsManager.Step.HEAL_FLAT; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager; import org.hyperledger.besu.ethereum.eth.sync.snapsync.RequestType; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; @@ -32,6 +31,7 @@ import org.hyperledger.besu.ethereum.trie.CompactEncoding; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.RangeStorageEntriesCollector; import org.hyperledger.besu.ethereum.trie.TrieIterator; +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; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountTrieNodeHealingRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountTrieNodeHealingRequest.java index d929721714..56598c9119 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountTrieNodeHealingRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountTrieNodeHealingRequest.java @@ -17,7 +17,6 @@ package org.hyperledger.besu.ethereum.eth.sync.snapsync.request.heal; import static org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest.createAccountTrieNodeDataRequest; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncProcessState; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapWorldDownloadState; @@ -25,6 +24,7 @@ import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.trie.CompactEncoding; 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.FlatDbMode; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageFlatDatabaseHealingRangeRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageFlatDatabaseHealingRangeRequest.java index a94424f023..ccc3f4453e 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageFlatDatabaseHealingRangeRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageFlatDatabaseHealingRangeRequest.java @@ -18,7 +18,6 @@ import static org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager.getRa import static org.hyperledger.besu.ethereum.eth.sync.snapsync.RequestType.STORAGE_RANGE; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncProcessState; @@ -28,6 +27,7 @@ import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.RangeStorageEntriesCollector; import org.hyperledger.besu.ethereum.trie.TrieIterator; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequest.java index ffcdb3e77b..e6650072a2 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequest.java @@ -15,12 +15,12 @@ package org.hyperledger.besu.ethereum.eth.sync.snapsync.request.heal; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncProcessState; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapWorldDownloadState; import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest; import org.hyperledger.besu.ethereum.trie.CompactEncoding; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.FlatDbMode; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage.Updater; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java index edefbc17a3..5425cf1c38 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java @@ -359,6 +359,13 @@ public class TransactionPool implements BlockAddedObserver { } finally { blockAddedLock.unlock(); } + } else { + try { + // wait a bit before retrying + Thread.sleep(100); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } } } return null; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldDownloadStateTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldDownloadStateTest.java index b853128827..91c770d47b 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldDownloadStateTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldDownloadStateTest.java @@ -20,14 +20,14 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.eth.manager.task.EthTask; import org.hyperledger.besu.ethereum.eth.sync.worldstate.StalledDownloadException; import org.hyperledger.besu.ethereum.eth.sync.worldstate.WorldStateDownloadProcess; -import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; +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.WorldStateStorage; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -82,7 +82,7 @@ public class FastWorldDownloadStateTest { new BonsaiWorldStateKeyValueStorage( new InMemoryKeyValueStorageProvider(), new NoOpMetricsSystem()); } else { - worldStateStorage = new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + worldStateStorage = new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); } downloadState = new FastWorldDownloadState( diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloaderTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloaderTest.java index 6d352abb7a..8fbe881cfa 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloaderTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloaderTest.java @@ -48,13 +48,13 @@ import org.hyperledger.besu.ethereum.eth.sync.worldstate.WorldStateDownloader; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; 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.Node; +import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive; +import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie; import org.hyperledger.besu.ethereum.trie.patricia.TrieNodeDecoder; -import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage; @@ -179,7 +179,7 @@ class FastWorldStateDownloaderTest { final InMemoryTasksPriorityQueues taskCollection = new InMemoryTasksPriorityQueues<>(); final WorldStateStorage localStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateDownloader downloader = createDownloader(ethProtocolManager.ethContext(), localStorage, taskCollection); @@ -196,7 +196,7 @@ class FastWorldStateDownloaderTest { @Timeout(value = 60) void downloadAlreadyAvailableWorldState() { // Setup existing state - final DefaultWorldStateArchive worldStateArchive = createInMemoryWorldStateArchive(); + final ForestWorldStateArchive worldStateArchive = createInMemoryWorldStateArchive(); final MutableWorldState worldState = worldStateArchive.getMutable(); // Generate accounts and save corresponding state root @@ -264,7 +264,7 @@ class FastWorldStateDownloaderTest { final InMemoryTasksPriorityQueues taskCollection = new InMemoryTasksPriorityQueues<>(); final WorldStateStorage localStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateDownloader downloader = createDownloader(ethProtocolManager.ethContext(), localStorage, taskCollection); @@ -282,7 +282,7 @@ class FastWorldStateDownloaderTest { // Check that all expected account data was downloaded final WorldStateArchive localWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( localStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final WorldState localWorldState = localWorldStateArchive.get(stateRoot, null).get(); assertThat(result).isDone(); @@ -319,7 +319,7 @@ class FastWorldStateDownloaderTest { final InMemoryTasksPriorityQueues taskCollection = new InMemoryTasksPriorityQueues<>(); final WorldStateStorage localStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); // Seed local storage with some contract values final Map knownCode = new HashMap<>(); @@ -356,7 +356,7 @@ class FastWorldStateDownloaderTest { // Check that all expected account data was downloaded final WorldStateArchive localWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( localStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final WorldState localWorldState = localWorldStateArchive.get(stateRoot, null).get(); assertThat(result).isDone(); @@ -404,7 +404,7 @@ class FastWorldStateDownloaderTest { final InMemoryTasksPriorityQueues taskCollection = new InMemoryTasksPriorityQueues<>(); final WorldStateStorage localStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateDownloader downloader = createDownloader(ethProtocolManager.ethContext(), localStorage, taskCollection); @@ -458,9 +458,9 @@ class FastWorldStateDownloaderTest { void doesNotRequestKnownAccountTrieNodesFromNetwork() { // Setup "remote" state final WorldStateStorage remoteStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateArchive remoteWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( remoteStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final MutableWorldState remoteWorldState = remoteWorldStateArchive.getMutable(); @@ -481,7 +481,7 @@ class FastWorldStateDownloaderTest { final InMemoryTasksPriorityQueues taskCollection = new InMemoryTasksPriorityQueues<>(); final WorldStateStorage localStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); // Seed local storage with some trie node values final Map allNodes = @@ -533,7 +533,7 @@ class FastWorldStateDownloaderTest { // Check that all expected account data was downloaded final WorldStateArchive localWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( localStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final WorldState localWorldState = localWorldStateArchive.get(stateRoot, null).get(); assertThat(result).isDone(); @@ -545,9 +545,9 @@ class FastWorldStateDownloaderTest { void doesNotRequestKnownStorageTrieNodesFromNetwork() { // Setup "remote" state final WorldStateStorage remoteStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateArchive remoteWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( remoteStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final MutableWorldState remoteWorldState = remoteWorldStateArchive.getMutable(); @@ -568,7 +568,7 @@ class FastWorldStateDownloaderTest { final InMemoryTasksPriorityQueues taskCollection = new InMemoryTasksPriorityQueues<>(); final WorldStateStorage localStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); // Seed local storage with some trie node values final List storageRootHashes = @@ -638,7 +638,7 @@ class FastWorldStateDownloaderTest { // Check that all expected account data was downloaded final WorldStateArchive localWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( localStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final WorldState localWorldState = localWorldStateArchive.get(stateRoot, null).get(); assertThat(result).isDone(); @@ -653,9 +653,9 @@ class FastWorldStateDownloaderTest { // Setup "remote" state final WorldStateStorage remoteStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateArchive remoteWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( remoteStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final MutableWorldState remoteWorldState = remoteWorldStateArchive.getMutable(); @@ -669,7 +669,7 @@ class FastWorldStateDownloaderTest { final InMemoryTasksPriorityQueues taskCollection = new InMemoryTasksPriorityQueues<>(); final WorldStateStorage localStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final SynchronizerConfiguration syncConfig = SynchronizerConfiguration.builder().worldStateMaxRequestsWithoutProgress(10).build(); final WorldStateDownloader downloader = @@ -715,9 +715,9 @@ class FastWorldStateDownloaderTest { void resumesFromNonEmptyQueue() { // Setup "remote" state final WorldStateStorage remoteStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateArchive remoteWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( remoteStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final MutableWorldState remoteWorldState = remoteWorldStateArchive.getMutable(); @@ -743,7 +743,7 @@ class FastWorldStateDownloaderTest { } final WorldStateStorage localStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final SynchronizerConfiguration syncConfig = SynchronizerConfiguration.builder().worldStateMaxRequestsWithoutProgress(10).build(); final WorldStateDownloader downloader = @@ -782,7 +782,7 @@ class FastWorldStateDownloaderTest { // Check that all expected account data was downloaded assertThat(result).isDone(); final WorldStateArchive localWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( localStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final WorldState localWorldState = localWorldStateArchive.get(stateRoot, null).get(); assertAccountsMatch(localWorldState, accounts); @@ -854,9 +854,9 @@ class FastWorldStateDownloaderTest { // Setup "remote" state final WorldStateStorage remoteStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateArchive remoteWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( remoteStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final MutableWorldState remoteWorldState = remoteWorldStateArchive.getMutable(); @@ -879,9 +879,9 @@ class FastWorldStateDownloaderTest { final InMemoryTasksPriorityQueues taskCollection = new InMemoryTasksPriorityQueues<>(); final WorldStateStorage localStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateArchive localWorldStateArchive = - new DefaultWorldStateArchive( + new ForestWorldStateArchive( localStorage, createPreimageStorage(), EvmConfiguration.DEFAULT); final SynchronizerConfiguration syncConfig = SynchronizerConfiguration.builder() diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/AccountHealingTrackingTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/AccountHealingTrackingTest.java index ca39d0c86f..ead7a1ca61 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/AccountHealingTrackingTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/AccountHealingTrackingTest.java @@ -21,7 +21,6 @@ import static org.mockito.Mockito.verify; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.TrieGenerator; import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest; @@ -32,6 +31,7 @@ import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.RangeStorageEntriesCollector; import org.hyperledger.besu.ethereum.trie.TrieIterator; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie; import org.hyperledger.besu.ethereum.trie.patricia.StoredNodeFactory; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/RangeManagerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/RangeManagerTest.java index 003db79a7e..d4295f5585 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/RangeManagerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/RangeManagerTest.java @@ -19,10 +19,10 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.TrieGenerator; import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; -import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.RangeStorageEntriesCollector; import org.hyperledger.besu.ethereum.trie.TrieIterator; +import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; @@ -118,7 +118,7 @@ public final class RangeManagerTest { public void testFindNewBeginElement() { final WorldStateStorage worldStateStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final MerkleTrie accountStateTrie = TrieGenerator.generateTrie(worldStateStorage, 15); @@ -157,7 +157,7 @@ public final class RangeManagerTest { public void testFindNewBeginElementWhenNothingIsMissing() { final WorldStateStorage worldStateStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final MerkleTrie accountStateTrie = TrieGenerator.generateTrie(worldStateStorage, 15); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadStateTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadStateTest.java index 22c2b73765..a8dc4a9b08 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadStateTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadStateTest.java @@ -25,7 +25,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.chain.BlockAddedEvent; import org.hyperledger.besu.ethereum.chain.BlockAddedObserver; import org.hyperledger.besu.ethereum.chain.Blockchain; @@ -39,7 +38,8 @@ import org.hyperledger.besu.ethereum.eth.sync.snapsync.context.SnapSyncStatePers import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.BytecodeRequest; import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest; import org.hyperledger.besu.ethereum.eth.sync.worldstate.WorldStateDownloadProcess; -import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; +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.WorldStateStorage; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -110,7 +110,7 @@ public class SnapWorldDownloadStateTest { new BonsaiWorldStateKeyValueStorage( new InMemoryKeyValueStorageProvider(), new NoOpMetricsSystem()); } else { - worldStateStorage = new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + worldStateStorage = new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); } downloadState = new SnapWorldDownloadState( diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/StackTrieTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/StackTrieTest.java index 10a0cf3f84..a9790b5666 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/StackTrieTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/StackTrieTest.java @@ -17,10 +17,10 @@ package org.hyperledger.besu.ethereum.eth.sync.snapsync; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.TrieGenerator; import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; -import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.RangeStorageEntriesCollector; import org.hyperledger.besu.ethereum.trie.TrieIterator; +import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; @@ -42,10 +42,10 @@ public class StackTrieTest { final int nbAccounts = 15; final WorldStateStorage worldStateStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateStorage recreatedWorldStateStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final MerkleTrie accountStateTrie = TrieGenerator.generateTrie(worldStateStorage, nbAccounts); @@ -94,10 +94,10 @@ public class StackTrieTest { final int nbAccounts = 15; final WorldStateStorage worldStateStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateStorage recreatedWorldStateStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final MerkleTrie accountStateTrie = TrieGenerator.generateTrie(worldStateStorage, nbAccounts); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequestTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequestTest.java index a95d4c3411..a61b5c8ea1 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequestTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequestTest.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.ethereum.eth.sync.snapsync.request.heal; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.TrieGenerator; import org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager; @@ -26,11 +25,12 @@ import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapsyncMetricsManager; import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest; import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; import org.hyperledger.besu.ethereum.storage.StorageProvider; -import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.CompactEncoding; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.RangeStorageEntriesCollector; import org.hyperledger.besu.ethereum.trie.TrieIterator; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; +import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; @@ -73,7 +73,7 @@ public class AccountFlatDatabaseHealingRangeRequestTest { @Test public void shouldReturnChildRequests() { final WorldStateStorage worldStateStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateProofProvider proofProvider = new WorldStateProofProvider(worldStateStorage); final MerkleTrie accountStateTrie = TrieGenerator.generateTrie(worldStateStorage, 15); @@ -138,7 +138,7 @@ public class AccountFlatDatabaseHealingRangeRequestTest { @Test public void shouldNotReturnChildRequestsWhenNoMoreAccounts() { final WorldStateStorage worldStateStorage = - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); final WorldStateProofProvider proofProvider = new WorldStateProofProvider(worldStateStorage); final MerkleTrie accountStateTrie = TrieGenerator.generateTrie(worldStateStorage, 15); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageFlatDatabaseHealingRangeRequestTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageFlatDatabaseHealingRangeRequestTest.java index a281385dd5..7fe3862573 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageFlatDatabaseHealingRangeRequestTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageFlatDatabaseHealingRangeRequestTest.java @@ -18,7 +18,6 @@ import static org.apache.tuweni.rlp.RLP.decodeValue; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.TrieGenerator; import org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager; @@ -32,6 +31,7 @@ import org.hyperledger.besu.ethereum.storage.StorageProvider; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.RangeStorageEntriesCollector; import org.hyperledger.besu.ethereum.trie.TrieIterator; +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; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequestTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequestTest.java index 447b37d14c..5295f4e3b5 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequestTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequestTest.java @@ -16,14 +16,14 @@ package org.hyperledger.besu.ethereum.eth.sync.snapsync.request.heal; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.TrieGenerator; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapWorldDownloadState; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.storage.StorageProvider; -import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.MerkleTrie; +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.StateTrieAccountValue; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; @@ -70,7 +70,7 @@ class StorageTrieNodeHealingRequestTest { public void setup(final DataStorageFormat storageFormat) { if (storageFormat.equals(DataStorageFormat.FOREST)) { - worldStateStorage = new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()); + worldStateStorage = new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()); } else { final StorageProvider storageProvider = new InMemoryKeyValueStorageProvider(); worldStateStorage = diff --git a/ethereum/evmtool/build.gradle b/ethereum/evmtool/build.gradle index 9bc302f60c..5bc7877fc2 100644 --- a/ethereum/evmtool/build.gradle +++ b/ethereum/evmtool/build.gradle @@ -66,7 +66,7 @@ dependencies { testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' - // No logging in grallvm EvmTool + // No logging in graalvm EvmTool nativeImageClasspath 'org.slf4j:slf4j-nop' } diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java index 0109d6c819..86f9b5e2cc 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java @@ -23,9 +23,9 @@ import org.hyperledger.besu.ethereum.chain.DefaultBlockchain; import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.MutableWorldState; -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.ethereum.worldstate.WorldStatePreimageStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -64,12 +64,12 @@ public class BlockchainModule { final EvmConfiguration evmConfiguration) { if ("memory".equals(keyValueStorageName)) { final MutableWorldState mutableWorldState = - new DefaultMutableWorldState( + new ForestMutableWorldState( worldStateStorage, worldStatePreimageStorage, evmConfiguration); genesisState.writeStateTo(mutableWorldState); return mutableWorldState; } else { - return new DefaultMutableWorldState( + return new ForestMutableWorldState( stateRoot, worldStateStorage, worldStatePreimageStorage, evmConfiguration); } } @@ -78,7 +78,7 @@ public class BlockchainModule { @Singleton WorldStateStorage provideWorldStateStorage( @Named("worldState") final KeyValueStorage keyValueStorage) { - return new WorldStateKeyValueStorage(keyValueStorage); + return new ForestWorldStateKeyValueStorage(keyValueStorage); } @Provides diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/peers/EnodeURLImpl.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/peers/EnodeURLImpl.java index 747a06efdf..55ca94a1ac 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/peers/EnodeURLImpl.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/peers/EnodeURLImpl.java @@ -83,7 +83,9 @@ public class EnodeURLImpl implements EnodeURL { String message = ""; if (enodeDnsConfiguration.dnsEnabled() && !enodeDnsConfiguration.updateEnabled()) { message = - "Invalid IP address (or DNS query resolved an invalid IP). --Xdns-enabled is true but --Xdns-update-enabled flag is false."; + String.format( + "Invalid IP address '%s' (or DNS query resolved an invalid IP). --Xdns-enabled is true but --Xdns-update-enabled flag is false.", + value); } else { message = String.format( diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnection.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnection.java index 066f9122cb..a05d03c7b5 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnection.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/AbstractPeerConnection.java @@ -51,6 +51,7 @@ public abstract class AbstractPeerConnection implements PeerConnection { private final Set agreedCapabilities; private final Map protocolToCapability = new HashMap<>(); private final AtomicBoolean disconnected = new AtomicBoolean(false); + private final AtomicBoolean terminatedImmediately = new AtomicBoolean(false); protected final PeerConnectionEventDispatcher connectionEventDispatcher; private final LabelledMetric outboundMessagesCounter; private final long initiatedAt; @@ -162,17 +163,19 @@ public abstract class AbstractPeerConnection implements PeerConnection { @Override public void terminateConnection(final DisconnectReason reason, final boolean peerInitiated) { - if (disconnected.compareAndSet(false, true)) { - connectionEventDispatcher.dispatchDisconnect(this, reason, peerInitiated); + if (terminatedImmediately.compareAndSet(false, true)) { + if (disconnected.compareAndSet(false, true)) { + connectionEventDispatcher.dispatchDisconnect(this, reason, peerInitiated); + } + // Always ensure the context gets closed immediately even if we previously sent a disconnect + // message and are waiting to close. + closeConnectionImmediately(); + LOG.atTrace() + .setMessage("Terminating connection {}, reason {}") + .addArgument(this) + .addArgument(reason) + .log(); } - // Always ensure the context gets closed immediately even if we previously sent a disconnect - // message and are waiting to close. - closeConnectionImmediately(); - LOG.atTrace() - .setMessage("Terminating connection {}, reason {}") - .addArgument(this) - .addArgument(reason) - .log(); } protected abstract void closeConnectionImmediately(); diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestUpdateAccumulator.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestUpdateAccumulator.java index e346b5abf6..b56053f54a 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestUpdateAccumulator.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestUpdateAccumulator.java @@ -16,11 +16,11 @@ package org.hyperledger.besu.ethereum.referencetests; 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.storage.BonsaiPreImageProxy; -import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldStateUpdateAccumulator; -import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldView; +import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiAccount; +import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiValue; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiPreImageProxy; +import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldStateUpdateAccumulator; +import org.hyperledger.besu.ethereum.trie.bonsai.worldview.BonsaiWorldView; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldState.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldState.java index e56d5c858f..26fd811bfa 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldState.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldState.java @@ -16,17 +16,17 @@ package org.hyperledger.besu.ethereum.referencetests; 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.BonsaiPreImageProxy; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; -import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogAddedEvent; -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.core.BlockHeader; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; +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.BonsaiPreImageProxy; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiWorldStateKeyValueStorage; +import org.hyperledger.besu.ethereum.trie.bonsai.trielog.TrieLogAddedEvent; +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.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.metrics.ObservableMetricsSystem; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldStateStorage.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldStateStorage.java index b998bf7d25..68057523a0 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldStateStorage.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BonsaiReferenceTestWorldStateStorage.java @@ -16,11 +16,11 @@ package org.hyperledger.besu.ethereum.referencetests; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.bonsai.BonsaiAccount; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiPreImageProxy; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage; -import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateLayerStorage; -import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldView; +import org.hyperledger.besu.ethereum.trie.bonsai.BonsaiAccount; +import org.hyperledger.besu.ethereum.trie.bonsai.storage.BonsaiPreImageProxy; +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.BonsaiWorldView; import org.hyperledger.besu.evm.account.AccountStorageEntry; import org.hyperledger.besu.evm.worldstate.WorldState; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/DefaultReferenceTestWorldState.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/DefaultReferenceTestWorldState.java index 45771578e1..d9ed862676 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/DefaultReferenceTestWorldState.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/DefaultReferenceTestWorldState.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.ethereum.referencetests; import org.hyperledger.besu.datatypes.Address; -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.internal.EvmConfiguration; import org.hyperledger.besu.evm.worldstate.WorldState; import org.hyperledger.besu.evm.worldstate.WorldUpdater; @@ -27,12 +27,12 @@ import java.util.Map; import com.fasterxml.jackson.annotation.JsonCreator; -public class DefaultReferenceTestWorldState extends DefaultMutableWorldState +public class DefaultReferenceTestWorldState extends ForestMutableWorldState implements ReferenceTestWorldState { DefaultReferenceTestWorldState() { super( - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()), + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()), new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()), EvmConfiguration.DEFAULT); } diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestBlockchain.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestBlockchain.java index 7e84ccbaf8..cfe577bf7a 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestBlockchain.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestBlockchain.java @@ -191,7 +191,7 @@ public class ReferenceTestBlockchain implements Blockchain { public Comparator getBlockChoiceRule() { return (a, b) -> { throw new NonDeterministicOperationException( - "ReferenceTestBlockchian for VMTest Chains do not support fork choice rules"); + "ReferenceTestBlockchain for VMTest Chains do not support fork choice rules"); }; } diff --git a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java index d36a0b6a87..b2dd41bbfa 100644 --- a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java +++ b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java @@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator; import org.hyperledger.besu.evm.gascalculator.ByzantiumGasCalculator; +import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator; import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator; import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator; import org.hyperledger.besu.evm.gascalculator.GasCalculator; @@ -33,6 +34,7 @@ import org.hyperledger.besu.evm.gascalculator.HomesteadGasCalculator; import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator; import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator; import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator; +import org.hyperledger.besu.evm.gascalculator.ShanghaiGasCalculator; import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator; import org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator; import org.hyperledger.besu.testutil.JsonTestParameters; @@ -54,7 +56,8 @@ public class TransactionTest { return REFERENCE_TEST_PROTOCOL_SCHEDULES .getByName(name) .getByBlockHeader(BlockHeaderBuilder.createDefault().buildBlockHeader()) - .getTransactionValidatorFactory().get(); + .getTransactionValidatorFactory() + .get(); } private static final String TEST_CONFIG_FILE_DIR_PATH = "TransactionTests/"; @@ -62,7 +65,9 @@ public class TransactionTest { public static Stream getTestParametersForConfig() { return JsonTestParameters.create(TransactionTestCaseSpec.class) .generator((name, fullPath, spec, collector) -> collector.add(name, fullPath, spec, true)) - .generate(TEST_CONFIG_FILE_DIR_PATH).stream().map(params -> Arguments.of(params[0], params[1])); + .generate(TEST_CONFIG_FILE_DIR_PATH) + .stream() + .map(params -> Arguments.of(params[0], params[1])); } @ParameterizedTest(name = "Name: {0}") @@ -125,8 +130,30 @@ public class TransactionTest { milestone(spec, name, "London", new LondonGasCalculator(), Optional.of(Wei.of(0))); } + @ParameterizedTest(name = "Name: {0}") + @MethodSource("getTestParametersForConfig") + public void merge(final String name, final TransactionTestCaseSpec spec) { + milestone(spec, name, "Merge", new LondonGasCalculator(), Optional.of(Wei.of(0))); + } + + @ParameterizedTest(name = "Name: {0}") + @MethodSource("getTestParametersForConfig") + public void shanghai(final String name, final TransactionTestCaseSpec spec) { + milestone(spec, name, "Shanghai", new ShanghaiGasCalculator(), Optional.of(Wei.of(0))); + } + + @ParameterizedTest(name = "Name: {0}") + @MethodSource("getTestParametersForConfig") + public void cancun(final String name, final TransactionTestCaseSpec spec) { + milestone(spec, name, "Cancun", new CancunGasCalculator(), Optional.of(Wei.of(0))); + } + public void milestone( - final TransactionTestCaseSpec spec, final String name, final String milestone, final GasCalculator gasCalculator, final Optional baseFee) { + final TransactionTestCaseSpec spec, + final String name, + final String milestone, + final GasCalculator gasCalculator, + final Optional baseFee) { final TransactionTestCaseSpec.Expectation expected = spec.expectation(milestone); diff --git a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTestCaseSpec.java b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTestCaseSpec.java index 7f9c3cb7c6..7ce7384e1a 100644 --- a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTestCaseSpec.java +++ b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTestCaseSpec.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.tuweni.bytes.Bytes; +import org.junit.jupiter.api.Assumptions; /** A Transaction test case specification. */ @JsonIgnoreProperties({"_info"}) @@ -109,9 +110,7 @@ public class TransactionTestCaseSpec { public Expectation expectation(final String milestone) { final Expectation expectation = expectations.get(milestone); - if (expectation == null) { - throw new IllegalStateException("Expectation for milestone " + milestone + " not found"); - } + Assumptions.assumeFalse(expectation == null, () -> "No expectation for milestone " + milestone); return expectation; } diff --git a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/rlp/RLPRefTest.java b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/rlp/RLPRefTest.java index a4eff43c98..b6d01dae83 100644 --- a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/rlp/RLPRefTest.java +++ b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/rlp/RLPRefTest.java @@ -16,12 +16,13 @@ package org.hyperledger.besu.ethereum.rlp; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import org.assertj.core.api.Assertions; import org.hyperledger.besu.ethereum.rlp.util.RLPTestUtil; import org.hyperledger.besu.testutil.JsonTestParameters; import java.util.stream.Stream; +import org.apache.tuweni.bytes.Bytes; +import org.assertj.core.api.Assertions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -29,23 +30,45 @@ import org.junit.jupiter.params.provider.MethodSource; /** The Ethereum reference RLP tests. */ public class RLPRefTest { - private static final String TEST_CONFIG_FILES = "RLPTests/rlptest.json"; + private static final String[] TEST_CONFIG_FILES = { + "RLPTests/rlptest.json", "RLPTests/invalidRLPTest.json" + }; + + private static final Bytes INVALID = Bytes.fromHexString("0x494e56414c4944"); public static Stream getTestParametersForConfig() { - return JsonTestParameters.create(RLPRefTestCaseSpec.class).generate(TEST_CONFIG_FILES).stream().map(params -> Arguments.of(params[0], params[1], params[2])); + return JsonTestParameters.create(RLPRefTestCaseSpec.class).generate(TEST_CONFIG_FILES).stream() + .map(params -> Arguments.of(params[0], params[1], params[2])); } @ParameterizedTest(name = "Name: {0}") @MethodSource("getTestParametersForConfig") public void encode(final String name, final RLPRefTestCaseSpec spec, final boolean runTest) { assumeTrue(runTest, "Test was blacklisted"); - Assertions.assertThat(RLPTestUtil.encode(spec.getIn())).isEqualTo(spec.getOut()); + if (!spec.getIn().equals(INVALID)) { + Assertions.assertThat(RLPTestUtil.encode(spec.getIn())).isEqualTo(spec.getOut()); + } } @ParameterizedTest(name = "Name: {0}") @MethodSource("getTestParametersForConfig") public void decode(final String name, final RLPRefTestCaseSpec spec, final boolean runTest) { assumeTrue(runTest, "Test was blacklisted"); - Assertions.assertThat(RLPTestUtil.decode(spec.getOut())).isEqualTo(spec.getIn()); + if (spec.getIn().equals(INVALID)) { + Assertions.assertThatThrownBy(() -> RLPTestUtil.decode(spec.getOut())) + .isInstanceOf(RLPException.class); + Assertions.assertThatThrownBy(() -> decode2(RLP.input(spec.getOut()))) + .isInstanceOf(RLPException.class); + } else { + Assertions.assertThat(RLPTestUtil.decode(spec.getOut())).isEqualTo(spec.getIn()); + } + } + + private static Object decode2(final RLPInput in) { + if (in.nextIsList()) { + return in.readList(RLPRefTest::decode2); + } else { + return in.readBytes(); + } } } diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java index 2286fe67cf..044f61b3b7 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java @@ -59,9 +59,9 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage; 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.worldstate.DefaultWorldStateArchive; +import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive; +import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -166,8 +166,8 @@ public class RetestethContext { mixHash = Optional.ofNullable(genesisState.getBlock().getHeader().getMixHashOrPrevRandao()); final WorldStateArchive worldStateArchive = - new DefaultWorldStateArchive( - new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()), + new ForestWorldStateArchive( + new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage()), new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()), EvmConfiguration.DEFAULT); final MutableWorldState worldState = worldStateArchive.getMutable(); diff --git a/evm/build.gradle b/evm/build.gradle index 83caaae31b..f90beea041 100644 --- a/evm/build.gradle +++ b/evm/build.gradle @@ -54,8 +54,6 @@ 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' } publishing { diff --git a/gradle.properties b/gradle.properties index 15fd81816e..44c04585e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=23.10.3-RC3 +version=23.10.3-RC4 org.gradle.welcome=never # Set exports/opens flags required by Google Java Format and ErrorProne plugins. (JEP-396) @@ -14,3 +14,5 @@ org.gradle.jvmargs=-Xmx4g \ --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \ --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \ --add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED +# Could be moved to sonar properties after https://sonarsource.atlassian.net/browse/SONARGRADL-134 +systemProp.sonar.gradle.skipCompile=true \ No newline at end of file diff --git a/gradle/allowed-licenses.json b/gradle/allowed-licenses.json new file mode 100644 index 0000000000..a5d4048b22 --- /dev/null +++ b/gradle/allowed-licenses.json @@ -0,0 +1,65 @@ +{ + "allowedLicenses": [ + { + "moduleLicense": "Apache License, Version 2.0", + "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" + }, + { + "moduleLicense": "BSD Zero Clause License", + "moduleLicenseUrl": "https://opensource.org/licenses/0BSD" + }, + { + "moduleLicense" : "The 2-Clause BSD License", + "moduleLicenseUrl" : "https://opensource.org/licenses/BSD-2-Clause" + }, + { + "moduleLicense": "The 3-Clause BSD License", + "moduleLicenseUrl": "https://opensource.org/licenses/BSD-3-Clause" + }, + { + "moduleLicense": "Bouncy Castle Licence", + "moduleLicenseUrl": "https://www.bouncycastle.org/licence.html" + }, + { + "moduleLicense": "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0", + "moduleLicenseUrl": "https://oss.oracle.com/licenses/CDDL" + }, + { + "moduleLicense" : "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1", + "moduleLicenseUrl" : "https://oss.oracle.com/licenses/CDDL-1.1" + }, + { + "moduleLicense": "Eclipse Distribution License - v 1.0", + "moduleLicenseUrl": "http://www.eclipse.org/legal/epl-v10.html" + }, + { + "moduleLicense": "Eclipse Public License - v 2.0", + "moduleLicenseUrl": "https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt" + }, + { + "moduleLicense": "MIT License", + "moduleLicenseUrl": "https://opensource.org/licenses/MIT" + }, + { + "moduleLicense": "CC0-1.0", + "moduleLicenseUrl": "https://creativecommons.org/publicdomain/zero/1.0/legalcode" + }, + { + "moduleLicense": "Public-Domain" + }, + { + "moduleLicense": "Unicode/ICU License", + "moduleLicenseUrl": "https://raw.githubusercontent.com/unicode-org/icu/main/icu4c/LICENSE" + }, + { + "moduleLicense": "Creative Commons Legal Code", + "moduleVersion": "1.0.3", + "moduleName": "org.reactivestreams:reactive-streams" + }, + { + "moduleLicense": "Eclipse Public License - v 1.0", + "moduleVersion": "4.13.2", + "moduleName": "junit:junit" + } + ] +} \ No newline at end of file diff --git a/gradle/check-licenses.gradle b/gradle/check-licenses.gradle deleted file mode 100644 index 3939c19116..0000000000 --- a/gradle/check-licenses.gradle +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * Check that the licenses of our 3rd parties are in our acceptedLicenses list. - * - * run it with "gradle checkLicenses" - * - * To add new accepted licenses you need to update this script. - * Some products may be available with multiple licenses. In this case you must update - * this script to add it in the downloadLicenses#licenses. - */ - -// Some parts of this code comes from Zipkin/https://github.com/openzipkin/zipkin/pull/852 -// Zipkin itself is under Apache License. - -/** - * The lists of the license we accept. - */ -ext.acceptedLicenses = [ - 'Apache License, Version 2.0', - 'BSD 3-Clause', - 'BSD License', - 'Bouncy Castle Licence', - 'CC0 1.0 Universal License', - 'Common Development and Distribution License 1.0', - 'Eclipse Public License 1.0', - 'Eclipse Public License - v 2.0', - 'MIT License', - 'Mozilla Public License 1.0', - 'Mozilla Public License Version 1.1', - 'Mozilla Public License Version 2.0', - 'Oracle Free Use Terms and Conditions (FUTC)', - 'Public Domain (CC0) License 1.0', - 'Public Domain', - 'Unicode/ICU License', - 'New BSD License' -]*.toLowerCase() - -/** - * This is the configuration we need for our licenses plugin: 'com.github.hierynomus.license' - * This plugin generates a list of dependencies. - */ -downloadLicenses { - includeProjectDependencies = false - reportByDependency = false - reportByLicenseType = true - dependencyConfiguration = 'runtimeClasspath' - excludeDependencies = [ - // only used for static analysis, not actually shipped - 'com.google.code.findbugs:jFormatString:3.0.0', - 'com.google.errorprone:javac:.*', - 'org.checkerframework:dataflow-shaded:.*', - 'org.checkerframework:dataflow-errorprone:.*', - ] - - ext.apache = license('Apache License, Version 2.0', 'http://opensource.org/licenses/Apache-2.0') - ext.bsd = license('BSD License', 'http://www.opensource.org/licenses/bsd-license.php') - ext.bsd3Clause = license('BSD 3-Clause', 'http://opensource.org/licenses/BSD-3-Clause') - ext.cc0 = license('Public Domain (CC0) License 1.0', 'https://creativecommons.org/publicdomain/zero/1.0') - ext.cddl = license('Common Development and Distribution License 1.0', 'http://opensource.org/licenses/CDDL-1.0') - ext.epl1 = license('Eclipse Public License 1.0', 'https://www.eclipse.org/legal/epl-v10.html') - ext.epl2 = license('Eclipse Public License - v 2.0', 'https://www.eclipse.org/legal/epl-v20.html') - ext.mit = license('MIT License', 'http://www.opensource.org/licenses/mit-license.php') - aliases = [ - (apache) : [ - 'Apache 2', - 'Apache 2.0', - 'Apache License 2.0', - 'Apache Software License - Version 2.0', - 'Apache Software License 2.0', - 'Apache v2', - 'Apache-2.0', - 'The Apache License, Version 2.0', - 'The Apache Software License, Version 2.0', - 'The Apache Software License, version 2.0', - license('', 'http://www.apache.org/licenses/LICENSE-2.0.txt') - ], - (bsd) : [ - 'BSD', - 'BSD-2-Clause', - 'BSD licence', - 'The BSD License', - ], - (bsd3Clause) : [ - '3-Clause BSD License', - 'BSD 3-Clause "New" or "Revised" License (BSD-3-Clause)', - 'BSD 3-Clause', - 'BSD Licence 3', - 'BSD License 3', - 'BSD-3-Clause', - 'Eclipse Distribution License - v 1.0', - 'Eclipse Distribution License (New BSD License)', - 'EDL 1.0', - 'New BSD License', - 'The BSD 3-Clause License', - license('', 'http://asm.ow2.org/license.html'), - license('BSD 3-Clause', 'http://www.scala-lang.org/license.html'), - license('BSD 3-clause', 'http://opensource.org/licenses/BSD-3-Clause'), - ], - (cc0) : [ - 'CC0' - ], - (cddl) : [ - 'CDDL 1.0', - 'CDDL 1.1', - 'Common Development and Distribution License (CDDL) v1.0', - 'CDDL + GPLv2 with classpath exception', - ], - (epl1) : [ - 'Eclipse Public License - Version 1.0', - 'Eclipse Public License - v 1.0', - 'Eclipse Public License 1.0 ', - ], - (epl2) : [ - 'Eclipse Public License - v 2.0', - 'Eclipse Public License version 2.0', - 'Eclipse Public License v2.0' - ], - (mit) : [ - 'MIT', - 'The MIT License', - 'The MIT License (MIT)', - 'SPDX-License-Identifier: MIT', - ], - ] - licenses = [ - (group('besu')) : apache, - (group('besu.ethereum.api')) : apache, - (group('besu.consensus')) : apache, - (group('besu.ethereum')) : apache, - (group('besu.metrics')) : apache, - (group('besu.plugins')) : apache, - (group('besu.services')) : apache, - - // JNA is dual licensed under Apache v2.0 or LGPL 2 licenses - // Explicitly declare that we are using the Apache v2.0 license - (group('net.java.dev.jna')) : apache, - - // RocksDB is dual licensed under Apache v2.0 or GPL 2 licenses - // Explicitly declare that we are using the Apache v2.0 license - (group('org.rocksdb')) : apache, - - // Logback is dual licensed under EPL v1.0 or LGPL v2.1 - // Explicitly declare that we are using the EPL v1.0 license - (group('ch.qos.logback')) : epl1, - - // JavaMail, JAXB, Glassfish and Java Servlet are dual licensed under CDDL 1.1 or GPL 2 w/ Classpath Exception - // Explicitly declare that we are using the CDDL 1.1 license - (group('com.sun.mail')) : cddl, - (group('javax.servlet')) : cddl, - (group('javax.xml.bind')) : cddl, - (group('org.glassfish')) : cddl, - - // javax.persistence is dual licensed under EPL 1.0 and EDL 1.0. - // Explicitly declare that we are using the EPL 1.0 license - (group('javax.persistence')) : epl1, - - // jnr-posix is released under a tri EPL v2.0/GPL/LGPL license - 'com.github.jnr:jnr-posix:3.1.15' : epl2, - - // io.netty:netty-tcnative-boringssl-static license markings are not machine readable. - // io.netty:netty-tcnative-classes license markings are not machine readable. - // Explicitly state Apache 2 License for license scanning. - 'io.netty:netty-tcnative-boringssl-static:2.0.46.Final' : apache, - 'io.netty:netty-tcnative-classes:2.0.46.Final' : apache, - - // ANTLR license markings are not all machine readable. - // Explicitly state BSD License for license scanning. - 'org.antlr:antlr-runtime:3.5.2': bsd, - 'org.antlr:ST4:4.3.1': bsd, - ] -} - -task lazyDownloadLicenses() { - if (gradle.startParameter.taskNames.contains('clean') || !file("$rootProject.buildDir/reports/license/license-dependency.xml").exists()) { - dependsOn ':downloadLicenses' - } -} - -task checkLicenses { - description "Verify that all dependencies use accepted licenses." - dependsOn ':lazyDownloadLicenses' - - def bads = "" - doLast { - def xml = new XmlParser().parse("${rootProject.buildDir}/reports/license/license-dependency.xml") - xml.each { license -> - if (!acceptedLicenses.contains((license.@name).toLowerCase())) { - def depStrings = [] - license.dependency.each { depStrings << it.text() } - bads = bads + depStrings + " => ${license.@name} \n" - } - } - if (bads != "") { - throw new GradleException("Some 3rd parties are using licenses not in our accepted licenses list:\n" + - bads + - "If it's a license acceptable for us, add it in the file check-licenses.gradle\n" + - "Be careful, some 3rd parties may accept multiple licenses.\n" + - "In this case, select the one you want to use by changing downloadLicenses.licenses\n" - ) - } - } -} diff --git a/gradle/license-normalizer-bundle.json b/gradle/license-normalizer-bundle.json new file mode 100644 index 0000000000..341b7ab5f6 --- /dev/null +++ b/gradle/license-normalizer-bundle.json @@ -0,0 +1,106 @@ +/** + * Copyright 2018 Evgeny Naumenko + * Copyright Hyperledger Besu contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "bundles" : [ + { "bundleName" : "Apache-1.1", "licenseName" : "Apache Software License, Version 1.1", "licenseUrl" : "https://www.apache.org/licenses/LICENSE-1.1" }, + { "bundleName" : "Apache-2.0", "licenseName" : "Apache License, Version 2.0", "licenseUrl" : "https://www.apache.org/licenses/LICENSE-2.0" }, + { "bundleName" : "0BSD", "licenseName" : "BSD Zero Clause License", "licenseUrl" : "https://opensource.org/licenses/0BSD" }, + { "bundleName" : "BSD-2-Clause", "licenseName" : "The 2-Clause BSD License", "licenseUrl" : "https://opensource.org/licenses/BSD-2-Clause" }, + { "bundleName" : "BSD-3-Clause", "licenseName" : "The 3-Clause BSD License", "licenseUrl" : "https://opensource.org/licenses/BSD-3-Clause" }, + { "bundleName" : "CC0-1.0", "licenseName" : "Creative Commons Legal Code", "licenseUrl" : "https://creativecommons.org/publicdomain/zero/1.0/legalcode" }, + { "bundleName" : "CDDL-1.0", "licenseName" : "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0", "licenseUrl" : "https://oss.oracle.com/licenses/CDDL" }, + { "bundleName" : "CDDL-1.1", "licenseName" : "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1", "licenseUrl" : "https://oss.oracle.com/licenses/CDDL-1.1" }, + { "bundleName" : "CPL-1.0", "licenseName" : "Common Public License - v 1.0", "licenseUrl" : "https://www.eclipse.org/legal/cpl-v10.html" }, + { "bundleName" : "EPL-1.0", "licenseName" : "Eclipse Public License - v 1.0", "licenseUrl" : "http://www.eclipse.org/legal/epl-v10.html" }, + { "bundleName" : "EPL-2.0", "licenseName" : "Eclipse Public License - v 2.0", "licenseUrl" : "https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt" }, + { "bundleName" : "EDL-1.0", "licenseName" : "Eclipse Distribution License - v 1.0", "licenseUrl" : "https://www.eclipse.org/org/documents/edl-v10.html" }, + { "bundleName" : "GPL-1.0", "licenseName" : "GNU GENERAL PUBLIC LICENSE, Version 1", "licenseUrl" : "https://www.gnu.org/licenses/gpl-1.0" }, + { "bundleName" : "GPL-2.0-only", "licenseName" : "GNU GENERAL PUBLIC LICENSE, Version 2", "licenseUrl" : "https://www.gnu.org/licenses/gpl-2.0" }, + { "bundleName" : "GPL-3.0-only", "licenseName" : "GNU GENERAL PUBLIC LICENSE, Version 3", "licenseUrl" : "https://www.gnu.org/licenses/gpl-3.0" }, + { "bundleName" : "GPL-2.0 WITH Classpath-exception-2.0", "licenseName" : "GNU GENERAL PUBLIC LICENSE, Version 2 + Classpath Exception", "licenseUrl" : "https://openjdk.java.net/legal/gplv2+ce.html" }, + { "bundleName" : "LGPL-2.1-only", "licenseName" : "GNU LESSER GENERAL PUBLIC LICENSE, Version 2.1", "licenseUrl" : "https://www.gnu.org/licenses/lgpl-2.1" }, + { "bundleName" : "LGPL-3.0-only", "licenseName" : "GNU LESSER GENERAL PUBLIC LICENSE, Version 3", "licenseUrl" : "https://www.gnu.org/licenses/lgpl-3.0" }, + { "bundleName" : "MIT", "licenseName" : "MIT License", "licenseUrl" : "https://opensource.org/licenses/MIT" }, + { "bundleName" : "MPL-1.1", "licenseName" : "Mozilla Public License Version 1.1", "licenseUrl" : "https://www.mozilla.org/en-US/MPL/1.1" }, + { "bundleName" : "MPL-2.0", "licenseName" : "Mozilla Public License, Version 2.0", "licenseUrl" : "https://www.mozilla.org/en-US/MPL/2.0" }, + { "bundleName" : "Public-Domain", "licenseName" : "PUBLIC DOMAIN", "licenseUrl" : "" } + ], + "transformationRules" : [ + { "bundleName" : "0BSD", "licenseNamePattern" : "BSD Zero Clause License" }, + { "bundleName" : "0BSD", "licenseNamePattern" : "BSD$" }, + { "bundleName" : "0BSD", "licenseNamePattern" : "BSD( |-)clause.*" }, + { "bundleName" : "0BSD", "licenseNamePattern" : "(The )?BSD( |-)(l|L)icen(s|c)e.*" }, + { "bundleName" : "Apache-2.0", "licenseNamePattern" : ".*The Apache Software License, Version 2\\.0.*" }, + { "bundleName" : "Apache-2.0", "licenseNamePattern" : ".*?Apache( |-|_)2.*" }, + { "bundleName" : "Apache-2.0", "licenseNamePattern" : "ASL 2\\.0" }, + { "bundleName" : "Apache-2.0", "licenseNamePattern" : ".*Apache License,?( Version)? 2.*" }, + { "bundleName" : "Apache-2.0", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/Apache-2\\.0.*" }, + { "bundleName" : "Apache-2.0", "licenseUrlPattern" : ".*www\\.apache\\.org/licenses/LICENSE-2\\.0.*" }, + { "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*www\\.gnu\\.org/licenses/old-licenses/lgpl-2\\.1\\.html" }, + { "bundleName" : "Apache-2.0", "licenseFileContentPattern" : ".*Apache License,?( Version)? 2.*" }, + { "bundleName" : "Apache-1.1", "licenseFileContentPattern" : ".*Apache Software License, Version 1\\.1.*" }, + { "bundleName" : "CC0-1.0", "licenseNamePattern" : "CC0(( |-)1(\\.0)?)?" }, + { "bundleName" : "CC0-1.0", "licenseUrlPattern" : ".*(www\\.)?creativecommons\\.org/publicdomain/zero/1\\.0/" }, + { "bundleName" : "CDDL-1.0", "licenseFileContentPattern" : ".*CDDL.*1\\.0" }, + { "bundleName" : "CDDL-1.0", "licenseUrlPattern" : ".*CDDL.*.?1\\.0" }, + { "bundleName" : "CDDL-1.1", "licenseUrlPattern" : ".*CDDL.*.?1\\.1" }, + { "bundleName" : "CDDL-1.0", "licenseNamePattern" : "Common Development and Distribution License( \\(CDDL\\),?)? (version )?(.?\\s?)?1\\.0" }, + { "bundleName" : "CDDL-1.1", "licenseNamePattern" : "Common Development and Distribution License( \\(CDDL\\),?)? (version )?(.?\\s?)?1\\.1" }, + { "bundleName" : "BSD-3-Clause", "licenseNamePattern" : ".*BSD( |-)3-clause.*" }, + { "bundleName" : "BSD-3-Clause", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/BSD-3-Clause" }, + { "bundleName" : "BSD-3-Clause", "licenseNamePattern" : ".*?(The )New BSD License.*" }, + { "bundleName" : "BSD-3-Clause", "licenseNamePattern" : ".*?Modified BSD License.*" }, + { "bundleName" : "BSD-2-Clause", "licenseNamePattern" : "BSD( |-)2-clause.*" }, + { "bundleName" : "BSD-2-Clause", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/BSD-2-Clause" }, + { "bundleName" : "BSD-2-Clause", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/bsd-license(\\.php)?" }, + { "bundleName" : "CDDL-1.0", "licenseNamePattern" : "Common Development and Distribution( License)?" }, + { "bundleName" : "CDDL-1.0", "licenseNamePattern" : "CDDL 1(\\.0)" }, + { "bundleName" : "CDDL-1.1", "licenseNamePattern" : "CDDL 1\\.1" }, + { "bundleName" : "CDDL-1.1", "licenseUrlPattern" : ".*(www\\.).opensource\\.org/licenses/CDDL-1\\.0" }, + { "bundleName" : "EPL-1.0", "licenseNamePattern" : "Eclipse Publish License.*(v|version)\\.?\\s?1(\\.?0)?" }, + { "bundleName" : "EPL-1.0", "licenseNamePattern" : "Eclipse Public License.*(v|version)\\.?\\s?1(\\.?0)?" }, + { "bundleName" : "EPL-2.0", "licenseNamePattern" : "Eclipse Public License.*(v|version)\\.?\\s?2(\\.?0)?" }, + { "bundleName" : "EPL-2.0", "licenseUrlPattern" : ".*(www\\.).opensource\\.org/licenses/EPL-2\\.0" }, + { "bundleName" : "EPL-2.0", "licenseUrlPattern" : ".*http.?://www\\.eclipse\\.org/legal/epl-.?2\\.?0.*" }, + { "bundleName" : "EPL-2.0", "licenseUrlPattern" : ".*http.?://www\\.eclipse\\.org/org.*/epl-.?2\\.?0.*" }, + { "bundleName" : "EPL-2.0", "licenseUrlPattern" : ".*http.?://projects\\.eclipse\\.org/.*/epl-.?2\\.?0.*" }, + { "bundleName" : "EDL-1.0", "licenseNamePattern" : "Eclipse Distribution License.*(v|version)\\.?\\s?1(\\.0)?" }, + { "bundleName" : "EDL-1.0", "licenseNamePattern" : "Eclipse Distribution License \\(New BSD License\\)" }, + { "bundleName" : "EDL-1.0", "licenseUrlPattern" : ".*http.?://(www\\.)?eclipse\\.org/org.*/edl-.?1\\.?0.*" }, + { "bundleName" : "GPL-2.0-only", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/GPL-2\\.0" }, + { "bundleName" : "GPL-2.0 WITH Classpath-exception-2.0", "licenseNamePattern" : "GNU General Public License, version 2.*classpath exception" }, + { "bundleName" : "GPL-2.0 WITH Classpath-exception-2.0", "licenseNamePattern" : "GNU General Public License, version 2.*cp?e" }, + { "bundleName" : "GPL-2.0 WITH Classpath-exception-2.0", "licenseNamePattern" : "GNU General Public License, version 2.*, with the classpath exception" }, + { "bundleName" : "GPL-2.0 WITH Classpath-exception-2.0", "licenseNamePattern" : "GPL2 w/ CPE" }, + { "bundleName" : "GPL-3.0-only", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/GPL-3\\.0" }, + { "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/LGPL-2\\.1" }, + { "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*(www\\.)?gnu\\.org/licenses(/old-licenses)?/lgpl-2\\.1(\\.(html|txt))?" }, + { "bundleName" : "LGPL-2.1-only", "licenseNamePattern" : "LGPL 2\\.1" }, + { "bundleName" : "LGPL-2.1-only", "licenseNamePattern" : "LGPL.*(v|version)\\.?\\s?2\\.1" }, + { "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*(www\\.)?repository.jboss.org/licenses/lgpl-2.1\\.txt" }, + { "bundleName" : "LGPL-3.0-only", "licenseUrlPattern" : ".*(www\\.).opensource\\.org/licenses/LGPL-3\\.0" }, + { "bundleName" : "LGPL-3.0-only", "licenseNamePattern" : "lgplv?3" }, + { "bundleName" : "LGPL-3.0-only", "licenseUrlPattern" : ".*(www\\.)?gnu\\.org/licenses(/old-licenses)?/lgpl(-3)?(\\.(html|txt))?" }, + { "bundleName" : "MIT", "licenseNamePattern" : "(The\\s)?MIT(\\slicen(c|s)e)?(\\s\\(MIT\\))?" }, + { "bundleName" : "MIT", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/MIT(\\.php)?" }, + { "bundleName" : "MPL-1.1", "licenseNamePattern" : "MPL 1\\.1" }, + { "bundleName" : "MPL-2.0", "licenseUrlPattern" : ".*(www\\.).opensource\\.org/licenses/MPL-2\\.0" }, + { "bundleName" : "Public-Domain", "licenseNamePattern" : "((public)\\s(domain)).*", "transformUrl" : false }, + { "bundleName" : "Public-Domain", "licenseFileContentPattern" : ".*(Creative)\\s(Commons).*", "transformUrl" : false }, + { "bundleName" : "Public-Domain", "licenseFileContentPattern" : ".*((Public)\\s(Domain)).*", "transformUrl" : false } + ] +} \ No newline at end of file diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 01ea0e0226..8265a2810c 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -33,60 +33,54 @@ - - - + + + - - - - - - - - - - + + - - - + + + - - + + - - + + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -99,9 +93,14 @@ - - - + + + + + + + + @@ -124,14 +123,19 @@ + + + + + - - - + + + @@ -169,9 +173,19 @@ - - - + + + + + + + + + + + + + @@ -184,12 +198,19 @@ - - - + + + - - + + + + + + + + + @@ -213,6 +234,14 @@ + + + + + + + + @@ -220,17 +249,6 @@ - - - - - - - - - - - @@ -255,8 +273,13 @@ - - + + + + + + + @@ -266,17 +289,6 @@ - - - - - - - - - - - @@ -299,6 +311,14 @@ + + + + + + + + @@ -306,8 +326,13 @@ - - + + + + + + + @@ -317,8 +342,13 @@ - - + + + + + + + @@ -326,6 +356,11 @@ + + + + + @@ -337,17 +372,30 @@ + + + + + + + + - - - + + + - - + + + + + + + @@ -361,9 +409,9 @@ - - - + + + @@ -395,9 +443,17 @@ - - - + + + + + + + + + + + @@ -536,20 +592,27 @@ + + + + + - - - + + + - - + + + + - - + + @@ -563,6 +626,11 @@ + + + + + @@ -571,6 +639,11 @@ + + + + + @@ -640,11 +713,21 @@ + + + + + + + + + + @@ -692,11 +775,6 @@ - - - - - @@ -736,6 +814,11 @@ + + + + + @@ -744,6 +827,11 @@ + + + + + @@ -767,9 +855,6 @@ - - - @@ -779,6 +864,11 @@ + + + + + @@ -811,14 +901,6 @@ - - - - - - - - @@ -827,6 +909,11 @@ + + + + + @@ -835,6 +922,11 @@ + + + + + @@ -855,9 +947,9 @@ - - - + + + @@ -868,6 +960,11 @@ + + + + + @@ -876,6 +973,14 @@ + + + + + + + + @@ -900,6 +1005,14 @@ + + + + + + + + @@ -918,6 +1031,11 @@ + + + + + @@ -931,14 +1049,6 @@ - - - - - - - - @@ -947,21 +1057,45 @@ + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + @@ -1139,12 +1273,12 @@ - - - + + + - - + + @@ -1155,6 +1289,14 @@ + + + + + + + + @@ -1166,14 +1308,6 @@ - - - - - - - - @@ -1190,9 +1324,9 @@ - - - + + + @@ -1237,6 +1371,11 @@ + + + + + @@ -1260,9 +1399,6 @@ - - - @@ -1272,6 +1408,22 @@ + + + + + + + + + + + + + + + + @@ -1305,6 +1457,14 @@ + + + + + + + + @@ -1313,6 +1473,19 @@ + + + + + + + + + + + + + @@ -1325,8 +1498,10 @@ - - + + + + @@ -1340,35 +1515,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + @@ -1379,6 +1531,14 @@ + + + + + + + + @@ -1395,17 +1555,9 @@ - - - - - - - - - - - + + + @@ -1424,6 +1576,14 @@ + + + + + + + + @@ -1432,6 +1592,11 @@ + + + + + @@ -1453,6 +1618,11 @@ + + + + + @@ -1461,6 +1631,11 @@ + + + + + @@ -1474,19 +1649,6 @@ - - - - - - - - - - - - - @@ -1495,6 +1657,11 @@ + + + + + @@ -1543,6 +1710,11 @@ + + + + + @@ -1567,6 +1739,11 @@ + + + + + @@ -1639,6 +1816,11 @@ + + + + + @@ -1679,6 +1861,11 @@ + + + + + @@ -1692,6 +1879,11 @@ + + + + + @@ -1708,6 +1900,16 @@ + + + + + + + + + + @@ -1935,6 +2137,11 @@ + + + + + @@ -1945,6 +2152,11 @@ + + + + + @@ -2057,6 +2269,11 @@ + + + + + @@ -2071,6 +2288,11 @@ + + + + + @@ -2079,6 +2301,11 @@ + + + + + @@ -2138,6 +2365,14 @@ + + + + + + + + @@ -2193,6 +2428,14 @@ + + + + + + + + @@ -2215,6 +2458,14 @@ + + + + + + + + @@ -2226,6 +2477,14 @@ + + + + + + + + @@ -2248,6 +2507,14 @@ + + + + + + + + @@ -2281,6 +2548,14 @@ + + + + + + + + @@ -2292,6 +2567,14 @@ + + + + + + + + @@ -2303,6 +2586,14 @@ + + + + + + + + @@ -2310,9 +2601,6 @@ - - - @@ -2321,9 +2609,6 @@ - - - @@ -2332,8 +2617,13 @@ - - + + + + + + + @@ -2343,8 +2633,13 @@ - - + + + + + + + @@ -2455,6 +2750,11 @@ + + + + + @@ -2463,6 +2763,11 @@ + + + + + @@ -2479,6 +2784,11 @@ + + + + + @@ -2495,6 +2805,11 @@ + + + + + @@ -2519,17 +2834,19 @@ - - - + + + + + - - - + + + - - + + @@ -2686,6 +3003,16 @@ + + + + + + + + + + @@ -2702,6 +3029,11 @@ + + + + + @@ -2710,6 +3042,11 @@ + + + + + @@ -2720,6 +3057,11 @@ + + + + + @@ -2738,6 +3080,11 @@ + + + + + @@ -2772,6 +3119,11 @@ + + + + + @@ -2788,6 +3140,11 @@ + + + + + @@ -2796,6 +3153,11 @@ + + + + + @@ -2809,6 +3171,11 @@ + + + + + @@ -2880,17 +3247,17 @@ - - - + + + - - + + - - - + + + @@ -2945,6 +3312,11 @@ + + + + + @@ -2966,25 +3338,22 @@ - - - - - - + + + - - - + + + - - - + + + - - + + @@ -3077,6 +3446,11 @@ + + + + + @@ -3085,6 +3459,11 @@ + + + + + @@ -3095,6 +3474,11 @@ + + + + + @@ -3120,9 +3504,14 @@ - - - + + + + + + + + @@ -3143,14 +3532,6 @@ - - - - - - - - @@ -3159,6 +3540,19 @@ + + + + + + + + + + + + + @@ -3175,9 +3569,9 @@ - - - + + + @@ -3188,8 +3582,16 @@ - - + + + + + + + + + + @@ -3208,6 +3610,11 @@ + + + + + @@ -3218,11 +3625,6 @@ - - - - - @@ -3238,6 +3640,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -3254,6 +3676,19 @@ + + + + + + + + + + + + + @@ -3262,14 +3697,22 @@ + + + + + + + + - - - + + + @@ -3277,9 +3720,9 @@ - - - + + + @@ -3292,14 +3735,6 @@ - - - - - - - - @@ -3308,14 +3743,12 @@ - - - + + + - - - - + + @@ -3352,12 +3785,12 @@ - - - + + + - - + + @@ -3365,11 +3798,21 @@ + + + + + + + + + + @@ -3378,11 +3821,21 @@ + + + + + + + + + + @@ -3391,6 +3844,11 @@ + + + + + @@ -3399,6 +3857,11 @@ + + + + + @@ -3407,6 +3870,11 @@ + + + + + @@ -3536,6 +4004,11 @@ + + + + + @@ -3560,6 +4033,11 @@ + + + + + @@ -3592,6 +4070,14 @@ + + + + + + + + @@ -3603,14 +4089,6 @@ - - - - - - - - @@ -3619,27 +4097,11 @@ - - - - - - - - - - - - - - - - @@ -3741,6 +4203,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3950,12 +4468,12 @@ - - - + + + - - + + @@ -3963,9 +4481,25 @@ - - - + + + + + + + + + + + + + + + + + + + @@ -3984,14 +4518,44 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + @@ -4026,6 +4590,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4034,6 +4806,14 @@ + + + + + + + + @@ -4042,6 +4822,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4058,6 +4902,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -4066,6 +4934,22 @@ + + + + + + + + + + + + + + + + @@ -4074,6 +4958,22 @@ + + + + + + + + + + + + + + + + @@ -4082,14 +4982,108 @@ - - - + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4100,6 +5094,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4113,6 +5203,11 @@ + + + + + @@ -4141,8 +5236,13 @@ - - + + + + + + + @@ -4166,6 +5266,11 @@ + + + + + @@ -4277,11 +5382,21 @@ + + + + + + + + + + @@ -4290,6 +5405,11 @@ + + + + + @@ -4361,6 +5481,11 @@ + + + + + @@ -4398,6 +5523,14 @@ + + + + + + + + @@ -4414,6 +5547,22 @@ + + + + + + + + + + + + + + + + @@ -4440,6 +5589,14 @@ + + + + + + + + @@ -4534,9 +5691,6 @@ - - - @@ -4576,44 +5730,60 @@ - - - + + + + + + + + + + + + + + + + + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -4672,6 +5842,22 @@ + + + + + + + + + + + + + + + + @@ -4683,6 +5869,14 @@ + + + + + + + + @@ -4702,6 +5896,14 @@ + + + + + + + + @@ -4721,6 +5923,14 @@ + + + + + + + + @@ -4758,23 +5968,12 @@ - - - - - - - - - - - @@ -4782,9 +5981,6 @@ - - - @@ -4812,9 +6008,6 @@ - - - @@ -4829,14 +6022,6 @@ - - - - - - - - @@ -4844,23 +6029,12 @@ - - - - - - - - - - - @@ -4868,8 +6042,13 @@ - - + + + + + + + @@ -4887,15 +6066,17 @@ - - - + + + + + @@ -4904,6 +6085,11 @@ + + + + + @@ -4912,11 +6098,21 @@ + + + + + + + + + + @@ -4930,6 +6126,11 @@ + + + + + @@ -4938,6 +6139,11 @@ + + + + + @@ -4959,6 +6165,14 @@ + + + + + + + + @@ -4967,6 +6181,11 @@ + + + + + @@ -4983,6 +6202,11 @@ + + + + + @@ -4996,6 +6220,11 @@ + + + + + @@ -5144,6 +6373,11 @@ + + + + + @@ -5152,6 +6386,14 @@ + + + + + + + + @@ -5160,6 +6402,16 @@ + + + + + + + + + + @@ -5168,19 +6420,34 @@ + + + + + + + + + + - - - + + + + + + + + @@ -5201,12 +6468,12 @@ - - - + + + - - + + @@ -5274,6 +6541,14 @@ + + + + + + + + @@ -5290,6 +6565,14 @@ + + + + + + + + @@ -5298,11 +6581,24 @@ + + + + + + + + + + + + + @@ -5319,6 +6615,11 @@ + + + + + @@ -5327,6 +6628,11 @@ + + + + + @@ -5359,6 +6665,11 @@ + + + + + @@ -5375,6 +6686,11 @@ + + + + + @@ -5383,6 +6699,11 @@ + + + + + @@ -5465,6 +6786,11 @@ + + + + + @@ -5473,6 +6799,11 @@ + + + + + @@ -5529,6 +6860,14 @@ + + + + + + + + @@ -5540,13 +6879,5 @@ - - - - - - - - diff --git a/nat/build.gradle b/nat/build.gradle index f6c814ad11..ec2fd3a3f0 100644 --- a/nat/build.gradle +++ b/nat/build.gradle @@ -45,6 +45,4 @@ dependencies { testImplementation 'org.assertj:assertj-core' testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'org.mockito:mockito-core' - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } diff --git a/pki/build.gradle b/pki/build.gradle index 8e2f52a473..cb6aaf8b86 100644 --- a/pki/build.gradle +++ b/pki/build.gradle @@ -37,8 +37,6 @@ 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' } configurations { testArtifacts } diff --git a/settings.gradle b/settings.gradle index 3a1c245a7f..15a0f8617d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -16,18 +16,6 @@ pluginManagement { repositories { - /* - * Temporary repository to host the improved version of the - * com.github.hierynomus.license plugin. Can be removed when an - * official version with the fix is release upstream - */ - maven { - url = uri('https://raw.githubusercontent.com/ConsenSys/license-gradle-plugin-fix-artifacts/main/') - content { - includeGroup('com.github.hierynomus.license') - includeGroup('com.hierynomus.gradle.plugins') - } - } gradlePluginPortal() } } diff --git a/util/build.gradle b/util/build.gradle index 9136a20b7e..b2a93b1c78 100644 --- a/util/build.gradle +++ b/util/build.gradle @@ -42,6 +42,4 @@ dependencies { testImplementation 'org.assertj:assertj-core' testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'org.mockito:mockito-core' - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' }