diff --git a/src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.cs b/src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.cs index ceec28b4b1e..06c9e82c6c1 100644 --- a/src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.cs +++ b/src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.cs @@ -1690,6 +1690,35 @@ public void Should_correctly_add_tx_to_local_pool_when_underpaid([Values] TxType _txPool.GetPendingTransactions().Should().NotContain(testTx); } + static IEnumerable<(byte[], AcceptTxResult)> CodeCases() + { + yield return (new byte[16], AcceptTxResult.SenderIsContract); + //Delegation code + yield return ([..Eip7702Constants.DelegationHeader, ..new byte[20]], AcceptTxResult.Accepted); + } + [TestCaseSource(nameof(CodeCases))] + public void SubmitTx_((byte[] code, AcceptTxResult expected) testCase) + { + ISpecProvider specProvider = GetPragueSpecProvider(); + TxPoolConfig txPoolConfig = new TxPoolConfig { Size = 30, PersistentBlobStorageSize = 0 }; + _txPool = CreatePool(txPoolConfig, specProvider); + + Transaction testTx = Build.A.Transaction + .WithNonce(0) + .WithMaxFeePerGas(9.GWei()) + .WithMaxPriorityFeePerGas(9.GWei()) + .WithGasLimit(100_000) + .WithTo(TestItem.AddressB) + .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject; + + EnsureSenderBalance(TestItem.PrivateKeyA.Address, UInt256.MaxValue); + + _stateProvider.InsertCode(TestItem.PrivateKeyA.Address, testCase.code, Prague.Instance); + + AcceptTxResult result = _txPool.SubmitTx(testTx, TxHandlingOptions.PersistentBroadcast); + result.Should().Be(testCase.expected); + } + private IDictionary GetPeers(int limit = 100) { var peers = new Dictionary(); diff --git a/src/Nethermind/Nethermind.TxPool/TxPool.cs b/src/Nethermind/Nethermind.TxPool/TxPool.cs index 5d09aace6d1..36fa328135b 100644 --- a/src/Nethermind/Nethermind.TxPool/TxPool.cs +++ b/src/Nethermind/Nethermind.TxPool/TxPool.cs @@ -52,8 +52,6 @@ public class TxPool : ITxPool, IDisposable private readonly IBlobTxStorage _blobTxStorage; private readonly IChainHeadInfoProvider _headInfo; private readonly ITxPoolConfig _txPoolConfig; - private readonly ICodeInfoRepository _codeInfoRepository; - private readonly IWorldState _worldState; private readonly bool _blobReorgsSupportEnabled; private readonly ILogger _logger; @@ -106,8 +104,6 @@ public TxPool(IEthereumEcdsa ecdsa, _blobTxStorage = blobTxStorage ?? throw new ArgumentNullException(nameof(blobTxStorage)); _headInfo = chainHeadInfoProvider ?? throw new ArgumentNullException(nameof(chainHeadInfoProvider)); _txPoolConfig = txPoolConfig; - _codeInfoRepository = codeInfoRepository; - _worldState = worldState; _blobReorgsSupportEnabled = txPoolConfig.BlobsSupport.SupportsReorgs(); _accounts = _accountCache = new AccountCache(_headInfo.AccountStateProvider); _specProvider = _headInfo.SpecProvider; @@ -157,7 +153,7 @@ public TxPool(IEthereumEcdsa ecdsa, postHashFilters.Add(incomingTxFilter); } - postHashFilters.Add(new DeployedCodeFilter(_worldState, _codeInfoRepository, _specProvider)); + postHashFilters.Add(new DeployedCodeFilter(worldState, codeInfoRepository, _specProvider)); _postHashFilters = postHashFilters.ToArray();