Merge pull request #22636 from karalabe/drop-eth64
eth, les: drop support for eth/64
This commit is contained in:
commit
9c653ff662
|
@ -29,6 +29,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/eth/protocols/eth"
|
||||||
"github.com/ethereum/go-ethereum/eth/protocols/snap"
|
"github.com/ethereum/go-ethereum/eth/protocols/snap"
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
|
@ -459,8 +460,8 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
|
||||||
d.mux.Post(DoneEvent{latest})
|
d.mux.Post(DoneEvent{latest})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if p.version < 64 {
|
if p.version < eth.ETH65 {
|
||||||
return fmt.Errorf("%w: advertized %d < required %d", errTooOld, p.version, 64)
|
return fmt.Errorf("%w: advertized %d < required %d", errTooOld, p.version, eth.ETH65)
|
||||||
}
|
}
|
||||||
mode := d.getMode()
|
mode := d.getMode()
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/eth/protocols/eth"
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
|
@ -515,16 +516,13 @@ func assertOwnForkedChain(t *testing.T, tester *downloadTester, common int, leng
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCanonicalSynchronisation64Full(t *testing.T) { testCanonSync(t, 64, FullSync) }
|
func TestCanonicalSynchronisation65Full(t *testing.T) { testCanonSync(t, eth.ETH65, FullSync) }
|
||||||
func TestCanonicalSynchronisation64Fast(t *testing.T) { testCanonSync(t, 64, FastSync) }
|
func TestCanonicalSynchronisation65Fast(t *testing.T) { testCanonSync(t, eth.ETH65, FastSync) }
|
||||||
|
func TestCanonicalSynchronisation65Light(t *testing.T) { testCanonSync(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestCanonicalSynchronisation65Full(t *testing.T) { testCanonSync(t, 65, FullSync) }
|
func TestCanonicalSynchronisation66Full(t *testing.T) { testCanonSync(t, eth.ETH66, FullSync) }
|
||||||
func TestCanonicalSynchronisation65Fast(t *testing.T) { testCanonSync(t, 65, FastSync) }
|
func TestCanonicalSynchronisation66Fast(t *testing.T) { testCanonSync(t, eth.ETH66, FastSync) }
|
||||||
func TestCanonicalSynchronisation65Light(t *testing.T) { testCanonSync(t, 65, LightSync) }
|
func TestCanonicalSynchronisation66Light(t *testing.T) { testCanonSync(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestCanonicalSynchronisation66Full(t *testing.T) { testCanonSync(t, 66, FullSync) }
|
|
||||||
func TestCanonicalSynchronisation66Fast(t *testing.T) { testCanonSync(t, 66, FastSync) }
|
|
||||||
func TestCanonicalSynchronisation66Light(t *testing.T) { testCanonSync(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testCanonSync(t *testing.T, protocol uint, mode SyncMode) {
|
func testCanonSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -545,14 +543,11 @@ func testCanonSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
|
|
||||||
// Tests that if a large batch of blocks are being downloaded, it is throttled
|
// Tests that if a large batch of blocks are being downloaded, it is throttled
|
||||||
// until the cached blocks are retrieved.
|
// until the cached blocks are retrieved.
|
||||||
func TestThrottling64Full(t *testing.T) { testThrottling(t, 64, FullSync) }
|
func TestThrottling65Full(t *testing.T) { testThrottling(t, eth.ETH65, FullSync) }
|
||||||
func TestThrottling64Fast(t *testing.T) { testThrottling(t, 64, FastSync) }
|
func TestThrottling65Fast(t *testing.T) { testThrottling(t, eth.ETH65, FastSync) }
|
||||||
|
|
||||||
func TestThrottling65Full(t *testing.T) { testThrottling(t, 65, FullSync) }
|
func TestThrottling66Full(t *testing.T) { testThrottling(t, eth.ETH66, FullSync) }
|
||||||
func TestThrottling65Fast(t *testing.T) { testThrottling(t, 65, FastSync) }
|
func TestThrottling66Fast(t *testing.T) { testThrottling(t, eth.ETH66, FastSync) }
|
||||||
|
|
||||||
func TestThrottling66Full(t *testing.T) { testThrottling(t, 66, FullSync) }
|
|
||||||
func TestThrottling66Fast(t *testing.T) { testThrottling(t, 66, FastSync) }
|
|
||||||
|
|
||||||
func testThrottling(t *testing.T, protocol uint, mode SyncMode) {
|
func testThrottling(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -633,16 +628,13 @@ func testThrottling(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
// Tests that simple synchronization against a forked chain works correctly. In
|
// Tests that simple synchronization against a forked chain works correctly. In
|
||||||
// this test common ancestor lookup should *not* be short circuited, and a full
|
// this test common ancestor lookup should *not* be short circuited, and a full
|
||||||
// binary search should be executed.
|
// binary search should be executed.
|
||||||
func TestForkedSync64Full(t *testing.T) { testForkedSync(t, 64, FullSync) }
|
func TestForkedSync65Full(t *testing.T) { testForkedSync(t, eth.ETH65, FullSync) }
|
||||||
func TestForkedSync64Fast(t *testing.T) { testForkedSync(t, 64, FastSync) }
|
func TestForkedSync65Fast(t *testing.T) { testForkedSync(t, eth.ETH65, FastSync) }
|
||||||
|
func TestForkedSync65Light(t *testing.T) { testForkedSync(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestForkedSync65Full(t *testing.T) { testForkedSync(t, 65, FullSync) }
|
func TestForkedSync66Full(t *testing.T) { testForkedSync(t, eth.ETH66, FullSync) }
|
||||||
func TestForkedSync65Fast(t *testing.T) { testForkedSync(t, 65, FastSync) }
|
func TestForkedSync66Fast(t *testing.T) { testForkedSync(t, eth.ETH66, FastSync) }
|
||||||
func TestForkedSync65Light(t *testing.T) { testForkedSync(t, 65, LightSync) }
|
func TestForkedSync66Light(t *testing.T) { testForkedSync(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestForkedSync66Full(t *testing.T) { testForkedSync(t, 66, FullSync) }
|
|
||||||
func TestForkedSync66Fast(t *testing.T) { testForkedSync(t, 66, FastSync) }
|
|
||||||
func TestForkedSync66Light(t *testing.T) { testForkedSync(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
func testForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -669,16 +661,13 @@ func testForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
|
|
||||||
// Tests that synchronising against a much shorter but much heavyer fork works
|
// Tests that synchronising against a much shorter but much heavyer fork works
|
||||||
// corrently and is not dropped.
|
// corrently and is not dropped.
|
||||||
func TestHeavyForkedSync64Full(t *testing.T) { testHeavyForkedSync(t, 64, FullSync) }
|
func TestHeavyForkedSync65Full(t *testing.T) { testHeavyForkedSync(t, eth.ETH65, FullSync) }
|
||||||
func TestHeavyForkedSync64Fast(t *testing.T) { testHeavyForkedSync(t, 64, FastSync) }
|
func TestHeavyForkedSync65Fast(t *testing.T) { testHeavyForkedSync(t, eth.ETH65, FastSync) }
|
||||||
|
func TestHeavyForkedSync65Light(t *testing.T) { testHeavyForkedSync(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestHeavyForkedSync65Full(t *testing.T) { testHeavyForkedSync(t, 65, FullSync) }
|
func TestHeavyForkedSync66Full(t *testing.T) { testHeavyForkedSync(t, eth.ETH66, FullSync) }
|
||||||
func TestHeavyForkedSync65Fast(t *testing.T) { testHeavyForkedSync(t, 65, FastSync) }
|
func TestHeavyForkedSync66Fast(t *testing.T) { testHeavyForkedSync(t, eth.ETH66, FastSync) }
|
||||||
func TestHeavyForkedSync65Light(t *testing.T) { testHeavyForkedSync(t, 65, LightSync) }
|
func TestHeavyForkedSync66Light(t *testing.T) { testHeavyForkedSync(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestHeavyForkedSync66Full(t *testing.T) { testHeavyForkedSync(t, 66, FullSync) }
|
|
||||||
func TestHeavyForkedSync66Fast(t *testing.T) { testHeavyForkedSync(t, 66, FastSync) }
|
|
||||||
func TestHeavyForkedSync66Light(t *testing.T) { testHeavyForkedSync(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
func testHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -707,16 +696,13 @@ func testHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
// Tests that chain forks are contained within a certain interval of the current
|
// Tests that chain forks are contained within a certain interval of the current
|
||||||
// chain head, ensuring that malicious peers cannot waste resources by feeding
|
// chain head, ensuring that malicious peers cannot waste resources by feeding
|
||||||
// long dead chains.
|
// long dead chains.
|
||||||
func TestBoundedForkedSync64Full(t *testing.T) { testBoundedForkedSync(t, 64, FullSync) }
|
func TestBoundedForkedSync65Full(t *testing.T) { testBoundedForkedSync(t, eth.ETH65, FullSync) }
|
||||||
func TestBoundedForkedSync64Fast(t *testing.T) { testBoundedForkedSync(t, 64, FastSync) }
|
func TestBoundedForkedSync65Fast(t *testing.T) { testBoundedForkedSync(t, eth.ETH65, FastSync) }
|
||||||
|
func TestBoundedForkedSync65Light(t *testing.T) { testBoundedForkedSync(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestBoundedForkedSync65Full(t *testing.T) { testBoundedForkedSync(t, 65, FullSync) }
|
func TestBoundedForkedSync66Full(t *testing.T) { testBoundedForkedSync(t, eth.ETH66, FullSync) }
|
||||||
func TestBoundedForkedSync65Fast(t *testing.T) { testBoundedForkedSync(t, 65, FastSync) }
|
func TestBoundedForkedSync66Fast(t *testing.T) { testBoundedForkedSync(t, eth.ETH66, FastSync) }
|
||||||
func TestBoundedForkedSync65Light(t *testing.T) { testBoundedForkedSync(t, 65, LightSync) }
|
func TestBoundedForkedSync66Light(t *testing.T) { testBoundedForkedSync(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestBoundedForkedSync66Full(t *testing.T) { testBoundedForkedSync(t, 66, FullSync) }
|
|
||||||
func TestBoundedForkedSync66Fast(t *testing.T) { testBoundedForkedSync(t, 66, FastSync) }
|
|
||||||
func TestBoundedForkedSync66Light(t *testing.T) { testBoundedForkedSync(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testBoundedForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
func testBoundedForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -744,16 +730,25 @@ func testBoundedForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
// Tests that chain forks are contained within a certain interval of the current
|
// 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
|
// chain head for short but heavy forks too. These are a bit special because they
|
||||||
// take different ancestor lookup paths.
|
// take different ancestor lookup paths.
|
||||||
func TestBoundedHeavyForkedSync64Full(t *testing.T) { testBoundedHeavyForkedSync(t, 64, FullSync) }
|
func TestBoundedHeavyForkedSync65Full(t *testing.T) {
|
||||||
func TestBoundedHeavyForkedSync64Fast(t *testing.T) { testBoundedHeavyForkedSync(t, 64, FastSync) }
|
testBoundedHeavyForkedSync(t, eth.ETH65, FullSync)
|
||||||
|
}
|
||||||
|
func TestBoundedHeavyForkedSync65Fast(t *testing.T) {
|
||||||
|
testBoundedHeavyForkedSync(t, eth.ETH65, FastSync)
|
||||||
|
}
|
||||||
|
func TestBoundedHeavyForkedSync65Light(t *testing.T) {
|
||||||
|
testBoundedHeavyForkedSync(t, eth.ETH65, LightSync)
|
||||||
|
}
|
||||||
|
|
||||||
func TestBoundedHeavyForkedSync65Full(t *testing.T) { testBoundedHeavyForkedSync(t, 65, FullSync) }
|
func TestBoundedHeavyForkedSync66Full(t *testing.T) {
|
||||||
func TestBoundedHeavyForkedSync65Fast(t *testing.T) { testBoundedHeavyForkedSync(t, 65, FastSync) }
|
testBoundedHeavyForkedSync(t, eth.ETH66, FullSync)
|
||||||
func TestBoundedHeavyForkedSync65Light(t *testing.T) { testBoundedHeavyForkedSync(t, 65, LightSync) }
|
}
|
||||||
|
func TestBoundedHeavyForkedSync66Fast(t *testing.T) {
|
||||||
func TestBoundedHeavyForkedSync66Full(t *testing.T) { testBoundedHeavyForkedSync(t, 66, FullSync) }
|
testBoundedHeavyForkedSync(t, eth.ETH66, FastSync)
|
||||||
func TestBoundedHeavyForkedSync66Fast(t *testing.T) { testBoundedHeavyForkedSync(t, 66, FastSync) }
|
}
|
||||||
func TestBoundedHeavyForkedSync66Light(t *testing.T) { testBoundedHeavyForkedSync(t, 66, LightSync) }
|
func TestBoundedHeavyForkedSync66Light(t *testing.T) {
|
||||||
|
testBoundedHeavyForkedSync(t, eth.ETH66, LightSync)
|
||||||
|
}
|
||||||
|
|
||||||
func testBoundedHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
func testBoundedHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -799,16 +794,13 @@ func TestInactiveDownloader63(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that a canceled download wipes all previously accumulated state.
|
// Tests that a canceled download wipes all previously accumulated state.
|
||||||
func TestCancel64Full(t *testing.T) { testCancel(t, 64, FullSync) }
|
func TestCancel65Full(t *testing.T) { testCancel(t, eth.ETH65, FullSync) }
|
||||||
func TestCancel64Fast(t *testing.T) { testCancel(t, 64, FastSync) }
|
func TestCancel65Fast(t *testing.T) { testCancel(t, eth.ETH65, FastSync) }
|
||||||
|
func TestCancel65Light(t *testing.T) { testCancel(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestCancel65Full(t *testing.T) { testCancel(t, 65, FullSync) }
|
func TestCancel66Full(t *testing.T) { testCancel(t, eth.ETH66, FullSync) }
|
||||||
func TestCancel65Fast(t *testing.T) { testCancel(t, 65, FastSync) }
|
func TestCancel66Fast(t *testing.T) { testCancel(t, eth.ETH66, FastSync) }
|
||||||
func TestCancel65Light(t *testing.T) { testCancel(t, 65, LightSync) }
|
func TestCancel66Light(t *testing.T) { testCancel(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestCancel66Full(t *testing.T) { testCancel(t, 66, FullSync) }
|
|
||||||
func TestCancel66Fast(t *testing.T) { testCancel(t, 66, FastSync) }
|
|
||||||
func TestCancel66Light(t *testing.T) { testCancel(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testCancel(t *testing.T, protocol uint, mode SyncMode) {
|
func testCancel(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -835,16 +827,13 @@ func testCancel(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that synchronisation from multiple peers works as intended (multi thread sanity test).
|
// Tests that synchronisation from multiple peers works as intended (multi thread sanity test).
|
||||||
func TestMultiSynchronisation64Full(t *testing.T) { testMultiSynchronisation(t, 64, FullSync) }
|
func TestMultiSynchronisation65Full(t *testing.T) { testMultiSynchronisation(t, eth.ETH65, FullSync) }
|
||||||
func TestMultiSynchronisation64Fast(t *testing.T) { testMultiSynchronisation(t, 64, FastSync) }
|
func TestMultiSynchronisation65Fast(t *testing.T) { testMultiSynchronisation(t, eth.ETH65, FastSync) }
|
||||||
|
func TestMultiSynchronisation65Light(t *testing.T) { testMultiSynchronisation(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestMultiSynchronisation65Full(t *testing.T) { testMultiSynchronisation(t, 65, FullSync) }
|
func TestMultiSynchronisation66Full(t *testing.T) { testMultiSynchronisation(t, eth.ETH66, FullSync) }
|
||||||
func TestMultiSynchronisation65Fast(t *testing.T) { testMultiSynchronisation(t, 65, FastSync) }
|
func TestMultiSynchronisation66Fast(t *testing.T) { testMultiSynchronisation(t, eth.ETH66, FastSync) }
|
||||||
func TestMultiSynchronisation65Light(t *testing.T) { testMultiSynchronisation(t, 65, LightSync) }
|
func TestMultiSynchronisation66Light(t *testing.T) { testMultiSynchronisation(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestMultiSynchronisation66Full(t *testing.T) { testMultiSynchronisation(t, 66, FullSync) }
|
|
||||||
func TestMultiSynchronisation66Fast(t *testing.T) { testMultiSynchronisation(t, 66, FastSync) }
|
|
||||||
func TestMultiSynchronisation66Light(t *testing.T) { testMultiSynchronisation(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testMultiSynchronisation(t *testing.T, protocol uint, mode SyncMode) {
|
func testMultiSynchronisation(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -868,16 +857,13 @@ func testMultiSynchronisation(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
|
|
||||||
// Tests that synchronisations behave well in multi-version protocol environments
|
// Tests that synchronisations behave well in multi-version protocol environments
|
||||||
// and not wreak havoc on other nodes in the network.
|
// and not wreak havoc on other nodes in the network.
|
||||||
func TestMultiProtoSynchronisation64Full(t *testing.T) { testMultiProtoSync(t, 64, FullSync) }
|
func TestMultiProtoSynchronisation65Full(t *testing.T) { testMultiProtoSync(t, eth.ETH65, FullSync) }
|
||||||
func TestMultiProtoSynchronisation64Fast(t *testing.T) { testMultiProtoSync(t, 64, FastSync) }
|
func TestMultiProtoSynchronisation65Fast(t *testing.T) { testMultiProtoSync(t, eth.ETH65, FastSync) }
|
||||||
|
func TestMultiProtoSynchronisation65Light(t *testing.T) { testMultiProtoSync(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestMultiProtoSynchronisation65Full(t *testing.T) { testMultiProtoSync(t, 65, FullSync) }
|
func TestMultiProtoSynchronisation66Full(t *testing.T) { testMultiProtoSync(t, eth.ETH66, FullSync) }
|
||||||
func TestMultiProtoSynchronisation65Fast(t *testing.T) { testMultiProtoSync(t, 65, FastSync) }
|
func TestMultiProtoSynchronisation66Fast(t *testing.T) { testMultiProtoSync(t, eth.ETH66, FastSync) }
|
||||||
func TestMultiProtoSynchronisation65Light(t *testing.T) { testMultiProtoSync(t, 65, LightSync) }
|
func TestMultiProtoSynchronisation66Light(t *testing.T) { testMultiProtoSync(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestMultiProtoSynchronisation66Full(t *testing.T) { testMultiProtoSync(t, 66, FullSync) }
|
|
||||||
func TestMultiProtoSynchronisation66Fast(t *testing.T) { testMultiProtoSync(t, 66, FastSync) }
|
|
||||||
func TestMultiProtoSynchronisation66Light(t *testing.T) { testMultiProtoSync(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) {
|
func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -889,9 +875,8 @@ func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
chain := testChainBase.shorten(blockCacheMaxItems - 15)
|
chain := testChainBase.shorten(blockCacheMaxItems - 15)
|
||||||
|
|
||||||
// Create peers of every type
|
// Create peers of every type
|
||||||
tester.newPeer("peer 64", 64, chain)
|
tester.newPeer("peer 65", eth.ETH65, chain)
|
||||||
tester.newPeer("peer 65", 65, chain)
|
tester.newPeer("peer 66", eth.ETH66, chain)
|
||||||
tester.newPeer("peer 66", 66, chain)
|
|
||||||
|
|
||||||
// Synchronise with the requested peer and make sure all blocks were retrieved
|
// Synchronise with the requested peer and make sure all blocks were retrieved
|
||||||
if err := tester.sync(fmt.Sprintf("peer %d", protocol), nil, mode); err != nil {
|
if err := tester.sync(fmt.Sprintf("peer %d", protocol), nil, mode); err != nil {
|
||||||
|
@ -900,7 +885,7 @@ func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
assertOwnChain(t, tester, chain.len())
|
assertOwnChain(t, tester, chain.len())
|
||||||
|
|
||||||
// Check that no peers have been dropped off
|
// Check that no peers have been dropped off
|
||||||
for _, version := range []int{64, 65, 66} {
|
for _, version := range []int{65, 66} {
|
||||||
peer := fmt.Sprintf("peer %d", version)
|
peer := fmt.Sprintf("peer %d", version)
|
||||||
if _, ok := tester.peers[peer]; !ok {
|
if _, ok := tester.peers[peer]; !ok {
|
||||||
t.Errorf("%s dropped", peer)
|
t.Errorf("%s dropped", peer)
|
||||||
|
@ -910,16 +895,13 @@ 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
|
// 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.
|
// made, and instead the header should be assembled into a whole block in itself.
|
||||||
func TestEmptyShortCircuit64Full(t *testing.T) { testEmptyShortCircuit(t, 64, FullSync) }
|
func TestEmptyShortCircuit65Full(t *testing.T) { testEmptyShortCircuit(t, eth.ETH65, FullSync) }
|
||||||
func TestEmptyShortCircuit64Fast(t *testing.T) { testEmptyShortCircuit(t, 64, FastSync) }
|
func TestEmptyShortCircuit65Fast(t *testing.T) { testEmptyShortCircuit(t, eth.ETH65, FastSync) }
|
||||||
|
func TestEmptyShortCircuit65Light(t *testing.T) { testEmptyShortCircuit(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestEmptyShortCircuit65Full(t *testing.T) { testEmptyShortCircuit(t, 65, FullSync) }
|
func TestEmptyShortCircuit66Full(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, FullSync) }
|
||||||
func TestEmptyShortCircuit65Fast(t *testing.T) { testEmptyShortCircuit(t, 65, FastSync) }
|
func TestEmptyShortCircuit66Fast(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, FastSync) }
|
||||||
func TestEmptyShortCircuit65Light(t *testing.T) { testEmptyShortCircuit(t, 65, LightSync) }
|
func TestEmptyShortCircuit66Light(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestEmptyShortCircuit66Full(t *testing.T) { testEmptyShortCircuit(t, 66, FullSync) }
|
|
||||||
func TestEmptyShortCircuit66Fast(t *testing.T) { testEmptyShortCircuit(t, 66, FastSync) }
|
|
||||||
func TestEmptyShortCircuit66Light(t *testing.T) { testEmptyShortCircuit(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testEmptyShortCircuit(t *testing.T, protocol uint, mode SyncMode) {
|
func testEmptyShortCircuit(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -967,16 +949,13 @@ func testEmptyShortCircuit(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
|
|
||||||
// Tests that headers are enqueued continuously, preventing malicious nodes from
|
// Tests that headers are enqueued continuously, preventing malicious nodes from
|
||||||
// stalling the downloader by feeding gapped header chains.
|
// stalling the downloader by feeding gapped header chains.
|
||||||
func TestMissingHeaderAttack64Full(t *testing.T) { testMissingHeaderAttack(t, 64, FullSync) }
|
func TestMissingHeaderAttack65Full(t *testing.T) { testMissingHeaderAttack(t, eth.ETH65, FullSync) }
|
||||||
func TestMissingHeaderAttack64Fast(t *testing.T) { testMissingHeaderAttack(t, 64, FastSync) }
|
func TestMissingHeaderAttack65Fast(t *testing.T) { testMissingHeaderAttack(t, eth.ETH65, FastSync) }
|
||||||
|
func TestMissingHeaderAttack65Light(t *testing.T) { testMissingHeaderAttack(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestMissingHeaderAttack65Full(t *testing.T) { testMissingHeaderAttack(t, 65, FullSync) }
|
func TestMissingHeaderAttack66Full(t *testing.T) { testMissingHeaderAttack(t, eth.ETH66, FullSync) }
|
||||||
func TestMissingHeaderAttack65Fast(t *testing.T) { testMissingHeaderAttack(t, 65, FastSync) }
|
func TestMissingHeaderAttack66Fast(t *testing.T) { testMissingHeaderAttack(t, eth.ETH66, FastSync) }
|
||||||
func TestMissingHeaderAttack65Light(t *testing.T) { testMissingHeaderAttack(t, 65, LightSync) }
|
func TestMissingHeaderAttack66Light(t *testing.T) { testMissingHeaderAttack(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestMissingHeaderAttack66Full(t *testing.T) { testMissingHeaderAttack(t, 66, FullSync) }
|
|
||||||
func TestMissingHeaderAttack66Fast(t *testing.T) { testMissingHeaderAttack(t, 66, FastSync) }
|
|
||||||
func TestMissingHeaderAttack66Light(t *testing.T) { testMissingHeaderAttack(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testMissingHeaderAttack(t *testing.T, protocol uint, mode SyncMode) {
|
func testMissingHeaderAttack(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -1002,16 +981,13 @@ func testMissingHeaderAttack(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
|
|
||||||
// Tests that if requested headers are shifted (i.e. first is missing), the queue
|
// Tests that if requested headers are shifted (i.e. first is missing), the queue
|
||||||
// detects the invalid numbering.
|
// detects the invalid numbering.
|
||||||
func TestShiftedHeaderAttack64Full(t *testing.T) { testShiftedHeaderAttack(t, 64, FullSync) }
|
func TestShiftedHeaderAttack65Full(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH65, FullSync) }
|
||||||
func TestShiftedHeaderAttack64Fast(t *testing.T) { testShiftedHeaderAttack(t, 64, FastSync) }
|
func TestShiftedHeaderAttack65Fast(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH65, FastSync) }
|
||||||
|
func TestShiftedHeaderAttack65Light(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestShiftedHeaderAttack65Full(t *testing.T) { testShiftedHeaderAttack(t, 65, FullSync) }
|
func TestShiftedHeaderAttack66Full(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH66, FullSync) }
|
||||||
func TestShiftedHeaderAttack65Fast(t *testing.T) { testShiftedHeaderAttack(t, 65, FastSync) }
|
func TestShiftedHeaderAttack66Fast(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH66, FastSync) }
|
||||||
func TestShiftedHeaderAttack65Light(t *testing.T) { testShiftedHeaderAttack(t, 65, LightSync) }
|
func TestShiftedHeaderAttack66Light(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestShiftedHeaderAttack66Full(t *testing.T) { testShiftedHeaderAttack(t, 66, FullSync) }
|
|
||||||
func TestShiftedHeaderAttack66Fast(t *testing.T) { testShiftedHeaderAttack(t, 66, FastSync) }
|
|
||||||
func TestShiftedHeaderAttack66Light(t *testing.T) { testShiftedHeaderAttack(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testShiftedHeaderAttack(t *testing.T, protocol uint, mode SyncMode) {
|
func testShiftedHeaderAttack(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -1042,9 +1018,8 @@ func testShiftedHeaderAttack(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
// Tests that upon detecting an invalid header, the recent ones are rolled back
|
// 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
|
// for various failure scenarios. Afterwards a full sync is attempted to make
|
||||||
// sure no state was corrupted.
|
// sure no state was corrupted.
|
||||||
func TestInvalidHeaderRollback64Fast(t *testing.T) { testInvalidHeaderRollback(t, 64, FastSync) }
|
func TestInvalidHeaderRollback65Fast(t *testing.T) { testInvalidHeaderRollback(t, eth.ETH65, FastSync) }
|
||||||
func TestInvalidHeaderRollback65Fast(t *testing.T) { testInvalidHeaderRollback(t, 65, FastSync) }
|
func TestInvalidHeaderRollback66Fast(t *testing.T) { testInvalidHeaderRollback(t, eth.ETH66, FastSync) }
|
||||||
func TestInvalidHeaderRollback66Fast(t *testing.T) { testInvalidHeaderRollback(t, 66, FastSync) }
|
|
||||||
|
|
||||||
func testInvalidHeaderRollback(t *testing.T, protocol uint, mode SyncMode) {
|
func testInvalidHeaderRollback(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -1134,16 +1109,25 @@ func testInvalidHeaderRollback(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
|
|
||||||
// Tests that a peer advertising a high TD doesn't get to stall the downloader
|
// Tests that a peer advertising a high TD doesn't get to stall the downloader
|
||||||
// afterwards by not sending any useful hashes.
|
// afterwards by not sending any useful hashes.
|
||||||
func TestHighTDStarvationAttack64Full(t *testing.T) { testHighTDStarvationAttack(t, 64, FullSync) }
|
func TestHighTDStarvationAttack65Full(t *testing.T) {
|
||||||
func TestHighTDStarvationAttack64Fast(t *testing.T) { testHighTDStarvationAttack(t, 64, FastSync) }
|
testHighTDStarvationAttack(t, eth.ETH65, FullSync)
|
||||||
|
}
|
||||||
|
func TestHighTDStarvationAttack65Fast(t *testing.T) {
|
||||||
|
testHighTDStarvationAttack(t, eth.ETH65, FastSync)
|
||||||
|
}
|
||||||
|
func TestHighTDStarvationAttack65Light(t *testing.T) {
|
||||||
|
testHighTDStarvationAttack(t, eth.ETH65, LightSync)
|
||||||
|
}
|
||||||
|
|
||||||
func TestHighTDStarvationAttack65Full(t *testing.T) { testHighTDStarvationAttack(t, 65, FullSync) }
|
func TestHighTDStarvationAttack66Full(t *testing.T) {
|
||||||
func TestHighTDStarvationAttack65Fast(t *testing.T) { testHighTDStarvationAttack(t, 65, FastSync) }
|
testHighTDStarvationAttack(t, eth.ETH66, FullSync)
|
||||||
func TestHighTDStarvationAttack65Light(t *testing.T) { testHighTDStarvationAttack(t, 65, LightSync) }
|
}
|
||||||
|
func TestHighTDStarvationAttack66Fast(t *testing.T) {
|
||||||
func TestHighTDStarvationAttack66Full(t *testing.T) { testHighTDStarvationAttack(t, 66, FullSync) }
|
testHighTDStarvationAttack(t, eth.ETH66, FastSync)
|
||||||
func TestHighTDStarvationAttack66Fast(t *testing.T) { testHighTDStarvationAttack(t, 66, FastSync) }
|
}
|
||||||
func TestHighTDStarvationAttack66Light(t *testing.T) { testHighTDStarvationAttack(t, 66, LightSync) }
|
func TestHighTDStarvationAttack66Light(t *testing.T) {
|
||||||
|
testHighTDStarvationAttack(t, eth.ETH66, LightSync)
|
||||||
|
}
|
||||||
|
|
||||||
func testHighTDStarvationAttack(t *testing.T, protocol uint, mode SyncMode) {
|
func testHighTDStarvationAttack(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -1159,9 +1143,8 @@ func testHighTDStarvationAttack(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that misbehaving peers are disconnected, whilst behaving ones are not.
|
// Tests that misbehaving peers are disconnected, whilst behaving ones are not.
|
||||||
func TestBlockHeaderAttackerDropping64(t *testing.T) { testBlockHeaderAttackerDropping(t, 64) }
|
func TestBlockHeaderAttackerDropping65(t *testing.T) { testBlockHeaderAttackerDropping(t, eth.ETH65) }
|
||||||
func TestBlockHeaderAttackerDropping65(t *testing.T) { testBlockHeaderAttackerDropping(t, 65) }
|
func TestBlockHeaderAttackerDropping66(t *testing.T) { testBlockHeaderAttackerDropping(t, eth.ETH66) }
|
||||||
func TestBlockHeaderAttackerDropping66(t *testing.T) { testBlockHeaderAttackerDropping(t, 66) }
|
|
||||||
|
|
||||||
func testBlockHeaderAttackerDropping(t *testing.T, protocol uint) {
|
func testBlockHeaderAttackerDropping(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -1213,16 +1196,13 @@ func testBlockHeaderAttackerDropping(t *testing.T, protocol uint) {
|
||||||
|
|
||||||
// Tests that synchronisation progress (origin block number, current block number
|
// Tests that synchronisation progress (origin block number, current block number
|
||||||
// and highest block number) is tracked and updated correctly.
|
// and highest block number) is tracked and updated correctly.
|
||||||
func TestSyncProgress64Full(t *testing.T) { testSyncProgress(t, 64, FullSync) }
|
func TestSyncProgress65Full(t *testing.T) { testSyncProgress(t, eth.ETH65, FullSync) }
|
||||||
func TestSyncProgress64Fast(t *testing.T) { testSyncProgress(t, 64, FastSync) }
|
func TestSyncProgress65Fast(t *testing.T) { testSyncProgress(t, eth.ETH65, FastSync) }
|
||||||
|
func TestSyncProgress65Light(t *testing.T) { testSyncProgress(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestSyncProgress65Full(t *testing.T) { testSyncProgress(t, 65, FullSync) }
|
func TestSyncProgress66Full(t *testing.T) { testSyncProgress(t, eth.ETH66, FullSync) }
|
||||||
func TestSyncProgress65Fast(t *testing.T) { testSyncProgress(t, 65, FastSync) }
|
func TestSyncProgress66Fast(t *testing.T) { testSyncProgress(t, eth.ETH66, FastSync) }
|
||||||
func TestSyncProgress65Light(t *testing.T) { testSyncProgress(t, 65, LightSync) }
|
func TestSyncProgress66Light(t *testing.T) { testSyncProgress(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestSyncProgress66Full(t *testing.T) { testSyncProgress(t, 66, FullSync) }
|
|
||||||
func TestSyncProgress66Fast(t *testing.T) { testSyncProgress(t, 66, FastSync) }
|
|
||||||
func TestSyncProgress66Light(t *testing.T) { testSyncProgress(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
func testSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -1300,16 +1280,13 @@ func checkProgress(t *testing.T, d *Downloader, stage string, want ethereum.Sync
|
||||||
// Tests that synchronisation progress (origin block number and highest block
|
// Tests that synchronisation progress (origin block number and highest block
|
||||||
// number) is tracked and updated correctly in case of a fork (or manual head
|
// number) is tracked and updated correctly in case of a fork (or manual head
|
||||||
// revertal).
|
// revertal).
|
||||||
func TestForkedSyncProgress64Full(t *testing.T) { testForkedSyncProgress(t, 64, FullSync) }
|
func TestForkedSyncProgress65Full(t *testing.T) { testForkedSyncProgress(t, eth.ETH65, FullSync) }
|
||||||
func TestForkedSyncProgress64Fast(t *testing.T) { testForkedSyncProgress(t, 64, FastSync) }
|
func TestForkedSyncProgress65Fast(t *testing.T) { testForkedSyncProgress(t, eth.ETH65, FastSync) }
|
||||||
|
func TestForkedSyncProgress65Light(t *testing.T) { testForkedSyncProgress(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestForkedSyncProgress65Full(t *testing.T) { testForkedSyncProgress(t, 65, FullSync) }
|
func TestForkedSyncProgress66Full(t *testing.T) { testForkedSyncProgress(t, eth.ETH66, FullSync) }
|
||||||
func TestForkedSyncProgress65Fast(t *testing.T) { testForkedSyncProgress(t, 65, FastSync) }
|
func TestForkedSyncProgress66Fast(t *testing.T) { testForkedSyncProgress(t, eth.ETH66, FastSync) }
|
||||||
func TestForkedSyncProgress65Light(t *testing.T) { testForkedSyncProgress(t, 65, LightSync) }
|
func TestForkedSyncProgress66Light(t *testing.T) { testForkedSyncProgress(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestForkedSyncProgress66Full(t *testing.T) { testForkedSyncProgress(t, 66, FullSync) }
|
|
||||||
func TestForkedSyncProgress66Fast(t *testing.T) { testForkedSyncProgress(t, 66, FastSync) }
|
|
||||||
func TestForkedSyncProgress66Light(t *testing.T) { testForkedSyncProgress(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testForkedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
func testForkedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -1379,16 +1356,13 @@ func testForkedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
// Tests that if synchronisation is aborted due to some failure, then the progress
|
// 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
|
// 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.
|
// continuation of the previous sync and not a new instance.
|
||||||
func TestFailedSyncProgress64Full(t *testing.T) { testFailedSyncProgress(t, 64, FullSync) }
|
func TestFailedSyncProgress65Full(t *testing.T) { testFailedSyncProgress(t, eth.ETH65, FullSync) }
|
||||||
func TestFailedSyncProgress64Fast(t *testing.T) { testFailedSyncProgress(t, 64, FastSync) }
|
func TestFailedSyncProgress65Fast(t *testing.T) { testFailedSyncProgress(t, eth.ETH65, FastSync) }
|
||||||
|
func TestFailedSyncProgress65Light(t *testing.T) { testFailedSyncProgress(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestFailedSyncProgress65Full(t *testing.T) { testFailedSyncProgress(t, 65, FullSync) }
|
func TestFailedSyncProgress66Full(t *testing.T) { testFailedSyncProgress(t, eth.ETH66, FullSync) }
|
||||||
func TestFailedSyncProgress65Fast(t *testing.T) { testFailedSyncProgress(t, 65, FastSync) }
|
func TestFailedSyncProgress66Fast(t *testing.T) { testFailedSyncProgress(t, eth.ETH66, FastSync) }
|
||||||
func TestFailedSyncProgress65Light(t *testing.T) { testFailedSyncProgress(t, 65, LightSync) }
|
func TestFailedSyncProgress66Light(t *testing.T) { testFailedSyncProgress(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestFailedSyncProgress66Full(t *testing.T) { testFailedSyncProgress(t, 66, FullSync) }
|
|
||||||
func TestFailedSyncProgress66Fast(t *testing.T) { testFailedSyncProgress(t, 66, FastSync) }
|
|
||||||
func TestFailedSyncProgress66Light(t *testing.T) { testFailedSyncProgress(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testFailedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
func testFailedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -1455,16 +1429,13 @@ func testFailedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
|
|
||||||
// Tests that if an attacker fakes a chain height, after the attack is detected,
|
// 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.
|
// the progress height is successfully reduced at the next sync invocation.
|
||||||
func TestFakedSyncProgress64Full(t *testing.T) { testFakedSyncProgress(t, 64, FullSync) }
|
func TestFakedSyncProgress65Full(t *testing.T) { testFakedSyncProgress(t, eth.ETH65, FullSync) }
|
||||||
func TestFakedSyncProgress64Fast(t *testing.T) { testFakedSyncProgress(t, 64, FastSync) }
|
func TestFakedSyncProgress65Fast(t *testing.T) { testFakedSyncProgress(t, eth.ETH65, FastSync) }
|
||||||
|
func TestFakedSyncProgress65Light(t *testing.T) { testFakedSyncProgress(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestFakedSyncProgress65Full(t *testing.T) { testFakedSyncProgress(t, 65, FullSync) }
|
func TestFakedSyncProgress66Full(t *testing.T) { testFakedSyncProgress(t, eth.ETH66, FullSync) }
|
||||||
func TestFakedSyncProgress65Fast(t *testing.T) { testFakedSyncProgress(t, 65, FastSync) }
|
func TestFakedSyncProgress66Fast(t *testing.T) { testFakedSyncProgress(t, eth.ETH66, FastSync) }
|
||||||
func TestFakedSyncProgress65Light(t *testing.T) { testFakedSyncProgress(t, 65, LightSync) }
|
func TestFakedSyncProgress66Light(t *testing.T) { testFakedSyncProgress(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestFakedSyncProgress66Full(t *testing.T) { testFakedSyncProgress(t, 66, FullSync) }
|
|
||||||
func TestFakedSyncProgress66Fast(t *testing.T) { testFakedSyncProgress(t, 66, FastSync) }
|
|
||||||
func TestFakedSyncProgress66Light(t *testing.T) { testFakedSyncProgress(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testFakedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
func testFakedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -1535,16 +1506,13 @@ func testFakedSyncProgress(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
|
|
||||||
// This test reproduces an issue where unexpected deliveries would
|
// This test reproduces an issue where unexpected deliveries would
|
||||||
// block indefinitely if they arrived at the right time.
|
// block indefinitely if they arrived at the right time.
|
||||||
func TestDeliverHeadersHang64Full(t *testing.T) { testDeliverHeadersHang(t, 64, FullSync) }
|
func TestDeliverHeadersHang65Full(t *testing.T) { testDeliverHeadersHang(t, eth.ETH65, FullSync) }
|
||||||
func TestDeliverHeadersHang64Fast(t *testing.T) { testDeliverHeadersHang(t, 64, FastSync) }
|
func TestDeliverHeadersHang65Fast(t *testing.T) { testDeliverHeadersHang(t, eth.ETH65, FastSync) }
|
||||||
|
func TestDeliverHeadersHang65Light(t *testing.T) { testDeliverHeadersHang(t, eth.ETH65, LightSync) }
|
||||||
|
|
||||||
func TestDeliverHeadersHang65Full(t *testing.T) { testDeliverHeadersHang(t, 65, FullSync) }
|
func TestDeliverHeadersHang66Full(t *testing.T) { testDeliverHeadersHang(t, eth.ETH66, FullSync) }
|
||||||
func TestDeliverHeadersHang65Fast(t *testing.T) { testDeliverHeadersHang(t, 65, FastSync) }
|
func TestDeliverHeadersHang66Fast(t *testing.T) { testDeliverHeadersHang(t, eth.ETH66, FastSync) }
|
||||||
func TestDeliverHeadersHang65Light(t *testing.T) { testDeliverHeadersHang(t, 65, LightSync) }
|
func TestDeliverHeadersHang66Light(t *testing.T) { testDeliverHeadersHang(t, eth.ETH66, LightSync) }
|
||||||
|
|
||||||
func TestDeliverHeadersHang66Full(t *testing.T) { testDeliverHeadersHang(t, 66, FullSync) }
|
|
||||||
func TestDeliverHeadersHang66Fast(t *testing.T) { testDeliverHeadersHang(t, 66, FastSync) }
|
|
||||||
func TestDeliverHeadersHang66Light(t *testing.T) { testDeliverHeadersHang(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testDeliverHeadersHang(t *testing.T, protocol uint, mode SyncMode) {
|
func testDeliverHeadersHang(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -1699,16 +1667,17 @@ func TestRemoteHeaderRequestSpan(t *testing.T) {
|
||||||
|
|
||||||
// Tests that peers below a pre-configured checkpoint block are prevented from
|
// Tests that peers below a pre-configured checkpoint block are prevented from
|
||||||
// being fast-synced from, avoiding potential cheap eclipse attacks.
|
// being fast-synced from, avoiding potential cheap eclipse attacks.
|
||||||
func TestCheckpointEnforcement64Full(t *testing.T) { testCheckpointEnforcement(t, 64, FullSync) }
|
func TestCheckpointEnforcement65Full(t *testing.T) { testCheckpointEnforcement(t, eth.ETH65, FullSync) }
|
||||||
func TestCheckpointEnforcement64Fast(t *testing.T) { testCheckpointEnforcement(t, 64, FastSync) }
|
func TestCheckpointEnforcement65Fast(t *testing.T) { testCheckpointEnforcement(t, eth.ETH65, FastSync) }
|
||||||
|
func TestCheckpointEnforcement65Light(t *testing.T) {
|
||||||
|
testCheckpointEnforcement(t, eth.ETH65, LightSync)
|
||||||
|
}
|
||||||
|
|
||||||
func TestCheckpointEnforcement65Full(t *testing.T) { testCheckpointEnforcement(t, 65, FullSync) }
|
func TestCheckpointEnforcement66Full(t *testing.T) { testCheckpointEnforcement(t, eth.ETH66, FullSync) }
|
||||||
func TestCheckpointEnforcement65Fast(t *testing.T) { testCheckpointEnforcement(t, 65, FastSync) }
|
func TestCheckpointEnforcement66Fast(t *testing.T) { testCheckpointEnforcement(t, eth.ETH66, FastSync) }
|
||||||
func TestCheckpointEnforcement65Light(t *testing.T) { testCheckpointEnforcement(t, 65, LightSync) }
|
func TestCheckpointEnforcement66Light(t *testing.T) {
|
||||||
|
testCheckpointEnforcement(t, eth.ETH66, LightSync)
|
||||||
func TestCheckpointEnforcement66Full(t *testing.T) { testCheckpointEnforcement(t, 66, FullSync) }
|
}
|
||||||
func TestCheckpointEnforcement66Fast(t *testing.T) { testCheckpointEnforcement(t, 66, FastSync) }
|
|
||||||
func TestCheckpointEnforcement66Light(t *testing.T) { testCheckpointEnforcement(t, 66, LightSync) }
|
|
||||||
|
|
||||||
func testCheckpointEnforcement(t *testing.T, protocol uint, mode SyncMode) {
|
func testCheckpointEnforcement(t *testing.T, protocol uint, mode SyncMode) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
|
@ -458,7 +458,7 @@ func (ps *peerSet) HeaderIdlePeers() ([]*peerConnection, int) {
|
||||||
defer p.lock.RUnlock()
|
defer p.lock.RUnlock()
|
||||||
return p.headerThroughput
|
return p.headerThroughput
|
||||||
}
|
}
|
||||||
return ps.idlePeers(eth.ETH64, eth.ETH66, idle, throughput)
|
return ps.idlePeers(eth.ETH65, eth.ETH66, idle, throughput)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BodyIdlePeers retrieves a flat list of all the currently body-idle peers within
|
// BodyIdlePeers retrieves a flat list of all the currently body-idle peers within
|
||||||
|
@ -472,7 +472,7 @@ func (ps *peerSet) BodyIdlePeers() ([]*peerConnection, int) {
|
||||||
defer p.lock.RUnlock()
|
defer p.lock.RUnlock()
|
||||||
return p.blockThroughput
|
return p.blockThroughput
|
||||||
}
|
}
|
||||||
return ps.idlePeers(eth.ETH64, eth.ETH66, idle, throughput)
|
return ps.idlePeers(eth.ETH65, eth.ETH66, idle, throughput)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReceiptIdlePeers retrieves a flat list of all the currently receipt-idle peers
|
// ReceiptIdlePeers retrieves a flat list of all the currently receipt-idle peers
|
||||||
|
@ -486,7 +486,7 @@ func (ps *peerSet) ReceiptIdlePeers() ([]*peerConnection, int) {
|
||||||
defer p.lock.RUnlock()
|
defer p.lock.RUnlock()
|
||||||
return p.receiptThroughput
|
return p.receiptThroughput
|
||||||
}
|
}
|
||||||
return ps.idlePeers(eth.ETH64, eth.ETH66, idle, throughput)
|
return ps.idlePeers(eth.ETH65, eth.ETH66, idle, throughput)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeDataIdlePeers retrieves a flat list of all the currently node-data-idle
|
// NodeDataIdlePeers retrieves a flat list of all the currently node-data-idle
|
||||||
|
@ -500,7 +500,7 @@ func (ps *peerSet) NodeDataIdlePeers() ([]*peerConnection, int) {
|
||||||
defer p.lock.RUnlock()
|
defer p.lock.RUnlock()
|
||||||
return p.stateThroughput
|
return p.stateThroughput
|
||||||
}
|
}
|
||||||
return ps.idlePeers(eth.ETH64, eth.ETH66, idle, throughput)
|
return ps.idlePeers(eth.ETH65, eth.ETH66, idle, throughput)
|
||||||
}
|
}
|
||||||
|
|
||||||
// idlePeers retrieves a flat list of all currently idle peers satisfying the
|
// idlePeers retrieves a flat list of all currently idle peers satisfying the
|
||||||
|
|
|
@ -496,11 +496,7 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
|
||||||
for peer, hashes := range annos {
|
for peer, hashes := range annos {
|
||||||
annoPeers++
|
annoPeers++
|
||||||
annoCount += len(hashes)
|
annoCount += len(hashes)
|
||||||
if peer.Version() >= eth.ETH65 {
|
peer.AsyncSendPooledTransactionHashes(hashes)
|
||||||
peer.AsyncSendPooledTransactionHashes(hashes)
|
|
||||||
} else {
|
|
||||||
peer.AsyncSendTransactions(hashes)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
log.Debug("Transaction broadcast", "txs", len(txs),
|
log.Debug("Transaction broadcast", "txs", len(txs),
|
||||||
"announce packs", annoPeers, "announced hashes", annoCount,
|
"announce packs", annoPeers, "announced hashes", annoCount,
|
||||||
|
|
|
@ -80,8 +80,8 @@ func (h *testEthHandler) Handle(peer *eth.Peer, packet eth.Packet) error {
|
||||||
|
|
||||||
// Tests that peers are correctly accepted (or rejected) based on the advertised
|
// Tests that peers are correctly accepted (or rejected) based on the advertised
|
||||||
// fork IDs in the protocol handshake.
|
// fork IDs in the protocol handshake.
|
||||||
func TestForkIDSplit64(t *testing.T) { testForkIDSplit(t, 64) }
|
func TestForkIDSplit65(t *testing.T) { testForkIDSplit(t, eth.ETH65) }
|
||||||
func TestForkIDSplit65(t *testing.T) { testForkIDSplit(t, 65) }
|
func TestForkIDSplit66(t *testing.T) { testForkIDSplit(t, eth.ETH66) }
|
||||||
|
|
||||||
func testForkIDSplit(t *testing.T, protocol uint) {
|
func testForkIDSplit(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -236,8 +236,8 @@ func testForkIDSplit(t *testing.T, protocol uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that received transactions are added to the local pool.
|
// Tests that received transactions are added to the local pool.
|
||||||
func TestRecvTransactions64(t *testing.T) { testRecvTransactions(t, 64) }
|
func TestRecvTransactions65(t *testing.T) { testRecvTransactions(t, eth.ETH65) }
|
||||||
func TestRecvTransactions65(t *testing.T) { testRecvTransactions(t, 65) }
|
func TestRecvTransactions66(t *testing.T) { testRecvTransactions(t, eth.ETH66) }
|
||||||
|
|
||||||
func testRecvTransactions(t *testing.T, protocol uint) {
|
func testRecvTransactions(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -294,8 +294,8 @@ func testRecvTransactions(t *testing.T, protocol uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test checks that pending transactions are sent.
|
// This test checks that pending transactions are sent.
|
||||||
func TestSendTransactions64(t *testing.T) { testSendTransactions(t, 64) }
|
func TestSendTransactions65(t *testing.T) { testSendTransactions(t, eth.ETH65) }
|
||||||
func TestSendTransactions65(t *testing.T) { testSendTransactions(t, 65) }
|
func TestSendTransactions66(t *testing.T) { testSendTransactions(t, eth.ETH66) }
|
||||||
|
|
||||||
func testSendTransactions(t *testing.T, protocol uint) {
|
func testSendTransactions(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -354,19 +354,7 @@ func testSendTransactions(t *testing.T, protocol uint) {
|
||||||
seen := make(map[common.Hash]struct{})
|
seen := make(map[common.Hash]struct{})
|
||||||
for len(seen) < len(insert) {
|
for len(seen) < len(insert) {
|
||||||
switch protocol {
|
switch protocol {
|
||||||
case 63, 64:
|
case 65, 66:
|
||||||
select {
|
|
||||||
case <-anns:
|
|
||||||
t.Errorf("tx announce received on pre eth/65")
|
|
||||||
case txs := <-bcasts:
|
|
||||||
for _, tx := range txs {
|
|
||||||
if _, ok := seen[tx.Hash()]; ok {
|
|
||||||
t.Errorf("duplicate transaction announced: %x", tx.Hash())
|
|
||||||
}
|
|
||||||
seen[tx.Hash()] = struct{}{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 65:
|
|
||||||
select {
|
select {
|
||||||
case hashes := <-anns:
|
case hashes := <-anns:
|
||||||
for _, hash := range hashes {
|
for _, hash := range hashes {
|
||||||
|
@ -392,8 +380,8 @@ func testSendTransactions(t *testing.T, protocol uint) {
|
||||||
|
|
||||||
// Tests that transactions get propagated to all attached peers, either via direct
|
// Tests that transactions get propagated to all attached peers, either via direct
|
||||||
// broadcasts or via announcements/retrievals.
|
// broadcasts or via announcements/retrievals.
|
||||||
func TestTransactionPropagation64(t *testing.T) { testTransactionPropagation(t, 64) }
|
func TestTransactionPropagation65(t *testing.T) { testTransactionPropagation(t, eth.ETH65) }
|
||||||
func TestTransactionPropagation65(t *testing.T) { testTransactionPropagation(t, 65) }
|
func TestTransactionPropagation66(t *testing.T) { testTransactionPropagation(t, eth.ETH66) }
|
||||||
|
|
||||||
func testTransactionPropagation(t *testing.T, protocol uint) {
|
func testTransactionPropagation(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -530,8 +518,8 @@ func testCheckpointChallenge(t *testing.T, syncmode downloader.SyncMode, checkpo
|
||||||
defer p2pLocal.Close()
|
defer p2pLocal.Close()
|
||||||
defer p2pRemote.Close()
|
defer p2pRemote.Close()
|
||||||
|
|
||||||
local := eth.NewPeer(eth.ETH64, p2p.NewPeer(enode.ID{1}, "", nil), p2pLocal, handler.txpool)
|
local := eth.NewPeer(eth.ETH65, p2p.NewPeer(enode.ID{1}, "", nil), p2pLocal, handler.txpool)
|
||||||
remote := eth.NewPeer(eth.ETH64, p2p.NewPeer(enode.ID{2}, "", nil), p2pRemote, handler.txpool)
|
remote := eth.NewPeer(eth.ETH65, p2p.NewPeer(enode.ID{2}, "", nil), p2pRemote, handler.txpool)
|
||||||
defer local.Close()
|
defer local.Close()
|
||||||
defer remote.Close()
|
defer remote.Close()
|
||||||
|
|
||||||
|
@ -620,8 +608,8 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
|
||||||
defer sourcePipe.Close()
|
defer sourcePipe.Close()
|
||||||
defer sinkPipe.Close()
|
defer sinkPipe.Close()
|
||||||
|
|
||||||
sourcePeer := eth.NewPeer(eth.ETH64, p2p.NewPeer(enode.ID{byte(i)}, "", nil), sourcePipe, nil)
|
sourcePeer := eth.NewPeer(eth.ETH65, p2p.NewPeer(enode.ID{byte(i)}, "", nil), sourcePipe, nil)
|
||||||
sinkPeer := eth.NewPeer(eth.ETH64, p2p.NewPeer(enode.ID{0}, "", nil), sinkPipe, nil)
|
sinkPeer := eth.NewPeer(eth.ETH65, p2p.NewPeer(enode.ID{0}, "", nil), sinkPipe, nil)
|
||||||
defer sourcePeer.Close()
|
defer sourcePeer.Close()
|
||||||
defer sinkPeer.Close()
|
defer sinkPeer.Close()
|
||||||
|
|
||||||
|
@ -672,8 +660,8 @@ func testBroadcastBlock(t *testing.T, peers, bcasts int) {
|
||||||
|
|
||||||
// Tests that a propagated malformed block (uncles or transactions don't match
|
// Tests that a propagated malformed block (uncles or transactions don't match
|
||||||
// with the hashes in the header) gets discarded and not broadcast forward.
|
// with the hashes in the header) gets discarded and not broadcast forward.
|
||||||
func TestBroadcastMalformedBlock64(t *testing.T) { testBroadcastMalformedBlock(t, 64) }
|
func TestBroadcastMalformedBlock65(t *testing.T) { testBroadcastMalformedBlock(t, eth.ETH65) }
|
||||||
func TestBroadcastMalformedBlock65(t *testing.T) { testBroadcastMalformedBlock(t, 65) }
|
func TestBroadcastMalformedBlock66(t *testing.T) { testBroadcastMalformedBlock(t, eth.ETH66) }
|
||||||
|
|
||||||
func testBroadcastMalformedBlock(t *testing.T, protocol uint) {
|
func testBroadcastMalformedBlock(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
|
@ -171,44 +171,27 @@ type Decoder interface {
|
||||||
Time() time.Time
|
Time() time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
var eth64 = map[uint64]msgHandler{
|
|
||||||
GetBlockHeadersMsg: handleGetBlockHeaders,
|
|
||||||
BlockHeadersMsg: handleBlockHeaders,
|
|
||||||
GetBlockBodiesMsg: handleGetBlockBodies,
|
|
||||||
BlockBodiesMsg: handleBlockBodies,
|
|
||||||
GetNodeDataMsg: handleGetNodeData,
|
|
||||||
NodeDataMsg: handleNodeData,
|
|
||||||
GetReceiptsMsg: handleGetReceipts,
|
|
||||||
ReceiptsMsg: handleReceipts,
|
|
||||||
NewBlockHashesMsg: handleNewBlockhashes,
|
|
||||||
NewBlockMsg: handleNewBlock,
|
|
||||||
TransactionsMsg: handleTransactions,
|
|
||||||
}
|
|
||||||
var eth65 = map[uint64]msgHandler{
|
var eth65 = map[uint64]msgHandler{
|
||||||
// old 64 messages
|
GetBlockHeadersMsg: handleGetBlockHeaders,
|
||||||
GetBlockHeadersMsg: handleGetBlockHeaders,
|
BlockHeadersMsg: handleBlockHeaders,
|
||||||
BlockHeadersMsg: handleBlockHeaders,
|
GetBlockBodiesMsg: handleGetBlockBodies,
|
||||||
GetBlockBodiesMsg: handleGetBlockBodies,
|
BlockBodiesMsg: handleBlockBodies,
|
||||||
BlockBodiesMsg: handleBlockBodies,
|
GetNodeDataMsg: handleGetNodeData,
|
||||||
GetNodeDataMsg: handleGetNodeData,
|
NodeDataMsg: handleNodeData,
|
||||||
NodeDataMsg: handleNodeData,
|
GetReceiptsMsg: handleGetReceipts,
|
||||||
GetReceiptsMsg: handleGetReceipts,
|
ReceiptsMsg: handleReceipts,
|
||||||
ReceiptsMsg: handleReceipts,
|
NewBlockHashesMsg: handleNewBlockhashes,
|
||||||
NewBlockHashesMsg: handleNewBlockhashes,
|
NewBlockMsg: handleNewBlock,
|
||||||
NewBlockMsg: handleNewBlock,
|
TransactionsMsg: handleTransactions,
|
||||||
TransactionsMsg: handleTransactions,
|
|
||||||
// New eth65 messages
|
|
||||||
NewPooledTransactionHashesMsg: handleNewPooledTransactionHashes,
|
NewPooledTransactionHashesMsg: handleNewPooledTransactionHashes,
|
||||||
GetPooledTransactionsMsg: handleGetPooledTransactions,
|
GetPooledTransactionsMsg: handleGetPooledTransactions,
|
||||||
PooledTransactionsMsg: handlePooledTransactions,
|
PooledTransactionsMsg: handlePooledTransactions,
|
||||||
}
|
}
|
||||||
|
|
||||||
var eth66 = map[uint64]msgHandler{
|
var eth66 = map[uint64]msgHandler{
|
||||||
// eth64 announcement messages (no id)
|
NewBlockHashesMsg: handleNewBlockhashes,
|
||||||
NewBlockHashesMsg: handleNewBlockhashes,
|
NewBlockMsg: handleNewBlock,
|
||||||
NewBlockMsg: handleNewBlock,
|
TransactionsMsg: handleTransactions,
|
||||||
TransactionsMsg: handleTransactions,
|
|
||||||
// eth65 announcement messages (no id)
|
|
||||||
NewPooledTransactionHashesMsg: handleNewPooledTransactionHashes,
|
NewPooledTransactionHashesMsg: handleNewPooledTransactionHashes,
|
||||||
// eth66 messages with request-id
|
// eth66 messages with request-id
|
||||||
GetBlockHeadersMsg: handleGetBlockHeaders66,
|
GetBlockHeadersMsg: handleGetBlockHeaders66,
|
||||||
|
@ -236,10 +219,8 @@ func handleMessage(backend Backend, peer *Peer) error {
|
||||||
}
|
}
|
||||||
defer msg.Discard()
|
defer msg.Discard()
|
||||||
|
|
||||||
var handlers = eth64
|
var handlers = eth65
|
||||||
if peer.Version() == ETH65 {
|
if peer.Version() >= ETH66 {
|
||||||
handlers = eth65
|
|
||||||
} else if peer.Version() >= ETH66 {
|
|
||||||
handlers = eth66
|
handlers = eth66
|
||||||
}
|
}
|
||||||
// Track the emount of time it takes to serve the request and run the handler
|
// Track the emount of time it takes to serve the request and run the handler
|
||||||
|
|
|
@ -110,8 +110,8 @@ func (b *testBackend) Handle(*Peer, Packet) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that block headers can be retrieved from a remote chain based on user queries.
|
// Tests that block headers can be retrieved from a remote chain based on user queries.
|
||||||
func TestGetBlockHeaders64(t *testing.T) { testGetBlockHeaders(t, 64) }
|
func TestGetBlockHeaders65(t *testing.T) { testGetBlockHeaders(t, ETH65) }
|
||||||
func TestGetBlockHeaders65(t *testing.T) { testGetBlockHeaders(t, 65) }
|
func TestGetBlockHeaders66(t *testing.T) { testGetBlockHeaders(t, ETH66) }
|
||||||
|
|
||||||
func testGetBlockHeaders(t *testing.T, protocol uint) {
|
func testGetBlockHeaders(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -254,18 +254,44 @@ func testGetBlockHeaders(t *testing.T, protocol uint) {
|
||||||
headers = append(headers, backend.chain.GetBlockByHash(hash).Header())
|
headers = append(headers, backend.chain.GetBlockByHash(hash).Header())
|
||||||
}
|
}
|
||||||
// Send the hash request and verify the response
|
// Send the hash request and verify the response
|
||||||
p2p.Send(peer.app, GetBlockHeadersMsg, tt.query)
|
if protocol <= ETH65 {
|
||||||
if err := p2p.ExpectMsg(peer.app, BlockHeadersMsg, headers); err != nil {
|
p2p.Send(peer.app, GetBlockHeadersMsg, tt.query)
|
||||||
t.Errorf("test %d: headers mismatch: %v", i, err)
|
if err := p2p.ExpectMsg(peer.app, BlockHeadersMsg, headers); err != nil {
|
||||||
|
t.Errorf("test %d: headers mismatch: %v", i, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p2p.Send(peer.app, GetBlockHeadersMsg, GetBlockHeadersPacket66{
|
||||||
|
RequestId: 123,
|
||||||
|
GetBlockHeadersPacket: tt.query,
|
||||||
|
})
|
||||||
|
if err := p2p.ExpectMsg(peer.app, BlockHeadersMsg, BlockHeadersPacket66{
|
||||||
|
RequestId: 123,
|
||||||
|
BlockHeadersPacket: headers,
|
||||||
|
}); err != nil {
|
||||||
|
t.Errorf("test %d: headers mismatch: %v", i, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// If the test used number origins, repeat with hashes as the too
|
// If the test used number origins, repeat with hashes as the too
|
||||||
if tt.query.Origin.Hash == (common.Hash{}) {
|
if tt.query.Origin.Hash == (common.Hash{}) {
|
||||||
if origin := backend.chain.GetBlockByNumber(tt.query.Origin.Number); origin != nil {
|
if origin := backend.chain.GetBlockByNumber(tt.query.Origin.Number); origin != nil {
|
||||||
tt.query.Origin.Hash, tt.query.Origin.Number = origin.Hash(), 0
|
tt.query.Origin.Hash, tt.query.Origin.Number = origin.Hash(), 0
|
||||||
|
|
||||||
p2p.Send(peer.app, GetBlockHeadersMsg, tt.query)
|
if protocol <= ETH65 {
|
||||||
if err := p2p.ExpectMsg(peer.app, BlockHeadersMsg, headers); err != nil {
|
p2p.Send(peer.app, GetBlockHeadersMsg, tt.query)
|
||||||
t.Errorf("test %d: headers mismatch: %v", i, err)
|
if err := p2p.ExpectMsg(peer.app, BlockHeadersMsg, headers); err != nil {
|
||||||
|
t.Errorf("test %d: headers mismatch: %v", i, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p2p.Send(peer.app, GetBlockHeadersMsg, GetBlockHeadersPacket66{
|
||||||
|
RequestId: 456,
|
||||||
|
GetBlockHeadersPacket: tt.query,
|
||||||
|
})
|
||||||
|
if err := p2p.ExpectMsg(peer.app, BlockHeadersMsg, BlockHeadersPacket66{
|
||||||
|
RequestId: 456,
|
||||||
|
BlockHeadersPacket: headers,
|
||||||
|
}); err != nil {
|
||||||
|
t.Errorf("test %d: headers mismatch: %v", i, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,8 +299,8 @@ func testGetBlockHeaders(t *testing.T, protocol uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that block contents can be retrieved from a remote chain based on their hashes.
|
// Tests that block contents can be retrieved from a remote chain based on their hashes.
|
||||||
func TestGetBlockBodies64(t *testing.T) { testGetBlockBodies(t, 64) }
|
func TestGetBlockBodies65(t *testing.T) { testGetBlockBodies(t, ETH65) }
|
||||||
func TestGetBlockBodies65(t *testing.T) { testGetBlockBodies(t, 65) }
|
func TestGetBlockBodies66(t *testing.T) { testGetBlockBodies(t, ETH66) }
|
||||||
|
|
||||||
func testGetBlockBodies(t *testing.T, protocol uint) {
|
func testGetBlockBodies(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -343,16 +369,29 @@ func testGetBlockBodies(t *testing.T, protocol uint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Send the hash request and verify the response
|
// Send the hash request and verify the response
|
||||||
p2p.Send(peer.app, GetBlockBodiesMsg, hashes)
|
if protocol <= ETH65 {
|
||||||
if err := p2p.ExpectMsg(peer.app, BlockBodiesMsg, bodies); err != nil {
|
p2p.Send(peer.app, GetBlockBodiesMsg, hashes)
|
||||||
t.Errorf("test %d: bodies mismatch: %v", i, err)
|
if err := p2p.ExpectMsg(peer.app, BlockBodiesMsg, bodies); err != nil {
|
||||||
|
t.Errorf("test %d: bodies mismatch: %v", i, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p2p.Send(peer.app, GetBlockBodiesMsg, GetBlockBodiesPacket66{
|
||||||
|
RequestId: 123,
|
||||||
|
GetBlockBodiesPacket: hashes,
|
||||||
|
})
|
||||||
|
if err := p2p.ExpectMsg(peer.app, BlockBodiesMsg, BlockBodiesPacket66{
|
||||||
|
RequestId: 123,
|
||||||
|
BlockBodiesPacket: bodies,
|
||||||
|
}); err != nil {
|
||||||
|
t.Errorf("test %d: bodies mismatch: %v", i, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that the state trie nodes can be retrieved based on hashes.
|
// Tests that the state trie nodes can be retrieved based on hashes.
|
||||||
func TestGetNodeData64(t *testing.T) { testGetNodeData(t, 64) }
|
func TestGetNodeData65(t *testing.T) { testGetNodeData(t, ETH65) }
|
||||||
func TestGetNodeData65(t *testing.T) { testGetNodeData(t, 65) }
|
func TestGetNodeData66(t *testing.T) { testGetNodeData(t, ETH66) }
|
||||||
|
|
||||||
func testGetNodeData(t *testing.T, protocol uint) {
|
func testGetNodeData(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -410,7 +449,14 @@ func testGetNodeData(t *testing.T, protocol uint) {
|
||||||
}
|
}
|
||||||
it.Release()
|
it.Release()
|
||||||
|
|
||||||
p2p.Send(peer.app, GetNodeDataMsg, hashes)
|
if protocol <= ETH65 {
|
||||||
|
p2p.Send(peer.app, GetNodeDataMsg, hashes)
|
||||||
|
} else {
|
||||||
|
p2p.Send(peer.app, GetNodeDataMsg, GetNodeDataPacket66{
|
||||||
|
RequestId: 123,
|
||||||
|
GetNodeDataPacket: hashes,
|
||||||
|
})
|
||||||
|
}
|
||||||
msg, err := peer.app.ReadMsg()
|
msg, err := peer.app.ReadMsg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to read node data response: %v", err)
|
t.Fatalf("failed to read node data response: %v", err)
|
||||||
|
@ -419,8 +465,16 @@ func testGetNodeData(t *testing.T, protocol uint) {
|
||||||
t.Fatalf("response packet code mismatch: have %x, want %x", msg.Code, NodeDataMsg)
|
t.Fatalf("response packet code mismatch: have %x, want %x", msg.Code, NodeDataMsg)
|
||||||
}
|
}
|
||||||
var data [][]byte
|
var data [][]byte
|
||||||
if err := msg.Decode(&data); err != nil {
|
if protocol <= ETH65 {
|
||||||
t.Fatalf("failed to decode response node data: %v", err)
|
if err := msg.Decode(&data); err != nil {
|
||||||
|
t.Fatalf("failed to decode response node data: %v", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var res NodeDataPacket66
|
||||||
|
if err := msg.Decode(&res); err != nil {
|
||||||
|
t.Fatalf("failed to decode response node data: %v", err)
|
||||||
|
}
|
||||||
|
data = res.NodeDataPacket
|
||||||
}
|
}
|
||||||
// Verify that all hashes correspond to the requested data, and reconstruct a state tree
|
// Verify that all hashes correspond to the requested data, and reconstruct a state tree
|
||||||
for i, want := range hashes {
|
for i, want := range hashes {
|
||||||
|
@ -452,8 +506,8 @@ func testGetNodeData(t *testing.T, protocol uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that the transaction receipts can be retrieved based on hashes.
|
// Tests that the transaction receipts can be retrieved based on hashes.
|
||||||
func TestGetBlockReceipts64(t *testing.T) { testGetBlockReceipts(t, 64) }
|
func TestGetBlockReceipts65(t *testing.T) { testGetBlockReceipts(t, ETH65) }
|
||||||
func TestGetBlockReceipts65(t *testing.T) { testGetBlockReceipts(t, 65) }
|
func TestGetBlockReceipts66(t *testing.T) { testGetBlockReceipts(t, ETH66) }
|
||||||
|
|
||||||
func testGetBlockReceipts(t *testing.T, protocol uint) {
|
func testGetBlockReceipts(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
@ -503,7 +557,7 @@ func testGetBlockReceipts(t *testing.T, protocol uint) {
|
||||||
// Collect the hashes to request, and the response to expect
|
// Collect the hashes to request, and the response to expect
|
||||||
var (
|
var (
|
||||||
hashes []common.Hash
|
hashes []common.Hash
|
||||||
receipts []types.Receipts
|
receipts [][]*types.Receipt
|
||||||
)
|
)
|
||||||
for i := uint64(0); i <= backend.chain.CurrentBlock().NumberU64(); i++ {
|
for i := uint64(0); i <= backend.chain.CurrentBlock().NumberU64(); i++ {
|
||||||
block := backend.chain.GetBlockByNumber(i)
|
block := backend.chain.GetBlockByNumber(i)
|
||||||
|
@ -512,8 +566,21 @@ func testGetBlockReceipts(t *testing.T, protocol uint) {
|
||||||
receipts = append(receipts, backend.chain.GetReceiptsByHash(block.Hash()))
|
receipts = append(receipts, backend.chain.GetReceiptsByHash(block.Hash()))
|
||||||
}
|
}
|
||||||
// Send the hash request and verify the response
|
// Send the hash request and verify the response
|
||||||
p2p.Send(peer.app, GetReceiptsMsg, hashes)
|
if protocol <= ETH65 {
|
||||||
if err := p2p.ExpectMsg(peer.app, ReceiptsMsg, receipts); err != nil {
|
p2p.Send(peer.app, GetReceiptsMsg, hashes)
|
||||||
t.Errorf("receipts mismatch: %v", err)
|
if err := p2p.ExpectMsg(peer.app, ReceiptsMsg, receipts); err != nil {
|
||||||
|
t.Errorf("receipts mismatch: %v", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p2p.Send(peer.app, GetReceiptsMsg, GetReceiptsPacket66{
|
||||||
|
RequestId: 123,
|
||||||
|
GetReceiptsPacket: hashes,
|
||||||
|
})
|
||||||
|
if err := p2p.ExpectMsg(peer.app, ReceiptsMsg, ReceiptsPacket66{
|
||||||
|
RequestId: 123,
|
||||||
|
ReceiptsPacket: receipts,
|
||||||
|
}); err != nil {
|
||||||
|
t.Errorf("receipts mismatch: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Tests that handshake failures are detected and reported correctly.
|
// Tests that handshake failures are detected and reported correctly.
|
||||||
func TestHandshake64(t *testing.T) { testHandshake(t, 64) }
|
func TestHandshake65(t *testing.T) { testHandshake(t, ETH65) }
|
||||||
func TestHandshake65(t *testing.T) { testHandshake(t, 65) }
|
func TestHandshake66(t *testing.T) { testHandshake(t, ETH66) }
|
||||||
|
|
||||||
func testHandshake(t *testing.T, protocol uint) {
|
func testHandshake(t *testing.T, protocol uint) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
|
@ -30,7 +30,6 @@ import (
|
||||||
|
|
||||||
// Constants to match up protocol versions and messages
|
// Constants to match up protocol versions and messages
|
||||||
const (
|
const (
|
||||||
ETH64 = 64
|
|
||||||
ETH65 = 65
|
ETH65 = 65
|
||||||
ETH66 = 66
|
ETH66 = 66
|
||||||
)
|
)
|
||||||
|
@ -41,11 +40,11 @@ const ProtocolName = "eth"
|
||||||
|
|
||||||
// ProtocolVersions are the supported versions of the `eth` protocol (first
|
// ProtocolVersions are the supported versions of the `eth` protocol (first
|
||||||
// is primary).
|
// is primary).
|
||||||
var ProtocolVersions = []uint{ETH66, ETH65, ETH64}
|
var ProtocolVersions = []uint{ETH66, ETH65}
|
||||||
|
|
||||||
// protocolLengths are the number of implemented message corresponding to
|
// protocolLengths are the number of implemented message corresponding to
|
||||||
// different protocol versions.
|
// different protocol versions.
|
||||||
var protocolLengths = map[uint]uint64{ETH66: 17, ETH65: 17, ETH64: 17}
|
var protocolLengths = map[uint]uint64{ETH66: 17, ETH65: 17}
|
||||||
|
|
||||||
// maxMessageSize is the maximum cap on the size of a protocol message.
|
// maxMessageSize is the maximum cap on the size of a protocol message.
|
||||||
const maxMessageSize = 10 * 1024 * 1024
|
const maxMessageSize = 10 * 1024 * 1024
|
||||||
|
|
|
@ -28,8 +28,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Tests that fast sync is disabled after a successful sync cycle.
|
// Tests that fast sync is disabled after a successful sync cycle.
|
||||||
func TestFastSyncDisabling64(t *testing.T) { testFastSyncDisabling(t, 64) }
|
func TestFastSyncDisabling65(t *testing.T) { testFastSyncDisabling(t, eth.ETH65) }
|
||||||
func TestFastSyncDisabling65(t *testing.T) { testFastSyncDisabling(t, 65) }
|
func TestFastSyncDisabling66(t *testing.T) { testFastSyncDisabling(t, eth.ETH66) }
|
||||||
|
|
||||||
// Tests that fast sync gets disabled as soon as a real block is successfully
|
// Tests that fast sync gets disabled as soon as a real block is successfully
|
||||||
// imported into the blockchain.
|
// imported into the blockchain.
|
||||||
|
|
|
@ -28,6 +28,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/forkid"
|
"github.com/ethereum/go-ethereum/core/forkid"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||||
|
"github.com/ethereum/go-ethereum/eth/protocols/eth"
|
||||||
"github.com/ethereum/go-ethereum/light"
|
"github.com/ethereum/go-ethereum/light"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
|
@ -470,7 +471,7 @@ func (d *downloaderPeerNotify) registerPeer(p *serverPeer) {
|
||||||
handler: h,
|
handler: h,
|
||||||
peer: p,
|
peer: p,
|
||||||
}
|
}
|
||||||
h.downloader.RegisterLightPeer(p.id, ethVersion, pc)
|
h.downloader.RegisterLightPeer(p.id, eth.ETH65, pc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *downloaderPeerNotify) unregisterPeer(p *serverPeer) {
|
func (d *downloaderPeerNotify) unregisterPeer(p *serverPeer) {
|
||||||
|
|
|
@ -41,7 +41,6 @@ import (
|
||||||
const (
|
const (
|
||||||
softResponseLimit = 2 * 1024 * 1024 // Target maximum size of returned blocks, headers or node data.
|
softResponseLimit = 2 * 1024 * 1024 // Target maximum size of returned blocks, headers or node data.
|
||||||
estHeaderRlpSize = 500 // Approximate size of an RLP encoded block header
|
estHeaderRlpSize = 500 // Approximate size of an RLP encoded block header
|
||||||
ethVersion = 64 // equivalent eth version for the downloader
|
|
||||||
|
|
||||||
MaxHeaderFetch = 192 // Amount of block headers to be fetched per retrieval request
|
MaxHeaderFetch = 192 // Amount of block headers to be fetched per retrieval request
|
||||||
MaxBodyFetch = 32 // Amount of block bodies to be fetched per retrieval request
|
MaxBodyFetch = 32 // Amount of block bodies to be fetched per retrieval request
|
||||||
|
|
Loading…
Reference in New Issue