-
Notifications
You must be signed in to change notification settings - Fork 130
[PAN-1062] Specify pending transaction retention period (2 of 2) #1333
[PAN-1062] Specify pending transaction retention period (2 of 2) #1333
Conversation
de9376e
to
3d7079f
Compare
@@ -80,6 +80,7 @@ public void startNode(final PantheonNode node) { | |||
new RocksDbConfiguration.Builder().databaseDir(tempDir).build()) | |||
.ethereumWireProtocolConfiguration(EthereumWireProtocolConfiguration.defaultConfig()) | |||
.clock(Clock.systemUTC()) | |||
.pendingTransactionRetentionPeriod(PendingTransactions.PENDING_TX_RETENTION_PERIOD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this up to between 78 and 79 since they touch the same part of config. In genreral wherever we do this call as well.
@@ -48,6 +48,7 @@ | |||
* <p>This class is safe for use across multiple threads. | |||
*/ | |||
public class PendingTransactions { | |||
public static final int PENDING_TX_RETENTION_PERIOD = 13; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a unit in the name. Seconds? Minutes? Hours? PENDING_TX_RETENTION_HOURS?
@@ -154,7 +154,9 @@ public TestNode( | |||
TestClock.fixed(), | |||
PendingTransactions.MAX_PENDING_TRANSACTIONS, | |||
metricsSystem, | |||
syncState); | |||
syncState, | |||
13); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the constant.
@@ -1056,7 +1056,8 @@ public void transactionMessagesGoToTheCorrectExecutor() { | |||
TestClock.fixed(), | |||
PendingTransactions.MAX_PENDING_TRANSACTIONS, | |||
metricsSystem, | |||
mock(SyncState.class)); | |||
mock(SyncState.class), | |||
13); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the constant.
@@ -34,6 +34,7 @@ | |||
String PANTHEON_HOME_PROPERTY_NAME = "pantheon.home"; | |||
String DEFAULT_DATA_DIR_PATH = "./build/data"; | |||
String MANDATORY_INTEGER_FORMAT_HELP = "<INTEGER>"; | |||
String PENDING_TX_RETENTION_PERIOD_FORMAT_HELP = "<INTEGER>h<INTEGER>m<INTEGER>s"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be just DURATION_HELP if we parse into the duration object.
names = {"--tx-pool-retention-period"}, | ||
paramLabel = PENDING_TX_RETENTION_PERIOD_FORMAT_HELP, | ||
description = | ||
"Maximum retention period of pending transactions in the transaction pool (default: ${DEFAULT-VALUE})", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need unit in the text if we stay at long/integer.
@@ -705,6 +713,7 @@ private void ensureAllNodesAreInWhitelist( | |||
.metricsSystem(metricsSystem.get()) | |||
.privacyParameters(privacyParameters()) | |||
.clock(Clock.systemUTC()) | |||
.pendingTransactionRetentionPeriod(pendingTxRetentionPeriod) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, move next to maxPendingTransactions.
@@ -77,6 +77,10 @@ | |||
private final List<Runnable> shutdownActions = new ArrayList<>(); | |||
private RocksDbConfiguration rocksdDbConfiguration; | |||
|
|||
/* * */ | |||
protected Integer pendingTransactionRetentionPeriod; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, adjacent to maxPendingTransactions. Also, needs a unit or needs to go to Duration. One of those.
@@ -151,6 +155,12 @@ | |||
return this; | |||
} | |||
|
|||
public PantheonControllerBuilder<C> pendingTransactionRetentionPeriod( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, adjacency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad but -- what do you mean by adjacency? maybe you mean move it near to maxPendingTransactions
, but already it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prior to the force push it wasn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, yeah- I always have to force push after I rebase - is there a better way to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to use git pull upstream master --no-rebase
when pulling changes from master after I've created the PR the first time. Avoids the need to force push.
@@ -215,6 +225,10 @@ | |||
PeerValidatorRunner.runValidator(ethContext, daoForkPeerValidator); | |||
} | |||
|
|||
if (pendingTransactionRetentionPeriod == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like stray debug code.
8e6b535
to
1533063
Compare
@@ -33,7 +33,12 @@ public static TransactionPool createTransactionPool( | |||
final Clock clock, | |||
final int maxPendingTransactions, | |||
final MetricsSystem metricsSystem, | |||
final SyncState syncState) { | |||
final SyncState syncState, | |||
final int pendingTransactionRetentionPeriod) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This argument needs to be grouped next to maxPendingTransactions. between line 34 and 35
@@ -34,6 +34,7 @@ | |||
String PANTHEON_HOME_PROPERTY_NAME = "pantheon.home"; | |||
String DEFAULT_DATA_DIR_PATH = "./build/data"; | |||
String MANDATORY_INTEGER_FORMAT_HELP = "<INTEGER>"; | |||
String DURATION_HELP = "<INTEGER>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless it's a new string simply re-use the existing generic strings. This can be deleted until we go to duration objects.
@@ -483,6 +483,14 @@ void setBootnodes(final List<String> values) { | |||
arity = "1") | |||
private final Integer txPoolMaxSize = PendingTransactions.MAX_PENDING_TRANSACTIONS; | |||
|
|||
@Option( | |||
names = {"--tx-pool-retention-hours"}, | |||
paramLabel = DURATION_HELP, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paramLabel = DURATION_HELP, | |
paramLabel = MANDATORY_INTEGER_FORMAT_HELP, |
@@ -151,6 +155,12 @@ | |||
return this; | |||
} | |||
|
|||
public PantheonControllerBuilder<C> pendingTransactionRetentionPeriod( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prior to the force push it wasn't
@@ -133,6 +133,7 @@ private void syncFromGenesis(final SyncMode mode) throws Exception { | |||
.clock(TestClock.fixed()) | |||
.maxPendingTransactions(PendingTransactions.MAX_PENDING_TRANSACTIONS) | |||
.storageProvider(createKeyValueStorageProvider(dbAhead)) | |||
.pendingTransactionRetentionPeriod(PendingTransactions.PENDING_TX_RETENTION_HOURS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move up a line, next to maxPendingTransacitons.
@@ -152,6 +153,7 @@ private void syncFromGenesis(final SyncMode mode) throws Exception { | |||
.clock(TestClock.fixed()) | |||
.maxPendingTransactions(PendingTransactions.MAX_PENDING_TRANSACTIONS) | |||
.storageProvider(createKeyValueStorageProvider(dbAhead)) | |||
.pendingTransactionRetentionPeriod(PendingTransactions.PENDING_TX_RETENTION_HOURS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move up a line, next to maxPendingTransacitons.
e05f1e1
to
742044a
Compare
4daf3fb
to
b888bf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a couple of nits to sort out.
@@ -151,6 +155,12 @@ | |||
return this; | |||
} | |||
|
|||
public PantheonControllerBuilder<C> pendingTransactionRetentionPeriod( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to use git pull upstream master --no-rebase
when pulling changes from master after I've created the PR the first time. Avoids the need to force push.
names = {"--tx-pool-retention-hours"}, | ||
paramLabel = MANDATORY_INTEGER_FORMAT_HELP, | ||
description = | ||
"Maximum retention period of pending transactions, expressed in hours. Represented by primitive type 'long'. (default: ${DEFAULT-VALUE})", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: drop the redundant word 'expressed' and user's don't care how we represent the value internally.
"Maximum retention period of pending transactions, expressed in hours. Represented by primitive type 'long'. (default: ${DEFAULT-VALUE})", | |
"Maximum retention period of pending transactions in hours (default: ${DEFAULT-VALUE})", |
|
||
verify(mockControllerBuilder).pendingTransactionRetentionPeriod(intArgumentCaptor.capture()); | ||
|
||
assertThat(intArgumentCaptor.getAllValues().get(0)).isEqualTo(pendingTxRetentionHours); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to use the int argument captor here - the verify(mockControllerBuilder).pendingTransactionRetentionPeriod(eq(pendingTxRetentionHours));
line below is enough to assert that the method was called with the argument we expect. You'd only use an argument captor when you don't know what the argument will be but want to check it's the same value used in some other place.
PR description
The acceptance criteria for this task has two components:
Configuration option to specify maximum length of time transactions are held in the pending transaction list before being dropped
When a transaction has been in the pending transaction list for the configured maximum period, it is removed
This change is intended to address the former.
Fixed Issue(s)
Specify at the command line (
PantheonCommand
) the maximum length of time transactions are held in the pending transaction list before being dropped.