Skip to content

Commit

Permalink
Add integration tests on block processing (#7378)
Browse files Browse the repository at this point in the history
Add a block processing integration test to verify that sequential and parallel execution have the same behaviour

Signed-off-by: Ameziane H <[email protected]>
Co-authored-by: Simon Dudley <[email protected]>
  • Loading branch information
ahamlat and siladu authored Aug 1, 2024
1 parent b727c95 commit 9cb8b06
Show file tree
Hide file tree
Showing 4 changed files with 918 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.core;

import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createBonsaiInMemoryWorldStateArchive;
import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive;

import org.hyperledger.besu.config.GenesisConfigFile;
Expand All @@ -31,10 +32,12 @@
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;

import java.math.BigInteger;
import java.util.Optional;
import java.util.function.Function;

public class ExecutionContextTestFixture {
Expand All @@ -52,7 +55,8 @@ private ExecutionContextTestFixture(
final GenesisConfigFile genesisConfigFile,
final ProtocolSchedule protocolSchedule,
final KeyValueStorage blockchainKeyValueStorage,
final KeyValueStorage variablesKeyValueStorage) {
final KeyValueStorage variablesKeyValueStorage,
final Optional<DataStorageFormat> dataStorageFormat) {
final GenesisState genesisState = GenesisState.fromConfig(genesisConfigFile, protocolSchedule);
this.genesis = genesisState.getBlock();
this.blockchainKeyValueStorage = blockchainKeyValueStorage;
Expand All @@ -67,7 +71,9 @@ private ExecutionContextTestFixture(
false),
new NoOpMetricsSystem(),
0);
this.stateArchive = createInMemoryWorldStateArchive();
if (dataStorageFormat.isPresent() && dataStorageFormat.get().equals(DataStorageFormat.BONSAI))
this.stateArchive = createBonsaiInMemoryWorldStateArchive(blockchain);
else this.stateArchive = createInMemoryWorldStateArchive();
this.protocolSchedule = protocolSchedule;
this.protocolContext =
new ProtocolContext(blockchain, stateArchive, null, new BadBlockManager());
Expand Down Expand Up @@ -115,6 +121,7 @@ public static class Builder {
private KeyValueStorage variablesKeyValueStorage;
private KeyValueStorage blockchainKeyValueStorage;
private ProtocolSchedule protocolSchedule;
private Optional<DataStorageFormat> dataStorageFormat = Optional.empty();

public Builder(final GenesisConfigFile genesisConfigFile) {
this.genesisConfigFile = genesisConfigFile;
Expand All @@ -135,6 +142,11 @@ public Builder protocolSchedule(final ProtocolSchedule protocolSchedule) {
return this;
}

public Builder dataStorageFormat(final DataStorageFormat dataStorageFormat) {
this.dataStorageFormat = Optional.of(dataStorageFormat);
return this;
}

public ExecutionContextTestFixture build() {
if (protocolSchedule == null) {
protocolSchedule =
Expand All @@ -157,8 +169,13 @@ public ExecutionContextTestFixture build() {
if (variablesKeyValueStorage == null) {
variablesKeyValueStorage = new InMemoryKeyValueStorage();
}

return new ExecutionContextTestFixture(
genesisConfigFile, protocolSchedule, variablesKeyValueStorage, blockchainKeyValueStorage);
genesisConfigFile,
protocolSchedule,
variablesKeyValueStorage,
blockchainKeyValueStorage,
dataStorageFormat);
}
}
}
Loading

0 comments on commit 9cb8b06

Please sign in to comment.