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 abd9ac90cf..e76e6108a2 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -130,6 +130,7 @@ import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; +import org.hyperledger.besu.ethereum.forest.pruner.PrunerConfiguration; import org.hyperledger.besu.ethereum.mainnet.FrontierTargetingGasLimitCalculator; import org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration; import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration; @@ -146,7 +147,6 @@ 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.evm.precompile.AbstractAltBnPrecompiledContract; import org.hyperledger.besu.evm.precompile.BigIntegerModularExponentiationPrecompiledContract; import org.hyperledger.besu.evm.precompile.KZGPointEvalPrecompiledContract; 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..05e4e8622d 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.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..453ae51d09 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 @@ -30,13 +30,13 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.TransactionReceipt; +import org.hyperledger.besu.ethereum.forest.ForestWorldStateArchive; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; 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.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/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index 643aed546c..276a063bf0 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -78,6 +78,10 @@ import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolFactory; +import org.hyperledger.besu.ethereum.forest.ForestWorldStateArchive; +import org.hyperledger.besu.ethereum.forest.pruner.MarkSweepPruner; +import org.hyperledger.besu.ethereum.forest.pruner.Pruner; +import org.hyperledger.besu.ethereum.forest.pruner.PrunerConfiguration; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; @@ -86,10 +90,6 @@ import org.hyperledger.besu.ethereum.storage.StorageProvider; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier; 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..c8db08ecbd 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java @@ -53,11 +53,11 @@ import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; +import org.hyperledger.besu.ethereum.forest.pruner.PrunerConfiguration; 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.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..e18e686954 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java @@ -50,11 +50,11 @@ import org.hyperledger.besu.ethereum.eth.sync.backwardsync.BackwardSyncContext; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; +import org.hyperledger.besu.ethereum.forest.pruner.Pruner; +import org.hyperledger.besu.ethereum.forest.pruner.PrunerConfiguration; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.storage.StorageProvider; 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/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index 955c9df7aa..8f004d494e 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -79,12 +79,12 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; +import org.hyperledger.besu.ethereum.forest.pruner.PrunerConfiguration; 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.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; 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..f87db6f824 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java @@ -39,6 +39,7 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; +import org.hyperledger.besu.ethereum.forest.pruner.PrunerConfiguration; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.storage.StorageProvider; @@ -48,7 +49,6 @@ import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage; 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/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..c7e7f43dd6 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 @@ -103,8 +103,8 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolMetrics; import org.hyperledger.besu.ethereum.eth.transactions.sorter.GasPricePendingTransactionsSorter; +import org.hyperledger.besu.ethereum.forest.ForestWorldStateArchive; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; -import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive; 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/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/worldstate/PrunerIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/forest/pruner/PrunerIntegrationTest.java similarity index 94% 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/forest/pruner/PrunerIntegrationTest.java index 77f871f100..c640ed6960 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/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.forest.pruner; import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain; @@ -25,12 +25,16 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; 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.forest.ForestWorldStateArchive; +import org.hyperledger.besu.ethereum.forest.pruner.Pruner.PruningPhase; +import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage; 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.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..94d5fe32ef 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 @@ -30,11 +30,11 @@ import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Withdrawal; +import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage; +import org.hyperledger.besu.ethereum.forest.worldview.ForestMutableWorldState; 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.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..509e51f165 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 @@ -21,12 +21,12 @@ import org.hyperledger.besu.crypto.KeyPairUtil; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.enclave.Enclave; import org.hyperledger.besu.enclave.EnclaveFactory; +import org.hyperledger.besu.ethereum.forest.ForestWorldStateArchive; import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator; 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.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/worldstate/DefaultWorldStateArchive.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/forest/ForestWorldStateArchive.java similarity index 89% 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/forest/ForestWorldStateArchive.java index a29bd9b2ff..72adfd10cf 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultWorldStateArchive.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/forest/ForestWorldStateArchive.java @@ -13,15 +13,19 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.worldstate; +package org.hyperledger.besu.ethereum.forest; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; +import org.hyperledger.besu.ethereum.forest.worldview.ForestMutableWorldState; 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.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/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/forest/pruner/MarkSweepPruner.java index 136e8b0144..0613cefd10 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPruner.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/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.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/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/forest/pruner/Pruner.java index 04949b55e1..3b37672b7d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/Pruner.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/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.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/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/forest/pruner/PrunerConfiguration.java index f2336ee9a3..e9ca4aeb87 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/PrunerConfiguration.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/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.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/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/forest/storage/ForestWorldStateKeyValueStorage.java index 74051b5e9b..fcddae8ab4 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/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.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/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/forest/worldview/ForestMutableWorldState.java index d50f702af3..27db6111e4 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/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.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/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..82915a61db 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 @@ -14,12 +14,12 @@ */ package org.hyperledger.besu.ethereum.privacy.storage.keyvalue; +import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateKeyValueStorage; 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.WorldStatePreimageStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; @@ -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..fa8a17eaee 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 @@ -17,6 +17,7 @@ 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.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; import org.hyperledger.besu.ethereum.storage.StorageProvider; @@ -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/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..5c8e96b410 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 @@ -22,17 +22,17 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.DefaultBlockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.chain.VariablesStorage; +import org.hyperledger.besu.ethereum.forest.ForestWorldStateArchive; +import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage; +import org.hyperledger.besu.ethereum.forest.worldview.ForestMutableWorldState; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage; 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.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..a9405d48aa 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 @@ -14,15 +14,15 @@ */ package org.hyperledger.besu.ethereum.core; +import org.hyperledger.besu.ethereum.forest.ForestWorldStateArchive; +import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage; +import org.hyperledger.besu.ethereum.forest.worldview.ForestMutableWorldState; import org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateKeyValueStorage; 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.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/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPrunerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/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/forest/pruner/MarkSweepPrunerTest.java index 28997591f7..01fb80b164 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPrunerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/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.forest.pruner; import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain; @@ -28,11 +28,15 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; 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.forest.ForestWorldStateArchive; +import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage; 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.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/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/forest/pruner/PrunerTest.java index 8f1b34bcca..a8cd0f8f1a 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/PrunerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/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.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/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/forest/storage/ForestKeyValueStorageWorldStateStorageTest.java index 758866fd6f..737e0e5d8f 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/forest/storage/ForestKeyValueStorageWorldStateStorageTest.java @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.storage.keyvalue; +package org.hyperledger.besu.ethereum.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.forest.storage.ForestWorldStateKeyValueStorage.Updater; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; @@ -25,24 +25,24 @@ 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/forest/worldview/ForestMutableWorldStateTest.java similarity index 98% 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/forest/worldview/ForestMutableWorldStateTest.java index 4e42356341..e2122267b5 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldStateTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/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.forest.worldview; import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldState; @@ -21,7 +21,7 @@ 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.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.evm.account.AccountStorageEntry; @@ -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/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..01e6db7a5f 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 @@ -19,8 +19,8 @@ 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.Wei; +import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage; 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.patricia.StoredMerklePatriciaTrie; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; @@ -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..a81269019b 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,7 +18,7 @@ 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.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.RangeStorageEntriesCollector; import org.hyperledger.besu.ethereum.trie.TrieIterator; @@ -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/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..fe795333e4 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 @@ -33,9 +33,9 @@ import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapDownloaderFactory; import org.hyperledger.besu.ethereum.eth.sync.snapsync.context.SnapSyncStatePersistenceManager; import org.hyperledger.besu.ethereum.eth.sync.state.PendingBlocksManager; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; +import org.hyperledger.besu.ethereum.forest.pruner.Pruner; 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.worldstate.WorldStateStorage; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.plugin.data.SyncStatus; 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..39847656cb 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 @@ -27,7 +27,7 @@ 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.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..2833f77add 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 @@ -46,15 +46,15 @@ import org.hyperledger.besu.ethereum.eth.sync.fastsync.FastSyncState; import org.hyperledger.besu.ethereum.eth.sync.worldstate.StalledDownloadException; import org.hyperledger.besu.ethereum.eth.sync.worldstate.WorldStateDownloader; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; +import org.hyperledger.besu.ethereum.forest.ForestWorldStateArchive; +import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage; 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.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/RangeManagerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/RangeManagerTest.java index 003db79a7e..de3a516f07 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 @@ -18,8 +18,8 @@ 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.forest.storage.ForestWorldStateKeyValueStorage; 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; @@ -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..4f31a6f4c6 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 @@ -39,7 +39,7 @@ 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.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..3325602264 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 @@ -16,8 +16,8 @@ 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.forest.storage.ForestWorldStateKeyValueStorage; 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; @@ -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..eeef28b322 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 @@ -24,9 +24,9 @@ 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.SnapsyncMetricsManager; import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest; +import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage; 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; @@ -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/StorageTrieNodeHealingRequestTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequestTest.java index 447b37d14c..f506bc903c 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 @@ -20,9 +20,9 @@ import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStor 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.forest.storage.ForestWorldStateKeyValueStorage; 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.worldstate.DataStorageFormat; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; @@ -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/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java index 0109d6c819..c784eda078 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.forest.storage.ForestWorldStateKeyValueStorage; +import org.hyperledger.besu.ethereum.forest.worldview.ForestMutableWorldState; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage; -import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState; 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/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..e411962dfa 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.forest.storage.ForestWorldStateKeyValueStorage; +import org.hyperledger.besu.ethereum.forest.worldview.ForestMutableWorldState; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage; -import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState; 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/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..6665a8d8bb 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 @@ -47,6 +47,8 @@ import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolCo import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolFactory; +import org.hyperledger.besu.ethereum.forest.ForestWorldStateArchive; +import org.hyperledger.besu.ethereum.forest.storage.ForestWorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.mainnet.EpochCalculator; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; @@ -59,9 +61,7 @@ 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.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();