|
|
|
@ -177,7 +177,7 @@ func unmarshalRlpHeaders(rlpdata []rlp.RawValue) []*types.Header { |
|
|
|
|
// function can be used to retrieve batches of headers from the particular peer.
|
|
|
|
|
func (dlp *downloadTesterPeer) RequestHeadersByHash(origin common.Hash, amount int, skip int, reverse bool, sink chan *eth.Response) (*eth.Request, error) { |
|
|
|
|
// Service the header query via the live handler code
|
|
|
|
|
rlpHeaders := eth.ServiceGetBlockHeadersQuery(dlp.chain, ð.GetBlockHeadersPacket{ |
|
|
|
|
rlpHeaders := eth.ServiceGetBlockHeadersQuery(dlp.chain, ð.GetBlockHeadersRequest{ |
|
|
|
|
Origin: eth.HashOrNumber{ |
|
|
|
|
Hash: origin, |
|
|
|
|
}, |
|
|
|
@ -205,7 +205,7 @@ func (dlp *downloadTesterPeer) RequestHeadersByHash(origin common.Hash, amount i |
|
|
|
|
} |
|
|
|
|
res := ð.Response{ |
|
|
|
|
Req: req, |
|
|
|
|
Res: (*eth.BlockHeadersPacket)(&headers), |
|
|
|
|
Res: (*eth.BlockHeadersRequest)(&headers), |
|
|
|
|
Meta: hashes, |
|
|
|
|
Time: 1, |
|
|
|
|
Done: make(chan error, 1), // Ignore the returned status
|
|
|
|
@ -221,7 +221,7 @@ func (dlp *downloadTesterPeer) RequestHeadersByHash(origin common.Hash, amount i |
|
|
|
|
// function can be used to retrieve batches of headers from the particular peer.
|
|
|
|
|
func (dlp *downloadTesterPeer) RequestHeadersByNumber(origin uint64, amount int, skip int, reverse bool, sink chan *eth.Response) (*eth.Request, error) { |
|
|
|
|
// Service the header query via the live handler code
|
|
|
|
|
rlpHeaders := eth.ServiceGetBlockHeadersQuery(dlp.chain, ð.GetBlockHeadersPacket{ |
|
|
|
|
rlpHeaders := eth.ServiceGetBlockHeadersQuery(dlp.chain, ð.GetBlockHeadersRequest{ |
|
|
|
|
Origin: eth.HashOrNumber{ |
|
|
|
|
Number: origin, |
|
|
|
|
}, |
|
|
|
@ -249,7 +249,7 @@ func (dlp *downloadTesterPeer) RequestHeadersByNumber(origin uint64, amount int, |
|
|
|
|
} |
|
|
|
|
res := ð.Response{ |
|
|
|
|
Req: req, |
|
|
|
|
Res: (*eth.BlockHeadersPacket)(&headers), |
|
|
|
|
Res: (*eth.BlockHeadersRequest)(&headers), |
|
|
|
|
Meta: hashes, |
|
|
|
|
Time: 1, |
|
|
|
|
Done: make(chan error, 1), // Ignore the returned status
|
|
|
|
@ -286,7 +286,7 @@ func (dlp *downloadTesterPeer) RequestBodies(hashes []common.Hash, sink chan *et |
|
|
|
|
} |
|
|
|
|
res := ð.Response{ |
|
|
|
|
Req: req, |
|
|
|
|
Res: (*eth.BlockBodiesPacket)(&bodies), |
|
|
|
|
Res: (*eth.BlockBodiesResponse)(&bodies), |
|
|
|
|
Meta: [][]common.Hash{txsHashes, uncleHashes, withdrawalHashes}, |
|
|
|
|
Time: 1, |
|
|
|
|
Done: make(chan error, 1), // Ignore the returned status
|
|
|
|
@ -317,7 +317,7 @@ func (dlp *downloadTesterPeer) RequestReceipts(hashes []common.Hash, sink chan * |
|
|
|
|
} |
|
|
|
|
res := ð.Response{ |
|
|
|
|
Req: req, |
|
|
|
|
Res: (*eth.ReceiptsPacket)(&receipts), |
|
|
|
|
Res: (*eth.ReceiptsResponse)(&receipts), |
|
|
|
|
Meta: hashes, |
|
|
|
|
Time: 1, |
|
|
|
|
Done: make(chan error, 1), // Ignore the returned status
|
|
|
|
@ -437,9 +437,9 @@ func assertOwnChain(t *testing.T, tester *downloadTester, length int) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestCanonicalSynchronisation66Full(t *testing.T) { testCanonSync(t, eth.ETH66, FullSync) } |
|
|
|
|
func TestCanonicalSynchronisation66Snap(t *testing.T) { testCanonSync(t, eth.ETH66, SnapSync) } |
|
|
|
|
func TestCanonicalSynchronisation66Light(t *testing.T) { testCanonSync(t, eth.ETH66, LightSync) } |
|
|
|
|
func TestCanonicalSynchronisation68Full(t *testing.T) { testCanonSync(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestCanonicalSynchronisation68Snap(t *testing.T) { testCanonSync(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestCanonicalSynchronisation68Light(t *testing.T) { testCanonSync(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestCanonicalSynchronisation67Full(t *testing.T) { testCanonSync(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestCanonicalSynchronisation67Snap(t *testing.T) { testCanonSync(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestCanonicalSynchronisation67Light(t *testing.T) { testCanonSync(t, eth.ETH67, LightSync) } |
|
|
|
@ -461,8 +461,8 @@ 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 TestThrottling66Full(t *testing.T) { testThrottling(t, eth.ETH66, FullSync) } |
|
|
|
|
func TestThrottling66Snap(t *testing.T) { testThrottling(t, eth.ETH66, SnapSync) } |
|
|
|
|
func TestThrottling68Full(t *testing.T) { testThrottling(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestThrottling68Snap(t *testing.T) { testThrottling(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestThrottling67Full(t *testing.T) { testThrottling(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestThrottling67Snap(t *testing.T) { testThrottling(t, eth.ETH67, SnapSync) } |
|
|
|
|
|
|
|
|
@ -543,9 +543,9 @@ 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 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) } |
|
|
|
|
func TestForkedSync68Full(t *testing.T) { testForkedSync(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestForkedSync68Snap(t *testing.T) { testForkedSync(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestForkedSync68Light(t *testing.T) { testForkedSync(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestForkedSync67Full(t *testing.T) { testForkedSync(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestForkedSync67Snap(t *testing.T) { testForkedSync(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestForkedSync67Light(t *testing.T) { testForkedSync(t, eth.ETH67, LightSync) } |
|
|
|
@ -573,9 +573,9 @@ func testForkedSync(t *testing.T, protocol uint, mode SyncMode) { |
|
|
|
|
|
|
|
|
|
// Tests that synchronising against a much shorter but much heavier fork works
|
|
|
|
|
// currently and is not dropped.
|
|
|
|
|
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) } |
|
|
|
|
func TestHeavyForkedSync68Full(t *testing.T) { testHeavyForkedSync(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestHeavyForkedSync68Snap(t *testing.T) { testHeavyForkedSync(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestHeavyForkedSync68Light(t *testing.T) { testHeavyForkedSync(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestHeavyForkedSync67Full(t *testing.T) { testHeavyForkedSync(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestHeavyForkedSync67Snap(t *testing.T) { testHeavyForkedSync(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestHeavyForkedSync67Light(t *testing.T) { testHeavyForkedSync(t, eth.ETH67, LightSync) } |
|
|
|
@ -605,9 +605,9 @@ 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 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) } |
|
|
|
|
func TestBoundedForkedSync68Full(t *testing.T) { testBoundedForkedSync(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestBoundedForkedSync68Snap(t *testing.T) { testBoundedForkedSync(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestBoundedForkedSync68Light(t *testing.T) { testBoundedForkedSync(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestBoundedForkedSync67Full(t *testing.T) { testBoundedForkedSync(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestBoundedForkedSync67Snap(t *testing.T) { testBoundedForkedSync(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestBoundedForkedSync67Light(t *testing.T) { testBoundedForkedSync(t, eth.ETH67, LightSync) } |
|
|
|
@ -636,14 +636,14 @@ 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 TestBoundedHeavyForkedSync66Full(t *testing.T) { |
|
|
|
|
testBoundedHeavyForkedSync(t, eth.ETH66, FullSync) |
|
|
|
|
func TestBoundedHeavyForkedSync68Full(t *testing.T) { |
|
|
|
|
testBoundedHeavyForkedSync(t, eth.ETH68, FullSync) |
|
|
|
|
} |
|
|
|
|
func TestBoundedHeavyForkedSync66Snap(t *testing.T) { |
|
|
|
|
testBoundedHeavyForkedSync(t, eth.ETH66, SnapSync) |
|
|
|
|
func TestBoundedHeavyForkedSync68Snap(t *testing.T) { |
|
|
|
|
testBoundedHeavyForkedSync(t, eth.ETH68, SnapSync) |
|
|
|
|
} |
|
|
|
|
func TestBoundedHeavyForkedSync66Light(t *testing.T) { |
|
|
|
|
testBoundedHeavyForkedSync(t, eth.ETH66, LightSync) |
|
|
|
|
func TestBoundedHeavyForkedSync68Light(t *testing.T) { |
|
|
|
|
testBoundedHeavyForkedSync(t, eth.ETH68, LightSync) |
|
|
|
|
} |
|
|
|
|
func TestBoundedHeavyForkedSync67Full(t *testing.T) { |
|
|
|
|
testBoundedHeavyForkedSync(t, eth.ETH67, FullSync) |
|
|
|
@ -678,9 +678,9 @@ func testBoundedHeavyForkedSync(t *testing.T, protocol uint, mode SyncMode) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that a canceled download wipes all previously accumulated state.
|
|
|
|
|
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) } |
|
|
|
|
func TestCancel68Full(t *testing.T) { testCancel(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestCancel68Snap(t *testing.T) { testCancel(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestCancel68Light(t *testing.T) { testCancel(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestCancel67Full(t *testing.T) { testCancel(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestCancel67Snap(t *testing.T) { testCancel(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestCancel67Light(t *testing.T) { testCancel(t, eth.ETH67, LightSync) } |
|
|
|
@ -708,9 +708,9 @@ func testCancel(t *testing.T, protocol uint, mode SyncMode) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that synchronisation from multiple peers works as intended (multi thread sanity test).
|
|
|
|
|
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) } |
|
|
|
|
func TestMultiSynchronisation68Full(t *testing.T) { testMultiSynchronisation(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestMultiSynchronisation68Snap(t *testing.T) { testMultiSynchronisation(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestMultiSynchronisation68Light(t *testing.T) { testMultiSynchronisation(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestMultiSynchronisation67Full(t *testing.T) { testMultiSynchronisation(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestMultiSynchronisation67Snap(t *testing.T) { testMultiSynchronisation(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestMultiSynchronisation67Light(t *testing.T) { testMultiSynchronisation(t, eth.ETH67, LightSync) } |
|
|
|
@ -735,9 +735,9 @@ 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 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) } |
|
|
|
|
func TestMultiProtoSynchronisation68Full(t *testing.T) { testMultiProtoSync(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestMultiProtoSynchronisation68Snap(t *testing.T) { testMultiProtoSync(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestMultiProtoSynchronisation68Light(t *testing.T) { testMultiProtoSync(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestMultiProtoSynchronisation67Full(t *testing.T) { testMultiProtoSync(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestMultiProtoSynchronisation67Snap(t *testing.T) { testMultiProtoSync(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestMultiProtoSynchronisation67Light(t *testing.T) { testMultiProtoSync(t, eth.ETH67, LightSync) } |
|
|
|
@ -750,7 +750,7 @@ func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) { |
|
|
|
|
chain := testChainBase.shorten(blockCacheMaxItems - 15) |
|
|
|
|
|
|
|
|
|
// Create peers of every type
|
|
|
|
|
tester.newPeer("peer 66", eth.ETH66, chain.blocks[1:]) |
|
|
|
|
tester.newPeer("peer 68", eth.ETH68, chain.blocks[1:]) |
|
|
|
|
tester.newPeer("peer 67", eth.ETH67, chain.blocks[1:]) |
|
|
|
|
|
|
|
|
|
// Synchronise with the requested peer and make sure all blocks were retrieved
|
|
|
|
@ -760,7 +760,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{66, 67} { |
|
|
|
|
for _, version := range []int{68, 67} { |
|
|
|
|
peer := fmt.Sprintf("peer %d", version) |
|
|
|
|
if _, ok := tester.peers[peer]; !ok { |
|
|
|
|
t.Errorf("%s dropped", peer) |
|
|
|
@ -770,9 +770,9 @@ 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 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) } |
|
|
|
|
func TestEmptyShortCircuit68Full(t *testing.T) { testEmptyShortCircuit(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestEmptyShortCircuit68Snap(t *testing.T) { testEmptyShortCircuit(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestEmptyShortCircuit68Light(t *testing.T) { testEmptyShortCircuit(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestEmptyShortCircuit67Full(t *testing.T) { testEmptyShortCircuit(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestEmptyShortCircuit67Snap(t *testing.T) { testEmptyShortCircuit(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestEmptyShortCircuit67Light(t *testing.T) { testEmptyShortCircuit(t, eth.ETH67, LightSync) } |
|
|
|
@ -821,9 +821,9 @@ 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 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) } |
|
|
|
|
func TestMissingHeaderAttack68Full(t *testing.T) { testMissingHeaderAttack(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestMissingHeaderAttack68Snap(t *testing.T) { testMissingHeaderAttack(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestMissingHeaderAttack68Light(t *testing.T) { testMissingHeaderAttack(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestMissingHeaderAttack67Full(t *testing.T) { testMissingHeaderAttack(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestMissingHeaderAttack67Snap(t *testing.T) { testMissingHeaderAttack(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestMissingHeaderAttack67Light(t *testing.T) { testMissingHeaderAttack(t, eth.ETH67, LightSync) } |
|
|
|
@ -850,9 +850,9 @@ 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 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) } |
|
|
|
|
func TestShiftedHeaderAttack68Full(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestShiftedHeaderAttack68Snap(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestShiftedHeaderAttack68Light(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestShiftedHeaderAttack67Full(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestShiftedHeaderAttack67Snap(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestShiftedHeaderAttack67Light(t *testing.T) { testShiftedHeaderAttack(t, eth.ETH67, LightSync) } |
|
|
|
@ -880,14 +880,14 @@ func testShiftedHeaderAttack(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 TestHighTDStarvationAttack66Full(t *testing.T) { |
|
|
|
|
testHighTDStarvationAttack(t, eth.ETH66, FullSync) |
|
|
|
|
func TestHighTDStarvationAttack68Full(t *testing.T) { |
|
|
|
|
testHighTDStarvationAttack(t, eth.ETH68, FullSync) |
|
|
|
|
} |
|
|
|
|
func TestHighTDStarvationAttack66Snap(t *testing.T) { |
|
|
|
|
testHighTDStarvationAttack(t, eth.ETH66, SnapSync) |
|
|
|
|
func TestHighTDStarvationAttack68Snap(t *testing.T) { |
|
|
|
|
testHighTDStarvationAttack(t, eth.ETH68, SnapSync) |
|
|
|
|
} |
|
|
|
|
func TestHighTDStarvationAttack66Light(t *testing.T) { |
|
|
|
|
testHighTDStarvationAttack(t, eth.ETH66, LightSync) |
|
|
|
|
func TestHighTDStarvationAttack68Light(t *testing.T) { |
|
|
|
|
testHighTDStarvationAttack(t, eth.ETH68, LightSync) |
|
|
|
|
} |
|
|
|
|
func TestHighTDStarvationAttack67Full(t *testing.T) { |
|
|
|
|
testHighTDStarvationAttack(t, eth.ETH67, FullSync) |
|
|
|
@ -911,7 +911,7 @@ func testHighTDStarvationAttack(t *testing.T, protocol uint, mode SyncMode) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests that misbehaving peers are disconnected, whilst behaving ones are not.
|
|
|
|
|
func TestBlockHeaderAttackerDropping66(t *testing.T) { testBlockHeaderAttackerDropping(t, eth.ETH66) } |
|
|
|
|
func TestBlockHeaderAttackerDropping68(t *testing.T) { testBlockHeaderAttackerDropping(t, eth.ETH68) } |
|
|
|
|
func TestBlockHeaderAttackerDropping67(t *testing.T) { testBlockHeaderAttackerDropping(t, eth.ETH67) } |
|
|
|
|
|
|
|
|
|
func testBlockHeaderAttackerDropping(t *testing.T, protocol uint) { |
|
|
|
@ -960,9 +960,9 @@ 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 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) } |
|
|
|
|
func TestSyncProgress68Full(t *testing.T) { testSyncProgress(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestSyncProgress68Snap(t *testing.T) { testSyncProgress(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestSyncProgress68Light(t *testing.T) { testSyncProgress(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestSyncProgress67Full(t *testing.T) { testSyncProgress(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestSyncProgress67Snap(t *testing.T) { testSyncProgress(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestSyncProgress67Light(t *testing.T) { testSyncProgress(t, eth.ETH67, LightSync) } |
|
|
|
@ -1040,9 +1040,9 @@ 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 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) } |
|
|
|
|
func TestForkedSyncProgress68Full(t *testing.T) { testForkedSyncProgress(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestForkedSyncProgress68Snap(t *testing.T) { testForkedSyncProgress(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestForkedSyncProgress68Light(t *testing.T) { testForkedSyncProgress(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestForkedSyncProgress67Full(t *testing.T) { testForkedSyncProgress(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestForkedSyncProgress67Snap(t *testing.T) { testForkedSyncProgress(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestForkedSyncProgress67Light(t *testing.T) { testForkedSyncProgress(t, eth.ETH67, LightSync) } |
|
|
|
@ -1114,9 +1114,9 @@ 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 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) } |
|
|
|
|
func TestFailedSyncProgress68Full(t *testing.T) { testFailedSyncProgress(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestFailedSyncProgress68Snap(t *testing.T) { testFailedSyncProgress(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestFailedSyncProgress68Light(t *testing.T) { testFailedSyncProgress(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestFailedSyncProgress67Full(t *testing.T) { testFailedSyncProgress(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestFailedSyncProgress67Snap(t *testing.T) { testFailedSyncProgress(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestFailedSyncProgress67Light(t *testing.T) { testFailedSyncProgress(t, eth.ETH67, LightSync) } |
|
|
|
@ -1183,9 +1183,9 @@ 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 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) } |
|
|
|
|
func TestFakedSyncProgress68Full(t *testing.T) { testFakedSyncProgress(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestFakedSyncProgress68Snap(t *testing.T) { testFakedSyncProgress(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestFakedSyncProgress68Light(t *testing.T) { testFakedSyncProgress(t, eth.ETH68, LightSync) } |
|
|
|
|
func TestFakedSyncProgress67Full(t *testing.T) { testFakedSyncProgress(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestFakedSyncProgress67Snap(t *testing.T) { testFakedSyncProgress(t, eth.ETH67, SnapSync) } |
|
|
|
|
func TestFakedSyncProgress67Light(t *testing.T) { testFakedSyncProgress(t, eth.ETH67, LightSync) } |
|
|
|
@ -1330,8 +1330,10 @@ 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 TestBeaconSync66Full(t *testing.T) { testBeaconSync(t, eth.ETH66, FullSync) } |
|
|
|
|
func TestBeaconSync66Snap(t *testing.T) { testBeaconSync(t, eth.ETH66, SnapSync) } |
|
|
|
|
func TestBeaconSync68Full(t *testing.T) { testBeaconSync(t, eth.ETH68, FullSync) } |
|
|
|
|
func TestBeaconSync68Snap(t *testing.T) { testBeaconSync(t, eth.ETH68, SnapSync) } |
|
|
|
|
func TestBeaconSync67Full(t *testing.T) { testBeaconSync(t, eth.ETH67, FullSync) } |
|
|
|
|
func TestBeaconSync67Snap(t *testing.T) { testBeaconSync(t, eth.ETH67, SnapSync) } |
|
|
|
|
|
|
|
|
|
func testBeaconSync(t *testing.T, protocol uint, mode SyncMode) { |
|
|
|
|
//log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
|
|
|
|
|