[PAN-1062] Evict old transactions (1 of 2) (#1299)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
S. Matthew English 6 years ago committed by GitHub
parent c8d9a5d54f
commit 2637e0004e
  1. 14
      consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/blockcreation/CliqueBlockCreatorTest.java
  2. 8
      consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/blockcreation/CliqueMinerExecutorTest.java
  3. 8
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestContextBuilder.java
  4. 8
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/blockcreation/IbftBlockCreatorTest.java
  5. 5
      consensus/ibftlegacy/src/test/java/tech/pegasys/pantheon/consensus/ibftlegacy/blockcreation/IbftBlockCreatorTest.java
  6. 30
      ethereum/blockcreation/src/test/java/tech/pegasys/pantheon/ethereum/blockcreation/BlockTransactionSelectorTest.java
  7. 9
      ethereum/blockcreation/src/test/java/tech/pegasys/pantheon/ethereum/blockcreation/EthHashBlockCreatorTest.java
  8. 14
      ethereum/blockcreation/src/test/java/tech/pegasys/pantheon/ethereum/blockcreation/EthHashMinerExecutorTest.java
  9. 22
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/transactions/PendingTransactions.java
  10. 7
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPoolFactory.java
  11. 51
      ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/PendingTransactionsTest.java
  12. 6
      ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/transactions/TransactionPoolTest.java
  13. 6
      ethereum/jsonrpc/src/integration-test/java/tech/pegasys/pantheon/ethereum/jsonrpc/methods/EthGetFilterChangesIntegrationTest.java
  14. 7
      pantheon/src/main/java/tech/pegasys/pantheon/Runner.java

@ -50,12 +50,14 @@ import tech.pegasys.pantheon.testutil.TestClock;
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());
@ -113,7 +115,8 @@ public class CliqueBlockCreatorTest {
new CliqueBlockCreator(
coinbase,
parent -> extraData.encode(),
new PendingTransactions(5, TestClock.fixed(), metricsSystem),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem),
protocolContext,
protocolSchedule,
gasLimit -> gasLimit,
@ -140,7 +143,8 @@ public class CliqueBlockCreatorTest {
new CliqueBlockCreator(
coinbase,
parent -> extraData.encode(),
new PendingTransactions(5, TestClock.fixed(), metricsSystem),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem),
protocolContext,
protocolSchedule,
gasLimit -> gasLimit,
@ -166,7 +170,8 @@ public class CliqueBlockCreatorTest {
new CliqueBlockCreator(
coinbase,
parent -> extraData.encode(),
new PendingTransactions(5, TestClock.fixed(), metricsSystem),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem),
protocolContext,
protocolSchedule,
gasLimit -> gasLimit,
@ -195,7 +200,8 @@ public class CliqueBlockCreatorTest {
new CliqueBlockCreator(
coinbase,
parent -> extraData.encode(),
new PendingTransactions(5, TestClock.fixed(), metricsSystem),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem),
protocolContext,
protocolSchedule,
gasLimit -> gasLimit,

@ -44,6 +44,7 @@ import tech.pegasys.pantheon.util.bytes.BytesValue;
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;
@ -54,6 +55,7 @@ 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();
@ -90,7 +92,8 @@ public class CliqueMinerExecutorTest {
cliqueProtocolContext,
Executors.newSingleThreadExecutor(),
CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerKeyPair),
new PendingTransactions(1, TestClock.fixed(), metricsSystem),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem),
proposerKeyPair,
new MiningParameters(AddressHelpers.ofValue(1), Wei.ZERO, wrappedVanityData, false),
mock(CliqueBlockScheduler.class),
@ -120,7 +123,8 @@ public class CliqueMinerExecutorTest {
cliqueProtocolContext,
Executors.newSingleThreadExecutor(),
CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerKeyPair),
new PendingTransactions(1, TestClock.fixed(), metricsSystem),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem),
proposerKeyPair,
new MiningParameters(AddressHelpers.ofValue(1), Wei.ZERO, wrappedVanityData, false),
mock(CliqueBlockScheduler.class),

@ -80,11 +80,14 @@ import java.util.Map;
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 {
@ -282,10 +285,13 @@ public class TestContextBuilder {
new ProtocolContext<>(
blockChain, worldStateArchive, new IbftContext(voteTallyCache, voteProposer));
final PendingTransactions pendingTransactions =
new PendingTransactions(TRANSACTION_EVICTION_INTERVAL_MS, 1, clock, metricsSystem);
final IbftBlockCreatorFactory blockCreatorFactory =
new IbftBlockCreatorFactory(
(gasLimit) -> gasLimit,
new PendingTransactions(1, clock, metricsSystem), // changed from IbftPantheonController
pendingTransactions, // changed from IbftPantheonController
protocolContext,
protocolSchedule,
miningParams,

@ -46,11 +46,13 @@ import java.time.Instant;
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
@ -81,6 +83,10 @@ public class IbftBlockCreatorTest {
createInMemoryWorldStateArchive(),
setupContextWithValidators(initialValidatorList));
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem);
final IbftBlockCreator blockCreator =
new IbftBlockCreator(
initialValidatorList.get(0),
@ -92,7 +98,7 @@ public class IbftBlockCreatorTest {
0,
initialValidatorList)
.encode(),
new PendingTransactions(1, TestClock.fixed(), metricsSystem),
pendingTransactions,
protContext,
protocolSchedule,
parentGasLimit -> parentGasLimit,

@ -46,11 +46,13 @@ import java.time.Instant;
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
@ -97,7 +99,8 @@ public class IbftBlockCreatorTest {
null,
initialValidatorList)
.encode(),
new PendingTransactions(1, TestClock.fixed(), metricsSystem),
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem),
protContext,
protocolSchedule,
parentGasLimit -> parentGasLimit,

@ -55,6 +55,7 @@ import tech.pegasys.pantheon.util.uint.UInt256;
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;
@ -63,6 +64,7 @@ import org.junit.Test;
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
@ -75,7 +77,9 @@ public class BlockTransactionSelectorTest {
final DefaultMutableWorldState worldState = inMemoryWorldState();
final PendingTransactions pendingTransactions =
new PendingTransactions(5, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
final Supplier<Boolean> isCancelled = () -> false;
final ProcessableBlockHeader blockHeader =
@ -113,7 +117,8 @@ public class BlockTransactionSelectorTest {
@Test
public void failedTransactionsAreIncludedInTheBlock() {
final PendingTransactions pendingTransactions =
new PendingTransactions(5, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
final Transaction transaction = createTransaction(1);
pendingTransactions.addRemoteTransaction(transaction);
@ -165,7 +170,8 @@ public class BlockTransactionSelectorTest {
@Test
public void invalidTransactionsTransactionProcessingAreSkippedButBlockStillFills() {
final PendingTransactions pendingTransactions =
new PendingTransactions(5, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
final List<Transaction> transactionsToInject = Lists.newArrayList();
for (int i = 0; i < 5; i++) {
@ -228,7 +234,8 @@ public class BlockTransactionSelectorTest {
@Test
public void subsetOfPendingTransactionsIncludedWhenBlockGasLimitHit() {
final PendingTransactions pendingTransactions =
new PendingTransactions(5, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
final List<Transaction> transactionsToInject = Lists.newArrayList();
// Transactions are reported in reverse order.
@ -294,7 +301,8 @@ public class BlockTransactionSelectorTest {
@Test
public void transactionOfferingGasPriceLessThanMinimumIsIdentifiedAndRemovedFromPending() {
final PendingTransactions pendingTransactions =
new PendingTransactions(5, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
final Blockchain blockchain = new TestBlockchain();
@ -339,7 +347,9 @@ public class BlockTransactionSelectorTest {
@Test
public void transactionTooLargeForBlockDoesNotPreventMoreBeingAddedIfBlockOccupancyNotReached() {
final PendingTransactions pendingTransactions =
new PendingTransactions(5, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
final Blockchain blockchain = new TestBlockchain();
final DefaultMutableWorldState worldState = inMemoryWorldState();
final Supplier<Boolean> isCancelled = () -> false;
@ -410,7 +420,9 @@ public class BlockTransactionSelectorTest {
@Test
public void transactionSelectionStopsWhenSufficientBlockOccupancyIsReached() {
final PendingTransactions pendingTransactions =
new PendingTransactions(10, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
final Blockchain blockchain = new TestBlockchain();
final DefaultMutableWorldState worldState = inMemoryWorldState();
final Supplier<Boolean> isCancelled = () -> false;
@ -492,7 +504,9 @@ public class BlockTransactionSelectorTest {
@Test
public void shouldDiscardTransactionsThatFailValidation() {
final PendingTransactions pendingTransactions =
new PendingTransactions(10, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 5, TestClock.fixed(), metricsSystem);
final TransactionProcessor transactionProcessor = mock(TransactionProcessor.class);
final Blockchain blockchain = new TestBlockchain();
final DefaultMutableWorldState worldState = inMemoryWorldState();

@ -30,6 +30,7 @@ import tech.pegasys.pantheon.util.bytes.BytesValue;
import java.io.IOException;
import java.math.BigInteger;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import com.google.common.collect.Lists;
@ -47,6 +48,7 @@ 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 =
@ -63,11 +65,16 @@ public class EthHashBlockCreatorTest {
@Test
public void createMainnetBlock1() throws IOException {
final EthHashSolver solver = new EthHashSolver(Lists.newArrayList(BLOCK_1_NONCE), new Light());
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem);
final EthHashBlockCreator blockCreator =
new EthHashBlockCreator(
BLOCK_1_COINBASE,
parent -> BLOCK_1_EXTRA_DATA,
new PendingTransactions(1, TestClock.fixed(), metricsSystem),
pendingTransactions,
executionContextTestFixture.getProtocolContext(),
executionContextTestFixture.getProtocolSchedule(),
gasLimit -> gasLimit,

@ -23,10 +23,12 @@ import tech.pegasys.pantheon.testutil.TestClock;
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
@ -34,12 +36,16 @@ public class EthHashMinerExecutorTest {
final MiningParameters miningParameters =
new MiningParametersTestBuilder().coinbase(null).build();
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem);
final EthHashMinerExecutor executor =
new EthHashMinerExecutor(
null,
Executors.newCachedThreadPool(),
null,
new PendingTransactions(1, TestClock.fixed(), metricsSystem),
pendingTransactions,
miningParameters,
new DefaultBlockScheduler(1, 10, TestClock.fixed()));
@ -52,12 +58,16 @@ public class EthHashMinerExecutorTest {
public void settingCoinbaseToNullThrowsException() {
final MiningParameters miningParameters = new MiningParametersTestBuilder().build();
final PendingTransactions pendingTransactions =
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, 1, TestClock.fixed(), metricsSystem);
final EthHashMinerExecutor executor =
new EthHashMinerExecutor(
null,
Executors.newCachedThreadPool(),
null,
new PendingTransactions(1, TestClock.fixed(), metricsSystem),
pendingTransactions,
miningParameters,
new DefaultBlockScheduler(1, 10, TestClock.fixed()));

@ -13,6 +13,7 @@
package tech.pegasys.pantheon.ethereum.eth.transactions;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toList;
import tech.pegasys.pantheon.ethereum.core.AccountTransactionOrder;
import tech.pegasys.pantheon.ethereum.core.Address;
@ -70,8 +71,14 @@ public class PendingTransactions {
private final Counter localTransactionAddedCounter;
private final Counter remoteTransactionAddedCounter;
private final long transactionEvictionIntervalMs;
public PendingTransactions(
final int maxPendingTransactions, final Clock clock, final MetricsSystem metricsSystem) {
final long transactionEvictionIntervalMs,
final int maxPendingTransactions,
final Clock clock,
final MetricsSystem metricsSystem) {
this.transactionEvictionIntervalMs = transactionEvictionIntervalMs;
this.maxPendingTransactions = maxPendingTransactions;
this.clock = clock;
final LabelledMetric<Counter> transactionAddedCounter =
@ -92,6 +99,19 @@ public class PendingTransactions {
"operation");
}
public void evictOldTransactions() {
synchronized (pendingTransactions) {
final Instant removeTransactionsBefore =
clock.instant().minusMillis(transactionEvictionIntervalMs);
final List<TransactionInfo> transactionsToRemove =
prioritizedTransactions.stream()
.filter(
transaction -> transaction.getAddedToPoolAt().isBefore(removeTransactionsBefore))
.collect(toList());
transactionsToRemove.forEach(transaction -> removeTransaction(transaction.getTransaction()));
}
}
List<Transaction> getLocalTransactions() {
synchronized (pendingTransactions) {
List<Transaction> localTransactions = new ArrayList<>();

@ -20,9 +20,12 @@ import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule;
import tech.pegasys.pantheon.metrics.MetricsSystem;
import java.time.Clock;
import java.util.concurrent.TimeUnit;
public class TransactionPoolFactory {
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.HOURS.toMillis(12);
public static TransactionPool createTransactionPool(
final ProtocolSchedule<?> protocolSchedule,
final ProtocolContext<?> protocolContext,
@ -31,8 +34,10 @@ public class TransactionPoolFactory {
final int maxPendingTransactions,
final MetricsSystem metricsSystem,
final SyncState syncState) {
final PendingTransactions pendingTransactions =
new PendingTransactions(maxPendingTransactions, clock, metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, maxPendingTransactions, clock, metricsSystem);
final PeerTransactionTracker transactionTracker = new PeerTransactionTracker();
final TransactionsMessageSender transactionsMessageSender =

@ -32,19 +32,23 @@ import tech.pegasys.pantheon.testutil.TestClock;
import java.util.ArrayList;
import java.util.List;
import java.util.OptionalLong;
import java.util.concurrent.TimeUnit;
import com.google.common.collect.Lists;
import org.junit.Test;
public class PendingTransactionsTest {
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
private static final int MAX_TRANSACTIONS = 5;
private static final KeyPair KEYS1 = KeyPair.generate();
private static final KeyPair KEYS2 = KeyPair.generate();
private final TestClock clock = new TestClock();
private final MetricsSystem metricsSystem = new NoOpMetricsSystem();
private final PendingTransactions transactions =
new PendingTransactions(MAX_TRANSACTIONS, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, MAX_TRANSACTIONS, TestClock.fixed(), metricsSystem);
private final Transaction transaction1 = createTransaction(2);
private final Transaction transaction2 = createTransaction(1);
@ -409,4 +413,49 @@ public class PendingTransactionsTest {
.nonce(transactionNumber)
.createTransaction(KEYS1);
}
@Test
public void shouldEvictMultipleOldTransactions() {
final long transactionEvictionIntervalMs = 1000L;
final PendingTransactions transactions =
new PendingTransactions(
transactionEvictionIntervalMs, MAX_TRANSACTIONS, clock, metricsSystem);
transactions.addRemoteTransaction(transaction1);
assertThat(transactions.size()).isEqualTo(1);
transactions.addRemoteTransaction(transaction2);
assertThat(transactions.size()).isEqualTo(2);
clock.stepMillis(2000);
transactions.evictOldTransactions();
assertThat(transactions.size()).isEqualTo(0);
}
@Test
public void shouldEvictSingleOldTransaction() {
final long transactionEvictionIntervalMs = 1000L;
final PendingTransactions transactions =
new PendingTransactions(
transactionEvictionIntervalMs, MAX_TRANSACTIONS, clock, metricsSystem);
transactions.addRemoteTransaction(transaction1);
assertThat(transactions.size()).isEqualTo(1);
clock.stepMillis(2000);
transactions.evictOldTransactions();
assertThat(transactions.size()).isEqualTo(0);
}
@Test
public void shouldEvictExclusivelyOldTransactions() {
final long transactionEvictionIntervalMs = 2L;
final PendingTransactions transactions =
new PendingTransactions(
transactionEvictionIntervalMs, MAX_TRANSACTIONS, clock, metricsSystem);
transactions.addRemoteTransaction(transaction1);
assertThat(transactions.size()).isEqualTo(1);
clock.stepMillis(2001);
transactions.addRemoteTransaction(transaction2);
assertThat(transactions.size()).isEqualTo(2);
transactions.evictOldTransactions();
assertThat(transactions.size()).isEqualTo(1);
}
}

@ -67,12 +67,14 @@ import tech.pegasys.pantheon.util.uint.UInt256;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
public class TransactionPoolTest {
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
private static final int MAX_TRANSACTIONS = 5;
private static final KeyPair KEY_PAIR1 = KeyPair.generate();
@ -89,8 +91,10 @@ public class TransactionPoolTest {
private final TransactionValidator transactionValidator = mock(TransactionValidator.class);
private MutableBlockchain blockchain;
private final PendingTransactions transactions =
new PendingTransactions(MAX_TRANSACTIONS, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, MAX_TRANSACTIONS, TestClock.fixed(), metricsSystem);
private final Transaction transaction1 = createTransaction(1);
private final Transaction transaction2 = createTransaction(2);
private final ExecutionContextTestFixture executionContext = ExecutionContextTestFixture.create();

@ -57,6 +57,7 @@ import tech.pegasys.pantheon.util.uint.UInt256;
import java.math.BigInteger;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.assertj.core.util.Lists;
import org.junit.Before;
@ -68,6 +69,7 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class EthGetFilterChangesIntegrationTest {
private static final long TRANSACTION_EVICTION_INTERVAL_MS = TimeUnit.MINUTES.toMillis(1);
@Mock private TransactionBatchAddedListener batchAddedListener;
private MutableBlockchain blockchain;
private final String ETH_METHOD = "eth_getFilterChanges";
@ -76,7 +78,9 @@ public class EthGetFilterChangesIntegrationTest {
private final MetricsSystem metricsSystem = new NoOpMetricsSystem();
private final PendingTransactions transactions =
new PendingTransactions(MAX_TRANSACTIONS, TestClock.fixed(), metricsSystem);
new PendingTransactions(
TRANSACTION_EVICTION_INTERVAL_MS, MAX_TRANSACTIONS, TestClock.fixed(), metricsSystem);
private static final int MAX_TRANSACTIONS = 5;
private static final KeyPair keyPair = KeyPair.generate();
private final Transaction transaction = createTransaction(1);

@ -73,6 +73,13 @@ public class Runner implements AutoCloseable {
if (networkRunner.getNetwork().isP2pEnabled()) {
pantheonController.getSynchronizer().start();
}
vertx.setPeriodic(
TimeUnit.MINUTES.toMillis(1),
time ->
pantheonController
.getTransactionPool()
.getPendingTransactions()
.evictOldTransactions());
jsonRpc.ifPresent(service -> waitForServiceToStart("jsonRpc", service.start()));
websocketRpc.ifPresent(service -> waitForServiceToStop("websocketRpc", service.start()));
metrics.ifPresent(service -> waitForServiceToStart("metrics", service.start()));

Loading…
Cancel
Save