move forest class to a specific package (#6293)

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

---------

Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Signed-off-by: matkt <karim.t2am@gmail.com>
pull/6300/head
Karim TAAM 11 months ago committed by GitHub
parent 75df5d60d5
commit ba05f24d71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  2. 4
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java
  3. 4
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java
  4. 12
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  5. 2
      besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java
  6. 4
      besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java
  7. 2
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
  8. 2
      besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java
  9. 4
      consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
  10. 15
      ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/forest/pruner/PrunerIntegrationTest.java
  11. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java
  12. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java
  13. 12
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/forest/ForestWorldStateArchive.java
  14. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/forest/pruner/MarkSweepPruner.java
  15. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/forest/pruner/Pruner.java
  16. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/forest/pruner/PrunerConfiguration.java
  17. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/forest/storage/ForestWorldStateKeyValueStorage.java
  18. 27
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/forest/worldview/ForestMutableWorldState.java
  19. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateMutableWorldStateUpdater.java
  20. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java
  21. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/keyvalue/PrivacyKeyValueStorageProvider.java
  22. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/KeyValueStorageProvider.java
  23. 14
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryKeyValueStorageProvider.java
  24. 14
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/InMemoryPrivacyStorageProvider.java
  25. 12
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/forest/pruner/MarkSweepPrunerTest.java
  26. 2
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/forest/pruner/PrunerTest.java
  27. 38
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/forest/storage/ForestKeyValueStorageWorldStateStorageTest.java
  28. 17
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/forest/worldview/ForestMutableWorldStateTest.java
  29. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateProofProviderTest.java
  30. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/proof/WorldStateRangeProofProviderTest.java
  31. 2
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java
  32. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldDownloadStateTest.java
  33. 56
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/worldstate/FastWorldStateDownloaderTest.java
  34. 6
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/RangeManagerTest.java
  35. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadStateTest.java
  36. 10
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/StackTrieTest.java
  37. 6
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequestTest.java
  38. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/StorageTrieNodeHealingRequestTest.java
  39. 10
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java
  40. 8
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/DefaultReferenceTestWorldState.java
  41. 8
      ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.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;

@ -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 {

@ -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();
}

@ -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);
}
};
}

@ -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;

@ -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;

@ -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;

@ -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;

@ -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 {

@ -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<Bytes, Optional<byte[]>> hashValueStore = new HashMap<>();
private final InMemoryKeyValueStorage stateStorage = new TestInMemoryStorage(hashValueStore);
private final WorldStateStorage worldStateStorage = new WorldStateKeyValueStorage(stateStorage);
private final WorldStateStorage worldStateStorage =
new ForestWorldStateKeyValueStorage(stateStorage);
private final WorldStateArchive worldStateArchive =
new DefaultWorldStateArchive(
new ForestWorldStateArchive(
worldStateStorage,
new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()),
EvmConfiguration.DEFAULT);

@ -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<GenesisAccount> genesisAccounts) {
final WorldStateKeyValueStorage stateStorage =
new WorldStateKeyValueStorage(new InMemoryKeyValueStorage());
final ForestWorldStateKeyValueStorage stateStorage =
new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage());
final WorldStatePreimageKeyValueStorage preimageStorage =
new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage());
final MutableWorldState worldState =
new DefaultMutableWorldState(stateStorage, preimageStorage, EvmConfiguration.DEFAULT);
new ForestMutableWorldState(stateStorage, preimageStorage, EvmConfiguration.DEFAULT);
writeAccountsTo(worldState, genesisAccounts, null);
return worldState.rootHash();
}

@ -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();

@ -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));
}

@ -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;

@ -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;

@ -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;

@ -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<NodesAddedListener> nodeAddedListeners = Subscribers.create();
private final KeyValueStorage keyValueStorage;
private final ReentrantLock lock = new ReentrantLock();
public WorldStateKeyValueStorage(final KeyValueStorage keyValueStorage) {
public ForestWorldStateKeyValueStorage(final KeyValueStorage keyValueStorage) {
this.keyValueStorage = keyValueStorage;
}

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

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

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

@ -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

@ -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));
}
}

@ -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);

@ -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

@ -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<Bytes, Optional<byte[]>> 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);

@ -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;

@ -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());
}
}

@ -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);

@ -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;

@ -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;

@ -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;

@ -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(

@ -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<NodeDataRequest> 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<NodeDataRequest> 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<NodeDataRequest> taskCollection =
new InMemoryTasksPriorityQueues<>();
final WorldStateStorage localStorage =
new WorldStateKeyValueStorage(new InMemoryKeyValueStorage());
new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage());
// Seed local storage with some contract values
final Map<Bytes32, Bytes> 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<NodeDataRequest> 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<NodeDataRequest> taskCollection =
new InMemoryTasksPriorityQueues<>();
final WorldStateStorage localStorage =
new WorldStateKeyValueStorage(new InMemoryKeyValueStorage());
new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage());
// Seed local storage with some trie node values
final Map<Bytes32, Bytes> 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<NodeDataRequest> taskCollection =
new InMemoryTasksPriorityQueues<>();
final WorldStateStorage localStorage =
new WorldStateKeyValueStorage(new InMemoryKeyValueStorage());
new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage());
// Seed local storage with some trie node values
final List<Bytes32> 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<NodeDataRequest> 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<NodeDataRequest> 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()

@ -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<Bytes, Bytes> 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<Bytes, Bytes> accountStateTrie =
TrieGenerator.generateTrie(worldStateStorage, 15);

@ -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(

@ -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<Bytes, Bytes> 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<Bytes, Bytes> accountStateTrie =
TrieGenerator.generateTrie(worldStateStorage, nbAccounts);

@ -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<Bytes, Bytes> 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<Bytes, Bytes> accountStateTrie =
TrieGenerator.generateTrie(worldStateStorage, 15);

@ -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 =

@ -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

@ -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);
}

@ -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();

Loading…
Cancel
Save