Skip to content

Commit 4a5771a

Browse files
authored
Merge branch 'ethereum:master' into gethintegration
2 parents 9ee4b89 + c5c7597 commit 4a5771a

File tree

23 files changed

+787
-200
lines changed

23 files changed

+787
-200
lines changed

accounts/usbwallet/trezor.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"errors"
2626
"fmt"
2727
"io"
28+
"math"
2829
"math/big"
2930

3031
"github.com/ethereum/go-ethereum/accounts"
@@ -249,7 +250,11 @@ func (w *trezorDriver) trezorSign(derivationPath []uint32, tx *types.Transaction
249250
}
250251
}
251252
// Extract the Ethereum signature and do a sanity validation
252-
if len(response.GetSignatureR()) == 0 || len(response.GetSignatureS()) == 0 || response.GetSignatureV() == 0 {
253+
if len(response.GetSignatureR()) == 0 || len(response.GetSignatureS()) == 0 {
254+
return common.Address{}, nil, errors.New("reply lacks signature")
255+
} else if response.GetSignatureV() == 0 && int(chainID.Int64()) <= (math.MaxUint32-36)/2 {
256+
// for chainId >= (MaxUint32-36)/2, Trezor returns signature bit only
257+
// https://github.com/trezor/trezor-mcu/pull/399
253258
return common.Address{}, nil, errors.New("reply lacks signature")
254259
}
255260
signature := append(append(response.GetSignatureR(), response.GetSignatureS()...), byte(response.GetSignatureV()))
@@ -261,7 +266,11 @@ func (w *trezorDriver) trezorSign(derivationPath []uint32, tx *types.Transaction
261266
} else {
262267
// Trezor backend does not support typed transactions yet.
263268
signer = types.NewEIP155Signer(chainID)
264-
signature[64] -= byte(chainID.Uint64()*2 + 35)
269+
// if chainId is above (MaxUint32 - 36) / 2 then the final v values is returned
270+
// directly. Otherwise, the returned value is 35 + chainid * 2.
271+
if signature[64] > 1 && int(chainID.Int64()) <= (math.MaxUint32-36)/2 {
272+
signature[64] -= byte(chainID.Uint64()*2 + 35)
273+
}
265274
}
266275

267276
// Inject the final signature into the transaction and sanity check the sender

build/checksums.txt

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,54 @@
55
# https://github.com/ethereum/execution-spec-tests/releases/download/pectra-devnet-6%40v1.0.0/
66
b69211752a3029083c020dc635fe12156ca1a6725a08559da540a0337586a77e fixtures_pectra-devnet-6.tar.gz
77

8-
# version:golang 1.24.1
8+
# version:golang 1.24.2
99
# https://go.dev/dl/
10-
8244ebf46c65607db10222b5806aeb31c1fcf8979c1b6b12f60c677e9a3c0656 go1.24.1.src.tar.gz
11-
8d627dc163a4bffa2b1887112ad6194af175dce108d606ed1714a089fb806033 go1.24.1.aix-ppc64.tar.gz
12-
addbfce2056744962e2d7436313ab93486660cf7a2e066d171b9d6f2da7c7abe go1.24.1.darwin-amd64.tar.gz
13-
58d529334561cff11087cd4ab18fe0b46d8d5aad88f45c02b9645f847e014512 go1.24.1.darwin-amd64.pkg
14-
295581b5619acc92f5106e5bcb05c51869337eb19742fdfa6c8346c18e78ff88 go1.24.1.darwin-arm64.tar.gz
15-
78b0fc8ddc344eb499f1a952c687cb84cbd28ba2b739cfa0d4eb042f07e44e82 go1.24.1.darwin-arm64.pkg
16-
e70053f56f7eb93806d80cbd5726f78509a0a467602f7bea0e2c4ee8ed7c3968 go1.24.1.dragonfly-amd64.tar.gz
17-
3595e2674ed8fe72e604ca59c964d3e5277aafb08475c2b1aaca2d2fd69c24fc go1.24.1.freebsd-386.tar.gz
18-
47d7de8bb64d5c3ee7b6723aa62d5ecb11e3568ef2249bbe1d4bbd432d37c00c go1.24.1.freebsd-amd64.tar.gz
19-
04eec3bcfaa14c1370cdf98e8307fac7e4853496c3045afb9c3124a29cbca205 go1.24.1.freebsd-arm.tar.gz
20-
51aa70146e40cfdc20927424083dc86e6223f85dc08089913a1651973b55665b go1.24.1.freebsd-arm64.tar.gz
21-
3c131d8e3fc285a1340f87813153e24226d3ddbd6e54f3facbd6e4c46a84655e go1.24.1.freebsd-riscv64.tar.gz
22-
201d09da737ba39d5367f87d4e8b31edaeeb3dc9b9c407cb8cfb40f90c5a727a go1.24.1.illumos-amd64.tar.gz
23-
8c530ecedbc17e42ce10177bea07ccc96a3e77c792ea1ea72173a9675d16ffa5 go1.24.1.linux-386.tar.gz
24-
cb2396bae64183cdccf81a9a6df0aea3bce9511fc21469fb89a0c00470088073 go1.24.1.linux-amd64.tar.gz
25-
8df5750ffc0281017fb6070fba450f5d22b600a02081dceef47966ffaf36a3af go1.24.1.linux-arm64.tar.gz
26-
6d95f8d7884bfe2364644c837f080f2b585903d0b771eb5b06044e226a4f120a go1.24.1.linux-armv6l.tar.gz
27-
19304a4a56e46d04604547d2d83235dc4f9b192c79832560ce337d26cc7b835a go1.24.1.linux-loong64.tar.gz
28-
6347be77fa5359c12a5308c8ab87147c1fc4717b0c216493d1706c3b9fcde22d go1.24.1.linux-mips.tar.gz
29-
1647df415f7030b82d4105670192aa7e8910e18563bb0d505192d72800cc2d21 go1.24.1.linux-mips64.tar.gz
30-
762da594e4ec0f9cf6defae6ef971f5f7901203ee6a2d979e317adec96657317 go1.24.1.linux-mips64le.tar.gz
31-
9d8133c7b23a557399fab870b5cf464079c2b623a43b214a7567cf11c254a444 go1.24.1.linux-mipsle.tar.gz
32-
132f10999abbaccbada47fa85462db30c423955913b14d6c692de25f4636c766 go1.24.1.linux-ppc64.tar.gz
33-
0fb522efcefabae6e37e69bdc444094e75bfe824ea6d4cc3cbc70c7ae1b16858 go1.24.1.linux-ppc64le.tar.gz
34-
eaef4323d5467ff97fb1979c8491764060dade19f02f3275a9313f9a0da3b9c0 go1.24.1.linux-riscv64.tar.gz
35-
6c05e14d8f11094cb56a1c50f390b6b658bed8a7cbd8d1a57e926581b7eabfce go1.24.1.linux-s390x.tar.gz
36-
5dbb287d343ea00d58a70b11629f32ee716dc50a6875c459ea2018df0f294cd8 go1.24.1.netbsd-386.tar.gz
37-
617aa3faee50ce84c343db0888e9a210c310a7203666b4ed620f31030c9fb32f go1.24.1.netbsd-amd64.tar.gz
38-
59a928b7080c4a6ac985946274b7c65ce1cecc0b468ecd992d17b7c12fab9296 go1.24.1.netbsd-arm.tar.gz
39-
28daa8d0feb4aef2af60cefa3305bb9314de7e8a05cbca41ac548964cdfe89b7 go1.24.1.netbsd-arm64.tar.gz
40-
b7382b2f5d99813aeac14db482faa3bfbd47a68880b607fa2a7e669e26bab9cd go1.24.1.openbsd-386.tar.gz
41-
2513b6537c45deead5e641c7ce7502913e7d5e6f0b21c52542fb11f81578690f go1.24.1.openbsd-amd64.tar.gz
42-
853c1917d4fc7b144c55a02842aa48542d5cc798dde8db96dc0fdbc263200e04 go1.24.1.openbsd-arm.tar.gz
43-
6bc207b91e6f6ae3347fb54616a8fb2f5c11983713846a4cef111ff3f4f94d14 go1.24.1.openbsd-arm64.tar.gz
44-
4279260e2f2b94ee94e81470d13db7367f4393b061fee60985528fa0fa430df4 go1.24.1.openbsd-ppc64.tar.gz
45-
6fc4023a0a339ee0778522364a127d94c78e62122288d47d820dba703f81dc07 go1.24.1.openbsd-riscv64.tar.gz
46-
b5eb9fafd77146e7e1f748acfd95559580ecc8d2f15abf432a20f58c929c7cd2 go1.24.1.plan9-386.tar.gz
47-
24dcad6361b141fc8cced15b092351e12a99d2e58d7013204a3013c50daf9fdd go1.24.1.plan9-amd64.tar.gz
48-
a026ac3b55aa1e6fdc2aaab30207a117eafbe965ed81d3aa0676409f280ddc37 go1.24.1.plan9-arm.tar.gz
49-
8e4f6a77388dc6e5aa481efd5abdb3b9f5c9463bb82f4db074494e04e5c84992 go1.24.1.solaris-amd64.tar.gz
50-
b799f4ab264eef12a014c759383ed934056608c483e0f73e34ea6caf9f1df5f9 go1.24.1.windows-386.zip
51-
db128981033ac82a64688a123f631e61297b6b8f52ca913145e57caa8ce94cc3 go1.24.1.windows-386.msi
52-
95666b551453209a2b8869d29d177285ff9573af10f085d961d7ae5440f645ce go1.24.1.windows-amd64.zip
53-
5968e7adcf26e68a54f1cd41ad561275a670a8e2ca5263bc375b524638557dfb go1.24.1.windows-amd64.msi
54-
e28c4e6d0b913955765b46157ab88ae59bb636acaa12d7bec959aa6900f1cebd go1.24.1.windows-arm64.zip
55-
6d352c1f154a102a5b90c480cc64bab205ccf2681e34e78a3a4d3f1ddfbc81e4 go1.24.1.windows-arm64.msi
10+
9dc77ffadc16d837a1bf32d99c624cb4df0647cee7b119edd9e7b1bcc05f2e00 go1.24.2.src.tar.gz
11+
427b373540d8fd51dbcc46bdecd340af109cd41514443c000d3dcde72b2c65a3 go1.24.2.aix-ppc64.tar.gz
12+
238d9c065d09ff6af229d2e3b8b5e85e688318d69f4006fb85a96e41c216ea83 go1.24.2.darwin-amd64.tar.gz
13+
535ed9ff283fee39575a7fb9b6d8b1901b6dc640d06dc71fd7d3faeefdaf8030 go1.24.2.darwin-amd64.pkg
14+
b70f8b3c5b4ccb0ad4ffa5ee91cd38075df20fdbd953a1daedd47f50fbcff47a go1.24.2.darwin-arm64.tar.gz
15+
4732f607a47ce4d898c0af01ff68f07e0820a6b50603aef5d5c777d1102505e2 go1.24.2.darwin-arm64.pkg
16+
c17686b5fd61a663fbfafccfa177961be59386cf294e935ce35866b9dcb8e78a go1.24.2.dragonfly-amd64.tar.gz
17+
026f1dd906189acff714c7625686bbc4ed91042618ba010d45b671461acc9e63 go1.24.2.freebsd-386.tar.gz
18+
49399ba759b570a8f87d12179133403da6c2dd296d63a8830dee309161b9c40c go1.24.2.freebsd-amd64.tar.gz
19+
1f48f47183794d97c29736004247ab541177cf984ac6322c78bc43828daa1172 go1.24.2.freebsd-arm.tar.gz
20+
ef856428b60a8c0bd9a2cba596e83024be6f1c2d5574e89cb1ff2262b08df8b9 go1.24.2.freebsd-arm64.tar.gz
21+
ec2088823e16df00600a6d0f72e9a7dc6d2f80c9c140c2043c0cf20e1404d1a9 go1.24.2.freebsd-riscv64.tar.gz
22+
e030e7cedbb8688f1d75cb80f3de6ee2e6617a67d34051e794e5992b53462147 go1.24.2.illumos-amd64.tar.gz
23+
4c382776d52313266f3026236297a224a6688751256a2dffa3f524d8d6f6c0ba go1.24.2.linux-386.tar.gz
24+
68097bd680839cbc9d464a0edce4f7c333975e27a90246890e9f1078c7e702ad go1.24.2.linux-amd64.tar.gz
25+
756274ea4b68fa5535eb9fe2559889287d725a8da63c6aae4d5f23778c229f4b go1.24.2.linux-arm64.tar.gz
26+
438d5d3d7dcb239b58d893a715672eabe670b9730b1fd1c8fc858a46722a598a go1.24.2.linux-armv6l.tar.gz
27+
6aefd3bf59c3c5592eda4fb287322207f119c2210f3795afa9be48d3ccb73e1b go1.24.2.linux-loong64.tar.gz
28+
93e49bb4692783b0e9a2deab9558c6e8d2867f35592aeff285adda60924167f3 go1.24.2.linux-mips.tar.gz
29+
6e86e703675016f3faf6604b8f68f20dc1bba75849136e6dd4f43f69c8a4a9d9 go1.24.2.linux-mips64.tar.gz
30+
f233d237538ca1559a7d7cf519a29f0147923a951377bc4e467af4c059e68851 go1.24.2.linux-mips64le.tar.gz
31+
545e1b9a7939f923fd53bde98334b987ef42eb353ee3e0bfede8aa06079d6b24 go1.24.2.linux-mipsle.tar.gz
32+
6eab31481f2f46187bc1b6c887662eef06fc9d7271a8390854072cdb387c8d74 go1.24.2.linux-ppc64.tar.gz
33+
5fff857791d541c71d8ea0171c73f6f99770d15ff7e2ad979104856d01f36563 go1.24.2.linux-ppc64le.tar.gz
34+
91bda1558fcbd1c92769ad86c8f5cf796f8c67b0d9d9c19f76eecfc75ce71527 go1.24.2.linux-riscv64.tar.gz
35+
1cb3448166d6abb515a85a3ee5afbdf932081fb58ad7143a8fb666fbc06146d9 go1.24.2.linux-s390x.tar.gz
36+
a9a2c0db2e826f20f00b02bee01dfdaeb49591c2f6ffacb78dc64a950894f7ff go1.24.2.netbsd-386.tar.gz
37+
cd1a35b76ed9c7b6c0c1616741bd319699a77867ade0be9924f32496c0a87a3f go1.24.2.netbsd-amd64.tar.gz
38+
8c666388d066e479155cc5116950eeb435df28087ef277c18f1dc7479f836e60 go1.24.2.netbsd-arm.tar.gz
39+
5d42f0be04f58da5be788a1e260f8747c316b8ce182bf0b273c2e4c691feaa1a go1.24.2.netbsd-arm64.tar.gz
40+
688effa23ea3973cc8b0fdf4246712cbeef55ff20c45f3a9e28b0c2db04246cf go1.24.2.openbsd-386.tar.gz
41+
e5daf95f1048d8026b1366450a3f8044d668b0639db6422ad9a83755c6745cf7 go1.24.2.openbsd-amd64.tar.gz
42+
aeadaf74bd544d1a12ba9b14c0e7cdb1964de3ba9a52acb4619e91dbae7def7b go1.24.2.openbsd-arm.tar.gz
43+
9e222d9adb0ce836a5b3c8d5aadbd167c8869c030b113f4a81aa88e9a200f279 go1.24.2.openbsd-arm64.tar.gz
44+
192fffa34536adc3cd1bb7c1ee785b8bc156ae7afd10bbf5db99ec8f2e93066e go1.24.2.openbsd-ppc64.tar.gz
45+
a23e90b451a390549042c2a7efbec6f29ed98b2d5618c8d2a35704e21be96e09 go1.24.2.openbsd-riscv64.tar.gz
46+
5cdcafe455d859b02779611a5a1e1d63e498b922e05818fb3debe410a5959e9e go1.24.2.plan9-386.tar.gz
47+
81351659804fa505c1b3ec6fdf9599f7f88df08614307eeb96071bf5e2e74beb go1.24.2.plan9-amd64.tar.gz
48+
6e337d5def14ed0123423c1c32e2e6d8b19161e5d5ffaa7356dad48ee0fd80b4 go1.24.2.plan9-arm.tar.gz
49+
07e6926ebc476c044d7d5b17706abfc52be52bccc2073d1734174efe63c6b35e go1.24.2.solaris-amd64.tar.gz
50+
13d86cb818bba331da75fcd18246ab31a1067b44fb4a243b6dfd93097eda7f37 go1.24.2.windows-386.zip
51+
8a702d9f7104a15bd935f4191c58c24c0b6389e066b9d5661b93915114a2bef0 go1.24.2.windows-386.msi
52+
29c553aabee0743e2ffa3e9fa0cda00ef3b3cc4ff0bc92007f31f80fd69892e1 go1.24.2.windows-amd64.zip
53+
acefb191e72fea0bdb1a3f5f8f6f5ab18b42b3bbce0c7183f189f25953aff275 go1.24.2.windows-amd64.msi
54+
ab267f7f9a3366d48d7664be9e627ce3e63273231430cce5f7783fb910f14148 go1.24.2.windows-arm64.zip
55+
d187bfe539356c39573d2f46766d1d08122b4f33da00fd14d12485fa9e241ff5 go1.24.2.windows-arm64.msi
5656

5757
# version:golangci 2.0.2
5858
# https://github.com/golangci/golangci-lint/releases/

core/txpool/blobpool/blobpool.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func newBlobTxMeta(id uint64, size uint64, storageSize uint32, tx *types.Transac
299299
// and leading up to the first no-change.
300300
type BlobPool struct {
301301
config Config // Pool configuration
302-
reserver *txpool.Reserver // Address reserver to ensure exclusivity across subpools
302+
reserver txpool.Reserver // Address reserver to ensure exclusivity across subpools
303303
hasPendingAuth func(common.Address) bool // Determine whether the specified address has a pending 7702-auth
304304

305305
store billy.Database // Persistent data store for the tx metadata and blobs
@@ -355,7 +355,7 @@ func (p *BlobPool) Filter(tx *types.Transaction) bool {
355355
// Init sets the gas price needed to keep a transaction in the pool and the chain
356356
// head to allow balance / nonce checks. The transaction journal will be loaded
357357
// from disk and filtered based on the provided starting settings.
358-
func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserver *txpool.Reserver) error {
358+
func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserver txpool.Reserver) error {
359359
p.reserver = reserver
360360

361361
var (
@@ -1349,6 +1349,9 @@ func (p *BlobPool) GetBlobs(vhashes []common.Hash) ([]*kzg4844.Blob, []*kzg4844.
13491349

13501350
// Add inserts a set of blob transactions into the pool if they pass validation (both
13511351
// consensus validity and pool restrictions).
1352+
//
1353+
// Note, if sync is set the method will block until all internal maintenance
1354+
// related to the add is finished. Only use this during tests for determinism.
13521355
func (p *BlobPool) Add(txs []*types.Transaction, sync bool) []error {
13531356
var (
13541357
adds = make([]*types.Transaction, 0, len(txs))
@@ -1792,6 +1795,9 @@ func (p *BlobPool) Status(hash common.Hash) txpool.TxStatus {
17921795

17931796
// Clear implements txpool.SubPool, removing all tracked transactions
17941797
// from the blob pool and persistent store.
1798+
//
1799+
// Note, do not use this in production / live code. In live code, the pool is
1800+
// meant to reset on a separate thread to avoid DoS vectors.
17951801
func (p *BlobPool) Clear() {
17961802
p.lock.Lock()
17971803
defer p.lock.Unlock()

core/txpool/blobpool/blobpool_test.go

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"math/big"
2727
"os"
2828
"path/filepath"
29+
"sync"
2930
"testing"
3031

3132
"github.com/ethereum/go-ethereum/common"
@@ -167,6 +168,44 @@ func (bc *testBlockChain) StateAt(common.Hash) (*state.StateDB, error) {
167168
return bc.statedb, nil
168169
}
169170

171+
// reserver is a utility struct to sanity check that accounts are
172+
// properly reserved by the blobpool (no duplicate reserves or unreserves).
173+
type reserver struct {
174+
accounts map[common.Address]struct{}
175+
lock sync.RWMutex
176+
}
177+
178+
func newReserver() txpool.Reserver {
179+
return &reserver{accounts: make(map[common.Address]struct{})}
180+
}
181+
182+
func (r *reserver) Hold(addr common.Address) error {
183+
r.lock.Lock()
184+
defer r.lock.Unlock()
185+
if _, exists := r.accounts[addr]; exists {
186+
panic("already reserved")
187+
}
188+
r.accounts[addr] = struct{}{}
189+
return nil
190+
}
191+
192+
func (r *reserver) Release(addr common.Address) error {
193+
r.lock.Lock()
194+
defer r.lock.Unlock()
195+
if _, exists := r.accounts[addr]; !exists {
196+
panic("not reserved")
197+
}
198+
delete(r.accounts, addr)
199+
return nil
200+
}
201+
202+
func (r *reserver) Has(address common.Address) bool {
203+
r.lock.RLock()
204+
defer r.lock.RUnlock()
205+
_, exists := r.accounts[address]
206+
return exists
207+
}
208+
170209
// makeTx is a utility method to construct a random blob transaction and sign it
171210
// with a valid key, only setting the interesting fields from the perspective of
172211
// the blob pool.
@@ -405,10 +444,6 @@ func verifyBlobRetrievals(t *testing.T, pool *BlobPool) {
405444
}
406445
}
407446

408-
func newReserver() *txpool.Reserver {
409-
return txpool.NewReservationTracker().NewHandle(42)
410-
}
411-
412447
// Tests that transactions can be loaded from disk on startup and that they are
413448
// correctly discarded if invalid.
414449
//

core/txpool/legacypool/legacypool.go

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ type LegacyPool struct {
237237
currentHead atomic.Pointer[types.Header] // Current head of the blockchain
238238
currentState *state.StateDB // Current state in the blockchain head
239239
pendingNonces *noncer // Pending state tracking virtual nonces
240-
reserver *txpool.Reserver // Address reserver to ensure exclusivity across subpools
240+
reserver txpool.Reserver // Address reserver to ensure exclusivity across subpools
241241

242242
pending map[common.Address]*list // All currently processable transactions
243243
queue map[common.Address]*list // Queued but non-processable transactions
@@ -302,7 +302,7 @@ func (pool *LegacyPool) Filter(tx *types.Transaction) bool {
302302
// Init sets the gas price needed to keep a transaction in the pool and the chain
303303
// head to allow balance / nonce checks. The internal
304304
// goroutines will be spun up and the pool deemed operational afterwards.
305-
func (pool *LegacyPool) Init(gasTip uint64, head *types.Header, reserver *txpool.Reserver) error {
305+
func (pool *LegacyPool) Init(gasTip uint64, head *types.Header, reserver txpool.Reserver) error {
306306
// Set the address reserver to request exclusive access to pooled accounts
307307
pool.reserver = reserver
308308

@@ -640,11 +640,18 @@ func (pool *LegacyPool) validateAuth(tx *types.Transaction) error {
640640
if err := pool.checkDelegationLimit(tx); err != nil {
641641
return err
642642
}
643-
// Authorities must not conflict with any pending or queued transactions,
644-
// nor with addresses that have already been reserved.
643+
// For symmetry, allow at most one in-flight tx for any authority with a
644+
// pending transaction.
645645
if auths := tx.SetCodeAuthorities(); len(auths) > 0 {
646646
for _, auth := range auths {
647-
if pool.pending[auth] != nil || pool.queue[auth] != nil {
647+
var count int
648+
if pending := pool.pending[auth]; pending != nil {
649+
count += pending.Len()
650+
}
651+
if queue := pool.queue[auth]; queue != nil {
652+
count += queue.Len()
653+
}
654+
if count > 1 {
648655
return ErrAuthorityReserved
649656
}
650657
// Because there is no exclusive lock held between different subpools
@@ -927,8 +934,8 @@ func (pool *LegacyPool) addRemoteSync(tx *types.Transaction) error {
927934

928935
// Add enqueues a batch of transactions into the pool if they are valid.
929936
//
930-
// If sync is set, the method will block until all internal maintenance related
931-
// to the add is finished. Only use this during tests for determinism!
937+
// Note, if sync is set the method will block until all internal maintenance
938+
// related to the add is finished. Only use this during tests for determinism.
932939
func (pool *LegacyPool) Add(txs []*types.Transaction, sync bool) []error {
933940
// Filter out known ones without obtaining the pool lock or recovering signatures
934941
var (
@@ -1886,6 +1893,9 @@ func numSlots(tx *types.Transaction) int {
18861893

18871894
// Clear implements txpool.SubPool, removing all tracked txs from the pool
18881895
// and rotating the journal.
1896+
//
1897+
// Note, do not use this in production / live code. In live code, the pool is
1898+
// meant to reset on a separate thread to avoid DoS vectors.
18891899
func (pool *LegacyPool) Clear() {
18901900
pool.mu.Lock()
18911901
defer pool.mu.Unlock()
@@ -1904,9 +1914,14 @@ func (pool *LegacyPool) Clear() {
19041914
// The transaction addition may attempt to reserve the sender addr which
19051915
// can't happen until Clear releases the reservation lock. Clear cannot
19061916
// acquire the subpool lock until the transaction addition is completed.
1907-
for _, tx := range pool.all.txs {
1908-
senderAddr, _ := types.Sender(pool.signer, tx)
1909-
pool.reserver.Release(senderAddr)
1917+
1918+
for addr := range pool.pending {
1919+
if _, ok := pool.queue[addr]; !ok {
1920+
pool.reserver.Release(addr)
1921+
}
1922+
}
1923+
for addr := range pool.queue {
1924+
pool.reserver.Release(addr)
19101925
}
19111926
pool.all = newLookup()
19121927
pool.priced = newPricedList(pool.all)

0 commit comments

Comments
 (0)