nethermind
nethermind copied to clipboard
Return `Accepted` if tx was rejected from standard TxPool, but added to broadcaster
Description
If tx from RPC is too cheap to add to standard TxPool, we are returning AcceptTxResult.FeeTooLowToCompete
even if tx was added to persistent broadcast. This way tx which we responded that was rejected, might still be included in the chain.
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.TxPool/TxPool.cs#L450-L461
Expected behavior If tx is not persistent (from network), do the same as now. If tx is persistent (from RPC), in this place: https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.TxPool/TxPool.cs#L457 refactor it e.g. to be bool TryBroadcast and in case if tx will be added to persistent broadcast, just return added. so just instead of:
if (tx.Hash == removed?.Hash)
{
if (isPersistentBroadcast)
{
_broadcaster.Broadcast(tx, isPersistentBroadcast);
}
Metrics.PendingTransactionsPassedFiltersButCannotCompeteOnFees++;
return AcceptTxResult.FeeTooLowToCompete;
}
do something like:
bool alreadyBroadcasted = false;
if (tx.Hash == removed?.Hash)
{
if (!isPersistentBroadcast || tx.SupportsBlobs || !_broadcaster.TryBroadcast(tx, true))
{
Metrics.PendingTransactionsPassedFiltersButCannotCompeteOnFees++;
return AcceptTxResult.FeeTooLowToCompete;
}
alreadyBroadcasted = true;
}
then here: https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.TxPool/TxPool.cs#L478 broadcast only if wasn't broadcasted yet
Feel free to solve the issue other way. Remember about tests
Optionally accept RPC txs to persistent pool (if rejected from std pools) only if fee is equal at least some % of current base fee (maybe refactor it https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.TxPool/TxBroadcaster.cs#L100-L125)
Hi @marcindsobczak is this issue solved by @pxyxyrus ?, is there something still pending, if yes, can you assign it to me?
It is solved @rishabhRsinghvi