Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINOR] Remove a BonsaiWorldStateProvider constructor #6090

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.worldstate.WorldState;
Expand Down Expand Up @@ -68,22 +66,6 @@ public class BonsaiWorldStateProvider implements WorldStateArchive {
private final BonsaiWorldStateKeyValueStorage worldStateStorage;
private final CachedMerkleTrieLoader cachedMerkleTrieLoader;

public BonsaiWorldStateProvider(
final StorageProvider provider,
final Blockchain blockchain,
final CachedMerkleTrieLoader cachedMerkleTrieLoader,
final ObservableMetricsSystem metricsSystem,
final BesuContext pluginContext) {
this(
(BonsaiWorldStateKeyValueStorage)
provider.createWorldStateStorage(DataStorageFormat.BONSAI),
blockchain,
Optional.empty(),
cachedMerkleTrieLoader,
metricsSystem,
pluginContext);
}

public BonsaiWorldStateProvider(
final BonsaiWorldStateKeyValueStorage worldStateStorage,
final Blockchain blockchain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.DefaultBlockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
Expand All @@ -35,6 +36,8 @@
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
import org.hyperledger.besu.services.kvstore.SegmentedInMemoryKeyValueStorage;

import java.util.Optional;

public class InMemoryKeyValueStorageProvider extends KeyValueStorageProvider {

public InMemoryKeyValueStorageProvider() {
Expand Down Expand Up @@ -86,8 +89,10 @@ public static BonsaiWorldStateProvider createBonsaiInMemoryWorldStateArchive(
final CachedMerkleTrieLoader cachedMerkleTrieLoader =
new CachedMerkleTrieLoader(new NoOpMetricsSystem());
return new BonsaiWorldStateProvider(
inMemoryKeyValueStorageProvider,
(BonsaiWorldStateKeyValueStorage)
inMemoryKeyValueStorageProvider.createWorldStateStorage(DataStorageFormat.BONSAI),
blockchain,
Optional.empty(),
cachedMerkleTrieLoader,
new NoOpMetricsSystem(),
null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
Expand Down Expand Up @@ -82,14 +81,10 @@ public class BlockImportExceptionHandlingTest {
private final WorldStateStorage worldStateStorage =
new BonsaiWorldStateKeyValueStorage(storageProvider, new NoOpMetricsSystem());

private CachedMerkleTrieLoader cachedMerkleTrieLoader;

private final WorldStateArchive worldStateArchive =
// contains a BonsaiWorldState which we need to spy on.
// do we need to also test with a DefaultWorldStateArchive?
spy(
new BonsaiWorldStateProvider(
storageProvider, blockchain, cachedMerkleTrieLoader, new NoOpMetricsSystem(), null));
spy(InMemoryKeyValueStorageProvider.createBonsaiInMemoryWorldStateArchive(blockchain));

private final BonsaiWorldState persisted =
spy(
Expand All @@ -109,7 +104,6 @@ public void setup() {
mainnetBlockValidator =
new MainnetBlockValidator(
blockHeaderValidator, blockBodyValidator, blockProcessor, badBlockManager);
cachedMerkleTrieLoader = new CachedMerkleTrieLoader(new NoOpMetricsSystem());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogFactoryImpl;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogLayer;
Expand Down Expand Up @@ -128,11 +127,7 @@ class LogRollingTests {
@BeforeEach
void createStorage() {
provider = new InMemoryKeyValueStorageProvider();
final CachedMerkleTrieLoader cachedMerkleTrieLoader =
new CachedMerkleTrieLoader(new NoOpMetricsSystem());
archive =
new BonsaiWorldStateProvider(
provider, blockchain, cachedMerkleTrieLoader, new NoOpMetricsSystem(), null);
archive = InMemoryKeyValueStorageProvider.createBonsaiInMemoryWorldStateArchive(blockchain);
accountStorage =
provider.getStorageBySegmentIdentifier(KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE);
codeStorage = provider.getStorageBySegmentIdentifier(KeyValueSegmentIdentifier.CODE_STORAGE);
Expand All @@ -144,15 +139,8 @@ void createStorage() {
provider.getStorageBySegmentIdentifier(KeyValueSegmentIdentifier.TRIE_LOG_STORAGE);

secondProvider = new InMemoryKeyValueStorageProvider();
final CachedMerkleTrieLoader secondOptimizedMerkleTrieLoader =
new CachedMerkleTrieLoader(new NoOpMetricsSystem());
secondArchive =
new BonsaiWorldStateProvider(
secondProvider,
blockchain,
secondOptimizedMerkleTrieLoader,
new NoOpMetricsSystem(),
null);
InMemoryKeyValueStorageProvider.createBonsaiInMemoryWorldStateArchive(blockchain);
secondAccountStorage =
secondProvider.getStorageBySegmentIdentifier(KeyValueSegmentIdentifier.ACCOUNT_INFO_STATE);
secondCodeStorage =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.CODE_STORAGE;
import static org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier.TRIE_BRANCH_STORAGE;

import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogFactoryImpl;
import org.hyperledger.besu.ethereum.bonsai.trielog.TrieLogLayer;
Expand Down Expand Up @@ -51,11 +50,8 @@ public static void main(final String[] arg) throws IOException {
new RollingFileReader((i, c) -> Path.of(String.format(arg[0] + "-%04d.rdat", i)), false);

final InMemoryKeyValueStorageProvider provider = new InMemoryKeyValueStorageProvider();
final CachedMerkleTrieLoader cachedMerkleTrieLoader =
new CachedMerkleTrieLoader(new NoOpMetricsSystem());
final BonsaiWorldStateProvider archive =
new BonsaiWorldStateProvider(
provider, null, cachedMerkleTrieLoader, new NoOpMetricsSystem(), null);
InMemoryKeyValueStorageProvider.createBonsaiInMemoryWorldStateArchive(null);
final BonsaiWorldState bonsaiState =
new BonsaiWorldState(
archive, new BonsaiWorldStateKeyValueStorage(provider, new NoOpMetricsSystem()));
Expand Down
Loading