|
|
@@ -26,6 +26,7 @@ import (
|
|
|
"os"
|
|
|
"strings"
|
|
|
"testing"
|
|
|
+ "time"
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
"github.com/ethereum/go-ethereum/consensus/ethash"
|
|
|
@@ -150,7 +151,10 @@ func (tt *rewindTest) dump(crash bool) string {
|
|
|
// chain to be rolled back to the committed block. Everything above the sethead
|
|
|
// point should be deleted. In between the committed block and the requested head
|
|
|
// the data can remain as "fast sync" data to avoid redownloading it.
|
|
|
-func TestShortSetHead(t *testing.T) {
|
|
|
+func TestShortSetHead(t *testing.T) { testShortSetHead(t, false) }
|
|
|
+func TestShortSetHeadWithSnapshots(t *testing.T) { testShortSetHead(t, true) }
|
|
|
+
|
|
|
+func testShortSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8 (HEAD)
|
|
|
//
|
|
|
@@ -181,7 +185,7 @@ func TestShortSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain where the fast sync pivot point was
|
|
|
@@ -190,7 +194,10 @@ func TestShortSetHead(t *testing.T) {
|
|
|
// Everything above the sethead point should be deleted. In between the committed
|
|
|
// block and the requested head the data can remain as "fast sync" data to avoid
|
|
|
// redownloading it.
|
|
|
-func TestShortFastSyncedSetHead(t *testing.T) {
|
|
|
+func TestShortFastSyncedSetHead(t *testing.T) { testShortFastSyncedSetHead(t, false) }
|
|
|
+func TestShortFastSyncedSetHeadWithSnapshots(t *testing.T) { testShortFastSyncedSetHead(t, true) }
|
|
|
+
|
|
|
+func testShortFastSyncedSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8 (HEAD)
|
|
|
//
|
|
|
@@ -221,7 +228,7 @@ func TestShortFastSyncedSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain where the fast sync pivot point was
|
|
|
@@ -229,7 +236,10 @@ func TestShortFastSyncedSetHead(t *testing.T) {
|
|
|
// detect that it was fast syncing and delete everything from the new head, since
|
|
|
// we can just pick up fast syncing from there. The head full block should be set
|
|
|
// to the genesis.
|
|
|
-func TestShortFastSyncingSetHead(t *testing.T) {
|
|
|
+func TestShortFastSyncingSetHead(t *testing.T) { testShortFastSyncingSetHead(t, false) }
|
|
|
+func TestShortFastSyncingSetHeadWithSnapshots(t *testing.T) { testShortFastSyncingSetHead(t, true) }
|
|
|
+
|
|
|
+func testShortFastSyncingSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8 (HEAD)
|
|
|
//
|
|
|
@@ -260,7 +270,7 @@ func TestShortFastSyncingSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain and a shorter side chain, where a
|
|
|
@@ -270,7 +280,10 @@ func TestShortFastSyncingSetHead(t *testing.T) {
|
|
|
// above the sethead point should be deleted. In between the committed block and
|
|
|
// the requested head the data can remain as "fast sync" data to avoid redownloading
|
|
|
// it. The side chain should be left alone as it was shorter.
|
|
|
-func TestShortOldForkedSetHead(t *testing.T) {
|
|
|
+func TestShortOldForkedSetHead(t *testing.T) { testShortOldForkedSetHead(t, false) }
|
|
|
+func TestShortOldForkedSetHeadWithSnapshots(t *testing.T) { testShortOldForkedSetHead(t, true) }
|
|
|
+
|
|
|
+func testShortOldForkedSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8 (HEAD)
|
|
|
// └->S1->S2->S3
|
|
|
@@ -303,7 +316,7 @@ func TestShortOldForkedSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain and a shorter side chain, where
|
|
|
@@ -314,6 +327,13 @@ func TestShortOldForkedSetHead(t *testing.T) {
|
|
|
// committed block and the requested head the data can remain as "fast sync" data
|
|
|
// to avoid redownloading it. The side chain should be left alone as it was shorter.
|
|
|
func TestShortOldForkedFastSyncedSetHead(t *testing.T) {
|
|
|
+ testShortOldForkedFastSyncedSetHead(t, false)
|
|
|
+}
|
|
|
+func TestShortOldForkedFastSyncedSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testShortOldForkedFastSyncedSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testShortOldForkedFastSyncedSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8 (HEAD)
|
|
|
// └->S1->S2->S3
|
|
|
@@ -346,7 +366,7 @@ func TestShortOldForkedFastSyncedSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain and a shorter side chain, where
|
|
|
@@ -356,6 +376,13 @@ func TestShortOldForkedFastSyncedSetHead(t *testing.T) {
|
|
|
// head, since we can just pick up fast syncing from there. The head full block
|
|
|
// should be set to the genesis.
|
|
|
func TestShortOldForkedFastSyncingSetHead(t *testing.T) {
|
|
|
+ testShortOldForkedFastSyncingSetHead(t, false)
|
|
|
+}
|
|
|
+func TestShortOldForkedFastSyncingSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testShortOldForkedFastSyncingSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testShortOldForkedFastSyncingSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8 (HEAD)
|
|
|
// └->S1->S2->S3
|
|
|
@@ -388,7 +415,7 @@ func TestShortOldForkedFastSyncingSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain and a shorter side chain, where a
|
|
|
@@ -402,7 +429,10 @@ func TestShortOldForkedFastSyncingSetHead(t *testing.T) {
|
|
|
// The side chain could be left to be if the fork point was before the new head
|
|
|
// we are deleting to, but it would be exceedingly hard to detect that case and
|
|
|
// properly handle it, so we'll trade extra work in exchange for simpler code.
|
|
|
-func TestShortNewlyForkedSetHead(t *testing.T) {
|
|
|
+func TestShortNewlyForkedSetHead(t *testing.T) { testShortNewlyForkedSetHead(t, false) }
|
|
|
+func TestShortNewlyForkedSetHeadWithSnapshots(t *testing.T) { testShortNewlyForkedSetHead(t, true) }
|
|
|
+
|
|
|
+func testShortNewlyForkedSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8
|
|
|
@@ -435,7 +465,7 @@ func TestShortNewlyForkedSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain and a shorter side chain, where
|
|
|
@@ -449,6 +479,13 @@ func TestShortNewlyForkedSetHead(t *testing.T) {
|
|
|
// we are deleting to, but it would be exceedingly hard to detect that case and
|
|
|
// properly handle it, so we'll trade extra work in exchange for simpler code.
|
|
|
func TestShortNewlyForkedFastSyncedSetHead(t *testing.T) {
|
|
|
+ testShortNewlyForkedFastSyncedSetHead(t, false)
|
|
|
+}
|
|
|
+func TestShortNewlyForkedFastSyncedSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testShortNewlyForkedFastSyncedSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testShortNewlyForkedFastSyncedSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8
|
|
|
@@ -481,7 +518,7 @@ func TestShortNewlyForkedFastSyncedSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain and a shorter side chain, where
|
|
|
@@ -495,6 +532,13 @@ func TestShortNewlyForkedFastSyncedSetHead(t *testing.T) {
|
|
|
// we are deleting to, but it would be exceedingly hard to detect that case and
|
|
|
// properly handle it, so we'll trade extra work in exchange for simpler code.
|
|
|
func TestShortNewlyForkedFastSyncingSetHead(t *testing.T) {
|
|
|
+ testShortNewlyForkedFastSyncingSetHead(t, false)
|
|
|
+}
|
|
|
+func TestShortNewlyForkedFastSyncingSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testShortNewlyForkedFastSyncingSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testShortNewlyForkedFastSyncingSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8
|
|
|
@@ -527,7 +571,7 @@ func TestShortNewlyForkedFastSyncingSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain and a longer side chain, where a
|
|
|
@@ -540,7 +584,10 @@ func TestShortNewlyForkedFastSyncingSetHead(t *testing.T) {
|
|
|
// The side chain could be left to be if the fork point was before the new head
|
|
|
// we are deleting to, but it would be exceedingly hard to detect that case and
|
|
|
// properly handle it, so we'll trade extra work in exchange for simpler code.
|
|
|
-func TestShortReorgedSetHead(t *testing.T) {
|
|
|
+func TestShortReorgedSetHead(t *testing.T) { testShortReorgedSetHead(t, false) }
|
|
|
+func TestShortReorgedSetHeadWithSnapshots(t *testing.T) { testShortReorgedSetHead(t, true) }
|
|
|
+
|
|
|
+func testShortReorgedSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10
|
|
|
@@ -573,7 +620,7 @@ func TestShortReorgedSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain and a longer side chain, where
|
|
|
@@ -588,6 +635,13 @@ func TestShortReorgedSetHead(t *testing.T) {
|
|
|
// we are deleting to, but it would be exceedingly hard to detect that case and
|
|
|
// properly handle it, so we'll trade extra work in exchange for simpler code.
|
|
|
func TestShortReorgedFastSyncedSetHead(t *testing.T) {
|
|
|
+ testShortReorgedFastSyncedSetHead(t, false)
|
|
|
+}
|
|
|
+func TestShortReorgedFastSyncedSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testShortReorgedFastSyncedSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testShortReorgedFastSyncedSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10
|
|
|
@@ -620,7 +674,7 @@ func TestShortReorgedFastSyncedSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a short canonical chain and a longer side chain, where
|
|
|
@@ -633,6 +687,13 @@ func TestShortReorgedFastSyncedSetHead(t *testing.T) {
|
|
|
// we are deleting to, but it would be exceedingly hard to detect that case and
|
|
|
// properly handle it, so we'll trade extra work in exchange for simpler code.
|
|
|
func TestShortReorgedFastSyncingSetHead(t *testing.T) {
|
|
|
+ testShortReorgedFastSyncingSetHead(t, false)
|
|
|
+}
|
|
|
+func TestShortReorgedFastSyncingSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testShortReorgedFastSyncingSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testShortReorgedFastSyncingSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10
|
|
|
@@ -665,7 +726,7 @@ func TestShortReorgedFastSyncingSetHead(t *testing.T) {
|
|
|
expHeadHeader: 7,
|
|
|
expHeadFastBlock: 7,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks where a recent
|
|
|
@@ -674,7 +735,10 @@ func TestShortReorgedFastSyncingSetHead(t *testing.T) {
|
|
|
// to the committed block. Everything above the sethead point should be deleted.
|
|
|
// In between the committed block and the requested head the data can remain as
|
|
|
// "fast sync" data to avoid redownloading it.
|
|
|
-func TestLongShallowSetHead(t *testing.T) {
|
|
|
+func TestLongShallowSetHead(t *testing.T) { testLongShallowSetHead(t, false) }
|
|
|
+func TestLongShallowSetHeadWithSnapshots(t *testing.T) { testLongShallowSetHead(t, true) }
|
|
|
+
|
|
|
+func testLongShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
//
|
|
|
@@ -710,7 +774,7 @@ func TestLongShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks where a recent
|
|
|
@@ -718,7 +782,10 @@ func TestLongShallowSetHead(t *testing.T) {
|
|
|
// sethead was called. In this case we expect the full chain to be rolled back
|
|
|
// to the committed block. Since the ancient limit was underflown, everything
|
|
|
// needs to be deleted onwards to avoid creating a gap.
|
|
|
-func TestLongDeepSetHead(t *testing.T) {
|
|
|
+func TestLongDeepSetHead(t *testing.T) { testLongDeepSetHead(t, false) }
|
|
|
+func TestLongDeepSetHeadWithSnapshots(t *testing.T) { testLongDeepSetHead(t, true) }
|
|
|
+
|
|
|
+func testLongDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
//
|
|
|
@@ -753,7 +820,7 @@ func TestLongDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 4,
|
|
|
expHeadFastBlock: 4,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks where the fast
|
|
|
@@ -763,6 +830,13 @@ func TestLongDeepSetHead(t *testing.T) {
|
|
|
// deleted. In between the committed block and the requested head the data can
|
|
|
// remain as "fast sync" data to avoid redownloading it.
|
|
|
func TestLongFastSyncedShallowSetHead(t *testing.T) {
|
|
|
+ testLongFastSyncedShallowSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongFastSyncedShallowSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongFastSyncedShallowSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongFastSyncedShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
//
|
|
|
@@ -798,7 +872,7 @@ func TestLongFastSyncedShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks where the fast
|
|
|
@@ -806,7 +880,10 @@ func TestLongFastSyncedShallowSetHead(t *testing.T) {
|
|
|
// which sethead was called. In this case we expect the full chain to be rolled
|
|
|
// back to the committed block. Since the ancient limit was underflown, everything
|
|
|
// needs to be deleted onwards to avoid creating a gap.
|
|
|
-func TestLongFastSyncedDeepSetHead(t *testing.T) {
|
|
|
+func TestLongFastSyncedDeepSetHead(t *testing.T) { testLongFastSyncedDeepSetHead(t, false) }
|
|
|
+func TestLongFastSyncedDeepSetHeadWithSnapshots(t *testing.T) { testLongFastSyncedDeepSetHead(t, true) }
|
|
|
+
|
|
|
+func testLongFastSyncedDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
//
|
|
|
@@ -841,7 +918,7 @@ func TestLongFastSyncedDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 4,
|
|
|
expHeadFastBlock: 4,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks where the fast
|
|
|
@@ -850,6 +927,13 @@ func TestLongFastSyncedDeepSetHead(t *testing.T) {
|
|
|
// syncing and delete everything from the new head, since we can just pick up fast
|
|
|
// syncing from there.
|
|
|
func TestLongFastSyncingShallowSetHead(t *testing.T) {
|
|
|
+ testLongFastSyncingShallowSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongFastSyncingShallowSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongFastSyncingShallowSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongFastSyncingShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
//
|
|
|
@@ -885,7 +969,7 @@ func TestLongFastSyncingShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks where the fast
|
|
|
@@ -894,6 +978,13 @@ func TestLongFastSyncingShallowSetHead(t *testing.T) {
|
|
|
// syncing and delete everything from the new head, since we can just pick up fast
|
|
|
// syncing from there.
|
|
|
func TestLongFastSyncingDeepSetHead(t *testing.T) {
|
|
|
+ testLongFastSyncingDeepSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongFastSyncingDeepSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongFastSyncingDeepSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongFastSyncingDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
//
|
|
|
@@ -928,7 +1019,7 @@ func TestLongFastSyncingDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter side
|
|
|
@@ -939,6 +1030,13 @@ func TestLongFastSyncingDeepSetHead(t *testing.T) {
|
|
|
// can remain as "fast sync" data to avoid redownloading it. The side chain is nuked
|
|
|
// by the freezer.
|
|
|
func TestLongOldForkedShallowSetHead(t *testing.T) {
|
|
|
+ testLongOldForkedShallowSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongOldForkedShallowSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongOldForkedShallowSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongOldForkedShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
// └->S1->S2->S3
|
|
|
@@ -975,7 +1073,7 @@ func TestLongOldForkedShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter side
|
|
|
@@ -984,7 +1082,10 @@ func TestLongOldForkedShallowSetHead(t *testing.T) {
|
|
|
// chain to be rolled back to the committed block. Since the ancient limit was
|
|
|
// underflown, everything needs to be deleted onwards to avoid creating a gap. The
|
|
|
// side chain is nuked by the freezer.
|
|
|
-func TestLongOldForkedDeepSetHead(t *testing.T) {
|
|
|
+func TestLongOldForkedDeepSetHead(t *testing.T) { testLongOldForkedDeepSetHead(t, false) }
|
|
|
+func TestLongOldForkedDeepSetHeadWithSnapshots(t *testing.T) { testLongOldForkedDeepSetHead(t, true) }
|
|
|
+
|
|
|
+func testLongOldForkedDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
// └->S1->S2->S3
|
|
|
@@ -1020,7 +1121,7 @@ func TestLongOldForkedDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 4,
|
|
|
expHeadFastBlock: 4,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter
|
|
|
@@ -1032,6 +1133,13 @@ func TestLongOldForkedDeepSetHead(t *testing.T) {
|
|
|
// requested head the data can remain as "fast sync" data to avoid redownloading
|
|
|
// it. The side chain is nuked by the freezer.
|
|
|
func TestLongOldForkedFastSyncedShallowSetHead(t *testing.T) {
|
|
|
+ testLongOldForkedFastSyncedShallowSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongOldForkedFastSyncedShallowSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongOldForkedFastSyncedShallowSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongOldForkedFastSyncedShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
// └->S1->S2->S3
|
|
|
@@ -1068,7 +1176,7 @@ func TestLongOldForkedFastSyncedShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter
|
|
|
@@ -1079,6 +1187,13 @@ func TestLongOldForkedFastSyncedShallowSetHead(t *testing.T) {
|
|
|
// underflown, everything needs to be deleted onwards to avoid creating a gap. The
|
|
|
// side chain is nuked by the freezer.
|
|
|
func TestLongOldForkedFastSyncedDeepSetHead(t *testing.T) {
|
|
|
+ testLongOldForkedFastSyncedDeepSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongOldForkedFastSyncedDeepSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongOldForkedFastSyncedDeepSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongOldForkedFastSyncedDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
// └->S1->S2->S3
|
|
|
@@ -1114,7 +1229,7 @@ func TestLongOldForkedFastSyncedDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 4,
|
|
|
expHeadFastBlock: 4,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter
|
|
|
@@ -1125,6 +1240,13 @@ func TestLongOldForkedFastSyncedDeepSetHead(t *testing.T) {
|
|
|
// just pick up fast syncing from there. The side chain is completely nuked by the
|
|
|
// freezer.
|
|
|
func TestLongOldForkedFastSyncingShallowSetHead(t *testing.T) {
|
|
|
+ testLongOldForkedFastSyncingShallowSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongOldForkedFastSyncingShallowSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongOldForkedFastSyncingShallowSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongOldForkedFastSyncingShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
// └->S1->S2->S3
|
|
|
@@ -1161,7 +1283,7 @@ func TestLongOldForkedFastSyncingShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter
|
|
|
@@ -1172,6 +1294,13 @@ func TestLongOldForkedFastSyncingShallowSetHead(t *testing.T) {
|
|
|
// just pick up fast syncing from there. The side chain is completely nuked by the
|
|
|
// freezer.
|
|
|
func TestLongOldForkedFastSyncingDeepSetHead(t *testing.T) {
|
|
|
+ testLongOldForkedFastSyncingDeepSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongOldForkedFastSyncingDeepSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongOldForkedFastSyncingDeepSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongOldForkedFastSyncingDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
// └->S1->S2->S3
|
|
|
@@ -1207,7 +1336,7 @@ func TestLongOldForkedFastSyncingDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter
|
|
|
@@ -1216,6 +1345,13 @@ func TestLongOldForkedFastSyncingDeepSetHead(t *testing.T) {
|
|
|
// chain is above the committed block. In this case the freezer will delete the
|
|
|
// sidechain since it's dangling, reverting to TestLongShallowSetHead.
|
|
|
func TestLongNewerForkedShallowSetHead(t *testing.T) {
|
|
|
+ testLongNewerForkedShallowSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongNewerForkedShallowSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongNewerForkedShallowSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongNewerForkedShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12
|
|
|
@@ -1252,7 +1388,7 @@ func TestLongNewerForkedShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter
|
|
|
@@ -1261,6 +1397,13 @@ func TestLongNewerForkedShallowSetHead(t *testing.T) {
|
|
|
// chain is above the committed block. In this case the freezer will delete the
|
|
|
// sidechain since it's dangling, reverting to TestLongDeepSetHead.
|
|
|
func TestLongNewerForkedDeepSetHead(t *testing.T) {
|
|
|
+ testLongNewerForkedDeepSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongNewerForkedDeepSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongNewerForkedDeepSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongNewerForkedDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12
|
|
|
@@ -1296,7 +1439,7 @@ func TestLongNewerForkedDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 4,
|
|
|
expHeadFastBlock: 4,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter
|
|
|
@@ -1305,6 +1448,13 @@ func TestLongNewerForkedDeepSetHead(t *testing.T) {
|
|
|
// the side chain is above the committed block. In this case the freezer will delete
|
|
|
// the sidechain since it's dangling, reverting to TestLongFastSyncedShallowSetHead.
|
|
|
func TestLongNewerForkedFastSyncedShallowSetHead(t *testing.T) {
|
|
|
+ testLongNewerForkedFastSyncedShallowSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongNewerForkedFastSyncedShallowSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongNewerForkedFastSyncedShallowSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongNewerForkedFastSyncedShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12
|
|
|
@@ -1341,7 +1491,7 @@ func TestLongNewerForkedFastSyncedShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter
|
|
|
@@ -1350,6 +1500,13 @@ func TestLongNewerForkedFastSyncedShallowSetHead(t *testing.T) {
|
|
|
// the side chain is above the committed block. In this case the freezer will delete
|
|
|
// the sidechain since it's dangling, reverting to TestLongFastSyncedDeepSetHead.
|
|
|
func TestLongNewerForkedFastSyncedDeepSetHead(t *testing.T) {
|
|
|
+ testLongNewerForkedFastSyncedDeepSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongNewerForkedFastSyncedDeepSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongNewerForkedFastSyncedDeepSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongNewerForkedFastSyncedDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12
|
|
|
@@ -1385,7 +1542,7 @@ func TestLongNewerForkedFastSyncedDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 4,
|
|
|
expHeadFastBlock: 4,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter
|
|
|
@@ -1394,6 +1551,13 @@ func TestLongNewerForkedFastSyncedDeepSetHead(t *testing.T) {
|
|
|
// chain is above the committed block. In this case the freezer will delete the
|
|
|
// sidechain since it's dangling, reverting to TestLongFastSyncinghallowSetHead.
|
|
|
func TestLongNewerForkedFastSyncingShallowSetHead(t *testing.T) {
|
|
|
+ testLongNewerForkedFastSyncingShallowSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongNewerForkedFastSyncingShallowSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongNewerForkedFastSyncingShallowSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongNewerForkedFastSyncingShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12
|
|
|
@@ -1430,7 +1594,7 @@ func TestLongNewerForkedFastSyncingShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a shorter
|
|
|
@@ -1439,6 +1603,13 @@ func TestLongNewerForkedFastSyncingShallowSetHead(t *testing.T) {
|
|
|
// chain is above the committed block. In this case the freezer will delete the
|
|
|
// sidechain since it's dangling, reverting to TestLongFastSyncingDeepSetHead.
|
|
|
func TestLongNewerForkedFastSyncingDeepSetHead(t *testing.T) {
|
|
|
+ testLongNewerForkedFastSyncingDeepSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongNewerForkedFastSyncingDeepSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongNewerForkedFastSyncingDeepSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongNewerForkedFastSyncingDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12
|
|
|
@@ -1474,14 +1645,17 @@ func TestLongNewerForkedFastSyncingDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a longer side
|
|
|
// chain, where a recent block - newer than the ancient limit - was already committed
|
|
|
// to disk and then sethead was called. In this case the freezer will delete the
|
|
|
// sidechain since it's dangling, reverting to TestLongShallowSetHead.
|
|
|
-func TestLongReorgedShallowSetHead(t *testing.T) {
|
|
|
+func TestLongReorgedShallowSetHead(t *testing.T) { testLongReorgedShallowSetHead(t, false) }
|
|
|
+func TestLongReorgedShallowSetHeadWithSnapshots(t *testing.T) { testLongReorgedShallowSetHead(t, true) }
|
|
|
+
|
|
|
+func testLongReorgedShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12->S13->S14->S15->S16->S17->S18->S19->S20->S21->S22->S23->S24->S25->S26
|
|
|
@@ -1518,14 +1692,17 @@ func TestLongReorgedShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a longer side
|
|
|
// chain, where a recent block - older than the ancient limit - was already committed
|
|
|
// to disk and then sethead was called. In this case the freezer will delete the
|
|
|
// sidechain since it's dangling, reverting to TestLongDeepSetHead.
|
|
|
-func TestLongReorgedDeepSetHead(t *testing.T) {
|
|
|
+func TestLongReorgedDeepSetHead(t *testing.T) { testLongReorgedDeepSetHead(t, false) }
|
|
|
+func TestLongReorgedDeepSetHeadWithSnapshots(t *testing.T) { testLongReorgedDeepSetHead(t, true) }
|
|
|
+
|
|
|
+func testLongReorgedDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12->S13->S14->S15->S16->S17->S18->S19->S20->S21->S22->S23->S24->S25->S26
|
|
|
@@ -1561,7 +1738,7 @@ func TestLongReorgedDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 4,
|
|
|
expHeadFastBlock: 4,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a longer
|
|
|
@@ -1570,6 +1747,13 @@ func TestLongReorgedDeepSetHead(t *testing.T) {
|
|
|
// freezer will delete the sidechain since it's dangling, reverting to
|
|
|
// TestLongFastSyncedShallowSetHead.
|
|
|
func TestLongReorgedFastSyncedShallowSetHead(t *testing.T) {
|
|
|
+ testLongReorgedFastSyncedShallowSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongReorgedFastSyncedShallowSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongReorgedFastSyncedShallowSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongReorgedFastSyncedShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12->S13->S14->S15->S16->S17->S18->S19->S20->S21->S22->S23->S24->S25->S26
|
|
|
@@ -1606,7 +1790,7 @@ func TestLongReorgedFastSyncedShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a longer
|
|
|
@@ -1615,6 +1799,13 @@ func TestLongReorgedFastSyncedShallowSetHead(t *testing.T) {
|
|
|
// freezer will delete the sidechain since it's dangling, reverting to
|
|
|
// TestLongFastSyncedDeepSetHead.
|
|
|
func TestLongReorgedFastSyncedDeepSetHead(t *testing.T) {
|
|
|
+ testLongReorgedFastSyncedDeepSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongReorgedFastSyncedDeepSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongReorgedFastSyncedDeepSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongReorgedFastSyncedDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12->S13->S14->S15->S16->S17->S18->S19->S20->S21->S22->S23->S24->S25->S26
|
|
|
@@ -1650,7 +1841,7 @@ func TestLongReorgedFastSyncedDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 4,
|
|
|
expHeadFastBlock: 4,
|
|
|
expHeadBlock: 4,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a longer
|
|
|
@@ -1660,6 +1851,13 @@ func TestLongReorgedFastSyncedDeepSetHead(t *testing.T) {
|
|
|
// head, since we can just pick up fast syncing from there. The side chain is
|
|
|
// completely nuked by the freezer.
|
|
|
func TestLongReorgedFastSyncingShallowSetHead(t *testing.T) {
|
|
|
+ testLongReorgedFastSyncingShallowSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongReorgedFastSyncingShallowSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongReorgedFastSyncingShallowSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongReorgedFastSyncingShallowSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12->S13->S14->S15->S16->S17->S18->S19->S20->S21->S22->S23->S24->S25->S26
|
|
|
@@ -1696,7 +1894,7 @@ func TestLongReorgedFastSyncingShallowSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
// Tests a sethead for a long canonical chain with frozen blocks and a longer
|
|
|
@@ -1706,6 +1904,13 @@ func TestLongReorgedFastSyncingShallowSetHead(t *testing.T) {
|
|
|
// head, since we can just pick up fast syncing from there. The side chain is
|
|
|
// completely nuked by the freezer.
|
|
|
func TestLongReorgedFastSyncingDeepSetHead(t *testing.T) {
|
|
|
+ testLongReorgedFastSyncingDeepSetHead(t, false)
|
|
|
+}
|
|
|
+func TestLongReorgedFastSyncingDeepSetHeadWithSnapshots(t *testing.T) {
|
|
|
+ testLongReorgedFastSyncingDeepSetHead(t, true)
|
|
|
+}
|
|
|
+
|
|
|
+func testLongReorgedFastSyncingDeepSetHead(t *testing.T, snapshots bool) {
|
|
|
// Chain:
|
|
|
// G->C1->C2->C3->C4->C5->C6->C7->C8->C9->C10->C11->C12->C13->C14->C15->C16->C17->C18->C19->C20->C21->C22->C23->C24 (HEAD)
|
|
|
// └->S1->S2->S3->S4->S5->S6->S7->S8->S9->S10->S11->S12->S13->S14->S15->S16->S17->S18->S19->S20->S21->S22->S23->S24->S25->S26
|
|
|
@@ -1741,13 +1946,13 @@ func TestLongReorgedFastSyncingDeepSetHead(t *testing.T) {
|
|
|
expHeadHeader: 6,
|
|
|
expHeadFastBlock: 6,
|
|
|
expHeadBlock: 0,
|
|
|
- })
|
|
|
+ }, snapshots)
|
|
|
}
|
|
|
|
|
|
-func testSetHead(t *testing.T, tt *rewindTest) {
|
|
|
+func testSetHead(t *testing.T, tt *rewindTest, snapshots bool) {
|
|
|
// It's hard to follow the test case, visualize the input
|
|
|
- //log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
|
|
|
- //fmt.Println(tt.dump(false))
|
|
|
+ // log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
|
|
|
+ // fmt.Println(tt.dump(false))
|
|
|
|
|
|
// Create a temporary persistent database
|
|
|
datadir, err := ioutil.TempDir("", "")
|
|
|
@@ -1766,8 +1971,18 @@ func testSetHead(t *testing.T, tt *rewindTest) {
|
|
|
var (
|
|
|
genesis = new(Genesis).MustCommit(db)
|
|
|
engine = ethash.NewFullFaker()
|
|
|
+ config = &CacheConfig{
|
|
|
+ TrieCleanLimit: 256,
|
|
|
+ TrieDirtyLimit: 256,
|
|
|
+ TrieTimeLimit: 5 * time.Minute,
|
|
|
+ SnapshotLimit: 0, // Disable snapshot
|
|
|
+ }
|
|
|
)
|
|
|
- chain, err := NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil)
|
|
|
+ if snapshots {
|
|
|
+ config.SnapshotLimit = 256
|
|
|
+ config.SnapshotWait = true
|
|
|
+ }
|
|
|
+ chain, err := NewBlockChain(db, config, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil)
|
|
|
if err != nil {
|
|
|
t.Fatalf("Failed to create chain: %v", err)
|
|
|
}
|
|
|
@@ -1790,6 +2005,11 @@ func testSetHead(t *testing.T, tt *rewindTest) {
|
|
|
}
|
|
|
if tt.commitBlock > 0 {
|
|
|
chain.stateCache.TrieDB().Commit(canonblocks[tt.commitBlock-1].Root(), true, nil)
|
|
|
+ if snapshots {
|
|
|
+ if err := chain.snaps.Cap(canonblocks[tt.commitBlock-1].Root(), 0); err != nil {
|
|
|
+ t.Fatalf("Failed to flatten snapshots: %v", err)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if _, err := chain.InsertChain(canonblocks[tt.commitBlock:]); err != nil {
|
|
|
t.Fatalf("Failed to import canonical chain tail: %v", err)
|