-
Notifications
You must be signed in to change notification settings - Fork 673
Make txpool test run faster #9382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0096352
Make txpool test run faster
asdacap 48c3102
Fix randomly failing pyspec test
asdacap f84c5ea
parallelize BroadcasterTests more
LukaszRozmej 99f543a
Even more
LukaszRozmej 8ec37c8
Parallelize more
LukaszRozmej 77e0280
Remove this part
asdacap 78ab65d
more parallel
LukaszRozmej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,15 +76,15 @@ public async Task should_not_broadcast_persisted_tx_to_peer_too_quickly() | |
| int addedTxsCount = TestItem.PrivateKeys.Length; | ||
| Transaction[] transactions = new Transaction[addedTxsCount]; | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| Parallel.For(0, addedTxsCount, i => | ||
| { | ||
| transactions[i] = Build.A.Transaction | ||
| .WithGasPrice(i.GWei()) | ||
| .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeys[i]) | ||
| .TestObject; | ||
|
|
||
| _broadcaster.Broadcast(transactions[i], true); | ||
| } | ||
| }); | ||
|
|
||
| _broadcaster.GetSnapshot().Length.Should().Be(addedTxsCount); | ||
|
|
||
|
|
@@ -126,15 +126,15 @@ public void should_pick_best_persistent_txs_to_broadcast([Values(1, 2, 99, 100, | |
| int addedTxsCount = TestItem.PrivateKeys.Length; | ||
| Transaction[] transactions = new Transaction[addedTxsCount]; | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| Parallel.For(0, addedTxsCount, i => | ||
| { | ||
| transactions[i] = Build.A.Transaction | ||
| .WithGasPrice(i.GWei()) | ||
| .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeys[i]) | ||
| .TestObject; | ||
|
|
||
| _broadcaster.Broadcast(transactions[i], true); | ||
| } | ||
| }); | ||
|
|
||
| _broadcaster.GetSnapshot().Length.Should().Be(addedTxsCount); | ||
|
|
||
|
|
@@ -210,7 +210,7 @@ public void should_skip_large_txs_when_picking_best_persistent_txs_to_broadcast( | |
| int addedTxsCount = TestItem.PrivateKeys.Length; | ||
| Transaction[] transactions = new Transaction[addedTxsCount]; | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| Parallel.For(0, addedTxsCount, i => | ||
| { | ||
| bool isLarge = i % 10 == 0; | ||
| transactions[i] = Build.A.Transaction | ||
|
|
@@ -221,7 +221,7 @@ public void should_skip_large_txs_when_picking_best_persistent_txs_to_broadcast( | |
| .TestObject; | ||
|
|
||
| _broadcaster.Broadcast(transactions[i], true); | ||
| } | ||
| }); | ||
|
|
||
| _broadcaster.GetSnapshot().Length.Should().Be(addedTxsCount); | ||
|
|
||
|
|
@@ -256,7 +256,7 @@ public void should_skip_blob_txs_when_picking_best_persistent_txs_to_broadcast([ | |
| int addedTxsCount = TestItem.PrivateKeys.Length; | ||
| Transaction[] transactions = new Transaction[addedTxsCount]; | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| Parallel.For(0, addedTxsCount, i => | ||
| { | ||
| bool isBlob = i % 10 == 0; | ||
| transactions[i] = Build.A.Transaction | ||
|
|
@@ -267,7 +267,7 @@ public void should_skip_blob_txs_when_picking_best_persistent_txs_to_broadcast([ | |
| .TestObject; | ||
|
|
||
| _broadcaster.Broadcast(transactions[i], true); | ||
| } | ||
| }); | ||
|
|
||
| _broadcaster.GetSnapshot().Length.Should().Be(addedTxsCount); | ||
|
|
||
|
|
@@ -308,15 +308,15 @@ public void should_not_pick_txs_with_GasPrice_lower_than_CurrentBaseFee([Values( | |
| int addedTxsCount = TestItem.PrivateKeys.Length; | ||
| Transaction[] transactions = new Transaction[addedTxsCount]; | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| Parallel.For(0, addedTxsCount, i => | ||
| { | ||
| transactions[i] = Build.A.Transaction | ||
| .WithGasPrice(i.GWei()) | ||
| .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeys[i]) | ||
| .TestObject; | ||
|
|
||
| _broadcaster.Broadcast(transactions[i], true); | ||
| } | ||
| }); | ||
|
|
||
| _broadcaster.GetSnapshot().Length.Should().Be(addedTxsCount); | ||
|
|
||
|
|
@@ -382,7 +382,7 @@ public void should_not_pick_1559_txs_with_MaxFeePerGas_lower_than_CurrentBaseFee | |
| int addedTxsCount = TestItem.PrivateKeys.Length; | ||
| Transaction[] transactions = new Transaction[addedTxsCount]; | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| Parallel.For(0, addedTxsCount, i => | ||
| { | ||
| transactions[i] = Build.A.Transaction | ||
| .WithType(TxType.EIP1559) | ||
|
|
@@ -391,7 +391,7 @@ public void should_not_pick_1559_txs_with_MaxFeePerGas_lower_than_CurrentBaseFee | |
| .TestObject; | ||
|
|
||
| _broadcaster.Broadcast(transactions[i], true); | ||
| } | ||
| }); | ||
|
|
||
| _broadcaster.GetSnapshot().Length.Should().Be(addedTxsCount); | ||
|
|
||
|
|
@@ -423,14 +423,17 @@ public void should_not_pick_blob_txs_with_MaxFeePerBlobGas_lower_than_CurrentFee | |
| int addedTxsCount = TestItem.PrivateKeys.Length; | ||
| Transaction[] transactions = new Transaction[addedTxsCount]; | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| Parallel.For(0, addedTxsCount, i => | ||
| { | ||
| transactions[i] = Build.A.Transaction | ||
| .WithShardBlobTxTypeAndFields() | ||
| .WithMaxFeePerBlobGas(i.GWei()) | ||
| .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeys[i]) | ||
| .TestObject; | ||
| }); | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| { | ||
|
Comment on lines
+435
to
+436
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
| _broadcaster.Broadcast(transactions[i], true); | ||
| } | ||
|
|
||
|
|
@@ -466,7 +469,7 @@ public void should_pick_tx_with_lowest_nonce_from_bucket() | |
| const int addedTxsCount = 5; | ||
| Transaction[] transactions = new Transaction[addedTxsCount]; | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| Parallel.For(0, addedTxsCount, i => | ||
| { | ||
| transactions[i] = Build.A.Transaction | ||
| .WithNonce((UInt256)i) | ||
|
|
@@ -475,7 +478,7 @@ public void should_pick_tx_with_lowest_nonce_from_bucket() | |
| .TestObject; | ||
|
|
||
| _broadcaster.Broadcast(transactions[i], true); | ||
| } | ||
| }); | ||
| _broadcaster.GetSnapshot().Length.Should().Be(addedTxsCount); | ||
|
|
||
| IList<Transaction> pickedTxs = _broadcaster.GetPersistentTxsToSend().TransactionsToSend; | ||
|
|
@@ -676,13 +679,13 @@ public void should_rebroadcast_all_persistent_transactions_if_PeerNotificationTh | |
| _txPoolConfig = new TxPoolConfig() { Size = 100, PeerNotificationThreshold = shouldBroadcastAll ? 100 : 5 }; | ||
| _broadcaster = new TxBroadcaster(_comparer, TimerFactory.Default, _txPoolConfig, _headInfo, _logManager); | ||
|
|
||
| for (int i = 0; i < _txPoolConfig.Size; i++) | ||
| Parallel.For(0, _txPoolConfig.Size, i => | ||
| { | ||
| Transaction tx = Build.A.Transaction | ||
| .WithNonce((UInt256)i) | ||
| .SignedAndResolved(TestItem.PrivateKeyA).TestObject; | ||
| _broadcaster.Broadcast(tx, true); | ||
| } | ||
| }); | ||
|
|
||
| Transaction[] pickedTxs = _broadcaster.GetPersistentTxsToSend().TransactionsToSend.ToArray(); | ||
| pickedTxs.Length.Should().Be(shouldBroadcastAll ? 100 : 1); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.