Skip to content

Commit

Permalink
BFT soak test - use both db modes (hyperledger#7496)
Browse files Browse the repository at this point in the history
* For test node runners use provided data storage config

Signed-off-by: Matthew Whitehead <[email protected]>

* Make the BFT soak mining tests use both Forest and Bonsai DBs

Signed-off-by: Matthew Whitehead <[email protected]>

---------

Signed-off-by: Matthew Whitehead <[email protected]>
  • Loading branch information
matthew1001 authored Aug 21, 2024
1 parent d7656b9 commit 0ec335f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.pki.keystore.KeyStoreWrapper;
import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.node.RunnableNode;
Expand Down Expand Up @@ -476,21 +478,28 @@ public BesuNode createIbft2Node(final String name, final String genesisFile) thr
.build());
}

public BesuNode createIbft2Node(final String name, final boolean fixedPort) throws IOException {
public BesuNode createIbft2Node(
final String name, final boolean fixedPort, final DataStorageFormat storageFormat)
throws IOException {
JsonRpcConfiguration rpcConfig = node.createJsonRpcWithIbft2EnabledConfig(false);
rpcConfig.addRpcApi("ADMIN,TXPOOL");
if (fixedPort) {
rpcConfig.setPort(
Math.abs(name.hashCode() % 60000)
+ 1024); // Generate a consistent port for p2p based on node name
}

BesuNodeConfigurationBuilder builder =
new BesuNodeConfigurationBuilder()
.name(name)
.miningEnabled()
.jsonRpcConfiguration(rpcConfig)
.webSocketConfiguration(node.createWebSocketEnabledConfig())
.devMode(false)
.dataStorageConfiguration(
storageFormat == DataStorageFormat.FOREST
? DataStorageConfiguration.DEFAULT_FOREST_CONFIG
: DataStorageConfiguration.DEFAULT_BONSAI_CONFIG)
.genesisConfigProvider(GenesisConfigurationFactory::createIbft2GenesisConfig);
if (fixedPort) {
builder.p2pPort(
Expand Down Expand Up @@ -527,7 +536,9 @@ public BesuNode createQbftNodeWithTLSPKCS11(final String name) throws IOExceptio
return createQbftNodeWithTLS(name, KeyStoreWrapper.KEYSTORE_TYPE_PKCS11);
}

public BesuNode createQbftNode(final String name, final boolean fixedPort) throws IOException {
public BesuNode createQbftNode(
final String name, final boolean fixedPort, final DataStorageFormat storageFormat)
throws IOException {
JsonRpcConfiguration rpcConfig = node.createJsonRpcWithQbftEnabledConfig(false);
rpcConfig.addRpcApi("ADMIN,TXPOOL");
if (fixedPort) {
Expand All @@ -543,6 +554,10 @@ public BesuNode createQbftNode(final String name, final boolean fixedPort) throw
.jsonRpcConfiguration(rpcConfig)
.webSocketConfiguration(node.createWebSocketEnabledConfig())
.devMode(false)
.dataStorageConfiguration(
storageFormat == DataStorageFormat.FOREST
? DataStorageConfiguration.DEFAULT_FOREST_CONFIG
: DataStorageConfiguration.DEFAULT_BONSAI_CONFIG)
.genesisConfigProvider(GenesisConfigurationFactory::createQbftGenesisConfig);
if (fixedPort) {
builder.p2pPort(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.tests.acceptance.bft;

import org.hyperledger.besu.plugin.services.storage.DataStorageFormat;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeFactory;

Expand All @@ -38,7 +39,9 @@ public static Stream<Arguments> getFactories() {
@FunctionalInterface
public interface NodeCreator {

BesuNode create(BesuNodeFactory factory, String name, boolean fixedPort) throws Exception;
BesuNode create(
BesuNodeFactory factory, String name, boolean fixedPort, DataStorageFormat storageFormat)
throws Exception;
}

@FunctionalInterface
Expand All @@ -64,11 +67,15 @@ public BftAcceptanceTestParameterization(
}

public BesuNode createNode(BesuNodeFactory factory, String name) throws Exception {
return creatorFn.create(factory, name, false);
return creatorFn.create(factory, name, false, DataStorageFormat.FOREST);
}

public BesuNode createBonsaiNodeFixedPort(BesuNodeFactory factory, String name) throws Exception {
return creatorFn.create(factory, name, true, DataStorageFormat.BONSAI);
}

public BesuNode createNodeFixedPort(BesuNodeFactory factory, String name) throws Exception {
return creatorFn.create(factory, name, true);
public BesuNode createForestNodeFixedPort(BesuNodeFactory factory, String name) throws Exception {
return creatorFn.create(factory, name, true, DataStorageFormat.FOREST);
}

public BesuNode createNodeWithValidators(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ public void shouldBeStableDuringLongTest(
// in between certain steps. There should be no upper-limit to how long the test is run for
assertThat(getTestDurationMins()).isGreaterThanOrEqualTo(MIN_TEST_TIME_MINS);

final BesuNode minerNode1 = nodeFactory.createNodeFixedPort(besu, "miner1");
final BesuNode minerNode2 = nodeFactory.createNodeFixedPort(besu, "miner2");
final BesuNode minerNode3 = nodeFactory.createNodeFixedPort(besu, "miner3");
final BesuNode minerNode4 = nodeFactory.createNodeFixedPort(besu, "miner4");
// Create a mix of Bonsai and Forest DB nodes
final BesuNode minerNode1 = nodeFactory.createBonsaiNodeFixedPort(besu, "miner1");
final BesuNode minerNode2 = nodeFactory.createForestNodeFixedPort(besu, "miner2");
final BesuNode minerNode3 = nodeFactory.createBonsaiNodeFixedPort(besu, "miner3");
final BesuNode minerNode4 = nodeFactory.createForestNodeFixedPort(besu, "miner4");

// Each step should be given a minimum of 3 minutes to complete successfully. If the time
// give to run the soak test results in a time-per-step lower than this then the time
Expand Down

0 comments on commit 0ec335f

Please sign in to comment.