Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PAN-1339] Send local transactions to new peers #1253

Merged
merged 11 commits into from
Apr 23, 2019

Conversation

smatthewenglish
Copy link
Contributor

@smatthewenglish smatthewenglish commented Apr 10, 2019

PR description

Method on TransactionPool to disseminate local transactions to newly connected peers.

Fixed Issue(s)

When a new peer connects, local transactions are sent to it

  • Remote transactions are not sent to newly connected peers

  • Event loop threads are not blocked while sending transactions

@smatthewenglish smatthewenglish added the work in progress Work on this pull request is ongoing label Apr 10, 2019
@smatthewenglish smatthewenglish force-pushed the palmbomen branch 8 times, most recently from 834a9a5 to 9f563b3 Compare April 16, 2019 17:47
for (Transaction transaction : localTransactions) {
peerTransactionTracker.addToPeerSendQueue(peer, transaction);
}
peerTransactionTracker.markTransactionsAsSeen(peer, localTransactions);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to call markTransactionsAsSeen. Marking seen transactions will be handled by TransactionsMessageSender.

@@ -101,9 +103,20 @@ public void setUp() {
SyncState syncState = mock(SyncState.class);
when(syncState.isInSync(anyLong())).thenReturn(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some tests for the new functionality?

Copy link
Contributor

@mbaxter mbaxter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just left one comment to address.

RespondingEthPeer peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager);
EthPeers ethPeers = ethContext.getEthPeers();

ethPeers.registerConnection(peer.getPeerConnection());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to call this or expose this method publicly.

@mbaxter
Copy link
Contributor

mbaxter commented Apr 17, 2019

Also, can you update the PR description?

Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a few little clean ups just to keep things tidy.

@@ -432,9 +450,19 @@ public void shouldAllowTransactionWhenAccountWhitelistControllerIsNotPresent() {
public void shouldRejectRemoteTransactionsWhenNotInSync() {
SyncState syncState = mock(SyncState.class);
when(syncState.isInSync(anyLong())).thenReturn(false);
EthContext ethContext = mock(EthContext.class);
EthPeers ethPeers = mock(EthPeers.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't these mocks be created as fields and just reused? Would save a lot of noise through the tests.

.thenReturn(valid());
when(transactionValidator.validateForSender(
eq(transactionRemote), nullable(Account.class), eq(true)))
.thenReturn(valid());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You could collapse this to one line:

when(transactionValidator.validateForSender(any(Transaction.class), nullable(Account.class), eq(true)).thenReturn(valid());

Set<Transaction> transactionsToSendToPeer =
peerTransactionTracker.claimTransactionsToSendToPeer(peer.getEthPeer());

assertThat(transactionsToSendToPeer.size()).isEqualTo(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be:

Suggested change
assertThat(transactionsToSendToPeer.size()).isEqualTo(1);
assertThat(transactionsToSendToPeer).containsExactly(transactionLocal);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then remove the line below that checks the hash.

@smatthewenglish smatthewenglish merged commit 9f3a56d into PegaSysEng:master Apr 23, 2019
notlesh pushed a commit to notlesh/pantheon that referenced this pull request Apr 24, 2019
notlesh pushed a commit to notlesh/pantheon that referenced this pull request May 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants