Skip to content

Commit fe1586b

Browse files
committed
eth, les: drop support for eth/64, fix eth/66 tests
1 parent 04dcc93 commit fe1586b

File tree

12 files changed

+286
-285
lines changed

12 files changed

+286
-285
lines changed

eth/downloader/downloader.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/ethereum/go-ethereum/common"
3030
"github.com/ethereum/go-ethereum/core/rawdb"
3131
"github.com/ethereum/go-ethereum/core/types"
32+
"github.com/ethereum/go-ethereum/eth/protocols/eth"
3233
"github.com/ethereum/go-ethereum/eth/protocols/snap"
3334
"github.com/ethereum/go-ethereum/ethdb"
3435
"github.com/ethereum/go-ethereum/event"
@@ -459,8 +460,8 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
459460
d.mux.Post(DoneEvent{latest})
460461
}
461462
}()
462-
if p.version < 64 {
463-
return fmt.Errorf("%w: advertized %d < required %d", errTooOld, p.version, 64)
463+
if p.version < eth.ETH65 {
464+
return fmt.Errorf("%w: advertized %d < required %d", errTooOld, p.version, eth.ETH65)
464465
}
465466
mode := d.getMode()
466467

eth/downloader/downloader_test.go

Lines changed: 148 additions & 179 deletions
Large diffs are not rendered by default.

eth/downloader/peer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func (ps *peerSet) HeaderIdlePeers() ([]*peerConnection, int) {
458458
defer p.lock.RUnlock()
459459
return p.headerThroughput
460460
}
461-
return ps.idlePeers(eth.ETH64, eth.ETH66, idle, throughput)
461+
return ps.idlePeers(eth.ETH65, eth.ETH66, idle, throughput)
462462
}
463463

464464
// BodyIdlePeers retrieves a flat list of all the currently body-idle peers within
@@ -472,7 +472,7 @@ func (ps *peerSet) BodyIdlePeers() ([]*peerConnection, int) {
472472
defer p.lock.RUnlock()
473473
return p.blockThroughput
474474
}
475-
return ps.idlePeers(eth.ETH64, eth.ETH66, idle, throughput)
475+
return ps.idlePeers(eth.ETH65, eth.ETH66, idle, throughput)
476476
}
477477

478478
// ReceiptIdlePeers retrieves a flat list of all the currently receipt-idle peers
@@ -486,7 +486,7 @@ func (ps *peerSet) ReceiptIdlePeers() ([]*peerConnection, int) {
486486
defer p.lock.RUnlock()
487487
return p.receiptThroughput
488488
}
489-
return ps.idlePeers(eth.ETH64, eth.ETH66, idle, throughput)
489+
return ps.idlePeers(eth.ETH65, eth.ETH66, idle, throughput)
490490
}
491491

492492
// NodeDataIdlePeers retrieves a flat list of all the currently node-data-idle
@@ -500,7 +500,7 @@ func (ps *peerSet) NodeDataIdlePeers() ([]*peerConnection, int) {
500500
defer p.lock.RUnlock()
501501
return p.stateThroughput
502502
}
503-
return ps.idlePeers(eth.ETH64, eth.ETH66, idle, throughput)
503+
return ps.idlePeers(eth.ETH65, eth.ETH66, idle, throughput)
504504
}
505505

506506
// idlePeers retrieves a flat list of all currently idle peers satisfying the

