Skip to content

Commit

Permalink
eth,cmd: removed logic related to eth65 protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-wjhan committed Jun 15, 2023
1 parent 44ad44f commit 5117bf4
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 599 deletions.
2 changes: 1 addition & 1 deletion cmd/devp2p/internal/ethtest/suite_test.go
Expand Up @@ -49,7 +49,7 @@ func TestEthSuite(t *testing.T) {
if err != nil {
t.Fatalf("could not create new test suite: %v", err)
}
for _, test := range suite.AllEthTests() {
for _, test := range suite.Eth66Tests() {
t.Run(test.Name, func(t *testing.T) {
result := utesting.RunTAP([]utesting.Test{{Name: test.Name, Fn: test.Fn}}, os.Stdout)
if result[0].Failed {
Expand Down
69 changes: 1 addition & 68 deletions eth/downloader/downloader_test.go
Expand Up @@ -458,8 +458,6 @@ func testCanonSync(t *testing.T, protocol uint, mode SyncMode) {

// Tests that if a large batch of blocks are being downloaded, it is throttled
// until the cached blocks are retrieved.
func TestThrottling65Full(t *testing.T) { testThrottling(t, eth.ETH65, FullSync) }
func TestThrottling65Snap(t *testing.T) { testThrottling(t, eth.ETH65, SnapSync) }
func TestThrottling66Full(t *testing.T) { testThrottling(t, eth.ETH66, FullSync) }
func TestThrottling66Snap(t *testing.T) { testThrottling(t, eth.ETH66, SnapSync) }
func TestThrottling67Full(t *testing.T) { testThrottling(t, eth.ETH67, FullSync) }
Expand Down Expand Up @@ -541,9 +539,6 @@ func testThrottling(t *testing.T, protocol uint, mode SyncMode) {
// Tests that simple synchronization against a forked chain works correctly. In
// this test common ancestor lookup should *not* be short circuited, and a full
// binary search should be executed.
func TestForkedSync65Full(t *testing.T) { testForkedSync(t, eth.ETH65, FullSync) }
func TestForkedSync65Snap(t *testing.T) { testForkedSync(t, eth.ETH65, SnapSync) }
func TestForkedSync65Light(t *testing.T) { testForkedSync(t, eth.ETH65, LightSync) }
func TestForkedSync66Full(t *testing.T) { testForkedSync(t, eth.ETH66, FullSync) }
func TestForkedSync66Snap(t *testing.T) { testForkedSync(t, eth.ETH66, SnapSync) }
func TestForkedSync66Light(t *testing.T) { testForkedSync(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -578,9 +573,6 @@ func testForkedSync(t *testing.T, protocol uint, mode SyncMode) {

// Tests that synchronising against a much shorter but much heavyer fork works
// corrently and is not dropped.
func TestHeavyForkedSync65Full(t *testing.T) { testHeavyForkedSync(t, eth.ETH65, FullSync) }
func TestHeavyForkedSync65Snap(t *testing.T) { testHeavyForkedSync(t, eth.ETH65, SnapSync) }
func TestHeavyForkedSync65Light(t *testing.T) { testHeavyForkedSync(t, eth.ETH65, LightSync) }
func TestHeavyForkedSync66Full(t *testing.T) { testHeavyForkedSync(t, eth.ETH66, FullSync) }
func TestHeavyForkedSync66Snap(t *testing.T) { testHeavyForkedSync(t, eth.ETH66, SnapSync) }
func TestHeavyForkedSync66Light(t *testing.T) { testHeavyForkedSync(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -617,9 +609,6 @@ func testHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) {
// Tests that chain forks are contained within a certain interval of the current
// chain head, ensuring that malicious peers cannot waste resources by feeding
// long dead chains.
func TestBoundedForkedSync65Full(t *testing.T) { testBoundedForkedSync(t, eth.ETH65, FullSync) }
func TestBoundedForkedSync65Snap(t *testing.T) { testBoundedForkedSync(t, eth.ETH65, SnapSync) }
func TestBoundedForkedSync65Light(t *testing.T) { testBoundedForkedSync(t, eth.ETH65, LightSync) }
func TestBoundedForkedSync66Full(t *testing.T) { testBoundedForkedSync(t, eth.ETH66, FullSync) }
func TestBoundedForkedSync66Snap(t *testing.T) { testBoundedForkedSync(t, eth.ETH66, SnapSync) }
func TestBoundedForkedSync66Light(t *testing.T) { testBoundedForkedSync(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -655,15 +644,6 @@ func testBoundedForkedSync(t *testing.T, protocol uint, mode SyncMode) {
// Tests that chain forks are contained within a certain interval of the current
// chain head for short but heavy forks too. These are a bit special because they
// take different ancestor lookup paths.
func TestBoundedHeavyForkedSync65Full(t *testing.T) {
testBoundedHeavyForkedSync(t, eth.ETH65, FullSync)
}
func TestBoundedHeavyForkedSync65Snap(t *testing.T) {
testBoundedHeavyForkedSync(t, eth.ETH65, SnapSync)
}
func TestBoundedHeavyForkedSync65Light(t *testing.T) {
testBoundedHeavyForkedSync(t, eth.ETH65, LightSync)
}
func TestBoundedHeavyForkedSync66Full(t *testing.T) {
testBoundedHeavyForkedSync(t, eth.ETH66, FullSync)
}
Expand Down Expand Up @@ -710,9 +690,6 @@ func testBoundedHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) {
}

// Tests that a canceled download wipes all previously accumulated state.
func TestCancel65Full(t *testing.T) { testCancel(t, eth.ETH65, FullSync) }
func TestCancel65Snap(t *testing.T) { testCancel(t, eth.ETH65, SnapSync) }
func TestCancel65Light(t *testing.T) { testCancel(t, eth.ETH65, LightSync) }
func TestCancel66Full(t *testing.T) { testCancel(t, eth.ETH66, FullSync) }
func TestCancel66Snap(t *testing.T) { testCancel(t, eth.ETH66, SnapSync) }
func TestCancel66Light(t *testing.T) { testCancel(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -743,9 +720,6 @@ func testCancel(t *testing.T, protocol uint, mode SyncMode) {
}

// Tests that synchronisation from multiple peers works as intended (multi thread sanity test).
func TestMultiSynchronisation65Full(t *testing.T) { testMultiSynchronisation(t, eth.ETH65, FullSync) }
func TestMultiSynchronisation65Snap(t *testing.T) { testMultiSynchronisation(t, eth.ETH65, SnapSync) }
func TestMultiSynchronisation65Light(t *testing.T) { testMultiSynchronisation(t, eth.ETH65, LightSync) }
func TestMultiSynchronisation66Full(t *testing.T) { testMultiSynchronisation(t, eth.ETH66, FullSync) }
func TestMultiSynchronisation66Snap(t *testing.T) { testMultiSynchronisation(t, eth.ETH66, SnapSync) }
func TestMultiSynchronisation66Light(t *testing.T) { testMultiSynchronisation(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -773,9 +747,6 @@ func testMultiSynchronisation(t *testing.T, protocol uint, mode SyncMode) {

// Tests that synchronisations behave well in multi-version protocol environments
// and not wreak havoc on other nodes in the network.
func TestMultiProtoSynchronisation65Full(t *testing.T) { testMultiProtoSync(t, eth.ETH65, FullSync) }
func TestMultiProtoSynchronisation65Snap(t *testing.T) { testMultiProtoSync(t, eth.ETH65, SnapSync) }
func TestMultiProtoSynchronisation65Light(t *testing.T) { testMultiProtoSync(t, eth.ETH65, LightSync) }
func TestMultiProtoSynchronisation66Full(t *testing.T) { testMultiProtoSync(t, eth.ETH66, FullSync) }
func TestMultiProtoSynchronisation66Snap(t *testing.T) { testMultiProtoSync(t, eth.ETH66, SnapSync) }
func TestMultiProtoSynchronisation66Light(t *testing.T) { testMultiProtoSync(t, eth.ETH66, LightSync) }
Expand All @@ -791,7 +762,6 @@ func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) {
chain := testChainBase.shorten(blockCacheMaxItems - 15)

// Create peers of every type
tester.newPeer("peer 65", eth.ETH65, chain.blocks[1:])
tester.newPeer("peer 66", eth.ETH66, chain.blocks[1:])
tester.newPeer("peer 67", eth.ETH67, chain.blocks[1:])

Expand All @@ -802,7 +772,7 @@ func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) {
assertOwnChain(t, tester, len(chain.blocks))

// Check that no peers have been dropped off
for _, version := range []int{65, 66, 67} {
for _, version := range []int{66, 67} {
peer := fmt.Sprintf("peer %d", version)
if _, ok := tester.peers[peer]; !ok {
t.Errorf("%s dropped", peer)
Expand All @@ -812,9 +782,6 @@ func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) {

// Tests that if a block is empty (e.g. header only), no body request should be
// made, and instead the header should be assembled into a whole block in itself.
func TestEmptyShortCircuit65Full(t *testing.T) { testEmptyShortCircuit(t, eth.ETH65, FullSync) }
func TestEmptyShortCircuit65Snap(t *testing.T) { testEmptyShortCircuit(t, eth.ETH65, SnapSync) }
func TestEmptyShortCircuit65Light(t *testing.T) { testEmptyShortCircuit(t, eth.ETH65, LightSync) }
func TestEmptyShortCircuit66Full(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, FullSync) }
func TestEmptyShortCircuit66Snap(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, SnapSync) }
func TestEmptyShortCircuit66Light(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -866,9 +833,6 @@ func testEmptyShortCircuit(t *testing.T, protocol uint, mode SyncMode) {

// Tests that headers are enqueued continuously, preventing malicious nodes from
// stalling the downloader by feeding gapped header chains.
func TestMissingHeaderAttack65Full(t *testing.T) { testMissingHeaderAttack(t, eth.ETH65, FullSync) }
func TestMissingHeaderAttack65Snap(t *testing.T) { testMissingHeaderAttack(t, eth.ETH65, SnapSync) }
func TestMissingHeaderAttack65Light(t *testing.T) { testMissingHeaderAttack(t, eth.ETH65, LightSync) }
func TestMissingHeaderAttack66Full(t *testing.T) { testMissingHeaderAttack(t, eth.ETH66, FullSync) }
func TestMissingHeaderAttack66Snap(t *testing.T) { testMissingHeaderAttack(t, eth.ETH66, SnapSync) }
func TestMissingHeaderAttack66Light(t *testing.T) { testMissingHeaderAttack(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -898,9 +862,6 @@ func testMissingHeaderAttack(t *testing.T, protocol uint, mode SyncMode) {

// Tests that if requested headers are shifted (i.e. first is missing), the queue
// detects the invalid numbering.
func TestShiftedHeaderAttack65Full(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH65, FullSync) }
func TestShiftedHeaderAttack65Snap(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH65, SnapSync) }
func TestShiftedHeaderAttack65Light(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH65, LightSync) }
func TestShiftedHeaderAttack66Full(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH66, FullSync) }
func TestShiftedHeaderAttack66Snap(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH66, SnapSync) }
func TestShiftedHeaderAttack66Light(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -932,7 +893,6 @@ func testShiftedHeaderAttack(t *testing.T, protocol uint, mode SyncMode) {
// Tests that upon detecting an invalid header, the recent ones are rolled back
// for various failure scenarios. Afterwards a full sync is attempted to make
// sure no state was corrupted.
func TestInvalidHeaderRollback65Snap(t *testing.T) { testInvalidHeaderRollback(t, eth.ETH65, SnapSync) }
func TestInvalidHeaderRollback66Snap(t *testing.T) { testInvalidHeaderRollback(t, eth.ETH66, SnapSync) }
func TestInvalidHeaderRollback67Snap(t *testing.T) { testInvalidHeaderRollback(t, eth.ETH67, SnapSync) }

Expand Down Expand Up @@ -1012,15 +972,6 @@ func testInvalidHeaderRollback(t *testing.T, protocol uint, mode SyncMode) {

// Tests that a peer advertising a high TD doesn't get to stall the downloader
// afterwards by not sending any useful hashes.
func TestHighTDStarvationAttack65Full(t *testing.T) {
testHighTDStarvationAttack(t, eth.ETH65, FullSync)
}
func TestHighTDStarvationAttack65Snap(t *testing.T) {
testHighTDStarvationAttack(t, eth.ETH65, SnapSync)
}
func TestHighTDStarvationAttack65Light(t *testing.T) {
testHighTDStarvationAttack(t, eth.ETH65, LightSync)
}
func TestHighTDStarvationAttack66Full(t *testing.T) {
testHighTDStarvationAttack(t, eth.ETH66, FullSync)
}
Expand Down Expand Up @@ -1052,7 +1003,6 @@ func testHighTDStarvationAttack(t *testing.T, protocol uint, mode SyncMode) {
}

// Tests that misbehaving peers are disconnected, whilst behaving ones are not.
func TestBlockHeaderAttackerDropping65(t *testing.T) { testBlockHeaderAttackerDropping(t, eth.ETH65) }
func TestBlockHeaderAttackerDropping66(t *testing.T) { testBlockHeaderAttackerDropping(t, eth.ETH66) }
func TestBlockHeaderAttackerDropping67(t *testing.T) { testBlockHeaderAttackerDropping(t, eth.ETH67) }

Expand Down Expand Up @@ -1102,9 +1052,6 @@ func testBlockHeaderAttackerDropping(t *testing.T, protocol uint) {

// Tests that synchronisation progress (origin block number, current block number
// and highest block number) is tracked and updated correctly.
func TestSyncProgress65Full(t *testing.T) { testSyncProgress(t, eth.ETH65, FullSync) }
func TestSyncProgress65Snap(t *testing.T) { testSyncProgress(t, eth.ETH65, SnapSync) }
func TestSyncProgress65Light(t *testing.T) { testSyncProgress(t, eth.ETH65, LightSync) }
func TestSyncProgress66Full(t *testing.T) { testSyncProgress(t, eth.ETH66, FullSync) }
func TestSyncProgress66Snap(t *testing.T) { testSyncProgress(t, eth.ETH66, SnapSync) }
func TestSyncProgress66Light(t *testing.T) { testSyncProgress(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -1189,9 +1136,6 @@ func checkProgress(t *testing.T, d *Downloader, stage string, want ethereum.Sync
// Tests that synchronisation progress (origin block number and highest block
// number) is tracked and updated correctly in case of a fork (or manual head
// revertal).
func TestForkedSyncProgress65Full(t *testing.T) { testForkedSyncProgress(t, eth.ETH65, FullSync) }
func TestForkedSyncProgress65Snap(t *testing.T) { testForkedSyncProgress(t, eth.ETH65, SnapSync) }
func TestForkedSyncProgress65Light(t *testing.T) { testForkedSyncProgress(t, eth.ETH65, LightSync) }
func TestForkedSyncProgress66Full(t *testing.T) { testForkedSyncProgress(t, eth.ETH66, FullSync) }
func TestForkedSyncProgress66Snap(t *testing.T) { testForkedSyncProgress(t, eth.ETH66, SnapSync) }
func TestForkedSyncProgress66Light(t *testing.T) { testForkedSyncProgress(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -1270,9 +1214,6 @@ func testForkedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
// Tests that if synchronisation is aborted due to some failure, then the progress
// origin is not updated in the next sync cycle, as it should be considered the
// continuation of the previous sync and not a new instance.
func TestFailedSyncProgress65Full(t *testing.T) { testFailedSyncProgress(t, eth.ETH65, FullSync) }
func TestFailedSyncProgress65Snap(t *testing.T) { testFailedSyncProgress(t, eth.ETH65, SnapSync) }
func TestFailedSyncProgress65Light(t *testing.T) { testFailedSyncProgress(t, eth.ETH65, LightSync) }
func TestFailedSyncProgress66Full(t *testing.T) { testFailedSyncProgress(t, eth.ETH66, FullSync) }
func TestFailedSyncProgress66Snap(t *testing.T) { testFailedSyncProgress(t, eth.ETH66, SnapSync) }
func TestFailedSyncProgress66Light(t *testing.T) { testFailedSyncProgress(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -1342,9 +1283,6 @@ func testFailedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {

// Tests that if an attacker fakes a chain height, after the attack is detected,
// the progress height is successfully reduced at the next sync invocation.
func TestFakedSyncProgress65Full(t *testing.T) { testFakedSyncProgress(t, eth.ETH65, FullSync) }
func TestFakedSyncProgress65Snap(t *testing.T) { testFakedSyncProgress(t, eth.ETH65, SnapSync) }
func TestFakedSyncProgress65Light(t *testing.T) { testFakedSyncProgress(t, eth.ETH65, LightSync) }
func TestFakedSyncProgress66Full(t *testing.T) { testFakedSyncProgress(t, eth.ETH66, FullSync) }
func TestFakedSyncProgress66Snap(t *testing.T) { testFakedSyncProgress(t, eth.ETH66, SnapSync) }
func TestFakedSyncProgress66Light(t *testing.T) { testFakedSyncProgress(t, eth.ETH66, LightSync) }
Expand Down Expand Up @@ -1496,11 +1434,6 @@ func TestRemoteHeaderRequestSpan(t *testing.T) {

// Tests that peers below a pre-configured checkpoint block are prevented from
// being fast-synced from, avoiding potential cheap eclipse attacks.
func TestCheckpointEnforcement65Full(t *testing.T) { testCheckpointEnforcement(t, eth.ETH65, FullSync) }
func TestCheckpointEnforcement65Snap(t *testing.T) { testCheckpointEnforcement(t, eth.ETH65, SnapSync) }
func TestCheckpointEnforcement65Light(t *testing.T) {
testCheckpointEnforcement(t, eth.ETH65, LightSync)
}
func TestCheckpointEnforcement66Full(t *testing.T) { testCheckpointEnforcement(t, eth.ETH66, FullSync) }
func TestCheckpointEnforcement66Snap(t *testing.T) { testCheckpointEnforcement(t, eth.ETH66, SnapSync) }
func TestCheckpointEnforcement66Light(t *testing.T) {
Expand Down
5 changes: 1 addition & 4 deletions eth/handler.go
Expand Up @@ -120,7 +120,6 @@ type handler struct {
requiredBlocks map[uint64]common.Hash

// channels for fetcher, syncer, txsyncLoop
txsyncCh chan *txsync
quitSync chan struct{}

chainSync *chainSyncer
Expand All @@ -144,7 +143,6 @@ func newHandler(config *handlerConfig) (*handler, error) {
peers: newPeerSet(),
merger: config.Merger,
requiredBlocks: config.RequiredBlocks,
txsyncCh: make(chan *txsync),
quitSync: make(chan struct{}),
}
if config.Sync == downloader.FullSync {
Expand Down Expand Up @@ -537,9 +535,8 @@ func (h *handler) Start(maxPeers int) {
go h.minedBroadcastLoop()

// start sync handlers
h.wg.Add(2)
h.wg.Add(1)
go h.chainSync.loop()
go h.txsyncLoop64() // TODO(karalabe): Legacy initial tx echange, drop with eth/64.
}

func (h *handler) Stop() {
Expand Down
4 changes: 0 additions & 4 deletions eth/handler_eth_test.go
Expand Up @@ -80,7 +80,6 @@ func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error {

// Tests that peers are correctly accepted (or rejected) based on the advertised
// fork IDs in the protocol handshake.
func TestForkIDSplit65(t *testing.T) { testForkIDSplit(t, eth.ETH65) }
func TestForkIDSplit66(t *testing.T) { testForkIDSplit(t, eth.ETH66) }

func testForkIDSplit(t *testing.T, protocol uint) {
Expand Down Expand Up @@ -238,7 +237,6 @@ func testForkIDSplit(t *testing.T, protocol uint) {
}

// Tests that received transactions are added to the local pool.
func TestRecvTransactions65(t *testing.T) { testRecvTransactions(t, eth.ETH65) }
func TestRecvTransactions66(t *testing.T) { testRecvTransactions(t, eth.ETH66) }

func testRecvTransactions(t *testing.T, protocol uint) {
Expand Down Expand Up @@ -381,7 +379,6 @@ func testSendTransactions(t *testing.T, protocol uint) {

// Tests that transactions get propagated to all attached peers, either via direct
// broadcasts or via announcements/retrievals.
func TestTransactionPropagation65(t *testing.T) { testTransactionPropagation(t, eth.ETH65) }
func TestTransactionPropagation66(t *testing.T) { testTransactionPropagation(t, eth.ETH66) }

func testTransactionPropagation(t *testing.T, protocol uint) {
Expand Down Expand Up @@ -688,7 +685,6 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {

// Tests that a propagated malformed block (uncles or transactions don't match
// with the hashes in the header) gets discarded and not broadcast forward.
func TestBroadcastMalformedBlock65(t *testing.T) { testBroadcastMalformedBlock(t, eth.ETH65) }
func TestBroadcastMalformedBlock66(t *testing.T) { testBroadcastMalformedBlock(t, eth.ETH66) }

func testBroadcastMalformedBlock(t *testing.T, protocol uint) {
Expand Down
15 changes: 4 additions & 11 deletions eth/protocols/eth/dispatcher.go
Expand Up @@ -47,10 +47,9 @@ type Request struct {
sink chan *Response // Channel to deliver the response on
cancel chan struct{} // Channel to cancel requests ahead of time

code uint64 // Message code of the request packet
want uint64 // Message code of the response packet
data interface{} // Data content of the request packet
data65 interface{} // Data content of the request packet for eth/65
code uint64 // Message code of the request packet
want uint64 // Message code of the response packet
data interface{} // Data content of the request packet

Peer string // Demultiplexer if cross-peer requests are batched together
Sent time.Time // Timestamp when the request was sent
Expand Down Expand Up @@ -196,13 +195,7 @@ func (p *Peer) dispatcher() {
req.Sent = time.Now()

requestTracker.Track(p.id, p.version, req.code, req.want, req.id)
var data interface{}
if p.Version() <= ETH65 {
data = req.data65
} else {
data = req.data
}
err := p2p.Send(p.rw, req.code, data)
err := p2p.Send(p.rw, req.code, req.data)
reqOp.fail <- err

if err == nil {
Expand Down

0 comments on commit 5117bf4

Please sign in to comment.