From dcb6f27078cb37ac9ff839cc41a3ad023915ab19 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Wed, 10 Jan 2024 12:44:18 +0100 Subject: [PATCH] Make transaction pool configurable in acceptance tests (#33) Signed-off-by: Fabio Di Fabio --- .../besu/tests/acceptance/dsl/node/BesuNode.java | 13 +++++++++++++ .../acceptance/dsl/node/ProcessBesuNodeRunner.java | 14 +++++++++++--- .../acceptance/dsl/node/ThreadBesuNodeRunner.java | 1 + .../node/configuration/BesuNodeConfiguration.java | 8 ++++++++ .../BesuNodeConfigurationBuilder.java | 11 ++++++++++- .../dsl/node/configuration/BesuNodeFactory.java | 1 + .../tests/acceptance/dsl/privacy/PrivacyNode.java | 1 + 7 files changed, 45 insertions(+), 4 deletions(-) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java index 60e0c601f5a..ba00ac8f22f 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java @@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; +import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; @@ -100,6 +101,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable private final String name; private MiningParameters miningParameters; + private TransactionPoolConfiguration txPoolConfiguration; private final List runCommand; private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT; private final JsonRpcConfiguration jsonRpcConfiguration; @@ -135,6 +137,7 @@ public BesuNode( final String name, final Optional dataPath, final MiningParameters miningParameters, + final TransactionPoolConfiguration txPoolConfiguration, final JsonRpcConfiguration jsonRpcConfiguration, final Optional engineRpcConfiguration, final WebSocketConfiguration webSocketConfiguration, @@ -184,6 +187,7 @@ public BesuNode( () -> this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory)); this.name = name; this.miningParameters = miningParameters; + this.txPoolConfiguration = txPoolConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration; this.webSocketConfiguration = webSocketConfiguration; @@ -669,6 +673,15 @@ public void setMiningParameters(final MiningParameters miningParameters) { this.miningParameters = miningParameters; } + public TransactionPoolConfiguration getTransactionPoolConfiguration() { + return txPoolConfiguration; + } + + public void setTransactionPoolConfiguration( + final TransactionPoolConfiguration txPoolConfiguration) { + this.txPoolConfiguration = txPoolConfiguration; + } + public PrivacyParameters getPrivacyParameters() { return privacyParameters; } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java index f01c58549bc..538cb89e126 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java @@ -17,8 +17,10 @@ import static com.google.common.base.Preconditions.checkState; import static java.nio.charset.StandardCharsets.UTF_8; +import org.hyperledger.besu.cli.options.TransactionPoolOptions; import org.hyperledger.besu.cli.options.unstable.NetworkingOptions; import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration; +import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; @@ -98,6 +100,15 @@ public void startNode(final BesuNode node) { params.add("--p2p-port"); params.add(node.getP2pPort()); + params.addAll( + TransactionPoolOptions.fromConfig( + ImmutableTransactionPoolConfiguration.builder() + .from(node.getTransactionPoolConfiguration()) + .strictTransactionReplayProtectionEnabled( + node.isStrictTxReplayProtectionEnabled()) + .build()) + .getCLIOptions()); + if (node.getMiningParameters().isMiningEnabled()) { params.add("--miner-enabled"); params.add("--miner-coinbase"); @@ -391,9 +402,6 @@ public void startNode(final BesuNode node) { params.add("--auto-log-bloom-caching-enabled"); params.add("false"); - params.add("--strict-tx-replay-protection-enabled"); - params.add(Boolean.toString(node.isStrictTxReplayProtectionEnabled())); - final String level = System.getProperty("root.log.level"); if (level != null) { params.add("--logging=" + level); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java index 501674ea383..429c91d2b99 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java @@ -182,6 +182,7 @@ public void startNode(final BesuNode node) { final TransactionPoolConfiguration txPoolConfig = ImmutableTransactionPoolConfiguration.builder() + .from(node.getTransactionPoolConfiguration()) .strictTransactionReplayProtectionEnabled(node.isStrictTxReplayProtectionEnabled()) .build(); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java index 3a61749881a..0c0d66be6a8 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java @@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; +import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; @@ -39,6 +40,7 @@ public class BesuNodeConfiguration { private final String name; private final Optional dataPath; private final MiningParameters miningParameters; + private final TransactionPoolConfiguration transactionPoolConfiguration; private final JsonRpcConfiguration jsonRpcConfiguration; private final Optional engineRpcConfiguration; private final WebSocketConfiguration webSocketConfiguration; @@ -74,6 +76,7 @@ public class BesuNodeConfiguration { final String name, final Optional dataPath, final MiningParameters miningParameters, + final TransactionPoolConfiguration transactionPoolConfiguration, final JsonRpcConfiguration jsonRpcConfiguration, final Optional engineRpcConfiguration, final WebSocketConfiguration webSocketConfiguration, @@ -106,6 +109,7 @@ public class BesuNodeConfiguration { final Map environment) { this.name = name; this.miningParameters = miningParameters; + this.transactionPoolConfiguration = transactionPoolConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration; this.webSocketConfiguration = webSocketConfiguration; @@ -147,6 +151,10 @@ public MiningParameters getMiningParameters() { return miningParameters; } + public TransactionPoolConfiguration getTransactionPoolConfiguration() { + return transactionPoolConfiguration; + } + public JsonRpcConfiguration getJsonRpcConfiguration() { return jsonRpcConfiguration; } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java index 2a7f16d24fd..c20e7ec6d11 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java @@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; +import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; @@ -63,7 +64,8 @@ public class BesuNodeConfigurationBuilder { .mutableInitValues( MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build()) .build(); - + private TransactionPoolConfiguration transactionPoolConfiguration = + TransactionPoolConfiguration.DEFAULT; private JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); private JsonRpcConfiguration engineRpcConfiguration = JsonRpcConfiguration.createEngineDefault(); private WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault(); @@ -128,6 +130,12 @@ public BesuNodeConfigurationBuilder miningConfiguration(final MiningParameters m return this; } + public BesuNodeConfigurationBuilder transactionPoolConfiguration( + final TransactionPoolConfiguration transactionPoolConfiguration) { + this.transactionPoolConfiguration = transactionPoolConfiguration; + return this; + } + public BesuNodeConfigurationBuilder jsonRpcConfiguration( final JsonRpcConfiguration jsonRpcConfiguration) { this.jsonRpcConfiguration = jsonRpcConfiguration; @@ -503,6 +511,7 @@ public BesuNodeConfiguration build() { name, dataPath, miningParameters, + transactionPoolConfiguration, jsonRpcConfiguration, Optional.of(engineRpcConfiguration), webSocketConfiguration, diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java index 4b24071ab33..ed26587812c 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java @@ -64,6 +64,7 @@ public BesuNode create(final BesuNodeConfiguration config) throws IOException { config.getName(), config.getDataPath(), config.getMiningParameters(), + config.getTransactionPoolConfiguration(), config.getJsonRpcConfiguration(), config.getEngineRpcConfiguration(), config.getWebSocketConfiguration(), diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java index 3d397e24e27..4ec4396d6b5 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java @@ -100,6 +100,7 @@ public PrivacyNode( besuConfig.getName(), besuConfig.getDataPath(), besuConfig.getMiningParameters(), + besuConfig.getTransactionPoolConfiguration(), besuConfig.getJsonRpcConfiguration(), besuConfig.getEngineRpcConfiguration(), besuConfig.getWebSocketConfiguration(),