From 1b856b52370ba0e06f5eb9afb29a8e69f420888b Mon Sep 17 00:00:00 2001
From: Alex Sharov <AskAlexSharov@gmail.com>
Date: Thu, 6 Jan 2022 11:33:01 +0700
Subject: [PATCH] Snapshot: mainnet hashes and fixes (#3210)
---
eth/stagedsync/stage_headers.go | 38 +++++++++++--------
.../snapshothashes/erigon-snapshots | 2 +-
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/eth/stagedsync/stage_headers.go b/eth/stagedsync/stage_headers.go
index c906538198..e96969ae8e 100644
--- a/eth/stagedsync/stage_headers.go
+++ b/eth/stagedsync/stage_headers.go
@@ -816,8 +816,14 @@ func DownloadAndIndexSnapshotsIfNeed(s *StageState, ctx context.Context, tx kv.R
}
// Fill kv.HeaderTD table from snapshots
- c, _ := tx.Cursor(kv.HeaderTD)
- count, _ := c.Count()
+ c, err := tx.Cursor(kv.HeaderTD)
+ if err != nil {
+ return err
+ }
+ count, err := c.Count()
+ if err != nil {
+ return err
+ }
if count == 0 || count == 1 { // genesis does write 1 record
logEvery := time.NewTicker(logInterval)
defer logEvery.Stop()
@@ -843,21 +849,23 @@ func DownloadAndIndexSnapshotsIfNeed(s *StageState, ctx context.Context, tx kv.R
return err
}
- // Fill kv.HeaderCanonical table from snapshots
- tx.ClearBucket(kv.HeaderCanonical)
- if err := fixCanonicalChain(s.LogPrefix(), logEvery, lastHeader.Number.Uint64(), lastHeader.Hash(), tx, cfg.blockReader); err != nil {
- return err
- }
+ if lastHeader != nil {
+ // Fill kv.HeaderCanonical table from snapshots
+ tx.ClearBucket(kv.HeaderCanonical)
+ if err := fixCanonicalChain(s.LogPrefix(), logEvery, lastHeader.Number.Uint64(), lastHeader.Hash(), tx, cfg.blockReader); err != nil {
+ return err
+ }
- sn, ok := cfg.snapshots.Blocks(cfg.snapshots.BlocksAvailable())
- if !ok {
- return fmt.Errorf("snapshot not found for block: %d", cfg.snapshots.BlocksAvailable())
- }
+ sn, ok := cfg.snapshots.Blocks(cfg.snapshots.BlocksAvailable())
+ if !ok {
+ return fmt.Errorf("snapshot not found for block: %d", cfg.snapshots.BlocksAvailable())
+ }
- // ResetSequence - allow set arbitrary value to sequence (for example to decrement it to exact value)
- lastTxnID := sn.TxnHashIdx.BaseDataID() + uint64(sn.Transactions.Count())
- if err := rawdb.ResetSequence(tx, kv.EthTx, lastTxnID+1); err != nil {
- return err
+ // ResetSequence - allow set arbitrary value to sequence (for example to decrement it to exact value)
+ lastTxnID := sn.TxnHashIdx.BaseDataID() + uint64(sn.Transactions.Count())
+ if err := rawdb.ResetSequence(tx, kv.EthTx, lastTxnID+1); err != nil {
+ return err
+ }
}
}
diff --git a/turbo/snapshotsync/snapshothashes/erigon-snapshots b/turbo/snapshotsync/snapshothashes/erigon-snapshots
index 42fb09c4cc..2c5b3e7758 160000
--- a/turbo/snapshotsync/snapshothashes/erigon-snapshots
+++ b/turbo/snapshotsync/snapshothashes/erigon-snapshots
@@ -1 +1 @@
-Subproject commit 42fb09c4cc58bd6c1acb8add828d7861e91a9183
+Subproject commit 2c5b3e77580645f869820a435e34a857092aa89f
--
GitLab