-
Notifications
You must be signed in to change notification settings - Fork 432
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
Fix/6790 return accepted for rejected tx added to broadcast #6889
Changes from 6 commits
ca922d9
1e4670a
401e318
13a767a
919bd2d
14e8b79
7936a1e
ca67a97
6d0a22c
7dfbdb6
4757f6f
018afc9
be126f5
b64dd50
3c19462
926c381
f8546dd
c695cc5
8360abc
031d15e
f97394e
a6150f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,31 +97,35 @@ public TxBroadcaster(IComparer<Transaction> comparer, | |
// only for testing reasons | ||
internal Transaction[] GetSnapshot() => _persistentTxs.GetSnapshot(); | ||
|
||
public void Broadcast(Transaction tx, bool isPersistent) | ||
public bool Broadcast(Transaction tx, bool isPersistent) | ||
{ | ||
if (isPersistent) | ||
{ | ||
StartBroadcast(tx); | ||
} | ||
else | ||
{ | ||
BroadcastOnce(tx); | ||
return StartBroadcast(tx); | ||
} | ||
|
||
BroadcastOnce(tx); | ||
|
||
return true; | ||
} | ||
|
||
private void StartBroadcast(Transaction tx) | ||
private bool StartBroadcast(Transaction tx) | ||
{ | ||
if (tx is null) return false; | ||
|
||
bool txInserted = _persistentTxs.TryInsert(tx.Hash, tx.SupportsBlobs ? new LightTransaction(tx) : tx); | ||
|
||
if (!txInserted) return false; | ||
|
||
// broadcast local tx only if MaxFeePerGas is not lower than configurable percent of current base fee | ||
// (70% by default). Otherwise only add to persistent txs and broadcast when tx will be ready for inclusion | ||
if (tx.MaxFeePerGas >= _baseFeeThreshold || tx.IsFree()) | ||
{ | ||
NotifyPeersAboutLocalTx(tx); | ||
return true; | ||
} | ||
|
||
if (tx.Hash is not null) | ||
{ | ||
_persistentTxs.TryInsert(tx.Hash, tx.SupportsBlobs ? new LightTransaction(tx) : tx); | ||
} | ||
return false; | ||
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. After this change, we will return
It depends if we want to add local tx with fee lower than 70% of 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. ah sorry I reviewed on wrong commit |
||
} | ||
|
||
private void BroadcastOnce(Transaction tx) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,14 +450,15 @@ private AcceptTxResult AddCore(Transaction tx, TxFilteringState state, bool isPe | |
if (tx.Hash == removed?.Hash) | ||
{ | ||
// it means it was added and immediately evicted - pool was full of better txs | ||
if (isPersistentBroadcast) | ||
if (!isPersistentBroadcast || tx.SupportsBlobs || !_broadcaster.Broadcast(tx, true)) | ||
{ | ||
// we are adding only to persistent broadcast - not good enough for standard pool, | ||
// but can be good enough for TxBroadcaster pool - for local txs only | ||
_broadcaster.Broadcast(tx, isPersistentBroadcast); | ||
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. what happened to 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. Since the if branch now has the opposite condition, if the
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. Not sure if running through all the normal flow here is best choice as this is a special case, when something we are not adding to main pool will have broadcasting, will wait for @marcindsobczak opinion. 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. Not a good option, we definitely don't want to run through all the normal flow here |
||
Metrics.PendingTransactionsPassedFiltersButCannotCompeteOnFees++; | ||
return AcceptTxResult.FeeTooLowToCompete; | ||
} else { | ||
return AcceptTxResult.Accepted; | ||
} | ||
Metrics.PendingTransactionsPassedFiltersButCannotCompeteOnFees++; | ||
return AcceptTxResult.FeeTooLowToCompete; | ||
} | ||
|
||
relevantPool.UpdateGroup(tx.SenderAddress!, state.SenderAccount, UpdateBucketWithAddedTransaction); | ||
|
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.
Minor cosmetic: would be good to rename method, right now we are not calling it if we want to
broadcast
(void), but when we want totry to broadcast
(bool return depending on success). So I recommend renaming it toTryBroadcast
andTryStartBroadcast
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.
Worth to consider before merging