eth/handler.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,7 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
496496
for peer, hashes := range annos {
497497
annoPeers++
498498
annoCount += len(hashes)
499-
if peer.Version() >= eth.ETH65 {
500-
peer.AsyncSendPooledTransactionHashes(hashes)
501-
} else {
502-
peer.AsyncSendTransactions(hashes)
503-
}
499+
peer.AsyncSendPooledTransactionHashes(hashes)
504500
}
505501
log.Debug("Transaction broadcast", "txs", len(txs),
506502
"announce packs", annoPeers, "announced hashes", annoCount,

eth/handler_eth_test.go

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error {
8080

8181
// Tests that peers are correctly accepted (or rejected) based on the advertised
8282
// fork IDs in the protocol handshake.
83-
func TestForkIDSplit64(t *testing.T) { testForkIDSplit(t, 64) }
84-
func TestForkIDSplit65(t *testing.T) { testForkIDSplit(t, 65) }
83+
func TestForkIDSplit65(t *testing.T) { testForkIDSplit(t, eth.ETH65) }
84+
func TestForkIDSplit66(t *testing.T) { testForkIDSplit(t, eth.ETH66) }
8585

8686
func testForkIDSplit(t *testing.T, protocol uint) {
8787
t.Parallel()
@@ -236,8 +236,8 @@ func testForkIDSplit(t *testing.T, protocol uint) {
236236
}
237237

238238
// Tests that received transactions are added to the local pool.
239-
func TestRecvTransactions64(t *testing.T) { testRecvTransactions(t, 64) }
240-
func TestRecvTransactions65(t *testing.T) { testRecvTransactions(t, 65) }
239+
func TestRecvTransactions65(t *testing.T) { testRecvTransactions(t, eth.ETH65) }
240+
func TestRecvTransactions66(t *testing.T) { testRecvTransactions(t, eth.ETH66) }
241241

242242
func testRecvTransactions(t *testing.T, protocol uint) {
243243
t.Parallel()
@@ -294,8 +294,8 @@ func testRecvTransactions(t *testing.T, protocol uint) {
294294
}
295295

296296
// This test checks that pending transactions are sent.
297-
func TestSendTransactions64(t *testing.T) { testSendTransactions(t, 64) }
298-
func TestSendTransactions65(t *testing.T) { testSendTransactions(t, 65) }
297+
func TestSendTransactions65(t *testing.T) { testSendTransactions(t, eth.ETH65) }
298+
func TestSendTransactions66(t *testing.T) { testSendTransactions(t, eth.ETH66) }
299299

300300
func testSendTransactions(t *testing.T, protocol uint) {
301301
t.Parallel()
@@ -354,19 +354,7 @@ func testSendTransactions(t *testing.T, protocol uint) {
354354
seen := make(map[common.Hash]struct{})
355355
for len(seen) < len(insert) {
356356
switch protocol {
357-
case 63, 64:
358-
select {
359-
case <-anns:
360-
t.Errorf("tx announce received on pre eth/65")
361-
case txs := <-bcasts:
362-
for _, tx := range txs {
363-
if _, ok := seen[tx.Hash()]; ok {
364-
t.Errorf("duplicate transaction announced: %x", tx.Hash())
365-
}
366-
seen[tx.Hash()] = struct{}{}
367-
}
368-
}
369-
case 65:
357+
case 65, 66:
370358
select {
371359
case hashes := <-anns:
372360
for _, hash := range hashes {
@@ -392,8 +380,8 @@ func testSendTransactions(t *testing.T, protocol uint) {
392380

393381
// Tests that transactions get propagated to all attached peers, either via direct
394382
// broadcasts or via announcements/retrievals.
395-
func TestTransactionPropagation64(t *testing.T) { testTransactionPropagation(t, 64) }
396-
func TestTransactionPropagation65(t *testing.T) { testTransactionPropagation(t, 65) }
383+
func TestTransactionPropagation65(t *testing.T) { testTransactionPropagation(t, eth.ETH65) }
384+
func TestTransactionPropagation66(t *testing.T) { testTransactionPropagation(t, eth.ETH66) }
397385

398386
func testTransactionPropagation(t *testing.T, protocol uint) {
399387
t.Parallel()
@@ -530,8 +518,8 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
530518
defer p2pLocal.Close()
531519
defer p2pRemote.Close()
532520

533-
local := eth.NewPeer(eth.ETH64, p2p.NewPeer(enode.ID{1}, "", nil), p2pLocal, handler.txpool)
534-
remote := eth.NewPeer(eth.ETH64, p2p.NewPeer(enode.ID{2}, "", nil), p2pRemote, handler.txpool)
521+
local := eth.NewPeer(eth.ETH65, p2p.NewPeer(enode.ID{1}, "", nil), p2pLocal, handler.txpool)
522+
remote := eth.NewPeer(eth.ETH65, p2p.NewPeer(enode.ID{2}, "", nil), p2pRemote, handler.txpool)
535523
defer local.Close()
536524
defer remote.Close()
537525

@@ -620,8 +608,8 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
620608
defer sourcePipe.Close()
621609
defer sinkPipe.Close()
622610

623-
sourcePeer := eth.NewPeer(eth.ETH64, p2p.NewPeer(enode.ID{byte(i)}, "", nil), sourcePipe, nil)
624-
sinkPeer := eth.NewPeer(eth.ETH64, p2p.NewPeer(enode.ID{0}, "", nil), sinkPipe, nil)
611+
sourcePeer := eth.NewPeer(eth.ETH65, p2p.NewPeer(enode.ID{byte(i)}, "", nil), sourcePipe, nil)
612+
sinkPeer := eth.NewPeer(eth.ETH65, p2p.NewPeer(enode.ID{0}, "", nil), sinkPipe, nil)
625613
defer sourcePeer.Close()
626614
defer sinkPeer.Close()
627615

@@ -672,8 +660,8 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
672660

673661
// Tests that a propagated malformed block (uncles or transactions don't match
674662
// with the hashes in the header) gets discarded and not broadcast forward.
675-
func TestBroadcastMalformedBlock64(t *testing.T) { testBroadcastMalformedBlock(t, 64) }
676-
func TestBroadcastMalformedBlock65(t *testing.T) { testBroadcastMalformedBlock(t, 65) }
663+
func TestBroadcastMalformedBlock65(t *testing.T) { testBroadcastMalformedBlock(t, eth.ETH65) }
664+
func TestBroadcastMalformedBlock66(t *testing.T) { testBroadcastMalformedBlock(t, eth.ETH66) }
677665

678666
func testBroadcastMalformedBlock(t *testing.T, protocol uint) {
679667
t.Parallel()

eth/protocols/eth/handler.go

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -171,44 +171,27 @@ type Decoder interface {
171171
Time() time.Time
172172
}
173173

174-
var eth64 = map[uint64]msgHandler{
175-
GetBlockHeadersMsg: handleGetBlockHeaders,
176-
BlockHeadersMsg: handleBlockHeaders,
177-
GetBlockBodiesMsg: handleGetBlockBodies,
178-
BlockBodiesMsg: handleBlockBodies,
179-
GetNodeDataMsg: handleGetNodeData,
180-
NodeDataMsg: handleNodeData,
181-
GetReceiptsMsg: handleGetReceipts,
182-
ReceiptsMsg: handleReceipts,
183-
NewBlockHashesMsg: handleNewBlockhashes,
184-
NewBlockMsg: handleNewBlock,
185-
TransactionsMsg: handleTransactions,
186-
}
187174
var eth65 = map[uint64]msgHandler{
188-
// old 64 messages
189-
GetBlockHeadersMsg: handleGetBlockHeaders,
190-
BlockHeadersMsg: handleBlockHeaders,
191-
GetBlockBodiesMsg: handleGetBlockBodies,
192-
BlockBodiesMsg: handleBlockBodies,
193-
GetNodeDataMsg: handleGetNodeData,
194-
NodeDataMsg: handleNodeData,
195-
GetReceiptsMsg: handleGetReceipts,
196-
ReceiptsMsg: handleReceipts,
197-
NewBlockHashesMsg: handleNewBlockhashes,
198-
NewBlockMsg: handleNewBlock,
199-
TransactionsMsg: handleTransactions,
200-
// New eth65 messages
175+
GetBlockHeadersMsg: handleGetBlockHeaders,
176+
BlockHeadersMsg: handleBlockHeaders,
177+
GetBlockBodiesMsg: handleGetBlockBodies,
178+
BlockBodiesMsg: handleBlockBodies,
179+
GetNodeDataMsg: handleGetNodeData,
180+
NodeDataMsg: handleNodeData,
181+
GetReceiptsMsg: handleGetReceipts,
182+
ReceiptsMsg: handleReceipts,
183+
NewBlockHashesMsg: handleNewBlockhashes,
184+
NewBlockMsg: handleNewBlock,
185+
TransactionsMsg: handleTransactions,
201186
NewPooledTransactionHashesMsg: handleNewPooledTransactionHashes,
202187
GetPooledTransactionsMsg: handleGetPooledTransactions,
203188
PooledTransactionsMsg: handlePooledTransactions,
204189
}
205190

206191
var eth66 = map[uint64]msgHandler{
207-
// eth64 announcement messages (no id)
208-
NewBlockHashesMsg: handleNewBlockhashes,
209-
NewBlockMsg: handleNewBlock,
210-
TransactionsMsg: handleTransactions,
211-
// eth65 announcement messages (no id)
192+
NewBlockHashesMsg: handleNewBlockhashes,
193+
NewBlockMsg: handleNewBlock,
194+
TransactionsMsg: handleTransactions,
212195
NewPooledTransactionHashesMsg: handleNewPooledTransactionHashes,
213196
// eth66 messages with request-id
214197
GetBlockHeadersMsg: handleGetBlockHeaders66,
@@ -236,10 +219,8 @@ func handleMessage(backend Backend, peer *Peer) error {
236219
}
237220
defer msg.Discard()
238221

239-
var handlers = eth64
240-
if peer.Version() == ETH65 {
241-
handlers = eth65
242-
} else if peer.Version() >= ETH66 {
222+
var handlers = eth65
223+
if peer.Version() >= ETH66 {
243224
handlers = eth66
244225
}
245226
// Track the emount of time it takes to serve the request and run the handler

0 commit comments

Comments
 (0)