mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 23:47:57 -05:00
[PAN-2797] Refactor experimental CLI options (#1629)
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
This commit is contained in:
@@ -20,7 +20,7 @@ import tech.pegasys.pantheon.cli.config.EthNetworkConfig;
|
||||
import tech.pegasys.pantheon.controller.KeyPairUtil;
|
||||
import tech.pegasys.pantheon.controller.PantheonController;
|
||||
import tech.pegasys.pantheon.controller.PantheonControllerBuilder;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.graphql.GraphQLConfiguration;
|
||||
@@ -115,8 +115,8 @@ public class ThreadPantheonNodeRunner implements PantheonNodeRunner {
|
||||
.nodePrivateKeyFile(KeyPairUtil.getDefaultKeyFile(node.homeDirectory()))
|
||||
.metricsSystem(noOpMetricsSystem)
|
||||
.transactionPoolConfiguration(TransactionPoolConfiguration.builder().build())
|
||||
.rocksDbConfiguration(new RocksDbConfiguration.Builder().databaseDir(tempDir).build())
|
||||
.ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig())
|
||||
.rocksDbConfiguration(RocksDbConfiguration.builder().databaseDir(tempDir).build())
|
||||
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.clock(Clock.systemUTC())
|
||||
.build();
|
||||
} catch (final IOException e) {
|
||||
|
||||
@@ -42,6 +42,7 @@ import tech.pegasys.pantheon.ethereum.core.BlockHeaderTestFixture;
|
||||
import tech.pegasys.pantheon.ethereum.core.Util;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule;
|
||||
import tech.pegasys.pantheon.ethereum.worldstate.WorldStateArchive;
|
||||
import tech.pegasys.pantheon.metrics.MetricsSystem;
|
||||
@@ -114,7 +115,7 @@ public class CliqueBlockCreatorTest {
|
||||
coinbase,
|
||||
parent -> extraData,
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
5,
|
||||
TestClock.fixed(),
|
||||
metricsSystem),
|
||||
@@ -145,7 +146,7 @@ public class CliqueBlockCreatorTest {
|
||||
coinbase,
|
||||
parent -> extraData,
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
5,
|
||||
TestClock.fixed(),
|
||||
metricsSystem),
|
||||
@@ -175,7 +176,7 @@ public class CliqueBlockCreatorTest {
|
||||
coinbase,
|
||||
parent -> extraData,
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
5,
|
||||
TestClock.fixed(),
|
||||
metricsSystem),
|
||||
@@ -208,7 +209,7 @@ public class CliqueBlockCreatorTest {
|
||||
coinbase,
|
||||
parent -> extraData,
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
5,
|
||||
TestClock.fixed(),
|
||||
metricsSystem),
|
||||
|
||||
@@ -37,6 +37,7 @@ import tech.pegasys.pantheon.ethereum.core.MiningParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.Util;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.metrics.MetricsSystem;
|
||||
import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem;
|
||||
import tech.pegasys.pantheon.testutil.TestClock;
|
||||
@@ -91,7 +92,7 @@ public class CliqueMinerExecutorTest {
|
||||
Executors.newSingleThreadExecutor(),
|
||||
CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerKeyPair),
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
metricsSystem),
|
||||
@@ -128,7 +129,7 @@ public class CliqueMinerExecutorTest {
|
||||
Executors.newSingleThreadExecutor(),
|
||||
CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerKeyPair),
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
metricsSystem),
|
||||
@@ -165,7 +166,7 @@ public class CliqueMinerExecutorTest {
|
||||
Executors.newSingleThreadExecutor(),
|
||||
CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerKeyPair),
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
metricsSystem),
|
||||
|
||||
@@ -62,6 +62,7 @@ import tech.pegasys.pantheon.ethereum.core.MiningParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.Util;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule;
|
||||
import tech.pegasys.pantheon.ethereum.worldstate.WorldStateArchive;
|
||||
import tech.pegasys.pantheon.metrics.MetricsSystem;
|
||||
@@ -285,7 +286,7 @@ public class TestContextBuilder {
|
||||
|
||||
final PendingTransactions pendingTransactions =
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 1, clock, metricsSystem);
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS, 1, clock, metricsSystem);
|
||||
|
||||
final IbftBlockCreatorFactory blockCreatorFactory =
|
||||
new IbftBlockCreatorFactory(
|
||||
|
||||
@@ -34,6 +34,7 @@ import tech.pegasys.pantheon.ethereum.core.BlockHeader;
|
||||
import tech.pegasys.pantheon.ethereum.core.BlockHeaderTestFixture;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.BlockHeaderValidator;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.HeaderValidationMode;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule;
|
||||
@@ -83,7 +84,10 @@ public class IbftBlockCreatorTest {
|
||||
|
||||
final PendingTransactions pendingTransactions =
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 1, TestClock.fixed(), metricsSystem);
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
metricsSystem);
|
||||
|
||||
final IbftBlockCreator blockCreator =
|
||||
new IbftBlockCreator(
|
||||
|
||||
@@ -15,7 +15,7 @@ package tech.pegasys.pantheon.consensus.ibftlegacy.protocol;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
import tech.pegasys.pantheon.ethereum.chain.Blockchain;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.manager.EthProtocolManager;
|
||||
import tech.pegasys.pantheon.ethereum.p2p.rlpx.wire.Capability;
|
||||
import tech.pegasys.pantheon.ethereum.worldstate.WorldStateArchive;
|
||||
@@ -37,7 +37,7 @@ public class Istanbul64ProtocolManager extends EthProtocolManager {
|
||||
final int computationWorkers,
|
||||
final Clock clock,
|
||||
final MetricsSystem metricsSystem,
|
||||
final EthereumWireProtocolConfiguration ethereumWireProtocolConfiguration) {
|
||||
final EthProtocolConfiguration ethereumWireProtocolConfiguration) {
|
||||
super(
|
||||
blockchain,
|
||||
worldStateArchive,
|
||||
|
||||
@@ -34,6 +34,7 @@ import tech.pegasys.pantheon.ethereum.core.BlockHeaderTestFixture;
|
||||
import tech.pegasys.pantheon.ethereum.core.Hash;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.BlockHeaderValidator;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.HeaderValidationMode;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule;
|
||||
@@ -98,7 +99,7 @@ public class IbftBlockCreatorTest {
|
||||
initialValidatorList)
|
||||
.encode(),
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
metricsSystem),
|
||||
|
||||
@@ -37,6 +37,7 @@ import tech.pegasys.pantheon.ethereum.core.WorldState;
|
||||
import tech.pegasys.pantheon.ethereum.core.WorldUpdater;
|
||||
import tech.pegasys.pantheon.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.MainnetTransactionProcessor;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.MainnetTransactionProcessor.Result;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule;
|
||||
@@ -68,7 +69,10 @@ public class BlockTransactionSelectorTest {
|
||||
|
||||
private final PendingTransactions pendingTransactions =
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 5, TestClock.fixed(), metricsSystem);
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
5,
|
||||
TestClock.fixed(),
|
||||
metricsSystem);
|
||||
private final Blockchain blockchain = new TestBlockchain();
|
||||
private final DefaultMutableWorldState worldState = inMemoryWorldState();
|
||||
private final Supplier<Boolean> isCancelled = () -> false;
|
||||
|
||||
@@ -19,6 +19,7 @@ import tech.pegasys.pantheon.ethereum.core.ExecutionContextTestFixture;
|
||||
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.EthHashSolver;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.EthHasher.Light;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolScheduleBuilder;
|
||||
@@ -66,7 +67,10 @@ public class EthHashBlockCreatorTest {
|
||||
|
||||
final PendingTransactions pendingTransactions =
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 1, TestClock.fixed(), metricsSystem);
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
metricsSystem);
|
||||
|
||||
final EthHashBlockCreator blockCreator =
|
||||
new EthHashBlockCreator(
|
||||
|
||||
@@ -17,6 +17,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import tech.pegasys.pantheon.ethereum.core.MiningParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.MiningParametersTestBuilder;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.metrics.MetricsSystem;
|
||||
import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem;
|
||||
import tech.pegasys.pantheon.testutil.TestClock;
|
||||
@@ -36,7 +37,10 @@ public class EthHashMinerExecutorTest {
|
||||
|
||||
final PendingTransactions pendingTransactions =
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 1, TestClock.fixed(), metricsSystem);
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
metricsSystem);
|
||||
|
||||
final EthHashMinerExecutor executor =
|
||||
new EthHashMinerExecutor(
|
||||
@@ -58,7 +62,10 @@ public class EthHashMinerExecutorTest {
|
||||
|
||||
final PendingTransactions pendingTransactions =
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 1, TestClock.fixed(), metricsSystem);
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
metricsSystem);
|
||||
|
||||
final EthHashMinerExecutor executor =
|
||||
new EthHashMinerExecutor(
|
||||
|
||||
@@ -53,7 +53,7 @@ public class OperationBenchmarkHelper {
|
||||
final Path storageDirectory = Files.createTempDirectory("benchmark");
|
||||
final KeyValueStorage keyValueStorage =
|
||||
RocksDbKeyValueStorage.create(
|
||||
new RocksDbConfiguration.Builder().databaseDir(storageDirectory).build(),
|
||||
RocksDbConfiguration.builder().databaseDir(storageDirectory).build(),
|
||||
new NoOpMetricsSystem());
|
||||
|
||||
final ExecutionContextTestFixture executionContext =
|
||||
|
||||
@@ -176,7 +176,7 @@ public class PrivacyParameters {
|
||||
Path privateDbPath = dataDir.resolve(PRIVATE_DATABASE_PATH);
|
||||
StorageProvider privateStorageProvider =
|
||||
RocksDbStorageProvider.create(
|
||||
new RocksDbConfiguration.Builder()
|
||||
RocksDbConfiguration.builder()
|
||||
.databaseDir(privateDbPath)
|
||||
.label("private_state")
|
||||
.build(),
|
||||
|
||||
@@ -36,7 +36,6 @@ dependencies {
|
||||
implementation project(':services:pipeline')
|
||||
implementation project(':services:tasks')
|
||||
|
||||
implementation 'info.picocli:picocli'
|
||||
implementation 'io.vertx:vertx-core'
|
||||
implementation 'com.google.guava:guava'
|
||||
|
||||
|
||||
@@ -81,9 +81,9 @@ public class WorldStateDownloaderBenchmark {
|
||||
ethProtocolManager =
|
||||
EthProtocolManagerTestUtil.create(
|
||||
new EthScheduler(
|
||||
syncConfig.downloaderParallelism(),
|
||||
syncConfig.transactionsParallelism(),
|
||||
syncConfig.computationParallelism(),
|
||||
syncConfig.getDownloaderParallelism(),
|
||||
syncConfig.getTransactionsParallelism(),
|
||||
syncConfig.getComputationParallelism(),
|
||||
metricsSystem));
|
||||
|
||||
peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager, blockHeader.getNumber());
|
||||
@@ -91,7 +91,7 @@ public class WorldStateDownloaderBenchmark {
|
||||
final EthContext ethContext = ethProtocolManager.ethContext();
|
||||
storageProvider =
|
||||
RocksDbStorageProvider.create(
|
||||
new RocksDbConfiguration.Builder().databaseDir(tempDir.resolve("database")).build(),
|
||||
RocksDbConfiguration.builder().databaseDir(tempDir.resolve("database")).build(),
|
||||
metricsSystem);
|
||||
worldStateStorage = storageProvider.createWorldStateStorage();
|
||||
|
||||
|
||||
@@ -17,9 +17,8 @@ import tech.pegasys.pantheon.util.number.PositiveNumber;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import picocli.CommandLine;
|
||||
|
||||
public class EthereumWireProtocolConfiguration {
|
||||
public class EthProtocolConfiguration {
|
||||
|
||||
public static final int DEFAULT_MAX_GET_BLOCK_HEADERS = 192;
|
||||
public static final int DEFAULT_MAX_GET_BLOCK_BODIES = 128;
|
||||
@@ -31,7 +30,7 @@ public class EthereumWireProtocolConfiguration {
|
||||
private final int maxGetReceipts;
|
||||
private final int maxGetNodeData;
|
||||
|
||||
public EthereumWireProtocolConfiguration(
|
||||
public EthProtocolConfiguration(
|
||||
final int maxGetBlockHeaders,
|
||||
final int maxGetBlockBodies,
|
||||
final int maxGetReceipts,
|
||||
@@ -42,8 +41,8 @@ public class EthereumWireProtocolConfiguration {
|
||||
this.maxGetNodeData = maxGetNodeData;
|
||||
}
|
||||
|
||||
public static EthereumWireProtocolConfiguration defaultConfig() {
|
||||
return new EthereumWireProtocolConfiguration(
|
||||
public static EthProtocolConfiguration defaultConfig() {
|
||||
return new EthProtocolConfiguration(
|
||||
DEFAULT_MAX_GET_BLOCK_HEADERS,
|
||||
DEFAULT_MAX_GET_BLOCK_BODIES,
|
||||
DEFAULT_MAX_GET_RECEIPTS,
|
||||
@@ -78,7 +77,7 @@ public class EthereumWireProtocolConfiguration {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final EthereumWireProtocolConfiguration that = (EthereumWireProtocolConfiguration) o;
|
||||
final EthProtocolConfiguration that = (EthProtocolConfiguration) o;
|
||||
return maxGetBlockHeaders == that.maxGetBlockHeaders
|
||||
&& maxGetBlockBodies == that.maxGetBlockBodies
|
||||
&& maxGetReceipts == that.maxGetReceipts
|
||||
@@ -101,41 +100,17 @@ public class EthereumWireProtocolConfiguration {
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@CommandLine.Option(
|
||||
hidden = true,
|
||||
names = {"--Xewp-max-get-headers"},
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Maximum request limit for Ethereum Wire Protocol GET_BLOCK_HEADERS. (default: ${DEFAULT-VALUE})")
|
||||
private PositiveNumber maxGetBlockHeaders =
|
||||
PositiveNumber.fromInt(EthereumWireProtocolConfiguration.DEFAULT_MAX_GET_BLOCK_HEADERS);
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_BLOCK_HEADERS);
|
||||
|
||||
@CommandLine.Option(
|
||||
hidden = true,
|
||||
names = {"--Xewp-max-get-bodies"},
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Maximum request limit for Ethereum Wire Protocol GET_BLOCK_BODIES. (default: ${DEFAULT-VALUE})")
|
||||
private PositiveNumber maxGetBlockBodies =
|
||||
PositiveNumber.fromInt(EthereumWireProtocolConfiguration.DEFAULT_MAX_GET_BLOCK_BODIES);
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_BLOCK_BODIES);
|
||||
|
||||
@CommandLine.Option(
|
||||
hidden = true,
|
||||
names = {"--Xewp-max-get-receipts"},
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Maximum request limit for Ethereum Wire Protocol GET_RECEIPTS. (default: ${DEFAULT-VALUE})")
|
||||
private PositiveNumber maxGetReceipts =
|
||||
PositiveNumber.fromInt(EthereumWireProtocolConfiguration.DEFAULT_MAX_GET_RECEIPTS);
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_RECEIPTS);
|
||||
|
||||
@CommandLine.Option(
|
||||
hidden = true,
|
||||
names = {"--Xewp-max-get-node-data"},
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Maximum request limit for Ethereum Wire Protocol GET_NODE_DATA. (default: ${DEFAULT-VALUE})")
|
||||
private PositiveNumber maxGetNodeData =
|
||||
PositiveNumber.fromInt(EthereumWireProtocolConfiguration.DEFAULT_MAX_GET_NODE_DATA);
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_NODE_DATA);
|
||||
|
||||
public Builder maxGetBlockHeaders(final PositiveNumber maxGetBlockHeaders) {
|
||||
this.maxGetBlockHeaders = maxGetBlockHeaders;
|
||||
@@ -157,8 +132,8 @@ public class EthereumWireProtocolConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
public EthereumWireProtocolConfiguration build() {
|
||||
return new EthereumWireProtocolConfiguration(
|
||||
public EthProtocolConfiguration build() {
|
||||
return new EthProtocolConfiguration(
|
||||
maxGetBlockHeaders.getValue(),
|
||||
maxGetBlockBodies.getValue(),
|
||||
maxGetReceipts.getValue(),
|
||||
@@ -19,7 +19,7 @@ import tech.pegasys.pantheon.ethereum.chain.MinedBlockObserver;
|
||||
import tech.pegasys.pantheon.ethereum.core.Block;
|
||||
import tech.pegasys.pantheon.ethereum.core.Hash;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocol;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.messages.EthPV62;
|
||||
import tech.pegasys.pantheon.ethereum.eth.messages.StatusMessage;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.BlockBroadcaster;
|
||||
@@ -72,7 +72,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
|
||||
final int networkId,
|
||||
final boolean fastSyncEnabled,
|
||||
final EthScheduler scheduler,
|
||||
final EthereumWireProtocolConfiguration ethereumWireProtocolConfiguration,
|
||||
final EthProtocolConfiguration ethereumWireProtocolConfiguration,
|
||||
final Clock clock,
|
||||
final MetricsSystem metricsSystem) {
|
||||
this.networkId = networkId;
|
||||
@@ -109,7 +109,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
|
||||
networkId,
|
||||
fastSyncEnabled,
|
||||
new EthScheduler(syncWorkers, txWorkers, computationWorkers, metricsSystem),
|
||||
EthereumWireProtocolConfiguration.defaultConfig(),
|
||||
EthProtocolConfiguration.defaultConfig(),
|
||||
clock,
|
||||
metricsSystem);
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
|
||||
final int computationWorkers,
|
||||
final Clock clock,
|
||||
final MetricsSystem metricsSystem,
|
||||
final EthereumWireProtocolConfiguration ethereumWireProtocolConfiguration) {
|
||||
final EthProtocolConfiguration ethereumWireProtocolConfiguration) {
|
||||
this(
|
||||
blockchain,
|
||||
worldStateArchive,
|
||||
|
||||
@@ -17,7 +17,7 @@ import tech.pegasys.pantheon.ethereum.core.BlockBody;
|
||||
import tech.pegasys.pantheon.ethereum.core.BlockHeader;
|
||||
import tech.pegasys.pantheon.ethereum.core.Hash;
|
||||
import tech.pegasys.pantheon.ethereum.core.TransactionReceipt;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.messages.BlockBodiesMessage;
|
||||
import tech.pegasys.pantheon.ethereum.eth.messages.BlockHeadersMessage;
|
||||
import tech.pegasys.pantheon.ethereum.eth.messages.EthPV62;
|
||||
@@ -51,13 +51,13 @@ class EthServer {
|
||||
private final Blockchain blockchain;
|
||||
private final WorldStateArchive worldStateArchive;
|
||||
private final EthMessages ethMessages;
|
||||
private final EthereumWireProtocolConfiguration ethereumWireProtocolConfiguration;
|
||||
private final EthProtocolConfiguration ethereumWireProtocolConfiguration;
|
||||
|
||||
EthServer(
|
||||
final Blockchain blockchain,
|
||||
final WorldStateArchive worldStateArchive,
|
||||
final EthMessages ethMessages,
|
||||
final EthereumWireProtocolConfiguration ethereumWireProtocolConfiguration) {
|
||||
final EthProtocolConfiguration ethereumWireProtocolConfiguration) {
|
||||
this.blockchain = blockchain;
|
||||
this.worldStateArchive = worldStateArchive;
|
||||
this.ethMessages = ethMessages;
|
||||
|
||||
@@ -143,7 +143,7 @@ public class BlockPropagationManager<C> {
|
||||
|
||||
if (blockAddedEvent.getEventType().equals(EventType.HEAD_ADVANCED)) {
|
||||
final long head = blockchain.getChainHeadBlockNumber();
|
||||
final long cutoff = head + config.blockPropagationRange().lowerEndpoint();
|
||||
final long cutoff = head + config.getBlockPropagationRange().lowerEndpoint();
|
||||
pendingBlocks.purgeBlocksOlderThan(cutoff);
|
||||
}
|
||||
}
|
||||
@@ -350,7 +350,7 @@ public class BlockPropagationManager<C> {
|
||||
final long blockNumber, final long localHeight, final long bestChainHeight) {
|
||||
final long distanceFromLocalHead = blockNumber - localHeight;
|
||||
final long distanceFromBestPeer = blockNumber - bestChainHeight;
|
||||
final Range<Long> importRange = config.blockPropagationRange();
|
||||
final Range<Long> importRange = config.getBlockPropagationRange();
|
||||
return importRange.contains(distanceFromLocalHead)
|
||||
&& importRange.contains(distanceFromBestPeer);
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ public class CheckpointHeaderFetcher {
|
||||
|
||||
public CompletableFuture<List<BlockHeader>> getNextCheckpointHeaders(
|
||||
final EthPeer peer, final BlockHeader previousCheckpointHeader) {
|
||||
final int skip = syncConfig.downloaderChainSegmentSize() - 1;
|
||||
final int maximumHeaderRequestSize = syncConfig.downloaderHeaderRequestSize();
|
||||
final int skip = syncConfig.getDownloaderChainSegmentSize() - 1;
|
||||
final int maximumHeaderRequestSize = syncConfig.getDownloaderHeaderRequestSize();
|
||||
final long previousCheckpointNumber = previousCheckpointHeader.getNumber();
|
||||
|
||||
final int additionalHeaderCount;
|
||||
@@ -117,7 +117,7 @@ public class CheckpointHeaderFetcher {
|
||||
if (finalCheckpointHeader.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
final int skip = syncConfig.downloaderChainSegmentSize() - 1;
|
||||
final int skip = syncConfig.getDownloaderChainSegmentSize() - 1;
|
||||
final long peerEstimatedHeight = peer.chainState().getEstimatedHeight();
|
||||
final long previousCheckpointNumber = previousCheckpointHeader.getNumber();
|
||||
return previousCheckpointNumber + skip >= peerEstimatedHeight;
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class SyncTargetManager<C> {
|
||||
protocolContext,
|
||||
ethContext,
|
||||
bestPeer,
|
||||
config.downloaderHeaderRequestSize(),
|
||||
config.getDownloaderHeaderRequestSize(),
|
||||
metricsSystem)
|
||||
.run()
|
||||
.handle(
|
||||
|
||||
@@ -13,27 +13,34 @@
|
||||
package tech.pegasys.pantheon.ethereum.eth.sync;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import tech.pegasys.pantheon.util.uint.UInt256;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Range;
|
||||
import picocli.CommandLine;
|
||||
|
||||
public class SynchronizerConfiguration {
|
||||
|
||||
// TODO: Determine reasonable defaults here
|
||||
private static final int DEFAULT_PIVOT_DISTANCE_FROM_HEAD = 50;
|
||||
private static final float DEFAULT_FULL_VALIDATION_RATE = .1f;
|
||||
private static final int DEFAULT_FAST_SYNC_MINIMUM_PEERS = 5;
|
||||
private static final int DEFAULT_WORLD_STATE_HASH_COUNT_PER_REQUEST = 384;
|
||||
private static final int DEFAULT_WORLD_STATE_REQUEST_PARALLELISM = 10;
|
||||
private static final int DEFAULT_WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS = 1000;
|
||||
private static final long DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING =
|
||||
public static final int DEFAULT_PIVOT_DISTANCE_FROM_HEAD = 50;
|
||||
public static final float DEFAULT_FULL_VALIDATION_RATE = .1f;
|
||||
public static final int DEFAULT_FAST_SYNC_MINIMUM_PEERS = 5;
|
||||
public static final int DEFAULT_WORLD_STATE_HASH_COUNT_PER_REQUEST = 384;
|
||||
public static final int DEFAULT_WORLD_STATE_REQUEST_PARALLELISM = 10;
|
||||
public static final int DEFAULT_WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS = 1000;
|
||||
public static final long DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING =
|
||||
TimeUnit.MINUTES.toMillis(5);
|
||||
public static final Range<Long> DEFAULT_BLOCK_PROPAGATION_RANGE = Range.closed(-10L, 30L);
|
||||
public static final long DEFAULT_DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_HEIGHT = 200L;
|
||||
public static final UInt256 DEFAULT_DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_TD =
|
||||
UInt256.of(1_000_000_000_000_000_000L);
|
||||
public static final int DEFAULT_DOWNLOADER_HEADER_REQUEST_SIZE = 200;
|
||||
public static final int DEFAULT_DOWNLOADER_CHECKPOINT_TIMEOUTS_PERMITTED = 5;
|
||||
public static final int DEFAULT_DOWNLOADER_CHAIN_SEGMENT_SIZE = 200;
|
||||
public static final int DEFAULT_DOWNLOADER_PARALLELISM = 4;
|
||||
public static final int DEFAULT_TRANSACTIONS_PARALLELISM = 2;
|
||||
public static final int DEFAULT_COMPUTATION_PARALLELISM = 2;
|
||||
|
||||
// Fast sync config
|
||||
private final int fastSyncPivotDistance;
|
||||
@@ -109,7 +116,7 @@ public class SynchronizerConfiguration {
|
||||
*
|
||||
* @return the sync mode
|
||||
*/
|
||||
public SyncMode syncMode() {
|
||||
public SyncMode getSyncMode() {
|
||||
return syncMode;
|
||||
}
|
||||
|
||||
@@ -120,7 +127,7 @@ public class SynchronizerConfiguration {
|
||||
* @return the range of blocks considered valid to import from the network, relative to the the
|
||||
* current chain head.
|
||||
*/
|
||||
public Range<Long> blockPropagationRange() {
|
||||
public Range<Long> getBlockPropagationRange() {
|
||||
return blockPropagationRange;
|
||||
}
|
||||
|
||||
@@ -129,39 +136,39 @@ public class SynchronizerConfiguration {
|
||||
*
|
||||
* @return distance from the chain head at which we should switch from fast sync to full sync.
|
||||
*/
|
||||
public int fastSyncPivotDistance() {
|
||||
public int getFastSyncPivotDistance() {
|
||||
return fastSyncPivotDistance;
|
||||
}
|
||||
|
||||
public long downloaderChangeTargetThresholdByHeight() {
|
||||
public long getDownloaderChangeTargetThresholdByHeight() {
|
||||
return downloaderChangeTargetThresholdByHeight;
|
||||
}
|
||||
|
||||
public UInt256 downloaderChangeTargetThresholdByTd() {
|
||||
public UInt256 getDownloaderChangeTargetThresholdByTd() {
|
||||
return downloaderChangeTargetThresholdByTd;
|
||||
}
|
||||
|
||||
public int downloaderHeaderRequestSize() {
|
||||
public int getDownloaderHeaderRequestSize() {
|
||||
return downloaderHeaderRequestSize;
|
||||
}
|
||||
|
||||
public int downloaderCheckpointTimeoutsPermitted() {
|
||||
public int getDownloaderCheckpointTimeoutsPermitted() {
|
||||
return downloaderCheckpointTimeoutsPermitted;
|
||||
}
|
||||
|
||||
public int downloaderChainSegmentSize() {
|
||||
public int getDownloaderChainSegmentSize() {
|
||||
return downloaderChainSegmentSize;
|
||||
}
|
||||
|
||||
public int downloaderParallelism() {
|
||||
public int getDownloaderParallelism() {
|
||||
return downloaderParallelism;
|
||||
}
|
||||
|
||||
public int transactionsParallelism() {
|
||||
public int getTransactionsParallelism() {
|
||||
return transactionsParallelism;
|
||||
}
|
||||
|
||||
public int computationParallelism() {
|
||||
public int getComputationParallelism() {
|
||||
return computationParallelism;
|
||||
}
|
||||
|
||||
@@ -172,7 +179,7 @@ public class SynchronizerConfiguration {
|
||||
*
|
||||
* @return rate at which blocks should be fully validated during fast sync.
|
||||
*/
|
||||
public float fastSyncFullValidationRate() {
|
||||
public float getFastSyncFullValidationRate() {
|
||||
return fastSyncFullValidationRate;
|
||||
}
|
||||
|
||||
@@ -204,148 +211,24 @@ public class SynchronizerConfiguration {
|
||||
private SyncMode syncMode = SyncMode.FULL;
|
||||
private int fastSyncMinimumPeerCount = DEFAULT_FAST_SYNC_MINIMUM_PEERS;
|
||||
private int maxTrailingPeers = Integer.MAX_VALUE;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-block-propagation-range",
|
||||
hidden = true,
|
||||
defaultValue = "-10..30",
|
||||
paramLabel = "<LONG>..<LONG>",
|
||||
description =
|
||||
"Range around chain head where inbound blocks are propagated (default: ${DEFAULT-VALUE})")
|
||||
public void parseBlockPropagationRange(final String arg) {
|
||||
// Use a method instead of a registered converter because of generics.
|
||||
checkArgument(
|
||||
arg.matches("-?\\d+\\.\\.-?\\d+"),
|
||||
"--Xsynchronizer-block-propagation-range should be of the form '<LONG>..<LONG>'");
|
||||
final Iterator<String> ends = Splitter.on("..").split(arg).iterator();
|
||||
blockPropagationRange =
|
||||
Range.closed(Long.parseLong(ends.next()), Long.parseLong(ends.next()));
|
||||
}
|
||||
|
||||
private Range<Long> blockPropagationRange = Range.closed(-10L, 30L);
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-downloader-change-target-threshold-by-height",
|
||||
hidden = true,
|
||||
defaultValue = "200",
|
||||
paramLabel = "<LONG>",
|
||||
description =
|
||||
"Minimum height difference before switching fast sync download peers (default: ${DEFAULT-VALUE})")
|
||||
private long downloaderChangeTargetThresholdByHeight = 200L;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-downloader-change-target-threshold-by-td",
|
||||
hidden = true,
|
||||
defaultValue = "1000000000000000000",
|
||||
paramLabel = "<UINT256>",
|
||||
description =
|
||||
"Minimum total difficulty difference before switching fast sync download peers (default: ${DEFAULT-VALUE})")
|
||||
private UInt256 downloaderChangeTargetThresholdByTd = UInt256.of(1_000_000_000_000_000_000L);
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-downloader-header-request-size",
|
||||
hidden = true,
|
||||
defaultValue = "200",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Number of headers to request per packet (default: ${DEFAULT-VALUE})")
|
||||
private int downloaderHeaderRequestSize = 200;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-downloader-checkpoint-timeouts-permitted",
|
||||
hidden = true,
|
||||
defaultValue = "5",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of tries to attempt to download checkpoints before stopping (default: ${DEFAULT-VALUE})")
|
||||
private int downloaderCheckpointTimeoutsPermitted = 5;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-downloader-chain-segment-size",
|
||||
hidden = true,
|
||||
defaultValue = "200",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Distance between checkpoint headers (default: ${DEFAULT-VALUE})")
|
||||
private int downloaderChainSegmentSize = 200;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-downloader-parallelism",
|
||||
hidden = true,
|
||||
defaultValue = "4",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of threads to provide to chain downloader (default: ${DEFAULT-VALUE})")
|
||||
private int downloaderParallelism = 4;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-transactions-parallelism",
|
||||
hidden = true,
|
||||
defaultValue = "2",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of threads to commit to transaction processing (default: ${DEFAULT-VALUE})")
|
||||
private int transactionsParallelism = 2;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-computation-parallelism",
|
||||
hidden = true,
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of threads to make available for bulk hash computations durring downloads (default: # of processors)")
|
||||
private int computationParallelism = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-fast-sync-pivot-distance",
|
||||
hidden = true,
|
||||
defaultValue = "50",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Distance from initial chain head to fast sync target (default: ${DEFAULT-VALUE})")
|
||||
private Range<Long> blockPropagationRange = DEFAULT_BLOCK_PROPAGATION_RANGE;
|
||||
private long downloaderChangeTargetThresholdByHeight =
|
||||
DEFAULT_DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_HEIGHT;
|
||||
private UInt256 downloaderChangeTargetThresholdByTd =
|
||||
DEFAULT_DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_TD;
|
||||
private int downloaderHeaderRequestSize = DEFAULT_DOWNLOADER_HEADER_REQUEST_SIZE;
|
||||
private int downloaderCheckpointTimeoutsPermitted =
|
||||
DEFAULT_DOWNLOADER_CHECKPOINT_TIMEOUTS_PERMITTED;
|
||||
private int downloaderChainSegmentSize = DEFAULT_DOWNLOADER_CHAIN_SEGMENT_SIZE;
|
||||
private int downloaderParallelism = DEFAULT_DOWNLOADER_PARALLELISM;
|
||||
private int transactionsParallelism = DEFAULT_TRANSACTIONS_PARALLELISM;
|
||||
private int computationParallelism = DEFAULT_COMPUTATION_PARALLELISM;
|
||||
private int fastSyncPivotDistance = DEFAULT_PIVOT_DISTANCE_FROM_HEAD;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-fast-sync-full-validation-rate",
|
||||
hidden = true,
|
||||
defaultValue = "0.1",
|
||||
paramLabel = "<FLOAT>",
|
||||
description =
|
||||
"Fraction of headers fast sync will fully validate (default: ${DEFAULT-VALUE})")
|
||||
private float fastSyncFullValidationRate = DEFAULT_FULL_VALIDATION_RATE;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-world-state-hash-count-per-request",
|
||||
hidden = true,
|
||||
defaultValue = "348",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Fast sync world state hashes queried per request (default: ${DEFAULT-VALUE})")
|
||||
private int worldStateHashCountPerRequest = DEFAULT_WORLD_STATE_HASH_COUNT_PER_REQUEST;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-world-state-request-parallelism",
|
||||
hidden = true,
|
||||
defaultValue = "10",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of concurrent requests to use when downloading fast sync world state (default: ${DEFAULT-VALUE})")
|
||||
private int worldStateRequestParallelism = DEFAULT_WORLD_STATE_REQUEST_PARALLELISM;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-world-state-max-requests-without-progress",
|
||||
hidden = true,
|
||||
defaultValue = "1000",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of world state requests accepted without progress before considering the download stalled (default: ${DEFAULT-VALUE})")
|
||||
private int worldStateMaxRequestsWithoutProgress =
|
||||
DEFAULT_WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = "--Xsynchronizer-world-state-min-millis-before-stalling",
|
||||
hidden = true,
|
||||
defaultValue = "300000",
|
||||
paramLabel = "<LONG>",
|
||||
description =
|
||||
"Minimum time in ms without progress before considering a world state download as stalled (default: ${DEFAULT-VALUE})")
|
||||
private long worldStateMinMillisBeforeStalling = DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING;
|
||||
|
||||
public Builder fastSyncPivotDistance(final int distance) {
|
||||
@@ -353,7 +236,7 @@ public class SynchronizerConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder fastSyncFastSyncFullValidationRate(final float rate) {
|
||||
public Builder fastSyncFullValidationRate(final float rate) {
|
||||
this.fastSyncFullValidationRate = rate;
|
||||
return this;
|
||||
}
|
||||
@@ -363,6 +246,12 @@ public class SynchronizerConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder blockPropagationRange(final Range<Long> blockPropagationRange) {
|
||||
checkNotNull(blockPropagationRange);
|
||||
this.blockPropagationRange = blockPropagationRange;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder downloaderChangeTargetThresholdByHeight(
|
||||
final long downloaderChangeTargetThresholdByHeight) {
|
||||
this.downloaderChangeTargetThresholdByHeight = downloaderChangeTargetThresholdByHeight;
|
||||
@@ -397,7 +286,7 @@ public class SynchronizerConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder downloaderParallelisim(final int downloaderParallelism) {
|
||||
public Builder downloaderParallelism(final int downloaderParallelism) {
|
||||
this.downloaderParallelism = downloaderParallelism;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class FastDownloaderFactory {
|
||||
final WorldStateStorage worldStateStorage,
|
||||
final SyncState syncState,
|
||||
final Clock clock) {
|
||||
if (syncConfig.syncMode() != SyncMode.FAST) {
|
||||
if (syncConfig.getSyncMode() != SyncMode.FAST) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public class FastSyncActions<C> {
|
||||
.map(
|
||||
peer -> {
|
||||
final long pivotBlockNumber =
|
||||
peer.chainState().getEstimatedHeight() - syncConfig.fastSyncPivotDistance();
|
||||
peer.chainState().getEstimatedHeight() - syncConfig.getFastSyncPivotDistance();
|
||||
if (pivotBlockNumber <= BlockHeader.GENESIS_BLOCK_NUMBER) {
|
||||
throw new FastSyncException(CHAIN_TOO_SHORT);
|
||||
} else {
|
||||
|
||||
@@ -73,16 +73,19 @@ public class FastSyncDownloadPipelineFactory<C> implements DownloadPipelineFacto
|
||||
"validationMode");
|
||||
attachedValidationPolicy =
|
||||
new FastSyncValidationPolicy(
|
||||
this.syncConfig.fastSyncFullValidationRate(),
|
||||
this.syncConfig.getFastSyncFullValidationRate(),
|
||||
LIGHT_SKIP_DETACHED,
|
||||
SKIP_DETACHED,
|
||||
fastSyncValidationCounter);
|
||||
ommerValidationPolicy =
|
||||
new FastSyncValidationPolicy(
|
||||
this.syncConfig.fastSyncFullValidationRate(), LIGHT, FULL, fastSyncValidationCounter);
|
||||
this.syncConfig.getFastSyncFullValidationRate(),
|
||||
LIGHT,
|
||||
FULL,
|
||||
fastSyncValidationCounter);
|
||||
detachedValidationPolicy =
|
||||
new FastSyncValidationPolicy(
|
||||
this.syncConfig.fastSyncFullValidationRate(),
|
||||
this.syncConfig.getFastSyncFullValidationRate(),
|
||||
LIGHT_DETACHED_ONLY,
|
||||
DETACHED_ONLY,
|
||||
fastSyncValidationCounter);
|
||||
@@ -90,8 +93,8 @@ public class FastSyncDownloadPipelineFactory<C> implements DownloadPipelineFacto
|
||||
|
||||
@Override
|
||||
public Pipeline<?> createDownloadPipelineForSyncTarget(final SyncTarget target) {
|
||||
final int downloaderParallelism = syncConfig.downloaderParallelism();
|
||||
final int headerRequestSize = syncConfig.downloaderHeaderRequestSize();
|
||||
final int downloaderParallelism = syncConfig.getDownloaderParallelism();
|
||||
final int headerRequestSize = syncConfig.getDownloaderHeaderRequestSize();
|
||||
final int singleHeaderBufferSize = headerRequestSize * downloaderParallelism;
|
||||
final CheckpointRangeSource checkpointRangeSource =
|
||||
new CheckpointRangeSource(
|
||||
@@ -105,7 +108,7 @@ public class FastSyncDownloadPipelineFactory<C> implements DownloadPipelineFacto
|
||||
ethContext.getScheduler(),
|
||||
target.peer(),
|
||||
target.commonAncestor(),
|
||||
syncConfig.downloaderCheckpointTimeoutsPermitted());
|
||||
syncConfig.getDownloaderCheckpointTimeoutsPermitted());
|
||||
final DownloadHeadersStep<C> downloadHeadersStep =
|
||||
new DownloadHeadersStep<>(
|
||||
protocolSchedule,
|
||||
|
||||
@@ -50,13 +50,13 @@ public class BetterSyncTargetEvaluator {
|
||||
.getBestBlock()
|
||||
.getTotalDifficulty()
|
||||
.minus(currentPeerChainState.getBestBlock().getTotalDifficulty());
|
||||
if (tdDifference.compareTo(config.downloaderChangeTargetThresholdByTd()) > 0) {
|
||||
if (tdDifference.compareTo(config.getDownloaderChangeTargetThresholdByTd()) > 0) {
|
||||
return true;
|
||||
}
|
||||
final long heightDifference =
|
||||
bestPeerChainState.getEstimatedHeight()
|
||||
- currentPeerChainState.getEstimatedHeight();
|
||||
return heightDifference > config.downloaderChangeTargetThresholdByHeight();
|
||||
return heightDifference > config.getDownloaderChangeTargetThresholdByHeight();
|
||||
})
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ public class FullSyncDownloadPipelineFactory<C> implements DownloadPipelineFacto
|
||||
|
||||
@Override
|
||||
public Pipeline<?> createDownloadPipelineForSyncTarget(final SyncTarget target) {
|
||||
final int downloaderParallelism = syncConfig.downloaderParallelism();
|
||||
final int headerRequestSize = syncConfig.downloaderHeaderRequestSize();
|
||||
final int downloaderParallelism = syncConfig.getDownloaderParallelism();
|
||||
final int headerRequestSize = syncConfig.getDownloaderHeaderRequestSize();
|
||||
final int singleHeaderBufferSize = headerRequestSize * downloaderParallelism;
|
||||
final CheckpointRangeSource checkpointRangeSource =
|
||||
new CheckpointRangeSource(
|
||||
@@ -72,7 +72,7 @@ public class FullSyncDownloadPipelineFactory<C> implements DownloadPipelineFacto
|
||||
ethContext.getScheduler(),
|
||||
target.peer(),
|
||||
target.commonAncestor(),
|
||||
syncConfig.downloaderCheckpointTimeoutsPermitted());
|
||||
syncConfig.getDownloaderCheckpointTimeoutsPermitted());
|
||||
final DownloadHeadersStep<C> downloadHeadersStep =
|
||||
new DownloadHeadersStep<>(
|
||||
protocolSchedule,
|
||||
|
||||
@@ -51,9 +51,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class PendingTransactions {
|
||||
|
||||
public static final int MAX_PENDING_TRANSACTIONS = 4096;
|
||||
public static final int DEFAULT_TX_RETENTION_HOURS = 13;
|
||||
|
||||
private final int maxTransactionRetentionHours;
|
||||
private final Clock clock;
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ import org.apache.logging.log4j.Logger;
|
||||
public class TransactionPool implements BlockAddedObserver {
|
||||
|
||||
private static final Logger LOG = getLogger();
|
||||
public static final int DEFAULT_TX_MSG_KEEP_ALIVE = 60;
|
||||
|
||||
private static final long SYNC_TOLERANCE = 100L;
|
||||
private static final String REMOTE = "remote";
|
||||
|
||||
@@ -14,9 +14,10 @@ package tech.pegasys.pantheon.ethereum.eth.transactions;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
public class TransactionPoolConfiguration {
|
||||
public static final int DEFAULT_TX_MSG_KEEP_ALIVE = 60;
|
||||
public static final int MAX_PENDING_TRANSACTIONS = 4096;
|
||||
public static final int DEFAULT_TX_RETENTION_HOURS = 13;
|
||||
|
||||
private final int txPoolMaxSize;
|
||||
private final int pendingTxRetentionPeriod;
|
||||
@@ -79,17 +80,9 @@ public class TransactionPoolConfiguration {
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int txPoolMaxSize = PendingTransactions.MAX_PENDING_TRANSACTIONS;
|
||||
private int pendingTxRetentionPeriod = PendingTransactions.DEFAULT_TX_RETENTION_HOURS;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {"--Xincoming-tx-messages-keep-alive-seconds"},
|
||||
paramLabel = "<INTEGER>",
|
||||
hidden = true,
|
||||
description =
|
||||
"Keep alive of incoming transaction messages in seconds (default: ${DEFAULT-VALUE})",
|
||||
arity = "1")
|
||||
private Integer txMessageKeepAliveSeconds = TransactionPool.DEFAULT_TX_MSG_KEEP_ALIVE;
|
||||
private int txPoolMaxSize = MAX_PENDING_TRANSACTIONS;
|
||||
private int pendingTxRetentionPeriod = DEFAULT_TX_RETENTION_HOURS;
|
||||
private Integer txMessageKeepAliveSeconds = DEFAULT_TX_MSG_KEEP_ALIVE;
|
||||
|
||||
public Builder txPoolMaxSize(final int txPoolMaxSize) {
|
||||
this.txPoolMaxSize = txPoolMaxSize;
|
||||
|
||||
@@ -34,7 +34,7 @@ import tech.pegasys.pantheon.ethereum.core.TransactionReceipt;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocol;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocol.EthVersion;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.manager.MockPeerConnection.PeerSendHandler;
|
||||
import tech.pegasys.pantheon.ethereum.eth.manager.ethtaskutils.BlockchainSetupUtil;
|
||||
import tech.pegasys.pantheon.ethereum.eth.messages.BlockBodiesMessage;
|
||||
@@ -121,7 +121,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final MessageData messageData =
|
||||
BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get()));
|
||||
final MockPeerConnection peer = setupPeer(ethManager, (cap, msg, conn) -> {});
|
||||
@@ -143,7 +143,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final MessageData messageData =
|
||||
BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get()));
|
||||
final MockPeerConnection peer =
|
||||
@@ -166,7 +166,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final MessageData messageData =
|
||||
BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get()));
|
||||
final MockPeerConnection peer =
|
||||
@@ -200,7 +200,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final MessageData messageData =
|
||||
BlockHeadersMessage.create(Collections.singletonList(blockchain.getBlockHeader(1).get()));
|
||||
final MockPeerConnection peer =
|
||||
@@ -234,7 +234,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final MessageData messageData =
|
||||
GetBlockBodiesMessage.create(Collections.singletonList(gen.hash()));
|
||||
final MockPeerConnection peer = setupPeer(ethManager, (cap, msg, conn) -> {});
|
||||
@@ -260,7 +260,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final long startBlock = 5L;
|
||||
final int blockCount = 5;
|
||||
final MessageData messageData =
|
||||
@@ -302,7 +302,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
new EthereumWireProtocolConfiguration(limit, limit, limit, limit))) {
|
||||
new EthProtocolConfiguration(limit, limit, limit, limit))) {
|
||||
final long startBlock = 5L;
|
||||
final int blockCount = 10;
|
||||
final MessageData messageData =
|
||||
@@ -343,7 +343,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final long endBlock = 10L;
|
||||
final int blockCount = 5;
|
||||
final MessageData messageData = GetBlockHeadersMessage.create(endBlock, blockCount, 0, true);
|
||||
@@ -383,7 +383,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final long startBlock = 5L;
|
||||
final int blockCount = 5;
|
||||
final int skip = 1;
|
||||
@@ -426,7 +426,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final long endBlock = 10L;
|
||||
final int blockCount = 5;
|
||||
final int skip = 1;
|
||||
@@ -490,7 +490,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() - 1L;
|
||||
final int blockCount = 5;
|
||||
final MessageData messageData =
|
||||
@@ -531,7 +531,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() + 1;
|
||||
final int blockCount = 5;
|
||||
final MessageData messageData =
|
||||
@@ -569,7 +569,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
// Setup blocks query
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() - 5;
|
||||
final int blockCount = 2;
|
||||
@@ -623,7 +623,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
new EthereumWireProtocolConfiguration(limit, limit, limit, limit))) {
|
||||
new EthProtocolConfiguration(limit, limit, limit, limit))) {
|
||||
// Setup blocks query
|
||||
final int blockCount = 10;
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() - blockCount;
|
||||
@@ -676,7 +676,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
// Setup blocks query
|
||||
final long expectedBlockNumber = blockchain.getChainHeadBlockNumber() - 1;
|
||||
final BlockHeader header = blockchain.getBlockHeader(expectedBlockNumber).get();
|
||||
@@ -723,7 +723,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
// Setup blocks query
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() - 5;
|
||||
final int blockCount = 2;
|
||||
@@ -776,7 +776,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
new EthereumWireProtocolConfiguration(limit, limit, limit, limit))) {
|
||||
new EthProtocolConfiguration(limit, limit, limit, limit))) {
|
||||
// Setup blocks query
|
||||
final int blockCount = 10;
|
||||
final long startBlock = blockchain.getChainHeadBlockNumber() - blockCount;
|
||||
@@ -828,7 +828,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
// Setup blocks query
|
||||
final long blockNumber = blockchain.getChainHeadBlockNumber() - 5;
|
||||
final BlockHeader header = blockchain.getBlockHeader(blockNumber).get();
|
||||
@@ -877,7 +877,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
// Setup node data query
|
||||
|
||||
final List<BytesValue> expectedResults = new ArrayList<>();
|
||||
@@ -929,7 +929,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig());
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
|
||||
// Define handler to validate response
|
||||
final PeerSendHandler onSend = mock(PeerSendHandler.class);
|
||||
@@ -1002,7 +1002,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig())) {
|
||||
EthProtocolConfiguration.defaultConfig())) {
|
||||
final long startBlock = 1L;
|
||||
final int requestedBlockCount = 13;
|
||||
final int receivedBlockCount = 2;
|
||||
@@ -1067,7 +1067,7 @@ public final class EthProtocolManagerTest {
|
||||
1,
|
||||
true,
|
||||
ethScheduler,
|
||||
EthereumWireProtocolConfiguration.defaultConfig(),
|
||||
EthProtocolConfiguration.defaultConfig(),
|
||||
TestClock.fixed(),
|
||||
metricsSystem)) {
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import tech.pegasys.pantheon.ethereum.chain.Blockchain;
|
||||
import tech.pegasys.pantheon.ethereum.chain.ChainHead;
|
||||
import tech.pegasys.pantheon.ethereum.chain.GenesisState;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocol;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.manager.DeterministicEthScheduler.TimeoutPolicy;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.MainnetProtocolSchedule;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule;
|
||||
@@ -52,7 +52,7 @@ public class EthProtocolManagerTestUtil {
|
||||
networkId,
|
||||
false,
|
||||
ethScheduler,
|
||||
EthereumWireProtocolConfiguration.defaultConfig(),
|
||||
EthProtocolConfiguration.defaultConfig(),
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem());
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import tech.pegasys.pantheon.ethereum.chain.Blockchain;
|
||||
import tech.pegasys.pantheon.ethereum.core.Hash;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.messages.GetNodeDataMessage;
|
||||
import tech.pegasys.pantheon.ethereum.eth.messages.NodeDataMessage;
|
||||
import tech.pegasys.pantheon.ethereum.worldstate.WorldStateArchive;
|
||||
@@ -47,10 +47,7 @@ public class EthServerTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
new EthServer(
|
||||
blockchain,
|
||||
worldStateArchive,
|
||||
ethMessages,
|
||||
new EthereumWireProtocolConfiguration(2, 2, 2, 2));
|
||||
blockchain, worldStateArchive, ethMessages, new EthProtocolConfiguration(2, 2, 2, 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -152,7 +152,7 @@ public class FastSyncActionsTest {
|
||||
@Test
|
||||
public void selectPivotBlockShouldFailIfBestPeerChainIsShorterThanPivotDistance() {
|
||||
EthProtocolManagerTestUtil.createPeer(
|
||||
ethProtocolManager, syncConfig.fastSyncPivotDistance() - 1);
|
||||
ethProtocolManager, syncConfig.getFastSyncPivotDistance() - 1);
|
||||
|
||||
assertThrowsFastSyncException(
|
||||
CHAIN_TOO_SHORT, () -> fastSyncActions.selectPivotBlock(EMPTY_SYNC_STATE));
|
||||
@@ -160,7 +160,8 @@ public class FastSyncActionsTest {
|
||||
|
||||
@Test
|
||||
public void selectPivotBlockShouldFailIfBestPeerChainIsEqualToPivotDistance() {
|
||||
EthProtocolManagerTestUtil.createPeer(ethProtocolManager, syncConfig.fastSyncPivotDistance());
|
||||
EthProtocolManagerTestUtil.createPeer(
|
||||
ethProtocolManager, syncConfig.getFastSyncPivotDistance());
|
||||
|
||||
assertThrowsFastSyncException(
|
||||
CHAIN_TOO_SHORT, () -> fastSyncActions.selectPivotBlock(EMPTY_SYNC_STATE));
|
||||
|
||||
@@ -171,7 +171,7 @@ public class FastSyncChainDownloaderTest {
|
||||
SynchronizerConfiguration.builder()
|
||||
.downloaderChainSegmentSize(5)
|
||||
.downloaderHeadersRequestSize(3)
|
||||
.downloaderParallelisim(1)
|
||||
.downloaderParallelism(1)
|
||||
.build();
|
||||
final long pivotBlockNumber = 25;
|
||||
final ChainDownloader downloader = downloader(syncConfig, pivotBlockNumber);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PendingTransactionsTest {
|
||||
private final StubMetricsSystem metricsSystem = new StubMetricsSystem();
|
||||
private final PendingTransactions transactions =
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
MAX_TRANSACTIONS,
|
||||
TestClock.fixed(),
|
||||
metricsSystem);
|
||||
|
||||
@@ -30,7 +30,7 @@ import tech.pegasys.pantheon.ethereum.core.Transaction;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocol;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.manager.EthContext;
|
||||
import tech.pegasys.pantheon.ethereum.eth.manager.EthProtocolManager;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.state.SyncState;
|
||||
@@ -116,7 +116,7 @@ public class TestNode implements Closeable {
|
||||
1,
|
||||
TestClock.fixed(),
|
||||
new NoOpMetricsSystem(),
|
||||
EthereumWireProtocolConfiguration.defaultConfig());
|
||||
EthProtocolConfiguration.defaultConfig());
|
||||
|
||||
final NetworkRunner networkRunner =
|
||||
NetworkRunner.builder()
|
||||
|
||||
@@ -93,7 +93,7 @@ public class TransactionPoolTest {
|
||||
|
||||
private final PendingTransactions transactions =
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
MAX_TRANSACTIONS,
|
||||
TestClock.fixed(),
|
||||
metricsSystem);
|
||||
|
||||
@@ -38,6 +38,7 @@ import tech.pegasys.pantheon.ethereum.eth.transactions.PeerTransactionTracker;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPool;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPool.TransactionBatchAddedListener;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.filter.FilterIdGenerator;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.filter.FilterManager;
|
||||
@@ -77,7 +78,7 @@ public class EthGetFilterChangesIntegrationTest {
|
||||
|
||||
private final PendingTransactions transactions =
|
||||
new PendingTransactions(
|
||||
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
|
||||
MAX_TRANSACTIONS,
|
||||
TestClock.fixed(),
|
||||
metricsSystem);
|
||||
|
||||
@@ -18,6 +18,8 @@ public class NetworkingConfiguration {
|
||||
private DiscoveryConfiguration discovery = new DiscoveryConfiguration();
|
||||
private RlpxConfiguration rlpx = new RlpxConfiguration();
|
||||
|
||||
private NetworkingConfiguration() {}
|
||||
|
||||
public static NetworkingConfiguration create() {
|
||||
return new NetworkingConfiguration();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ dependencies {
|
||||
|
||||
implementation 'com.google.guava:guava'
|
||||
implementation 'io.prometheus:simpleclient'
|
||||
implementation 'info.picocli:picocli'
|
||||
implementation 'org.apache.logging.log4j:log4j-api'
|
||||
implementation 'org.rocksdb:rocksdbjni'
|
||||
}
|
||||
|
||||
@@ -16,11 +16,7 @@ import static org.apache.logging.log4j.LogManager.getLogger;
|
||||
|
||||
import tech.pegasys.pantheon.cli.PantheonCommand;
|
||||
import tech.pegasys.pantheon.controller.PantheonController;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.services.PantheonPluginContextImpl;
|
||||
import tech.pegasys.pantheon.services.kvstore.RocksDbConfiguration;
|
||||
import tech.pegasys.pantheon.util.BlockImporter;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -41,10 +37,6 @@ public final class Pantheon {
|
||||
new BlockImporter(),
|
||||
new RunnerBuilder(),
|
||||
new PantheonController.Builder(),
|
||||
new SynchronizerConfiguration.Builder(),
|
||||
EthereumWireProtocolConfiguration.builder(),
|
||||
new RocksDbConfiguration.Builder(),
|
||||
TransactionPoolConfiguration.builder(),
|
||||
new PantheonPluginContextImpl(),
|
||||
System.getenv());
|
||||
|
||||
|
||||
@@ -104,17 +104,19 @@ public class RunnerBuilder {
|
||||
|
||||
private Vertx vertx;
|
||||
private PantheonController<?> pantheonController;
|
||||
|
||||
private Collection<BytesValue> bannedNodeIds = new ArrayList<>();
|
||||
private boolean p2pEnabled = true;
|
||||
private boolean discovery;
|
||||
private EthNetworkConfig ethNetworkConfig;
|
||||
private String p2pAdvertisedHost;
|
||||
private int p2pListenPort;
|
||||
private int maxPeers;
|
||||
private EthNetworkConfig ethNetworkConfig;
|
||||
|
||||
private JsonRpcConfiguration jsonRpcConfiguration;
|
||||
private GraphQLConfiguration graphQLConfiguration;
|
||||
private WebSocketConfiguration webSocketConfiguration;
|
||||
private Path dataDir;
|
||||
private Collection<BytesValue> bannedNodeIds = new ArrayList<>();
|
||||
private MetricsConfiguration metricsConfiguration;
|
||||
private MetricsSystem metricsSystem;
|
||||
private Optional<PermissioningConfiguration> permissioningConfiguration = Optional.empty();
|
||||
@@ -249,7 +251,7 @@ public class RunnerBuilder {
|
||||
.setSupportedProtocols(subProtocols)
|
||||
.setClientId(PantheonInfo.version());
|
||||
final NetworkingConfiguration networkConfig =
|
||||
new NetworkingConfiguration()
|
||||
NetworkingConfiguration.create()
|
||||
.setRlpx(rlpxConfiguration)
|
||||
.setDiscovery(discoveryConfiguration);
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ import tech.pegasys.pantheon.cli.custom.CorsAllowedOriginsProperty;
|
||||
import tech.pegasys.pantheon.cli.custom.JsonRPCWhitelistHostsProperty;
|
||||
import tech.pegasys.pantheon.cli.custom.RpcAuthFileValidator;
|
||||
import tech.pegasys.pantheon.cli.error.PantheonExceptionHandler;
|
||||
import tech.pegasys.pantheon.cli.options.EthProtocolOptions;
|
||||
import tech.pegasys.pantheon.cli.options.RocksDBOptions;
|
||||
import tech.pegasys.pantheon.cli.options.SynchronizerOptions;
|
||||
import tech.pegasys.pantheon.cli.options.TransactionPoolOptions;
|
||||
import tech.pegasys.pantheon.cli.subcommands.PasswordSubCommand;
|
||||
import tech.pegasys.pantheon.cli.subcommands.PublicKeySubCommand;
|
||||
import tech.pegasys.pantheon.cli.subcommands.PublicKeySubCommand.KeyLoader;
|
||||
@@ -54,11 +58,8 @@ import tech.pegasys.pantheon.ethereum.core.Address;
|
||||
import tech.pegasys.pantheon.ethereum.core.MiningParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SyncMode;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.TrailingPeerRequirements;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.PendingTransactions;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.graphql.GraphQLConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration;
|
||||
@@ -149,10 +150,10 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
|
||||
|
||||
private final BlockImporter blockImporter;
|
||||
|
||||
private final SynchronizerConfiguration.Builder synchronizerConfigurationBuilder;
|
||||
private final EthereumWireProtocolConfiguration.Builder ethereumWireConfigurationBuilder;
|
||||
private final RocksDbConfiguration.Builder rocksDbConfigurationBuilder;
|
||||
private final TransactionPoolConfiguration.Builder transactionPoolConfigurationBuilder;
|
||||
final SynchronizerOptions synchronizerOptions = SynchronizerOptions.create();
|
||||
final EthProtocolOptions ethProtocolOptions = EthProtocolOptions.create();
|
||||
final RocksDBOptions rocksDBOptions = RocksDBOptions.create();
|
||||
final TransactionPoolOptions transactionPoolOptions = TransactionPoolOptions.create();
|
||||
private final RunnerBuilder runnerBuilder;
|
||||
private final PantheonController.Builder controllerBuilderFactory;
|
||||
private final PantheonPluginContextImpl pantheonPluginContext;
|
||||
@@ -566,7 +567,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
|
||||
description =
|
||||
"Maximum number of pending transactions that will be kept in the transaction pool (default: ${DEFAULT-VALUE})",
|
||||
arity = "1")
|
||||
private final Integer txPoolMaxSize = PendingTransactions.MAX_PENDING_TRANSACTIONS;
|
||||
private final Integer txPoolMaxSize = TransactionPoolConfiguration.MAX_PENDING_TRANSACTIONS;
|
||||
|
||||
@Option(
|
||||
names = {"--tx-pool-retention-hours"},
|
||||
@@ -574,7 +575,8 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
|
||||
description =
|
||||
"Maximum retention period of pending transactions in hours (default: ${DEFAULT-VALUE})",
|
||||
arity = "1")
|
||||
private final Integer pendingTxRetentionPeriod = PendingTransactions.DEFAULT_TX_RETENTION_HOURS;
|
||||
private final Integer pendingTxRetentionPeriod =
|
||||
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS;
|
||||
|
||||
private EthNetworkConfig ethNetworkConfig;
|
||||
private JsonRpcConfiguration jsonRpcConfiguration;
|
||||
@@ -593,20 +595,12 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
|
||||
final BlockImporter blockImporter,
|
||||
final RunnerBuilder runnerBuilder,
|
||||
final PantheonController.Builder controllerBuilderFactory,
|
||||
final SynchronizerConfiguration.Builder synchronizerConfigurationBuilder,
|
||||
final EthereumWireProtocolConfiguration.Builder ethereumWireConfigurationBuilder,
|
||||
final RocksDbConfiguration.Builder rocksDbConfigurationBuilder,
|
||||
final TransactionPoolConfiguration.Builder transactionPoolConfigurationBuilder,
|
||||
final PantheonPluginContextImpl pantheonPluginContext,
|
||||
final Map<String, String> environment) {
|
||||
this.logger = logger;
|
||||
this.blockImporter = blockImporter;
|
||||
this.runnerBuilder = runnerBuilder;
|
||||
this.controllerBuilderFactory = controllerBuilderFactory;
|
||||
this.synchronizerConfigurationBuilder = synchronizerConfigurationBuilder;
|
||||
this.ethereumWireConfigurationBuilder = ethereumWireConfigurationBuilder;
|
||||
this.rocksDbConfigurationBuilder = rocksDbConfigurationBuilder;
|
||||
this.transactionPoolConfigurationBuilder = transactionPoolConfigurationBuilder;
|
||||
this.pantheonPluginContext = pantheonPluginContext;
|
||||
this.environment = environment;
|
||||
}
|
||||
@@ -683,13 +677,13 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
|
||||
commandLine,
|
||||
ImmutableMap.of(
|
||||
"Synchronizer",
|
||||
synchronizerConfigurationBuilder,
|
||||
synchronizerOptions,
|
||||
"RocksDB",
|
||||
rocksDbConfigurationBuilder,
|
||||
rocksDBOptions,
|
||||
"Ethereum Wire Protocol",
|
||||
ethereumWireConfigurationBuilder,
|
||||
ethProtocolOptions,
|
||||
"TransactionPool",
|
||||
transactionPoolConfigurationBuilder));
|
||||
transactionPoolOptions));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -838,7 +832,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
|
||||
return controllerBuilderFactory
|
||||
.fromEthNetworkConfig(updateNetworkConfig(getNetwork()))
|
||||
.synchronizerConfiguration(buildSyncConfig())
|
||||
.ethereumWireProtocolConfiguration(ethereumWireConfigurationBuilder.build())
|
||||
.ethProtocolConfiguration(ethProtocolOptions.toDomainObject())
|
||||
.rocksDbConfiguration(buildRocksDbConfiguration())
|
||||
.dataDirectory(dataDir())
|
||||
.miningParameters(
|
||||
@@ -1099,19 +1093,20 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
|
||||
}
|
||||
|
||||
private SynchronizerConfiguration buildSyncConfig() {
|
||||
return synchronizerConfigurationBuilder
|
||||
return synchronizerOptions
|
||||
.toDomainObject()
|
||||
.syncMode(syncMode)
|
||||
.fastSyncMinimumPeerCount(fastSyncMinPeerCount)
|
||||
.maxTrailingPeers(TrailingPeerRequirements.calculateMaxTrailingPeers(maxPeers))
|
||||
.build();
|
||||
}
|
||||
|
||||
private RocksDbConfiguration buildRocksDbConfiguration() {
|
||||
return rocksDbConfigurationBuilder.databaseDir(dataDir().resolve(DATABASE_PATH)).build();
|
||||
return rocksDBOptions.toDomainObject().databaseDir(dataDir().resolve(DATABASE_PATH)).build();
|
||||
}
|
||||
|
||||
private TransactionPoolConfiguration buildTransactionPoolConfiguration() {
|
||||
return transactionPoolConfigurationBuilder
|
||||
return transactionPoolOptions
|
||||
.toDomainObject()
|
||||
.txPoolMaxSize(txPoolMaxSize)
|
||||
.pendingTxRetentionPeriod(pendingTxRetentionPeriod)
|
||||
.build();
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This interface represents logic that translates between CLI options and a domain object.
|
||||
*
|
||||
* @param <T> A class to be constructed from CLI arguments.
|
||||
*/
|
||||
public interface CLIOptions<T> {
|
||||
|
||||
/**
|
||||
* Transform CLI options into a domain object.
|
||||
*
|
||||
* @return A domain object representing these CLI options.
|
||||
*/
|
||||
T toDomainObject();
|
||||
|
||||
/** @return The list of CLI options corresponding to this class. */
|
||||
List<String> getCLIOptions();
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.util.number.PositiveNumber;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
public class EthProtocolOptions implements CLIOptions<EthProtocolConfiguration> {
|
||||
private static final String MAX_GET_HEADERS_FLAG = "--Xewp-max-get-headers";
|
||||
private static final String MAX_GET_BODIES_FLAG = "--Xewp-max-get-bodies";
|
||||
private static final String MAX_GET_RECEIPTS_FLAG = "--Xewp-max-get-receipts";
|
||||
private static final String MAX_GET_NODE_DATA_FLAG = "--Xewp-max-get-node-data";
|
||||
|
||||
@CommandLine.Option(
|
||||
hidden = true,
|
||||
names = {MAX_GET_HEADERS_FLAG},
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Maximum request limit for Ethereum Wire Protocol GET_BLOCK_HEADERS. (default: ${DEFAULT-VALUE})")
|
||||
private PositiveNumber maxGetBlockHeaders =
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_BLOCK_HEADERS);
|
||||
|
||||
@CommandLine.Option(
|
||||
hidden = true,
|
||||
names = {MAX_GET_BODIES_FLAG},
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Maximum request limit for Ethereum Wire Protocol GET_BLOCK_BODIES. (default: ${DEFAULT-VALUE})")
|
||||
private PositiveNumber maxGetBlockBodies =
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_BLOCK_BODIES);
|
||||
|
||||
@CommandLine.Option(
|
||||
hidden = true,
|
||||
names = {MAX_GET_RECEIPTS_FLAG},
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Maximum request limit for Ethereum Wire Protocol GET_RECEIPTS. (default: ${DEFAULT-VALUE})")
|
||||
private PositiveNumber maxGetReceipts =
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_RECEIPTS);
|
||||
|
||||
@CommandLine.Option(
|
||||
hidden = true,
|
||||
names = {MAX_GET_NODE_DATA_FLAG},
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Maximum request limit for Ethereum Wire Protocol GET_NODE_DATA. (default: ${DEFAULT-VALUE})")
|
||||
private PositiveNumber maxGetNodeData =
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_NODE_DATA);
|
||||
|
||||
private EthProtocolOptions() {}
|
||||
|
||||
public static EthProtocolOptions create() {
|
||||
return new EthProtocolOptions();
|
||||
}
|
||||
|
||||
public static EthProtocolOptions fromConfig(final EthProtocolConfiguration config) {
|
||||
final EthProtocolOptions options = create();
|
||||
options.maxGetBlockHeaders = PositiveNumber.fromInt(config.getMaxGetBlockHeaders());
|
||||
options.maxGetBlockBodies = PositiveNumber.fromInt(config.getMaxGetBlockBodies());
|
||||
options.maxGetReceipts = PositiveNumber.fromInt(config.getMaxGetReceipts());
|
||||
options.maxGetNodeData = PositiveNumber.fromInt(config.getMaxGetNodeData());
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EthProtocolConfiguration toDomainObject() {
|
||||
return EthProtocolConfiguration.builder()
|
||||
.maxGetBlockHeaders(maxGetBlockHeaders)
|
||||
.maxGetBlockBodies(maxGetBlockBodies)
|
||||
.maxGetReceipts(maxGetReceipts)
|
||||
.maxGetNodeData(maxGetNodeData)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCLIOptions() {
|
||||
return Arrays.asList(
|
||||
MAX_GET_HEADERS_FLAG,
|
||||
OptionParser.format(maxGetBlockHeaders.getValue()),
|
||||
MAX_GET_BODIES_FLAG,
|
||||
OptionParser.format(maxGetBlockBodies.getValue()),
|
||||
MAX_GET_RECEIPTS_FLAG,
|
||||
OptionParser.format(maxGetReceipts.getValue()),
|
||||
MAX_GET_NODE_DATA_FLAG,
|
||||
OptionParser.format(maxGetNodeData.getValue()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import tech.pegasys.pantheon.util.uint.UInt256;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Range;
|
||||
|
||||
public class OptionParser {
|
||||
|
||||
public static Range<Long> parseLongRange(final String arg) {
|
||||
checkArgument(arg.matches("-?\\d+\\.\\.-?\\d+"));
|
||||
final Iterator<String> ends = Splitter.on("..").split(arg).iterator();
|
||||
return Range.closed(parseLong(ends.next()), parseLong(ends.next()));
|
||||
}
|
||||
|
||||
public static long parseLong(final String arg) {
|
||||
return Long.parseLong(arg, 10);
|
||||
}
|
||||
|
||||
public static String format(final Range<Long> range) {
|
||||
return format(range.lowerEndpoint()) + ".." + format(range.upperEndpoint());
|
||||
}
|
||||
|
||||
public static String format(final int value) {
|
||||
return Integer.toString(value, 10);
|
||||
}
|
||||
|
||||
public static String format(final long value) {
|
||||
return Long.toString(value, 10);
|
||||
}
|
||||
|
||||
public static String format(final float value) {
|
||||
return Float.toString(value);
|
||||
}
|
||||
|
||||
public static String format(final UInt256 value) {
|
||||
return new BigInteger(value.toUnprefixedHexString(), 16).toString(10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import tech.pegasys.pantheon.services.kvstore.RocksDbConfiguration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
public class RocksDBOptions implements CLIOptions<RocksDbConfiguration.Builder> {
|
||||
private static final String MAX_OPEN_FILES_FLAG = "--Xrocksdb-max-open-files";
|
||||
private static final String CACHE_CAPACITY_FLAG = "--Xrocksdb-cache-capacity";
|
||||
private static final String MAX_BACKGROUND_COMPACTIONS_FLAG =
|
||||
"--Xrocksdb-max-background-compactions";
|
||||
private static final String BACKGROUND_THREAD_COUNT_FLAG = "--Xrocksdb-background-thread-count";
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {MAX_OPEN_FILES_FLAG},
|
||||
hidden = true,
|
||||
defaultValue = "1024",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Max number of files RocksDB will open (default: ${DEFAULT-VALUE})")
|
||||
int maxOpenFiles;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {CACHE_CAPACITY_FLAG},
|
||||
hidden = true,
|
||||
defaultValue = "8388608",
|
||||
paramLabel = "<LONG>",
|
||||
description = "Cache capacity of RocksDB (default: ${DEFAULT-VALUE})")
|
||||
long cacheCapacity;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {MAX_BACKGROUND_COMPACTIONS_FLAG},
|
||||
hidden = true,
|
||||
defaultValue = "4",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Maximum number of RocksDB background compactions (default: ${DEFAULT-VALUE})")
|
||||
int maxBackgroundCompactions;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {BACKGROUND_THREAD_COUNT_FLAG},
|
||||
hidden = true,
|
||||
defaultValue = "4",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Number of RocksDB background threads (default: ${DEFAULT-VALUE})")
|
||||
int backgroundThreadCount;
|
||||
|
||||
private RocksDBOptions() {}
|
||||
|
||||
public static RocksDBOptions create() {
|
||||
return new RocksDBOptions();
|
||||
}
|
||||
|
||||
public static RocksDBOptions fromConfig(final RocksDbConfiguration config) {
|
||||
final RocksDBOptions options = create();
|
||||
options.maxOpenFiles = config.getMaxOpenFiles();
|
||||
options.cacheCapacity = config.getCacheCapacity();
|
||||
options.maxBackgroundCompactions = config.getMaxBackgroundCompactions();
|
||||
options.backgroundThreadCount = config.getBackgroundThreadCount();
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RocksDbConfiguration.Builder toDomainObject() {
|
||||
return RocksDbConfiguration.builder()
|
||||
.maxOpenFiles(maxOpenFiles)
|
||||
.cacheCapacity(cacheCapacity)
|
||||
.maxBackgroundCompactions(maxBackgroundCompactions)
|
||||
.backgroundThreadCount(backgroundThreadCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCLIOptions() {
|
||||
return Arrays.asList(
|
||||
MAX_OPEN_FILES_FLAG,
|
||||
OptionParser.format(maxOpenFiles),
|
||||
CACHE_CAPACITY_FLAG,
|
||||
OptionParser.format(cacheCapacity),
|
||||
MAX_BACKGROUND_COMPACTIONS_FLAG,
|
||||
OptionParser.format(maxBackgroundCompactions),
|
||||
BACKGROUND_THREAD_COUNT_FLAG,
|
||||
OptionParser.format(backgroundThreadCount));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import tech.pegasys.pantheon.util.uint.UInt256;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Range;
|
||||
import picocli.CommandLine;
|
||||
|
||||
public class SynchronizerOptions implements CLIOptions<SynchronizerConfiguration.Builder> {
|
||||
private static final String BLOCK_PROPAGATION_RANGE_FLAG =
|
||||
"--Xsynchronizer-block-propagation-range";
|
||||
private static final String DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_HEIGHT_FLAG =
|
||||
"--Xsynchronizer-downloader-change-target-threshold-by-height";
|
||||
private static final String DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_TD_FLAG =
|
||||
"--Xsynchronizer-downloader-change-target-threshold-by-td";
|
||||
private static final String DOWNLOADER_HEADER_REQUEST_SIZE_FLAG =
|
||||
"--Xsynchronizer-downloader-header-request-size";
|
||||
private static final String DOWNLOADER_CHECKPOINT_TIMEOUTS_PERMITTED_FLAG =
|
||||
"--Xsynchronizer-downloader-checkpoint-timeouts-permitted";
|
||||
private static final String DOWNLOADER_CHAIN_SEGMENT_SIZE_FLAG =
|
||||
"--Xsynchronizer-downloader-chain-segment-size";
|
||||
private static final String DOWNLOADER_PARALLELISM_FLAG =
|
||||
"--Xsynchronizer-downloader-parallelism";
|
||||
private static final String TRANSACTIONS_PARALLELISM_FLAG =
|
||||
"--Xsynchronizer-transactions-parallelism";
|
||||
private static final String COMPUTATION_PARALLELISM_FLAG =
|
||||
"--Xsynchronizer-computation-parallelism";
|
||||
private static final String PIVOT_DISTANCE_FROM_HEAD_FLAG =
|
||||
"--Xsynchronizer-fast-sync-pivot-distance";
|
||||
private static final String FULL_VALIDATION_RATE_FLAG =
|
||||
"--Xsynchronizer-fast-sync-full-validation-rate";
|
||||
private static final String WORLD_STATE_HASH_COUNT_PER_REQUEST_FLAG =
|
||||
"--Xsynchronizer-world-state-hash-count-per-request";
|
||||
private static final String WORLD_STATE_REQUEST_PARALLELISM_FLAG =
|
||||
"--Xsynchronizer-world-state-request-parallelism";
|
||||
private static final String WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS_FLAG =
|
||||
"--Xsynchronizer-world-state-max-requests-without-progress";
|
||||
private static final String WORLD_STATE_MIN_MILLIS_BEFORE_STALLING_FLAG =
|
||||
"--Xsynchronizer-world-state-min-millis-before-stalling";
|
||||
|
||||
@CommandLine.Option(
|
||||
names = BLOCK_PROPAGATION_RANGE_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "-10..30",
|
||||
paramLabel = "<LONG>..<LONG>",
|
||||
description =
|
||||
"Range around chain head where inbound blocks are propagated (default: ${DEFAULT-VALUE})")
|
||||
public void parseBlockPropagationRange(final String arg) {
|
||||
blockPropagationRange = OptionParser.parseLongRange(arg);
|
||||
}
|
||||
|
||||
private Range<Long> blockPropagationRange =
|
||||
SynchronizerConfiguration.DEFAULT_BLOCK_PROPAGATION_RANGE;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_HEIGHT_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "200",
|
||||
paramLabel = "<LONG>",
|
||||
description =
|
||||
"Minimum height difference before switching fast sync download peers (default: ${DEFAULT-VALUE})")
|
||||
private long downloaderChangeTargetThresholdByHeight =
|
||||
SynchronizerConfiguration.DEFAULT_DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_HEIGHT;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_TD_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "1000000000000000000",
|
||||
paramLabel = "<UINT256>",
|
||||
description =
|
||||
"Minimum total difficulty difference before switching fast sync download peers (default: ${DEFAULT-VALUE})")
|
||||
private UInt256 downloaderChangeTargetThresholdByTd =
|
||||
SynchronizerConfiguration.DEFAULT_DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_TD;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = DOWNLOADER_HEADER_REQUEST_SIZE_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "200",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Number of headers to request per packet (default: ${DEFAULT-VALUE})")
|
||||
private int downloaderHeaderRequestSize =
|
||||
SynchronizerConfiguration.DEFAULT_DOWNLOADER_HEADER_REQUEST_SIZE;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = DOWNLOADER_CHECKPOINT_TIMEOUTS_PERMITTED_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "5",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of tries to attempt to download checkpoints before stopping (default: ${DEFAULT-VALUE})")
|
||||
private int downloaderCheckpointTimeoutsPermitted =
|
||||
SynchronizerConfiguration.DEFAULT_DOWNLOADER_CHECKPOINT_TIMEOUTS_PERMITTED;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = DOWNLOADER_CHAIN_SEGMENT_SIZE_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "200",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Distance between checkpoint headers (default: ${DEFAULT-VALUE})")
|
||||
private int downloaderChainSegmentSize =
|
||||
SynchronizerConfiguration.DEFAULT_DOWNLOADER_CHAIN_SEGMENT_SIZE;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = DOWNLOADER_PARALLELISM_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "4",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Number of threads to provide to chain downloader (default: ${DEFAULT-VALUE})")
|
||||
private int downloaderParallelism = SynchronizerConfiguration.DEFAULT_DOWNLOADER_PARALLELISM;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = TRANSACTIONS_PARALLELISM_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "2",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of threads to commit to transaction processing (default: ${DEFAULT-VALUE})")
|
||||
private int transactionsParallelism = SynchronizerConfiguration.DEFAULT_TRANSACTIONS_PARALLELISM;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = COMPUTATION_PARALLELISM_FLAG,
|
||||
hidden = true,
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of threads to make available for bulk hash computations during downloads (default: # of processors)")
|
||||
private int computationParallelism = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
@CommandLine.Option(
|
||||
names = PIVOT_DISTANCE_FROM_HEAD_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "50",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Distance from initial chain head to fast sync target (default: ${DEFAULT-VALUE})")
|
||||
private int fastSyncPivotDistance = SynchronizerConfiguration.DEFAULT_PIVOT_DISTANCE_FROM_HEAD;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = FULL_VALIDATION_RATE_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "0.1",
|
||||
paramLabel = "<FLOAT>",
|
||||
description = "Fraction of headers fast sync will fully validate (default: ${DEFAULT-VALUE})")
|
||||
private float fastSyncFullValidationRate = SynchronizerConfiguration.DEFAULT_FULL_VALIDATION_RATE;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = WORLD_STATE_HASH_COUNT_PER_REQUEST_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "384",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Fast sync world state hashes queried per request (default: ${DEFAULT-VALUE})")
|
||||
private int worldStateHashCountPerRequest =
|
||||
SynchronizerConfiguration.DEFAULT_WORLD_STATE_HASH_COUNT_PER_REQUEST;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = WORLD_STATE_REQUEST_PARALLELISM_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "10",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of concurrent requests to use when downloading fast sync world state (default: ${DEFAULT-VALUE})")
|
||||
private int worldStateRequestParallelism =
|
||||
SynchronizerConfiguration.DEFAULT_WORLD_STATE_REQUEST_PARALLELISM;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "1000",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Number of world state requests accepted without progress before considering the download stalled (default: ${DEFAULT-VALUE})")
|
||||
private int worldStateMaxRequestsWithoutProgress =
|
||||
SynchronizerConfiguration.DEFAULT_WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = WORLD_STATE_MIN_MILLIS_BEFORE_STALLING_FLAG,
|
||||
hidden = true,
|
||||
defaultValue = "300000",
|
||||
paramLabel = "<LONG>",
|
||||
description =
|
||||
"Minimum time in ms without progress before considering a world state download as stalled (default: ${DEFAULT-VALUE})")
|
||||
private long worldStateMinMillisBeforeStalling =
|
||||
SynchronizerConfiguration.DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING;
|
||||
|
||||
private SynchronizerOptions() {}
|
||||
|
||||
public static SynchronizerOptions create() {
|
||||
return new SynchronizerOptions();
|
||||
}
|
||||
|
||||
public static SynchronizerOptions fromConfig(final SynchronizerConfiguration config) {
|
||||
final SynchronizerOptions options = new SynchronizerOptions();
|
||||
options.blockPropagationRange = config.getBlockPropagationRange();
|
||||
options.downloaderChangeTargetThresholdByHeight =
|
||||
config.getDownloaderChangeTargetThresholdByHeight();
|
||||
options.downloaderChangeTargetThresholdByTd = config.getDownloaderChangeTargetThresholdByTd();
|
||||
options.downloaderHeaderRequestSize = config.getDownloaderHeaderRequestSize();
|
||||
options.downloaderCheckpointTimeoutsPermitted =
|
||||
config.getDownloaderCheckpointTimeoutsPermitted();
|
||||
options.downloaderChainSegmentSize = config.getDownloaderChainSegmentSize();
|
||||
options.downloaderParallelism = config.getDownloaderParallelism();
|
||||
options.transactionsParallelism = config.getTransactionsParallelism();
|
||||
options.computationParallelism = config.getComputationParallelism();
|
||||
options.fastSyncPivotDistance = config.getFastSyncPivotDistance();
|
||||
options.fastSyncFullValidationRate = config.getFastSyncFullValidationRate();
|
||||
options.worldStateHashCountPerRequest = config.getWorldStateHashCountPerRequest();
|
||||
options.worldStateRequestParallelism = config.getWorldStateRequestParallelism();
|
||||
options.worldStateMaxRequestsWithoutProgress = config.getWorldStateMaxRequestsWithoutProgress();
|
||||
options.worldStateMinMillisBeforeStalling = config.getWorldStateMinMillisBeforeStalling();
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SynchronizerConfiguration.Builder toDomainObject() {
|
||||
final SynchronizerConfiguration.Builder builder = SynchronizerConfiguration.builder();
|
||||
builder.blockPropagationRange(blockPropagationRange);
|
||||
builder.downloaderChangeTargetThresholdByHeight(downloaderChangeTargetThresholdByHeight);
|
||||
builder.downloaderChangeTargetThresholdByTd(downloaderChangeTargetThresholdByTd);
|
||||
builder.downloaderHeadersRequestSize(downloaderHeaderRequestSize);
|
||||
builder.downloaderCheckpointTimeoutsPermitted(downloaderCheckpointTimeoutsPermitted);
|
||||
builder.downloaderChainSegmentSize(downloaderChainSegmentSize);
|
||||
builder.downloaderParallelism(downloaderParallelism);
|
||||
builder.transactionsParallelism(transactionsParallelism);
|
||||
builder.computationParallelism(computationParallelism);
|
||||
builder.fastSyncPivotDistance(fastSyncPivotDistance);
|
||||
builder.fastSyncFullValidationRate(fastSyncFullValidationRate);
|
||||
builder.worldStateHashCountPerRequest(worldStateHashCountPerRequest);
|
||||
builder.worldStateRequestParallelism(worldStateRequestParallelism);
|
||||
builder.worldStateMaxRequestsWithoutProgress(worldStateMaxRequestsWithoutProgress);
|
||||
builder.worldStateMinMillisBeforeStalling(worldStateMinMillisBeforeStalling);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCLIOptions() {
|
||||
return Arrays.asList(
|
||||
BLOCK_PROPAGATION_RANGE_FLAG,
|
||||
OptionParser.format(blockPropagationRange),
|
||||
DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_HEIGHT_FLAG,
|
||||
OptionParser.format(downloaderChangeTargetThresholdByHeight),
|
||||
DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_TD_FLAG,
|
||||
OptionParser.format(downloaderChangeTargetThresholdByTd),
|
||||
DOWNLOADER_HEADER_REQUEST_SIZE_FLAG,
|
||||
OptionParser.format(downloaderHeaderRequestSize),
|
||||
DOWNLOADER_CHECKPOINT_TIMEOUTS_PERMITTED_FLAG,
|
||||
OptionParser.format(downloaderCheckpointTimeoutsPermitted),
|
||||
DOWNLOADER_CHAIN_SEGMENT_SIZE_FLAG,
|
||||
OptionParser.format(downloaderChainSegmentSize),
|
||||
DOWNLOADER_PARALLELISM_FLAG,
|
||||
OptionParser.format(downloaderParallelism),
|
||||
TRANSACTIONS_PARALLELISM_FLAG,
|
||||
OptionParser.format(transactionsParallelism),
|
||||
COMPUTATION_PARALLELISM_FLAG,
|
||||
OptionParser.format(computationParallelism),
|
||||
PIVOT_DISTANCE_FROM_HEAD_FLAG,
|
||||
OptionParser.format(fastSyncPivotDistance),
|
||||
FULL_VALIDATION_RATE_FLAG,
|
||||
OptionParser.format(fastSyncFullValidationRate),
|
||||
WORLD_STATE_HASH_COUNT_PER_REQUEST_FLAG,
|
||||
OptionParser.format(worldStateHashCountPerRequest),
|
||||
WORLD_STATE_REQUEST_PARALLELISM_FLAG,
|
||||
OptionParser.format(worldStateRequestParallelism),
|
||||
WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS_FLAG,
|
||||
OptionParser.format(worldStateMaxRequestsWithoutProgress),
|
||||
WORLD_STATE_MIN_MILLIS_BEFORE_STALLING_FLAG,
|
||||
OptionParser.format(worldStateMinMillisBeforeStalling));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import picocli.CommandLine;
|
||||
|
||||
public class TransactionPoolOptions implements CLIOptions<TransactionPoolConfiguration.Builder> {
|
||||
private static final String TX_MESSAGE_KEEP_ALIVE_SEC_FLAG =
|
||||
"--Xincoming-tx-messages-keep-alive-seconds";
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {TX_MESSAGE_KEEP_ALIVE_SEC_FLAG},
|
||||
paramLabel = "<INTEGER>",
|
||||
hidden = true,
|
||||
description =
|
||||
"Keep alive of incoming transaction messages in seconds (default: ${DEFAULT-VALUE})",
|
||||
arity = "1")
|
||||
private Integer txMessageKeepAliveSeconds =
|
||||
TransactionPoolConfiguration.DEFAULT_TX_MSG_KEEP_ALIVE;
|
||||
|
||||
private TransactionPoolOptions() {}
|
||||
|
||||
public static TransactionPoolOptions create() {
|
||||
return new TransactionPoolOptions();
|
||||
}
|
||||
|
||||
public static TransactionPoolOptions fromConfig(final TransactionPoolConfiguration config) {
|
||||
final TransactionPoolOptions options = TransactionPoolOptions.create();
|
||||
options.txMessageKeepAliveSeconds = config.getTxMessageKeepAliveSeconds();
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionPoolConfiguration.Builder toDomainObject() {
|
||||
return TransactionPoolConfiguration.builder()
|
||||
.txMessageKeepAliveSeconds(txMessageKeepAliveSeconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCLIOptions() {
|
||||
return Arrays.asList(
|
||||
TX_MESSAGE_KEEP_ALIVE_SEC_FLAG, OptionParser.format(txMessageKeepAliveSeconds));
|
||||
}
|
||||
}
|
||||
@@ -101,9 +101,9 @@ public class IbftLegacyPantheonControllerBuilder extends PantheonControllerBuild
|
||||
protocolContext.getWorldStateArchive(),
|
||||
networkId,
|
||||
fastSyncEnabled,
|
||||
syncConfig.downloaderParallelism(),
|
||||
syncConfig.transactionsParallelism(),
|
||||
syncConfig.computationParallelism(),
|
||||
syncConfig.getDownloaderParallelism(),
|
||||
syncConfig.getTransactionsParallelism(),
|
||||
syncConfig.getComputationParallelism(),
|
||||
clock,
|
||||
metricsSystem,
|
||||
ethereumWireProtocolConfiguration);
|
||||
|
||||
@@ -27,7 +27,7 @@ import tech.pegasys.pantheon.ethereum.core.MiningParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.Synchronizer;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocol;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.manager.EthContext;
|
||||
import tech.pegasys.pantheon.ethereum.eth.manager.EthProtocolManager;
|
||||
import tech.pegasys.pantheon.ethereum.eth.peervalidation.DaoForkPeerValidator;
|
||||
@@ -66,7 +66,7 @@ public abstract class PantheonControllerBuilder<C> {
|
||||
protected GenesisConfigFile genesisConfig;
|
||||
protected SynchronizerConfiguration syncConfig;
|
||||
protected EthProtocolManager ethProtocolManager;
|
||||
protected EthereumWireProtocolConfiguration ethereumWireProtocolConfiguration;
|
||||
protected EthProtocolConfiguration ethereumWireProtocolConfiguration;
|
||||
protected TransactionPoolConfiguration transactionPoolConfiguration;
|
||||
protected Integer networkId;
|
||||
protected MiningParameters miningParameters;
|
||||
@@ -101,9 +101,9 @@ public abstract class PantheonControllerBuilder<C> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public PantheonControllerBuilder<C> ethereumWireProtocolConfiguration(
|
||||
final EthereumWireProtocolConfiguration ethereumWireProtocolConfiguration) {
|
||||
this.ethereumWireProtocolConfiguration = ethereumWireProtocolConfiguration;
|
||||
public PantheonControllerBuilder<C> ethProtocolConfiguration(
|
||||
final EthProtocolConfiguration ethProtocolConfiguration) {
|
||||
this.ethereumWireProtocolConfiguration = ethProtocolConfiguration;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public abstract class PantheonControllerBuilder<C> {
|
||||
|
||||
final MutableBlockchain blockchain = protocolContext.getBlockchain();
|
||||
|
||||
final boolean fastSyncEnabled = syncConfig.syncMode().equals(SyncMode.FAST);
|
||||
final boolean fastSyncEnabled = syncConfig.getSyncMode().equals(SyncMode.FAST);
|
||||
ethProtocolManager = createEthProtocolManager(protocolContext, fastSyncEnabled);
|
||||
final SyncState syncState =
|
||||
new SyncState(blockchain, ethProtocolManager.ethContext().getEthPeers());
|
||||
@@ -308,9 +308,9 @@ public abstract class PantheonControllerBuilder<C> {
|
||||
protocolContext.getWorldStateArchive(),
|
||||
networkId,
|
||||
fastSyncEnabled,
|
||||
syncConfig.downloaderParallelism(),
|
||||
syncConfig.transactionsParallelism(),
|
||||
syncConfig.computationParallelism(),
|
||||
syncConfig.getDownloaderParallelism(),
|
||||
syncConfig.getTransactionsParallelism(),
|
||||
syncConfig.getComputationParallelism(),
|
||||
clock,
|
||||
metricsSystem,
|
||||
ethereumWireProtocolConfiguration);
|
||||
|
||||
@@ -21,7 +21,7 @@ import tech.pegasys.pantheon.ethereum.core.Address;
|
||||
import tech.pegasys.pantheon.ethereum.core.InMemoryStorageProvider;
|
||||
import tech.pegasys.pantheon.ethereum.core.MiningParametersTestBuilder;
|
||||
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.PrecompiledContract;
|
||||
@@ -54,7 +54,7 @@ public class PrivacyTest {
|
||||
new PantheonController.Builder()
|
||||
.fromGenesisConfig(GenesisConfigFile.mainnet())
|
||||
.synchronizerConfiguration(SynchronizerConfiguration.builder().build())
|
||||
.ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig())
|
||||
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.storageProvider(new InMemoryStorageProvider())
|
||||
.networkId(1)
|
||||
.miningParameters(new MiningParametersTestBuilder().enabled(false).build())
|
||||
|
||||
@@ -30,7 +30,7 @@ import tech.pegasys.pantheon.ethereum.core.BlockSyncTestUtils;
|
||||
import tech.pegasys.pantheon.ethereum.core.InMemoryStorageProvider;
|
||||
import tech.pegasys.pantheon.ethereum.core.MiningParametersTestBuilder;
|
||||
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SyncMode;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
@@ -124,7 +124,7 @@ public final class RunnerTest {
|
||||
new MainnetPantheonControllerBuilder()
|
||||
.genesisConfigFile(GenesisConfigFile.mainnet())
|
||||
.synchronizerConfiguration(syncConfigAhead)
|
||||
.ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig())
|
||||
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.dataDirectory(dataDirAhead)
|
||||
.networkId(networkId)
|
||||
.miningParameters(new MiningParametersTestBuilder().enabled(false).build())
|
||||
@@ -143,7 +143,7 @@ public final class RunnerTest {
|
||||
new MainnetPantheonControllerBuilder()
|
||||
.genesisConfigFile(GenesisConfigFile.mainnet())
|
||||
.synchronizerConfiguration(syncConfigAhead)
|
||||
.ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig())
|
||||
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.dataDirectory(dataDirAhead)
|
||||
.networkId(networkId)
|
||||
.miningParameters(new MiningParametersTestBuilder().enabled(false).build())
|
||||
@@ -201,7 +201,7 @@ public final class RunnerTest {
|
||||
new MainnetPantheonControllerBuilder()
|
||||
.genesisConfigFile(GenesisConfigFile.mainnet())
|
||||
.synchronizerConfiguration(syncConfigBehind)
|
||||
.ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig())
|
||||
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.dataDirectory(dataDirBehind)
|
||||
.networkId(networkId)
|
||||
.miningParameters(new MiningParametersTestBuilder().enabled(false).build())
|
||||
@@ -330,7 +330,7 @@ public final class RunnerTest {
|
||||
|
||||
private StorageProvider createKeyValueStorageProvider(final Path dbAhead) throws IOException {
|
||||
return RocksDbStorageProvider.create(
|
||||
new RocksDbConfiguration.Builder().databaseDir(dbAhead).build(), new NoOpMetricsSystem());
|
||||
RocksDbConfiguration.builder().databaseDir(dbAhead).build(), new NoOpMetricsSystem());
|
||||
}
|
||||
|
||||
private JsonRpcConfiguration jsonRpcConfiguration() {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class BlockSubCommandTest extends CommandTestAbstract {
|
||||
// Block sub-command
|
||||
@Test
|
||||
public void blockSubCommandExistAnbHaveSubCommands() {
|
||||
CommandSpec spec = parseCommand();
|
||||
CommandSpec spec = parseCommand().getSpec();
|
||||
assertThat(spec.subcommands()).containsKeys(BLOCK_SUBCOMMAND_NAME);
|
||||
assertThat(spec.subcommands().get(BLOCK_SUBCOMMAND_NAME).getSubcommands())
|
||||
.containsKeys(BLOCK_IMPORT_SUBCOMMAND_NAME);
|
||||
|
||||
@@ -23,12 +23,15 @@ import static org.mockito.Mockito.when;
|
||||
import tech.pegasys.pantheon.Runner;
|
||||
import tech.pegasys.pantheon.RunnerBuilder;
|
||||
import tech.pegasys.pantheon.cli.config.EthNetworkConfig;
|
||||
import tech.pegasys.pantheon.cli.options.EthProtocolOptions;
|
||||
import tech.pegasys.pantheon.cli.options.RocksDBOptions;
|
||||
import tech.pegasys.pantheon.cli.options.SynchronizerOptions;
|
||||
import tech.pegasys.pantheon.cli.options.TransactionPoolOptions;
|
||||
import tech.pegasys.pantheon.cli.subcommands.PublicKeySubCommand.KeyLoader;
|
||||
import tech.pegasys.pantheon.controller.PantheonController;
|
||||
import tech.pegasys.pantheon.controller.PantheonControllerBuilder;
|
||||
import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair;
|
||||
import tech.pegasys.pantheon.ethereum.ProtocolContext;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.manager.EthProtocolManager;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.BlockBroadcaster;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
@@ -40,7 +43,6 @@ import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule;
|
||||
import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration;
|
||||
import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration;
|
||||
import tech.pegasys.pantheon.services.PantheonPluginContextImpl;
|
||||
import tech.pegasys.pantheon.services.kvstore.RocksDbConfiguration;
|
||||
import tech.pegasys.pantheon.util.BlockImporter;
|
||||
import tech.pegasys.pantheon.util.bytes.BytesValue;
|
||||
|
||||
@@ -67,6 +69,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import picocli.CommandLine;
|
||||
import picocli.CommandLine.Help.Ansi;
|
||||
import picocli.CommandLine.Model.CommandSpec;
|
||||
import picocli.CommandLine.RunLast;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@@ -81,42 +84,37 @@ public abstract class CommandTestAbstract {
|
||||
private final PrintStream errPrintStream = new PrintStream(commandErrorOutput);
|
||||
private final HashMap<String, String> environment = new HashMap<>();
|
||||
|
||||
@Mock RunnerBuilder mockRunnerBuilder;
|
||||
@Mock Runner mockRunner;
|
||||
@Mock protected RunnerBuilder mockRunnerBuilder;
|
||||
@Mock protected Runner mockRunner;
|
||||
|
||||
@Mock PantheonController.Builder mockControllerBuilderFactory;
|
||||
@Mock protected PantheonController.Builder mockControllerBuilderFactory;
|
||||
|
||||
@Mock PantheonControllerBuilder<Void> mockControllerBuilder;
|
||||
@Mock EthProtocolManager mockEthProtocolManager;
|
||||
@Mock ProtocolSchedule<Object> mockProtocolSchedule;
|
||||
@Mock ProtocolContext<Object> mockProtocolContext;
|
||||
@Mock BlockBroadcaster mockBlockBroadcaster;
|
||||
@Mock SynchronizerConfiguration.Builder mockSyncConfBuilder;
|
||||
@Mock EthereumWireProtocolConfiguration.Builder mockEthereumWireProtocolConfigurationBuilder;
|
||||
@Mock SynchronizerConfiguration mockSyncConf;
|
||||
@Mock RocksDbConfiguration.Builder mockRocksDbConfBuilder;
|
||||
@Mock RocksDbConfiguration mockRocksDbConf;
|
||||
protected TransactionPoolConfiguration.Builder mockTransactionPoolConfigurationBuilder =
|
||||
TransactionPoolConfiguration.builder();
|
||||
@Mock TransactionPoolConfiguration mockTransactionPoolConfiguration;
|
||||
@Mock PantheonController<Object> mockController;
|
||||
@Mock BlockImporter mockBlockImporter;
|
||||
@Mock Logger mockLogger;
|
||||
@Mock PantheonPluginContextImpl mockPantheonPluginContext;
|
||||
@Mock protected PantheonControllerBuilder<Void> mockControllerBuilder;
|
||||
@Mock protected EthProtocolManager mockEthProtocolManager;
|
||||
@Mock protected ProtocolSchedule<Object> mockProtocolSchedule;
|
||||
@Mock protected ProtocolContext<Object> mockProtocolContext;
|
||||
@Mock protected BlockBroadcaster mockBlockBroadcaster;
|
||||
@Mock protected PantheonController<Object> mockController;
|
||||
@Mock protected BlockImporter mockBlockImporter;
|
||||
@Mock protected Logger mockLogger;
|
||||
@Mock protected PantheonPluginContextImpl mockPantheonPluginContext;
|
||||
|
||||
@Captor ArgumentCaptor<Collection<BytesValue>> bytesValueCollectionCollector;
|
||||
@Captor ArgumentCaptor<Collection<String>> stringListArgumentCaptor;
|
||||
@Captor ArgumentCaptor<Path> pathArgumentCaptor;
|
||||
@Captor ArgumentCaptor<File> fileArgumentCaptor;
|
||||
@Captor ArgumentCaptor<String> stringArgumentCaptor;
|
||||
@Captor ArgumentCaptor<Integer> intArgumentCaptor;
|
||||
@Captor ArgumentCaptor<EthNetworkConfig> ethNetworkConfigArgumentCaptor;
|
||||
@Captor ArgumentCaptor<JsonRpcConfiguration> jsonRpcConfigArgumentCaptor;
|
||||
@Captor ArgumentCaptor<GraphQLConfiguration> graphQLConfigArgumentCaptor;
|
||||
@Captor ArgumentCaptor<WebSocketConfiguration> wsRpcConfigArgumentCaptor;
|
||||
@Captor ArgumentCaptor<MetricsConfiguration> metricsConfigArgumentCaptor;
|
||||
@Captor ArgumentCaptor<PermissioningConfiguration> permissioningConfigurationArgumentCaptor;
|
||||
@Captor ArgumentCaptor<TransactionPoolConfiguration> transactionPoolConfigurationArgumentCaptor;
|
||||
@Captor protected ArgumentCaptor<Collection<BytesValue>> bytesValueCollectionCollector;
|
||||
@Captor protected ArgumentCaptor<Path> pathArgumentCaptor;
|
||||
@Captor protected ArgumentCaptor<File> fileArgumentCaptor;
|
||||
@Captor protected ArgumentCaptor<String> stringArgumentCaptor;
|
||||
@Captor protected ArgumentCaptor<Integer> intArgumentCaptor;
|
||||
@Captor protected ArgumentCaptor<EthNetworkConfig> ethNetworkConfigArgumentCaptor;
|
||||
@Captor protected ArgumentCaptor<SynchronizerConfiguration> syncConfigurationCaptor;
|
||||
@Captor protected ArgumentCaptor<JsonRpcConfiguration> jsonRpcConfigArgumentCaptor;
|
||||
@Captor protected ArgumentCaptor<GraphQLConfiguration> graphQLConfigArgumentCaptor;
|
||||
@Captor protected ArgumentCaptor<WebSocketConfiguration> wsRpcConfigArgumentCaptor;
|
||||
@Captor protected ArgumentCaptor<MetricsConfiguration> metricsConfigArgumentCaptor;
|
||||
|
||||
@Captor
|
||||
protected ArgumentCaptor<PermissioningConfiguration> permissioningConfigurationArgumentCaptor;
|
||||
|
||||
@Captor protected ArgumentCaptor<TransactionPoolConfiguration> transactionPoolConfigCaptor;
|
||||
|
||||
@Rule public final TemporaryFolder temp = new TemporaryFolder();
|
||||
|
||||
@@ -132,8 +130,7 @@ public abstract class CommandTestAbstract {
|
||||
// doReturn used because of generic PantheonController
|
||||
doReturn(mockControllerBuilder).when(mockControllerBuilderFactory).fromEthNetworkConfig(any());
|
||||
when(mockControllerBuilder.synchronizerConfiguration(any())).thenReturn(mockControllerBuilder);
|
||||
when(mockControllerBuilder.ethereumWireProtocolConfiguration(any()))
|
||||
.thenReturn(mockControllerBuilder);
|
||||
when(mockControllerBuilder.ethProtocolConfiguration(any())).thenReturn(mockControllerBuilder);
|
||||
when(mockControllerBuilder.rocksDbConfiguration(any())).thenReturn(mockControllerBuilder);
|
||||
when(mockControllerBuilder.transactionPoolConfiguration(any()))
|
||||
.thenReturn(mockControllerBuilder);
|
||||
@@ -152,17 +149,6 @@ public abstract class CommandTestAbstract {
|
||||
|
||||
when(mockEthProtocolManager.getBlockBroadcaster()).thenReturn(mockBlockBroadcaster);
|
||||
|
||||
when(mockSyncConfBuilder.syncMode(any())).thenReturn(mockSyncConfBuilder);
|
||||
when(mockSyncConfBuilder.maxTrailingPeers(anyInt())).thenReturn(mockSyncConfBuilder);
|
||||
when(mockSyncConfBuilder.fastSyncMinimumPeerCount(anyInt())).thenReturn(mockSyncConfBuilder);
|
||||
when(mockSyncConfBuilder.build()).thenReturn(mockSyncConf);
|
||||
|
||||
when(mockEthereumWireProtocolConfigurationBuilder.build())
|
||||
.thenReturn(EthereumWireProtocolConfiguration.defaultConfig());
|
||||
|
||||
when(mockRocksDbConfBuilder.databaseDir(any())).thenReturn(mockRocksDbConfBuilder);
|
||||
when(mockRocksDbConfBuilder.build()).thenReturn(mockRocksDbConf);
|
||||
|
||||
when(mockRunnerBuilder.vertx(any())).thenReturn(mockRunnerBuilder);
|
||||
when(mockRunnerBuilder.pantheonController(any())).thenReturn(mockRunnerBuilder);
|
||||
when(mockRunnerBuilder.discovery(anyBoolean())).thenReturn(mockRunnerBuilder);
|
||||
@@ -199,20 +185,19 @@ public abstract class CommandTestAbstract {
|
||||
environment.put(name, value);
|
||||
}
|
||||
|
||||
protected CommandLine.Model.CommandSpec parseCommand(final String... args) {
|
||||
protected TestPantheonCommand parseCommand(final String... args) {
|
||||
return parseCommand(System.in, args);
|
||||
}
|
||||
|
||||
protected CommandLine.Model.CommandSpec parseCommand(
|
||||
final KeyLoader keyLoader, final String... args) {
|
||||
protected TestPantheonCommand parseCommand(final KeyLoader keyLoader, final String... args) {
|
||||
return parseCommand(keyLoader, System.in, args);
|
||||
}
|
||||
|
||||
protected CommandLine.Model.CommandSpec parseCommand(final InputStream in, final String... args) {
|
||||
protected TestPantheonCommand parseCommand(final InputStream in, final String... args) {
|
||||
return parseCommand(f -> KeyPair.generate(), in, args);
|
||||
}
|
||||
|
||||
private CommandLine.Model.CommandSpec parseCommand(
|
||||
private TestPantheonCommand parseCommand(
|
||||
final KeyLoader keyLoader, final InputStream in, final String... args) {
|
||||
// turn off ansi usage globally in picocli
|
||||
System.setProperty("picocli.ansi", "false");
|
||||
@@ -223,10 +208,6 @@ public abstract class CommandTestAbstract {
|
||||
mockBlockImporter,
|
||||
mockRunnerBuilder,
|
||||
mockControllerBuilderFactory,
|
||||
mockSyncConfBuilder,
|
||||
mockEthereumWireProtocolConfigurationBuilder,
|
||||
mockRocksDbConfBuilder,
|
||||
mockTransactionPoolConfigurationBuilder,
|
||||
keyLoader,
|
||||
mockPantheonPluginContext,
|
||||
environment);
|
||||
@@ -237,11 +218,11 @@ public abstract class CommandTestAbstract {
|
||||
pantheonCommand.exceptionHandler().useErr(errPrintStream).useAnsi(Ansi.OFF),
|
||||
in,
|
||||
args);
|
||||
return pantheonCommand.spec;
|
||||
return pantheonCommand;
|
||||
}
|
||||
|
||||
@CommandLine.Command
|
||||
static class TestPantheonCommand extends PantheonCommand {
|
||||
public static class TestPantheonCommand extends PantheonCommand {
|
||||
@CommandLine.Spec CommandLine.Model.CommandSpec spec;
|
||||
private final KeyLoader keyLoader;
|
||||
|
||||
@@ -255,10 +236,6 @@ public abstract class CommandTestAbstract {
|
||||
final BlockImporter mockBlockImporter,
|
||||
final RunnerBuilder mockRunnerBuilder,
|
||||
final PantheonController.Builder controllerBuilderFactory,
|
||||
final SynchronizerConfiguration.Builder mockSyncConfBuilder,
|
||||
final EthereumWireProtocolConfiguration.Builder mockEthereumConfigurationMockBuilder,
|
||||
final RocksDbConfiguration.Builder mockRocksDbConfBuilder,
|
||||
final TransactionPoolConfiguration.Builder mockTransactionPoolConfigurationBuilder,
|
||||
final KeyLoader keyLoader,
|
||||
final PantheonPluginContextImpl pantheonPluginContext,
|
||||
final Map<String, String> environment) {
|
||||
@@ -267,13 +244,29 @@ public abstract class CommandTestAbstract {
|
||||
mockBlockImporter,
|
||||
mockRunnerBuilder,
|
||||
controllerBuilderFactory,
|
||||
mockSyncConfBuilder,
|
||||
mockEthereumConfigurationMockBuilder,
|
||||
mockRocksDbConfBuilder,
|
||||
mockTransactionPoolConfigurationBuilder,
|
||||
pantheonPluginContext,
|
||||
environment);
|
||||
this.keyLoader = keyLoader;
|
||||
}
|
||||
|
||||
public CommandSpec getSpec() {
|
||||
return spec;
|
||||
}
|
||||
|
||||
public RocksDBOptions getRocksDBOptions() {
|
||||
return rocksDBOptions;
|
||||
}
|
||||
|
||||
public SynchronizerOptions getSynchronizerOptions() {
|
||||
return synchronizerOptions;
|
||||
}
|
||||
|
||||
public EthProtocolOptions getEthProtocolOptions() {
|
||||
return ethProtocolOptions;
|
||||
}
|
||||
|
||||
public TransactionPoolOptions getTransactionPoolOptions() {
|
||||
return transactionPoolOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import tech.pegasys.pantheon.ethereum.core.MiningParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SyncMode;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.graphql.GraphQLConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi;
|
||||
@@ -164,14 +165,13 @@ public class PantheonCommandTest extends CommandTestAbstract {
|
||||
verify(mockControllerBuilderFactory).fromEthNetworkConfig(ethNetworkArg.capture());
|
||||
final ArgumentCaptor<MiningParameters> miningArg =
|
||||
ArgumentCaptor.forClass(MiningParameters.class);
|
||||
verify(mockControllerBuilder).synchronizerConfiguration(isNotNull());
|
||||
verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture());
|
||||
verify(mockControllerBuilder).dataDirectory(isNotNull());
|
||||
verify(mockControllerBuilder).miningParameters(miningArg.capture());
|
||||
verify(mockControllerBuilder).nodePrivateKeyFile(isNotNull());
|
||||
verify(mockControllerBuilder).build();
|
||||
|
||||
verify(mockSyncConfBuilder).syncMode(eq(SyncMode.FULL));
|
||||
|
||||
assertThat(syncConfigurationCaptor.getValue().getSyncMode()).isEqualTo(SyncMode.FULL);
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
assertThat(miningArg.getValue().getCoinbase()).isEqualTo(Optional.empty());
|
||||
assertThat(miningArg.getValue().getMinTransactionGasPrice()).isEqualTo(Wei.of(1000));
|
||||
@@ -328,9 +328,10 @@ public class PantheonCommandTest extends CommandTestAbstract {
|
||||
.build();
|
||||
verify(mockControllerBuilder).dataDirectory(eq(Paths.get("/opt/pantheon").toAbsolutePath()));
|
||||
verify(mockControllerBuilderFactory).fromEthNetworkConfig(eq(networkConfig));
|
||||
verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture());
|
||||
|
||||
verify(mockSyncConfBuilder).syncMode(eq(SyncMode.FAST));
|
||||
verify(mockSyncConfBuilder).fastSyncMinimumPeerCount(eq(13));
|
||||
assertThat(syncConfigurationCaptor.getValue().getSyncMode()).isEqualTo(SyncMode.FAST);
|
||||
assertThat(syncConfigurationCaptor.getValue().getFastSyncMinimumPeerCount()).isEqualTo(13);
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
@@ -651,7 +652,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
|
||||
final Path toml = createTempFile("toml", Resources.toByteArray(configFile));
|
||||
|
||||
// Parse it.
|
||||
final CommandLine.Model.CommandSpec spec = parseCommand("--config-file", toml.toString());
|
||||
final CommandLine.Model.CommandSpec spec = parseCommand("--config-file", toml.toString()).spec;
|
||||
final TomlParseResult tomlResult = Toml.parse(toml);
|
||||
|
||||
// Verify we configured everything
|
||||
@@ -717,9 +718,11 @@ public class PantheonCommandTest extends CommandTestAbstract {
|
||||
verify(mockRunnerBuilder).metricsConfiguration(eq(metricsConfiguration));
|
||||
verify(mockRunnerBuilder).build();
|
||||
verify(mockControllerBuilder).build();
|
||||
verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture());
|
||||
|
||||
verify(mockSyncConfBuilder).syncMode(eq(SyncMode.FULL));
|
||||
verify(mockSyncConfBuilder).fastSyncMinimumPeerCount(eq(5));
|
||||
final SynchronizerConfiguration syncConfig = syncConfigurationCaptor.getValue();
|
||||
assertThat(syncConfig.getSyncMode()).isEqualTo(SyncMode.FULL);
|
||||
assertThat(syncConfig.getFastSyncMinimumPeerCount()).isEqualTo(5);
|
||||
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
|
||||
@@ -1220,13 +1223,24 @@ public class PantheonCommandTest extends CommandTestAbstract {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void syncModeOptionMustBeUsed() {
|
||||
|
||||
public void syncMode_fast() {
|
||||
parseCommand("--sync-mode", "FAST");
|
||||
verify(mockSyncConfBuilder).syncMode(eq(SyncMode.FAST));
|
||||
verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture());
|
||||
|
||||
final SynchronizerConfiguration syncConfig = syncConfigurationCaptor.getValue();
|
||||
assertThat(syncConfig.getSyncMode()).isEqualTo(SyncMode.FAST);
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void syncMode_full() {
|
||||
parseCommand("--sync-mode", "FULL");
|
||||
verify(mockSyncConfBuilder).syncMode(eq(SyncMode.FULL));
|
||||
verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture());
|
||||
|
||||
final SynchronizerConfiguration syncConfig = syncConfigurationCaptor.getValue();
|
||||
assertThat(syncConfig.getSyncMode()).isEqualTo(SyncMode.FULL);
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
@@ -1244,10 +1258,12 @@ public class PantheonCommandTest extends CommandTestAbstract {
|
||||
|
||||
@Test
|
||||
public void parsesValidFastSyncMinPeersOption() {
|
||||
|
||||
parseCommand("--sync-mode", "FAST", "--fast-sync-min-peers", "11");
|
||||
verify(mockSyncConfBuilder).syncMode(eq(SyncMode.FAST));
|
||||
verify(mockSyncConfBuilder).fastSyncMinimumPeerCount(eq(11));
|
||||
verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture());
|
||||
|
||||
final SynchronizerConfiguration syncConfig = syncConfigurationCaptor.getValue();
|
||||
assertThat(syncConfig.getSyncMode()).isEqualTo(SyncMode.FAST);
|
||||
assertThat(syncConfig.getFastSyncMinimumPeerCount()).isEqualTo(11);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
@@ -1262,89 +1278,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
|
||||
.contains("Invalid value for option '--fast-sync-min-peers': 'ten' is not an int");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesValidEwpMaxGetHeadersOptions() {
|
||||
|
||||
parseCommand("--Xewp-max-get-headers", "13");
|
||||
verify(mockEthereumWireProtocolConfigurationBuilder).build();
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesInvalidEwpMaxGetHeadersOptionsShouldFail() {
|
||||
|
||||
parseCommand("--Xewp-max-get-headers", "-13");
|
||||
verifyZeroInteractions(mockRunnerBuilder);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString())
|
||||
.contains(
|
||||
"Invalid value for option '--Xewp-max-get-headers': cannot convert '-13' to PositiveNumber");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesValidEwpMaxGetBodiesOptions() {
|
||||
|
||||
parseCommand("--Xewp-max-get-bodies", "14");
|
||||
verify(mockEthereumWireProtocolConfigurationBuilder).build();
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesInvalidEwpMaxGetBodiesOptionsShouldFail() {
|
||||
|
||||
parseCommand("--Xewp-max-get-bodies", "-14");
|
||||
verifyZeroInteractions(mockRunnerBuilder);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString())
|
||||
.contains(
|
||||
"Invalid value for option '--Xewp-max-get-bodies': cannot convert '-14' to PositiveNumber");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesValidEwpMaxGetReceiptsOptions() {
|
||||
|
||||
parseCommand("--Xewp-max-get-receipts", "15");
|
||||
verify(mockEthereumWireProtocolConfigurationBuilder).build();
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesInvalidEwpMaxGetReceiptsOptionsShouldFail() {
|
||||
|
||||
parseCommand("--Xewp-max-get-receipts", "-15");
|
||||
verifyZeroInteractions(mockRunnerBuilder);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString())
|
||||
.contains(
|
||||
"Invalid value for option '--Xewp-max-get-receipts': cannot convert '-15' to PositiveNumber");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesValidEwpMaxGetNodeDataOptions() {
|
||||
|
||||
parseCommand("--Xewp-max-get-node-data", "16");
|
||||
verify(mockEthereumWireProtocolConfigurationBuilder).build();
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesInvalidEwpMaxGetNodeDataOptionsShouldFail() {
|
||||
|
||||
parseCommand("--Xewp-max-get-node-data", "-16");
|
||||
verifyZeroInteractions(mockRunnerBuilder);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString())
|
||||
.contains(
|
||||
"Invalid value for option '--Xewp-max-get-node-data': cannot convert '-16' to PositiveNumber");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rpcHttpEnabledPropertyDefaultIsFalse() {
|
||||
parseCommand();
|
||||
@@ -2610,26 +2543,13 @@ public class PantheonCommandTest extends CommandTestAbstract {
|
||||
final int pendingTxRetentionHours = 999;
|
||||
parseCommand("--tx-pool-retention-hours", String.valueOf(pendingTxRetentionHours));
|
||||
verify(mockControllerBuilder)
|
||||
.transactionPoolConfiguration(transactionPoolConfigurationArgumentCaptor.capture());
|
||||
assertThat(transactionPoolConfigurationArgumentCaptor.getValue().getPendingTxRetentionPeriod())
|
||||
.transactionPoolConfiguration(transactionPoolConfigCaptor.capture());
|
||||
assertThat(transactionPoolConfigCaptor.getValue().getPendingTxRetentionPeriod())
|
||||
.isEqualTo(pendingTxRetentionHours);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void txMessageKeepAliveSeconds() {
|
||||
final int txMessageKeepAliveSeconds = 999;
|
||||
parseCommand(
|
||||
"--Xincoming-tx-messages-keep-alive-seconds", String.valueOf(txMessageKeepAliveSeconds));
|
||||
verify(mockControllerBuilder)
|
||||
.transactionPoolConfiguration(transactionPoolConfigurationArgumentCaptor.capture());
|
||||
assertThat(transactionPoolConfigurationArgumentCaptor.getValue().getTxMessageKeepAliveSeconds())
|
||||
.isEqualTo(txMessageKeepAliveSeconds);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void txMessageKeepAliveSecondsWithInvalidInputShouldFail() {
|
||||
parseCommand("--Xincoming-tx-messages-keep-alive-seconds", "acbd");
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PasswordSubCommandTest extends CommandTestAbstract {
|
||||
|
||||
@Test
|
||||
public void passwordSubCommandExistAnbHaveSubCommands() {
|
||||
final CommandSpec spec = parseCommand();
|
||||
final CommandSpec spec = parseCommand().getSpec();
|
||||
assertThat(spec.subcommands()).containsKeys("password");
|
||||
assertThat(spec.subcommands().get("password").getSubcommands()).containsKeys("hash");
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
|
||||
@@ -78,7 +78,7 @@ public class PublicKeySubCommandTest extends CommandTestAbstract {
|
||||
// public-key sub-command
|
||||
@Test
|
||||
public void publicKeySubCommandExistAnbHaveSubCommands() {
|
||||
CommandSpec spec = parseCommand();
|
||||
CommandSpec spec = parseCommand().getSpec();
|
||||
assertThat(spec.subcommands()).containsKeys(PUBLIC_KEY_SUBCOMMAND_NAME);
|
||||
assertThat(spec.subcommands().get(PUBLIC_KEY_SUBCOMMAND_NAME).getSubcommands())
|
||||
.containsKeys(PUBLIC_KEY_EXPORT_SUBCOMMAND_NAME)
|
||||
|
||||
@@ -75,7 +75,7 @@ public class OperatorSubCommandTest extends CommandTestAbstract {
|
||||
|
||||
@Test
|
||||
public void operatorSubCommandExistAndHaveSubCommands() {
|
||||
final CommandSpec spec = parseCommand();
|
||||
final CommandSpec spec = parseCommand().getSpec();
|
||||
assertThat(spec.subcommands()).containsKeys(COMMAND_NAME);
|
||||
assertThat(spec.subcommands().get(COMMAND_NAME).getSubcommands())
|
||||
.containsKeys(GENERATE_BLOCKCHAIN_CONFIG_SUBCOMMAND_NAME);
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import tech.pegasys.pantheon.cli.CommandTestAbstract;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public abstract class AbstractCLIOptionsTest<D, T extends CLIOptions<D>>
|
||||
extends CommandTestAbstract {
|
||||
@Test
|
||||
public void fromDomainObject_default() {
|
||||
fromDomainObject(createDefaultDomainObject());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromDomainObject_customize() {
|
||||
fromDomainObject(createCustomizedDomainObject());
|
||||
}
|
||||
|
||||
private void fromDomainObject(final D domainObject) {
|
||||
final T options = optionsFromDomainObject(domainObject);
|
||||
final D domainObjectFromOptions = options.toDomainObject();
|
||||
|
||||
final List<String> fieldsToIgnore = getFieldsToIgnore();
|
||||
final String[] ignored = fieldsToIgnore.toArray(new String[0]);
|
||||
assertThat(domainObjectFromOptions).isEqualToIgnoringGivenFields(domainObject, ignored);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCLIOptions_default() {
|
||||
getCLIOptions(createDefaultDomainObject());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCLIOptions_custom() {
|
||||
getCLIOptions(createCustomizedDomainObject());
|
||||
}
|
||||
|
||||
private void getCLIOptions(final D domainObject) {
|
||||
T options = optionsFromDomainObject(domainObject);
|
||||
final String[] cliOptions = options.getCLIOptions().toArray(new String[0]);
|
||||
|
||||
final TestPantheonCommand cmd = parseCommand(cliOptions);
|
||||
final T optionsFromCommand = getOptionsFromPantheonCommand(cmd);
|
||||
|
||||
assertThat(optionsFromCommand).isEqualToComparingFieldByField(options);
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultValues() {
|
||||
final TestPantheonCommand cmd = parseCommand();
|
||||
|
||||
final D defaultDomainObject = createDefaultDomainObject();
|
||||
final T defaultOptions = optionsFromDomainObject(defaultDomainObject);
|
||||
final T optionsFromCommand = getOptionsFromPantheonCommand(cmd);
|
||||
|
||||
// Check default values supplied by CLI match expected default values
|
||||
final String[] fieldsToIgnore = getFieldsWithComputedDefaults().toArray(new String[0]);
|
||||
assertThat(optionsFromCommand).isEqualToIgnoringGivenFields(defaultOptions, fieldsToIgnore);
|
||||
}
|
||||
|
||||
abstract D createDefaultDomainObject();
|
||||
|
||||
abstract D createCustomizedDomainObject();
|
||||
|
||||
protected List<String> getFieldsWithComputedDefaults() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
protected List<String> getFieldsToIgnore() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
abstract T optionsFromDomainObject(D domainObject);
|
||||
|
||||
abstract T getOptionsFromPantheonCommand(final TestPantheonCommand pantheonCommand);
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.util.number.PositiveNumber;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class EthProtocolOptionsTest
|
||||
extends AbstractCLIOptionsTest<EthProtocolConfiguration, EthProtocolOptions> {
|
||||
|
||||
@Test
|
||||
public void parsesValidEwpMaxGetHeadersOptions() {
|
||||
|
||||
final TestPantheonCommand cmd = parseCommand("--Xewp-max-get-headers", "13");
|
||||
|
||||
final EthProtocolOptions options = getOptionsFromPantheonCommand(cmd);
|
||||
final EthProtocolConfiguration config = options.toDomainObject();
|
||||
assertThat(config.getMaxGetBlockHeaders()).isEqualTo(13);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesInvalidEwpMaxGetHeadersOptionsShouldFail() {
|
||||
parseCommand("--Xewp-max-get-headers", "-13");
|
||||
verifyZeroInteractions(mockRunnerBuilder);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString())
|
||||
.contains(
|
||||
"Invalid value for option '--Xewp-max-get-headers': cannot convert '-13' to PositiveNumber");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesValidEwpMaxGetBodiesOptions() {
|
||||
final TestPantheonCommand cmd = parseCommand("--Xewp-max-get-bodies", "14");
|
||||
|
||||
final EthProtocolOptions options = getOptionsFromPantheonCommand(cmd);
|
||||
final EthProtocolConfiguration config = options.toDomainObject();
|
||||
assertThat(config.getMaxGetBlockBodies()).isEqualTo(14);
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesInvalidEwpMaxGetBodiesOptionsShouldFail() {
|
||||
parseCommand("--Xewp-max-get-bodies", "-14");
|
||||
verifyZeroInteractions(mockRunnerBuilder);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString())
|
||||
.contains(
|
||||
"Invalid value for option '--Xewp-max-get-bodies': cannot convert '-14' to PositiveNumber");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesValidEwpMaxGetReceiptsOptions() {
|
||||
final TestPantheonCommand cmd = parseCommand("--Xewp-max-get-receipts", "15");
|
||||
|
||||
final EthProtocolOptions options = getOptionsFromPantheonCommand(cmd);
|
||||
final EthProtocolConfiguration config = options.toDomainObject();
|
||||
assertThat(config.getMaxGetReceipts()).isEqualTo(15);
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesInvalidEwpMaxGetReceiptsOptionsShouldFail() {
|
||||
parseCommand("--Xewp-max-get-receipts", "-15");
|
||||
|
||||
verifyZeroInteractions(mockRunnerBuilder);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString())
|
||||
.contains(
|
||||
"Invalid value for option '--Xewp-max-get-receipts': cannot convert '-15' to PositiveNumber");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesValidEwpMaxGetNodeDataOptions() {
|
||||
final TestPantheonCommand cmd = parseCommand("--Xewp-max-get-node-data", "16");
|
||||
|
||||
final EthProtocolOptions options = getOptionsFromPantheonCommand(cmd);
|
||||
final EthProtocolConfiguration config = options.toDomainObject();
|
||||
assertThat(config.getMaxGetNodeData()).isEqualTo(16);
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parsesInvalidEwpMaxGetNodeDataOptionsShouldFail() {
|
||||
parseCommand("--Xewp-max-get-node-data", "-16");
|
||||
verifyZeroInteractions(mockRunnerBuilder);
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString())
|
||||
.contains(
|
||||
"Invalid value for option '--Xewp-max-get-node-data': cannot convert '-16' to PositiveNumber");
|
||||
}
|
||||
|
||||
@Override
|
||||
EthProtocolConfiguration createDefaultDomainObject() {
|
||||
return EthProtocolConfiguration.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
EthProtocolConfiguration createCustomizedDomainObject() {
|
||||
return EthProtocolConfiguration.builder()
|
||||
.maxGetBlockHeaders(
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_BLOCK_HEADERS + 2))
|
||||
.maxGetBlockBodies(
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_BLOCK_BODIES + 2))
|
||||
.maxGetReceipts(
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_RECEIPTS + 2))
|
||||
.maxGetNodeData(
|
||||
PositiveNumber.fromInt(EthProtocolConfiguration.DEFAULT_MAX_GET_NODE_DATA + 2))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
EthProtocolOptions optionsFromDomainObject(final EthProtocolConfiguration domainObject) {
|
||||
return EthProtocolOptions.fromConfig(domainObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
EthProtocolOptions getOptionsFromPantheonCommand(final TestPantheonCommand pantheonCommand) {
|
||||
return pantheonCommand.getEthProtocolOptions();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import tech.pegasys.pantheon.util.uint.UInt256;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import com.google.common.collect.Range;
|
||||
import org.junit.Test;
|
||||
|
||||
public class OptionParserTest {
|
||||
|
||||
@Test
|
||||
public void parseLongRange_negative() {
|
||||
final String input = "-11..-5";
|
||||
final Range<Long> expected = Range.closed(-11L, -5L);
|
||||
assertThat(OptionParser.parseLongRange(input)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseLongRange_positive() {
|
||||
final String input = "11..22";
|
||||
final Range<Long> expected = Range.closed(11L, 22L);
|
||||
assertThat(OptionParser.parseLongRange(input)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseLongRange_spanningZero() {
|
||||
final String input = "-11..22";
|
||||
final Range<Long> expected = Range.closed(-11L, 22L);
|
||||
assertThat(OptionParser.parseLongRange(input)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseLongRange_singleElement() {
|
||||
final String input = "1..1";
|
||||
final Range<Long> expected = Range.closed(1L, 1L);
|
||||
assertThat(OptionParser.parseLongRange(input)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseLongRange_outOfOrderBounds() {
|
||||
final String input = "2..1";
|
||||
assertThatThrownBy(() -> OptionParser.parseLongRange(input))
|
||||
.isInstanceOf(IllegalArgumentException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void format_longRange() {
|
||||
final Range<Long> input = Range.closed(-11L, -5L);
|
||||
final String expected = "-11..-5";
|
||||
assertThat(OptionParser.format(input)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void format_uint256() {
|
||||
final UInt256 input = UInt256.of(new BigInteger("123456789", 10));
|
||||
final String expected = "123456789";
|
||||
assertThat(OptionParser.format(input)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void format_positiveInt() {
|
||||
final int input = 1233;
|
||||
final String expected = "1233";
|
||||
assertThat(OptionParser.format(input)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void format_negativeInt() {
|
||||
final int input = -1233;
|
||||
final String expected = "-1233";
|
||||
assertThat(OptionParser.format(input)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void format_positiveLong() {
|
||||
final long input = 1233L;
|
||||
final String expected = "1233";
|
||||
assertThat(OptionParser.format(input)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void format_negativeLong() {
|
||||
final long input = -1233L;
|
||||
final String expected = "-1233";
|
||||
assertThat(OptionParser.format(input)).isEqualTo(expected);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import tech.pegasys.pantheon.services.kvstore.RocksDbConfiguration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class RocksDBOptionsTest
|
||||
extends AbstractCLIOptionsTest<RocksDbConfiguration.Builder, RocksDBOptions> {
|
||||
|
||||
@Override
|
||||
RocksDbConfiguration.Builder createDefaultDomainObject() {
|
||||
return RocksDbConfiguration.builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
RocksDbConfiguration.Builder createCustomizedDomainObject() {
|
||||
return RocksDbConfiguration.builder()
|
||||
.maxOpenFiles(RocksDbConfiguration.DEFAULT_MAX_OPEN_FILES + 1)
|
||||
.cacheCapacity(RocksDbConfiguration.DEFAULT_CACHE_CAPACITY + 1)
|
||||
.maxBackgroundCompactions(RocksDbConfiguration.DEFAULT_MAX_BACKGROUND_COMPACTIONS + 1)
|
||||
.backgroundThreadCount(RocksDbConfiguration.DEFAULT_BACKGROUND_THREAD_COUNT + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
RocksDBOptions optionsFromDomainObject(final RocksDbConfiguration.Builder domainObject) {
|
||||
return RocksDBOptions.fromConfig(domainObject.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
RocksDBOptions getOptionsFromPantheonCommand(final TestPantheonCommand command) {
|
||||
return command.getRocksDBOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldsToIgnore() {
|
||||
return Arrays.asList("databaseDir", "useColumns");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Range;
|
||||
|
||||
public class SynchronizerOptionsTest
|
||||
extends AbstractCLIOptionsTest<SynchronizerConfiguration.Builder, SynchronizerOptions> {
|
||||
|
||||
@Override
|
||||
SynchronizerConfiguration.Builder createDefaultDomainObject() {
|
||||
return SynchronizerConfiguration.builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
SynchronizerConfiguration.Builder createCustomizedDomainObject() {
|
||||
return SynchronizerConfiguration.builder()
|
||||
.fastSyncPivotDistance(SynchronizerConfiguration.DEFAULT_PIVOT_DISTANCE_FROM_HEAD + 10)
|
||||
.fastSyncFullValidationRate(SynchronizerConfiguration.DEFAULT_FULL_VALIDATION_RATE / 2)
|
||||
.fastSyncMinimumPeerCount(SynchronizerConfiguration.DEFAULT_FAST_SYNC_MINIMUM_PEERS + 2)
|
||||
.worldStateHashCountPerRequest(
|
||||
SynchronizerConfiguration.DEFAULT_WORLD_STATE_HASH_COUNT_PER_REQUEST + 2)
|
||||
.worldStateRequestParallelism(
|
||||
SynchronizerConfiguration.DEFAULT_WORLD_STATE_REQUEST_PARALLELISM * 2)
|
||||
.worldStateMaxRequestsWithoutProgress(
|
||||
SynchronizerConfiguration.DEFAULT_WORLD_STATE_MAX_REQUESTS_WITHOUT_PROGRESS * 2)
|
||||
.worldStateMinMillisBeforeStalling(
|
||||
SynchronizerConfiguration.DEFAULT_WORLD_STATE_MIN_MILLIS_BEFORE_STALLING * 2)
|
||||
.blockPropagationRange(
|
||||
Range.closed(
|
||||
SynchronizerConfiguration.DEFAULT_BLOCK_PROPAGATION_RANGE.lowerEndpoint() - 2,
|
||||
SynchronizerConfiguration.DEFAULT_BLOCK_PROPAGATION_RANGE.upperEndpoint() + 2))
|
||||
.downloaderChangeTargetThresholdByHeight(
|
||||
SynchronizerConfiguration.DEFAULT_DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_HEIGHT + 2)
|
||||
.downloaderChangeTargetThresholdByTd(
|
||||
SynchronizerConfiguration.DEFAULT_DOWNLOADER_CHANGE_TARGET_THRESHOLD_BY_TD.plus(2L))
|
||||
.downloaderHeadersRequestSize(
|
||||
SynchronizerConfiguration.DEFAULT_DOWNLOADER_HEADER_REQUEST_SIZE + 2)
|
||||
.downloaderCheckpointTimeoutsPermitted(
|
||||
SynchronizerConfiguration.DEFAULT_DOWNLOADER_CHECKPOINT_TIMEOUTS_PERMITTED + 2)
|
||||
.downloaderChainSegmentSize(
|
||||
SynchronizerConfiguration.DEFAULT_DOWNLOADER_CHAIN_SEGMENT_SIZE + 2)
|
||||
.downloaderParallelism(SynchronizerConfiguration.DEFAULT_DOWNLOADER_PARALLELISM + 2)
|
||||
.transactionsParallelism(SynchronizerConfiguration.DEFAULT_TRANSACTIONS_PARALLELISM + 2)
|
||||
.computationParallelism(SynchronizerConfiguration.DEFAULT_COMPUTATION_PARALLELISM + 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldsWithComputedDefaults() {
|
||||
return Arrays.asList("maxTrailingPeers", "computationParallelism");
|
||||
}
|
||||
|
||||
@Override
|
||||
SynchronizerOptions getOptionsFromPantheonCommand(final TestPantheonCommand pantheonCommand) {
|
||||
return pantheonCommand.getSynchronizerOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFieldsToIgnore() {
|
||||
return Arrays.asList("fastSyncMinimumPeerCount");
|
||||
}
|
||||
|
||||
@Override
|
||||
SynchronizerOptions optionsFromDomainObject(
|
||||
final SynchronizerConfiguration.Builder domainObject) {
|
||||
return SynchronizerOptions.fromConfig(domainObject.build());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2019 ConsenSys AG.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package tech.pegasys.pantheon.cli.options;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TransactionPoolOptionsTest
|
||||
extends AbstractCLIOptionsTest<TransactionPoolConfiguration.Builder, TransactionPoolOptions> {
|
||||
|
||||
@Test
|
||||
public void txMessageKeepAliveSeconds() {
|
||||
final int txMessageKeepAliveSeconds = 999;
|
||||
final TestPantheonCommand cmd =
|
||||
parseCommand(
|
||||
"--Xincoming-tx-messages-keep-alive-seconds",
|
||||
String.valueOf(txMessageKeepAliveSeconds));
|
||||
|
||||
final TransactionPoolOptions options = getOptionsFromPantheonCommand(cmd);
|
||||
final TransactionPoolConfiguration config = options.toDomainObject().build();
|
||||
assertThat(config.getTxMessageKeepAliveSeconds()).isEqualTo(txMessageKeepAliveSeconds);
|
||||
|
||||
assertThat(commandOutput.toString()).isEmpty();
|
||||
assertThat(commandErrorOutput.toString()).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
TransactionPoolConfiguration.Builder createDefaultDomainObject() {
|
||||
return TransactionPoolConfiguration.builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
TransactionPoolConfiguration.Builder createCustomizedDomainObject() {
|
||||
return TransactionPoolConfiguration.builder()
|
||||
.txMessageKeepAliveSeconds(TransactionPoolConfiguration.DEFAULT_TX_MSG_KEEP_ALIVE + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
TransactionPoolOptions optionsFromDomainObject(
|
||||
final TransactionPoolConfiguration.Builder domainObject) {
|
||||
return TransactionPoolOptions.fromConfig(domainObject.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
TransactionPoolOptions getOptionsFromPantheonCommand(final TestPantheonCommand pantheonCommand) {
|
||||
return pantheonCommand.getTransactionPoolOptions();
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class RLPSubCommandTest extends CommandTestAbstract {
|
||||
// RLP sub-command
|
||||
@Test
|
||||
public void rlpSubCommandExistAnbHaveSubCommands() {
|
||||
final CommandSpec spec = parseCommand();
|
||||
final CommandSpec spec = parseCommand().getSpec();
|
||||
assertThat(spec.subcommands()).containsKeys(RLP_SUBCOMMAND_NAME);
|
||||
assertThat(spec.subcommands().get(RLP_SUBCOMMAND_NAME).getSubcommands())
|
||||
.containsKeys(RLP_ENCODE_SUBCOMMAND_NAME);
|
||||
|
||||
@@ -21,7 +21,7 @@ import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair;
|
||||
import tech.pegasys.pantheon.ethereum.core.InMemoryStorageProvider;
|
||||
import tech.pegasys.pantheon.ethereum.core.MiningParametersTestBuilder;
|
||||
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthereumWireProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.EthProtocolConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.transactions.TransactionPoolConfiguration;
|
||||
import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem;
|
||||
@@ -55,7 +55,7 @@ public final class BlockImporterTest {
|
||||
new PantheonController.Builder()
|
||||
.fromGenesisConfig(GenesisConfigFile.mainnet())
|
||||
.synchronizerConfiguration(SynchronizerConfiguration.builder().build())
|
||||
.ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig())
|
||||
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.storageProvider(new InMemoryStorageProvider())
|
||||
.networkId(1)
|
||||
.miningParameters(new MiningParametersTestBuilder().enabled(false).build())
|
||||
@@ -94,7 +94,7 @@ public final class BlockImporterTest {
|
||||
new PantheonController.Builder()
|
||||
.fromGenesisConfig(GenesisConfigFile.fromConfig(config))
|
||||
.synchronizerConfiguration(SynchronizerConfiguration.builder().build())
|
||||
.ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig())
|
||||
.ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig())
|
||||
.storageProvider(new InMemoryStorageProvider())
|
||||
.networkId(10)
|
||||
.miningParameters(new MiningParametersTestBuilder().enabled(false).build())
|
||||
|
||||
@@ -33,7 +33,6 @@ dependencies {
|
||||
implementation project(':services:util')
|
||||
|
||||
implementation 'com.google.guava:guava'
|
||||
implementation 'info.picocli:picocli'
|
||||
implementation 'io.prometheus:simpleclient'
|
||||
implementation 'org.apache.logging.log4j:log4j-api'
|
||||
implementation 'org.rocksdb:rocksdbjni'
|
||||
|
||||
@@ -34,11 +34,13 @@ import java.util.stream.Collectors;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.rocksdb.BlockBasedTableConfig;
|
||||
import org.rocksdb.ColumnFamilyDescriptor;
|
||||
import org.rocksdb.ColumnFamilyHandle;
|
||||
import org.rocksdb.ColumnFamilyOptions;
|
||||
import org.rocksdb.DBOptions;
|
||||
import org.rocksdb.Env;
|
||||
import org.rocksdb.LRUCache;
|
||||
import org.rocksdb.RocksDBException;
|
||||
import org.rocksdb.RocksIterator;
|
||||
import org.rocksdb.Statistics;
|
||||
@@ -87,7 +89,7 @@ public class ColumnarRocksDbKeyValueStorage
|
||||
new ColumnFamilyDescriptor(
|
||||
DEFAULT_COLUMN.getBytes(StandardCharsets.UTF_8),
|
||||
new ColumnFamilyOptions()
|
||||
.setTableFormatConfig(rocksDbConfiguration.getBlockBasedTableConfig())));
|
||||
.setTableFormatConfig(createBlockBasedTableConfig(rocksDbConfiguration))));
|
||||
|
||||
stats = new Statistics();
|
||||
options =
|
||||
@@ -190,6 +192,11 @@ public class ColumnarRocksDbKeyValueStorage
|
||||
}
|
||||
}
|
||||
|
||||
private BlockBasedTableConfig createBlockBasedTableConfig(final RocksDbConfiguration config) {
|
||||
final LRUCache cache = new LRUCache(config.getCacheCapacity());
|
||||
return new BlockBasedTableConfig().setBlockCache(cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColumnFamilyHandle getSegmentIdentifierByName(final Segment segment) {
|
||||
return columnHandlesByName.get(segment.getName());
|
||||
|
||||
@@ -16,27 +16,27 @@ import tech.pegasys.pantheon.services.util.RocksDbUtil;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.rocksdb.BlockBasedTableConfig;
|
||||
import org.rocksdb.LRUCache;
|
||||
import picocli.CommandLine;
|
||||
|
||||
public class RocksDbConfiguration {
|
||||
public static final int DEFAULT_MAX_OPEN_FILES = 1024;
|
||||
public static final long DEFAULT_CACHE_CAPACITY = 8388608;
|
||||
public static final int DEFAULT_MAX_BACKGROUND_COMPACTIONS = 4;
|
||||
public static final int DEFAULT_BACKGROUND_THREAD_COUNT = 4;
|
||||
|
||||
private final Path databaseDir;
|
||||
private final int maxOpenFiles;
|
||||
private final BlockBasedTableConfig blockBasedTableConfig;
|
||||
private final String label;
|
||||
private final int maxBackgroundCompactions;
|
||||
private final int backgroundThreadCount;
|
||||
private final boolean useColumns;
|
||||
private final long cacheCapacity;
|
||||
|
||||
public RocksDbConfiguration(
|
||||
private RocksDbConfiguration(
|
||||
final Path databaseDir,
|
||||
final int maxOpenFiles,
|
||||
final int maxBackgroundCompactions,
|
||||
final int backgroundThreadCount,
|
||||
final boolean useColumns,
|
||||
final LRUCache cache,
|
||||
final long cacheCapacity,
|
||||
final String label) {
|
||||
this.maxBackgroundCompactions = maxBackgroundCompactions;
|
||||
this.backgroundThreadCount = backgroundThreadCount;
|
||||
@@ -44,10 +44,14 @@ public class RocksDbConfiguration {
|
||||
RocksDbUtil.loadNativeLibrary();
|
||||
this.databaseDir = databaseDir;
|
||||
this.maxOpenFiles = maxOpenFiles;
|
||||
this.blockBasedTableConfig = new BlockBasedTableConfig().setBlockCache(cache);
|
||||
this.cacheCapacity = cacheCapacity;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Path getDatabaseDir() {
|
||||
return databaseDir;
|
||||
}
|
||||
@@ -64,8 +68,8 @@ public class RocksDbConfiguration {
|
||||
return backgroundThreadCount;
|
||||
}
|
||||
|
||||
public BlockBasedTableConfig getBlockBasedTableConfig() {
|
||||
return blockBasedTableConfig;
|
||||
public long getCacheCapacity() {
|
||||
return cacheCapacity;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
@@ -79,51 +83,16 @@ public class RocksDbConfiguration {
|
||||
public static class Builder {
|
||||
|
||||
Path databaseDir;
|
||||
LRUCache cache = null;
|
||||
String label = "blockchain";
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {"--Xrocksdb-max-open-files"},
|
||||
hidden = true,
|
||||
defaultValue = "1024",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Max number of files RocksDB will open (default: ${DEFAULT-VALUE})")
|
||||
int maxOpenFiles;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {"--Xrocksdb-cache-capacity"},
|
||||
hidden = true,
|
||||
defaultValue = "8388608",
|
||||
paramLabel = "<LONG>",
|
||||
description = "Cache capacity of RocksDB (default: ${DEFAULT-VALUE})")
|
||||
long cacheCapacity;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {"--Xrocksdb-max-background-compactions"},
|
||||
hidden = true,
|
||||
defaultValue = "4",
|
||||
paramLabel = "<INTEGER>",
|
||||
description =
|
||||
"Maximum number of RocksDB background compactions (default: ${DEFAULT-VALUE})")
|
||||
int maxBackgroundCompactions;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {"--Xrocksdb-background-thread-count"},
|
||||
hidden = true,
|
||||
defaultValue = "4",
|
||||
paramLabel = "<INTEGER>",
|
||||
description = "Number of RocksDB background threads (default: ${DEFAULT-VALUE})")
|
||||
int backgroundThreadCount;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {"--Xrocksdb-columns-enabled"},
|
||||
hidden = true,
|
||||
defaultValue = "false",
|
||||
paramLabel = "<BOOLEAN>",
|
||||
description =
|
||||
"Whether to separate chain and world state into separate RocksDB columns (default: ${DEFAULT-VALUE})")
|
||||
int maxOpenFiles = DEFAULT_MAX_OPEN_FILES;
|
||||
long cacheCapacity = DEFAULT_CACHE_CAPACITY;
|
||||
int maxBackgroundCompactions = DEFAULT_MAX_BACKGROUND_COMPACTIONS;
|
||||
int backgroundThreadCount = DEFAULT_BACKGROUND_THREAD_COUNT;
|
||||
boolean useColumns = false;
|
||||
|
||||
private Builder() {}
|
||||
|
||||
public Builder databaseDir(final Path databaseDir) {
|
||||
this.databaseDir = databaseDir;
|
||||
return this;
|
||||
@@ -159,22 +128,14 @@ public class RocksDbConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
private LRUCache createCache(final long cacheCapacity) {
|
||||
RocksDbUtil.loadNativeLibrary();
|
||||
return new LRUCache(cacheCapacity);
|
||||
}
|
||||
|
||||
public RocksDbConfiguration build() {
|
||||
if (cache == null) {
|
||||
cache = createCache(cacheCapacity);
|
||||
}
|
||||
return new RocksDbConfiguration(
|
||||
databaseDir,
|
||||
maxOpenFiles,
|
||||
maxBackgroundCompactions,
|
||||
backgroundThreadCount,
|
||||
useColumns,
|
||||
cache,
|
||||
cacheCapacity,
|
||||
label);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.util.function.Predicate;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.rocksdb.BlockBasedTableConfig;
|
||||
import org.rocksdb.LRUCache;
|
||||
import org.rocksdb.Options;
|
||||
import org.rocksdb.RocksDBException;
|
||||
import org.rocksdb.RocksIterator;
|
||||
@@ -67,7 +69,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
|
||||
new Options()
|
||||
.setCreateIfMissing(true)
|
||||
.setMaxOpenFiles(rocksDbConfiguration.getMaxOpenFiles())
|
||||
.setTableFormatConfig(rocksDbConfiguration.getBlockBasedTableConfig())
|
||||
.setTableFormatConfig(createBlockBasedTableConfig(rocksDbConfiguration))
|
||||
.setMaxBackgroundCompactions(rocksDbConfiguration.getMaxBackgroundCompactions())
|
||||
.setStatistics(stats);
|
||||
options.getEnv().setBackgroundThreads(rocksDbConfiguration.getBackgroundThreadCount());
|
||||
@@ -138,6 +140,11 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
private BlockBasedTableConfig createBlockBasedTableConfig(final RocksDbConfiguration config) {
|
||||
final LRUCache cache = new LRUCache(config.getCacheCapacity());
|
||||
return new BlockBasedTableConfig().setBlockCache(cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<BytesValue> get(final BytesValue key) throws StorageException {
|
||||
throwIfClosed();
|
||||
|
||||
@@ -99,14 +99,13 @@ public class ColumnarRocksDbKeyValueStorageTest extends AbstractKeyValueStorageT
|
||||
|
||||
private SegmentedKeyValueStorage<ColumnFamilyHandle> createSegmentedStore() throws Exception {
|
||||
return ColumnarRocksDbKeyValueStorage.create(
|
||||
new RocksDbConfiguration.Builder().databaseDir(folder.newFolder().toPath()).build(),
|
||||
RocksDbConfiguration.builder().databaseDir(folder.newFolder().toPath()).build(),
|
||||
Arrays.asList(TestSegment.FOO, TestSegment.BAR),
|
||||
new NoOpMetricsSystem());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected KeyValueStorage createStore() throws Exception {
|
||||
return new SegmentedKeyValueStorageAdapter<ColumnFamilyHandle>(
|
||||
TestSegment.FOO, createSegmentedStore());
|
||||
return new SegmentedKeyValueStorageAdapter<>(TestSegment.FOO, createSegmentedStore());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class RocksDbKeyValueStorageTest extends AbstractKeyValueStorageTest {
|
||||
@Override
|
||||
protected KeyValueStorage createStore() throws Exception {
|
||||
return RocksDbKeyValueStorage.create(
|
||||
new RocksDbConfiguration.Builder()
|
||||
RocksDbConfiguration.builder()
|
||||
.databaseDir(folder.newFolder().toPath())
|
||||
.useColumns(false)
|
||||
.build(),
|
||||
|
||||
@@ -15,6 +15,8 @@ package tech.pegasys.pantheon.util.number;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static java.lang.Integer.parseInt;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PositiveNumber {
|
||||
|
||||
private int value;
|
||||
@@ -46,4 +48,21 @@ public class PositiveNumber {
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof PositiveNumber)) {
|
||||
return false;
|
||||
}
|
||||
final PositiveNumber that = (PositiveNumber) o;
|
||||
return value == that.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user