Skip to content
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

Broadcast best persistent txs instead of random #3768

Merged
merged 27 commits into from
Feb 11, 2022
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
950c024
broadcast specified % of best txs in persistent broadcast instead of …
marcindsobczak Jan 25, 2022
b9065a3
broadcast only if persistent broadcast enabled
marcindsobczak Jan 25, 2022
8d13892
sort and broadcast only tx with lowest nonce of every address
marcindsobczak Jan 26, 2022
b74bb48
ensure there are no stale txs in broadcaster
marcindsobczak Jan 26, 2022
e47b7bd
add xml description
marcindsobczak Jan 27, 2022
aecccb4
fix concurrency issue
marcindsobczak Jan 27, 2022
11799f9
test for removing stale txs from persistent broadcast
marcindsobczak Jan 27, 2022
ca5c4a3
cosmetic
marcindsobczak Jan 27, 2022
9a8be4a
limit max amount of picked txs to actual number of them
marcindsobczak Jan 27, 2022
99ab9c3
simplified broadcaster
marcindsobczak Jan 27, 2022
da671bd
add test for picking best txs from persistent txs
marcindsobczak Jan 27, 2022
ef31c7c
add more test cases
marcindsobczak Jan 27, 2022
77b30d3
cosmetic, add comment
marcindsobczak Jan 27, 2022
3e192bb
Merge remote-tracking branch 'origin/master' into refactor/persistent…
marcindsobczak Jan 27, 2022
3e2fbbe
method names changes
marcindsobczak Jan 31, 2022
4674cfa
refactor getting stale txs algorithm to be thread safe
marcindsobczak Jan 31, 2022
535d95a
one more test
marcindsobczak Jan 31, 2022
106a049
cosmetic
marcindsobczak Jan 31, 2022
2581e41
make test more accurate
marcindsobczak Jan 31, 2022
824bafa
cosmetic
marcindsobczak Jan 31, 2022
9e59a33
drop linq
marcindsobczak Jan 31, 2022
f90e257
small refactor
LukaszRozmej Jan 31, 2022
b85812b
small refactoring
LukaszRozmej Feb 1, 2022
6e413b6
broadcast from persistent txs only when MaxFeePerGas >= CurrentBaseFee
marcindsobczak Feb 1, 2022
7f99c62
add tests
marcindsobczak Feb 1, 2022
30fcfeb
fix test
marcindsobczak Feb 1, 2022
39a1c69
break when all txs picked
marcindsobczak Feb 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions src/Nethermind/Nethermind.TxPool/Collections/SortedPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,26 +236,23 @@ public IEnumerable<TValue> TryGetStaleValues(TGroupKey groupKey, Predicate<TValu
{
if (_buckets.TryGetValue(groupKey, out SortedSet<TValue>? bucket))
{
if (!where(bucket.First()))
{
return ArraySegment<TValue>.Empty;
}

List<TValue> staleValues = new() { bucket.First() };
foreach (TValue value in bucket.Skip(1))
using SortedSet<TValue>.Enumerator enumerator = bucket.GetEnumerator();
bool keepGoing = true;
List<TValue>? list = null;

while (keepGoing && enumerator.MoveNext())
{
if (where(value))
{
staleValues.Add(value);
}
else
keepGoing = where(enumerator.Current);
if (keepGoing)
{
return staleValues;
list ??= new List<TValue>();
list.Add(enumerator.Current);
}
else return list ?? Enumerable.Empty<TValue>();
}
return staleValues;
return list!;
LukaszRozmej marked this conversation as resolved.
Show resolved Hide resolved
}
return ArraySegment<TValue>.Empty;
return Enumerable.Empty<TValue>();
}

/// <summary>
Expand Down