Skip to content

Commit 2be1890

Browse files
benaadamskamilchodola
authored andcommitted
Accept local tx even when syncing (#8242)
1 parent 4264b17 commit 2be1890

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ public void should_accept_access_list_transactions_only_when_eip2930_enabled([Va
11511151
}
11521152

11531153
[Test]
1154-
public void should_accept_only_when_synced([Values(false, true)] bool isSynced)
1154+
public void should_accept_only_when_synced([Values(false, true)] bool isSynced, [Values(false, true)] bool isLocal)
11551155
{
11561156
if (!isSynced)
11571157
{
@@ -1165,9 +1165,9 @@ public void should_accept_only_when_synced([Values(false, true)] bool isSynced)
11651165
.WithChainId(TestBlockchainIds.ChainId)
11661166
.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject;
11671167
EnsureSenderBalance(tx);
1168-
AcceptTxResult result = _txPool.SubmitTx(tx, TxHandlingOptions.PersistentBroadcast);
1169-
_txPool.GetPendingTransactionsCount().Should().Be(isSynced ? 1 : 0);
1170-
result.Should().Be(isSynced ? AcceptTxResult.Accepted : AcceptTxResult.Syncing);
1168+
AcceptTxResult result = _txPool.SubmitTx(tx, isLocal ? TxHandlingOptions.PersistentBroadcast : TxHandlingOptions.None);
1169+
_txPool.GetPendingTransactionsCount().Should().Be((isSynced || isLocal) ? 1 : 0);
1170+
result.Should().Be((isSynced || isLocal) ? AcceptTxResult.Accepted : AcceptTxResult.Syncing);
11711171
}
11721172

11731173
[Test]

src/Nethermind/Nethermind.TxPool/TxPool.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,13 @@ public void RemovePeer(PublicKey nodeId)
419419

420420
public AcceptTxResult SubmitTx(Transaction tx, TxHandlingOptions handlingOptions)
421421
{
422-
if (!AcceptTxWhenNotSynced && _headInfo.IsSyncing) return AcceptTxResult.Syncing;
422+
if (!AcceptTxWhenNotSynced &&
423+
_headInfo.IsSyncing &&
424+
// If local tx allow it to be accepted even when syncing
425+
(handlingOptions & TxHandlingOptions.PersistentBroadcast) == 0)
426+
{
427+
return AcceptTxResult.Syncing;
428+
}
423429

424430
Metrics.PendingTransactionsReceived++;
425431

0 commit comments

Comments
 (0)