Commit 93e5c77
authored
[SharovBot] fix(txpool): evict zombie queued txns exceeding MaxNonceGap (#19449)
**[SharovBot]**
## Split from #19393 per @yperbasis review
This PR contains **Bug #2 only** (zombie queued transaction eviction),
extracted from #19393 which was asked to be split into separate PRs.
## Problem
Queued transactions with an impossibly large nonce gap (e.g. on-chain
nonce=281, queued nonce=16,814 — gap of 16,533) sit in the pool forever.
They can never become pending without filling thousands of nonce
positions first, causing unbounded queued pool bloat (4,000+ txns
observed on Gnosis Chain, Erigon 3.3.8).
The existing blob-txn nonce-gap eviction only covered `BlobTxnType`.
Regular transactions had no gap limit.
## Fix
- Add `MaxNonceGap uint64` to `txpoolcfg.Config` (default: 64)
- Add `NonceTooDistant` (DiscardReason 37) for observability
- In `onSenderStateChange`, evict txns whose nonce exceeds `noGapsNonce`
by more than `MaxNonceGap`
- `noGapsNonce` accounts for consecutive txns already pooled, so
consecutive txns are never zombie-evicted
- Fix `toDelReasons` parallel slice to track correct discard reason per
evicted tx (was always logging `NonceTooLow`)
## Tests
- `TestZombieQueuedEviction` — 3 sub-tests:
1. Zombie tx (gap=65 > MaxNonceGap=64) is evicted with `NonceTooDistant`
2. Tx at exactly MaxNonceGap boundary (gap=64) is kept
3. Consecutive txns beyond MaxNonceGap are never zombie-evicted
## Testing
```
go build ./txnprovider/txpool/... ✅
go test ./txnprovider/txpool/... -run TestZombieQueuedEviction -count=1 ✅
```
## Related
- Bug #1 (stale pending / AuRa nonce) will be addressed separately per
@yperbasis feedback
- Backport to release/3.3 will follow once this is merged
- Original combined PR: #193931 parent 1fc4ace commit 93e5c77
File tree
3 files changed
+189
-3
lines changed- txnprovider/txpool
- txpoolcfg
3 files changed
+189
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1863 | 1863 | | |
1864 | 1864 | | |
1865 | 1865 | | |
1866 | | - | |
| 1866 | + | |
| 1867 | + | |
1867 | 1868 | | |
1868 | 1869 | | |
1869 | 1870 | | |
| 1871 | + | |
1870 | 1872 | | |
1871 | 1873 | | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
1872 | 1882 | | |
1873 | 1883 | | |
1874 | 1884 | | |
| |||
1888 | 1898 | | |
1889 | 1899 | | |
1890 | 1900 | | |
| 1901 | + | |
1891 | 1902 | | |
1892 | 1903 | | |
1893 | 1904 | | |
| |||
1956 | 1967 | | |
1957 | 1968 | | |
1958 | 1969 | | |
1959 | | - | |
1960 | | - | |
| 1970 | + | |
| 1971 | + | |
1961 | 1972 | | |
1962 | 1973 | | |
1963 | 1974 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1815 | 1815 | | |
1816 | 1816 | | |
1817 | 1817 | | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
| |||
77 | 83 | | |
78 | 84 | | |
79 | 85 | | |
| 86 | + | |
| 87 | + | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
| |||
121 | 129 | | |
122 | 130 | | |
123 | 131 | | |
| 132 | + | |
124 | 133 | | |
125 | 134 | | |
126 | 135 | | |
| |||
199 | 208 | | |
200 | 209 | | |
201 | 210 | | |
| 211 | + | |
| 212 | + | |
202 | 213 | | |
203 | 214 | | |
204 | 215 | | |
| |||
0 commit comments