Skip to content

Commit

Permalink
Merge pull request #6 from PegaSysEng/master
Browse files Browse the repository at this point in the history
pull from base repo
  • Loading branch information
zyfrank authored Apr 30, 2019
2 parents a643ef3 + 5870191 commit e929046
Show file tree
Hide file tree
Showing 33 changed files with 185 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public void startNode(final PantheonNode node) {
.nodePrivateKeyFile(KeyPairUtil.getDefaultKeyFile(node.homeDirectory()))
.metricsSystem(noOpMetricsSystem)
.maxPendingTransactions(PendingTransactions.MAX_PENDING_TRANSACTIONS)
.rocksdDbConfiguration(
new RocksDbConfiguration.Builder().databaseDir(tempDir).build())
.pendingTransactionRetentionPeriod(PendingTransactions.DEFAULT_TX_RETENTION_HOURS)
.rocksDbConfiguration(new RocksDbConfiguration.Builder().databaseDir(tempDir).build())
.ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig())
.clock(Clock.systemUTC())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.util.List;
import java.util.concurrent.TimeUnit;

import com.google.common.collect.Lists;
import org.junit.Before;
import org.junit.Test;

public class CliqueBlockCreatorTest {
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);

private final KeyPair proposerKeyPair = KeyPair.generate();
private final Address proposerAddress = Util.publicKeyToAddress(proposerKeyPair.getPublicKey());
Expand Down Expand Up @@ -116,7 +114,10 @@ public void proposerAddressCanBeExtractFromAConstructedBlock() {
coinbase,
parent -> extraData.encode(),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem),
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
5,
TestClock.fixed(),
metricsSystem),
protocolContext,
protocolSchedule,
gasLimit -> gasLimit,
Expand Down Expand Up @@ -144,7 +145,10 @@ public void insertsValidVoteIntoConstructedBlock() {
coinbase,
parent -> extraData.encode(),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem),
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
5,
TestClock.fixed(),
metricsSystem),
protocolContext,
protocolSchedule,
gasLimit -> gasLimit,
Expand All @@ -171,7 +175,10 @@ public void insertsNoVoteWhenAuthInValidators() {
coinbase,
parent -> extraData.encode(),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem),
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
5,
TestClock.fixed(),
metricsSystem),
protocolContext,
protocolSchedule,
gasLimit -> gasLimit,
Expand Down Expand Up @@ -201,7 +208,10 @@ public void insertsNoVoteWhenAtEpoch() {
coinbase,
parent -> extraData.encode(),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem),
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
5,
TestClock.fixed(),
metricsSystem),
protocolContext,
protocolSchedule,
gasLimit -> gasLimit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import java.util.List;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import com.google.common.collect.Lists;
import io.vertx.core.json.JsonObject;
Expand All @@ -55,7 +54,6 @@ public class CliqueMinerExecutorTest {

private static final GenesisConfigOptions GENESIS_CONFIG_OPTIONS =
GenesisConfigFile.fromConfig(new JsonObject()).getConfigOptions();
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
private final KeyPair proposerKeyPair = KeyPair.generate();
private Address localAddress;
private final List<Address> validatorList = Lists.newArrayList();
Expand Down Expand Up @@ -93,7 +91,10 @@ public void extraDataCreatedOnEpochBlocksContainsValidators() {
Executors.newSingleThreadExecutor(),
CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerKeyPair),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem),
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
1,
TestClock.fixed(),
metricsSystem),
proposerKeyPair,
new MiningParameters(AddressHelpers.ofValue(1), Wei.ZERO, wrappedVanityData, false),
mock(CliqueBlockScheduler.class),
Expand Down Expand Up @@ -124,7 +125,10 @@ public void extraDataForNonEpochBlocksDoesNotContainValidaors() {
Executors.newSingleThreadExecutor(),
CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerKeyPair),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem),
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
1,
TestClock.fixed(),
metricsSystem),
proposerKeyPair,
new MiningParameters(AddressHelpers.ofValue(1), Wei.ZERO, wrappedVanityData, false),
mock(CliqueBlockScheduler.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import com.google.common.collect.Iterables;

public class TestContextBuilder {

private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
private static MetricsSystem metricsSystem = new NoOpMetricsSystem();

private static class ControllerAndState {
Expand Down Expand Up @@ -286,7 +284,8 @@ private static ControllerAndState createControllerAndFinalState(
blockChain, worldStateArchive, new IbftContext(voteTallyCache, voteProposer));

final PendingTransactions pendingTransactions =
new PendingTransactions(TRANSACTION_EVICTION_INTERVAL_MS, 1, clock, metricsSystem);
new PendingTransactions(
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 1, clock, metricsSystem);

final IbftBlockCreatorFactory blockCreatorFactory =
new IbftBlockCreatorFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

import com.google.common.collect.Lists;
import org.junit.Test;

public class IbftBlockCreatorTest {
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
private final MetricsSystem metricsSystem = new NoOpMetricsSystem();

@Test
Expand Down Expand Up @@ -85,7 +83,7 @@ public void createdBlockPassesValidationRulesAndHasAppropriateHashAndMixHash() {

final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 1, TestClock.fixed(), metricsSystem);

final IbftBlockCreator blockCreator =
new IbftBlockCreator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

import com.google.common.collect.Lists;
import org.junit.Test;

public class IbftBlockCreatorTest {
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
private final MetricsSystem metricsSystem = new NoOpMetricsSystem();

@Test
Expand Down Expand Up @@ -100,7 +98,10 @@ public void headerProducedPassesValidationRules() {
initialValidatorList)
.encode(),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem),
PendingTransactions.DEFAULT_TX_RETENTION_HOURS,
1,
TestClock.fixed(),
metricsSystem),
protContext,
protocolSchedule,
parentGasLimit -> parentGasLimit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import java.math.BigInteger;
import java.time.Instant;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;

import com.google.common.collect.Lists;
Expand All @@ -64,7 +63,6 @@
public class BlockTransactionSelectorTest {

private static final KeyPair keyPair = KeyPair.generate();
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
private final MetricsSystem metricsSystem = new NoOpMetricsSystem();

@Test
Expand All @@ -78,7 +76,7 @@ public void emptyPendingTransactionsResultsInEmptyVettingResult() {

final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 5, TestClock.fixed(), metricsSystem);

final Supplier<Boolean> isCancelled = () -> false;

Expand Down Expand Up @@ -118,7 +116,7 @@ public void emptyPendingTransactionsResultsInEmptyVettingResult() {
public void failedTransactionsAreIncludedInTheBlock() {
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 5, TestClock.fixed(), metricsSystem);

final Transaction transaction = createTransaction(1);
pendingTransactions.addRemoteTransaction(transaction);
Expand Down Expand Up @@ -171,7 +169,7 @@ public void failedTransactionsAreIncludedInTheBlock() {
public void invalidTransactionsTransactionProcessingAreSkippedButBlockStillFills() {
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 5, TestClock.fixed(), metricsSystem);

final List<Transaction> transactionsToInject = Lists.newArrayList();
for (int i = 0; i < 5; i++) {
Expand Down Expand Up @@ -235,7 +233,7 @@ public void invalidTransactionsTransactionProcessingAreSkippedButBlockStillFills
public void subsetOfPendingTransactionsIncludedWhenBlockGasLimitHit() {
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 5, TestClock.fixed(), metricsSystem);

final List<Transaction> transactionsToInject = Lists.newArrayList();
// Transactions are reported in reverse order.
Expand Down Expand Up @@ -302,7 +300,7 @@ public void subsetOfPendingTransactionsIncludedWhenBlockGasLimitHit() {
public void transactionOfferingGasPriceLessThanMinimumIsIdentifiedAndRemovedFromPending() {
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 5, TestClock.fixed(), metricsSystem);

final Blockchain blockchain = new TestBlockchain();

Expand Down Expand Up @@ -348,7 +346,7 @@ public void transactionOfferingGasPriceLessThanMinimumIsIdentifiedAndRemovedFrom
public void transactionTooLargeForBlockDoesNotPreventMoreBeingAddedIfBlockOccupancyNotReached() {
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 5, TestClock.fixed(), metricsSystem);

final Blockchain blockchain = new TestBlockchain();
final DefaultMutableWorldState worldState = inMemoryWorldState();
Expand Down Expand Up @@ -421,7 +419,7 @@ public void transactionTooLargeForBlockDoesNotPreventMoreBeingAddedIfBlockOccupa
public void transactionSelectionStopsWhenSufficientBlockOccupancyIsReached() {
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 5, TestClock.fixed(), metricsSystem);

final Blockchain blockchain = new TestBlockchain();
final DefaultMutableWorldState worldState = inMemoryWorldState();
Expand Down Expand Up @@ -505,7 +503,7 @@ public void transactionSelectionStopsWhenSufficientBlockOccupancyIsReached() {
public void shouldDiscardTransactionsThatFailValidation() {
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 5, TestClock.fixed(), metricsSystem);

final TransactionProcessor transactionProcessor = mock(TransactionProcessor.class);
final Blockchain blockchain = new TestBlockchain();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import java.io.IOException;
import java.math.BigInteger;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import com.google.common.collect.Lists;
Expand All @@ -48,7 +47,6 @@ public class EthHashBlockCreatorTest {

private static final BytesValue BLOCK_1_EXTRA_DATA =
BytesValue.fromHexString("0x476574682f76312e302e302f6c696e75782f676f312e342e32");
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
private final MetricsSystem metricsSystem = new NoOpMetricsSystem();

private final ExecutionContextTestFixture executionContextTestFixture =
Expand All @@ -68,7 +66,7 @@ public void createMainnetBlock1() throws IOException {

final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 1, TestClock.fixed(), metricsSystem);

final EthHashBlockCreator blockCreator =
new EthHashBlockCreator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import tech.pegasys.pantheon.util.Subscribers;

import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.junit.Test;

public class EthHashMinerExecutorTest {
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
private final MetricsSystem metricsSystem = new NoOpMetricsSystem();

@Test
Expand All @@ -38,7 +36,7 @@ public void startingMiningWithoutCoinbaseThrowsException() {

final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 1, TestClock.fixed(), metricsSystem);

final EthHashMinerExecutor executor =
new EthHashMinerExecutor(
Expand All @@ -60,7 +58,7 @@ public void settingCoinbaseToNullThrowsException() {

final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem);
PendingTransactions.DEFAULT_TX_RETENTION_HOURS, 1, TestClock.fixed(), metricsSystem);

final EthHashMinerExecutor executor =
new EthHashMinerExecutor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ public void parseBlockPropagationRange(final String arg) {
@CommandLine.Option(
names = "--Xsynchronizer-pipeline-full-sync-enabled",
hidden = true,
defaultValue = "false",
defaultValue = "true",
paramLabel = "<BOOLEAN>",
description = "Enable the pipeline based chain downloader during full synchronization")
private Boolean piplineDownloaderForFullSyncEnabled = false;
private Boolean piplineDownloaderForFullSyncEnabled = true;

public Builder fastSyncPivotDistance(final int distance) {
fastSyncPivotDistance = distance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static <C> ChainDownloader create(
metricsSystem);
}

LOG.info("Using EthTaskChainDownloader");
return new EthTaskChainDownloader<>(
config,
ethContext,
Expand Down
Loading

0 comments on commit e929046

Please sign in to comment.