good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit f3065a11 authored by ledgerwatch's avatar ledgerwatch Committed by GitHub
Browse files

TxLookup fix 2 (#3994) (#3996)


* save

* save

* tolerate some fails

* tolerate some fails

Co-authored-by: default avatarAlexey Sharp <alexeysharp@Alexeys-iMac.local>

Co-authored-by: default avatarAlex Sharov <AskAlexSharov@gmail.com>
Co-authored-by: default avatarAlexey Sharp <alexeysharp@Alexeys-iMac.local>
parent b7f591b6
Branches
Tags v2022.04.04
No related merge requests found
...@@ -14,6 +14,7 @@ import ( ...@@ -14,6 +14,7 @@ import (
"github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/erigon/ethdb/prune"
"github.com/ledgerwatch/erigon/turbo/snapshotsync" "github.com/ledgerwatch/erigon/turbo/snapshotsync"
"github.com/ledgerwatch/log/v3"
) )
type TxLookupCfg struct { type TxLookupCfg struct {
...@@ -68,10 +69,11 @@ func SpawnTxLookup(s *StageState, tx kv.RwTx, toBlock uint64, cfg TxLookupCfg, c ...@@ -68,10 +69,11 @@ func SpawnTxLookup(s *StageState, tx kv.RwTx, toBlock uint64, cfg TxLookupCfg, c
return err return err
} }
} }
} else if cfg.snapshots != nil && cfg.snapshots.Cfg().Enabled { }
if cfg.snapshots != nil && cfg.snapshots.Cfg().Enabled {
if cfg.snapshots.BlocksAvailable() > startBlock { if cfg.snapshots.BlocksAvailable() > startBlock {
// Snapshot .idx files already have TxLookup index - then no reason iterate over them here // Snapshot .idx files already have TxLookup index - then no reason iterate over them here
startBlock = cfg.snapshots.BlocksAvailable() + 1 startBlock = cfg.snapshots.BlocksAvailable()
if err = s.UpdatePrune(tx, startBlock); err != nil { // prune func of this stage will use this value to prevent all ancient blocks traversal if err = s.UpdatePrune(tx, startBlock); err != nil { // prune func of this stage will use this value to prevent all ancient blocks traversal
return err return err
} }
...@@ -210,6 +212,10 @@ func deleteTxLookupRange(tx kv.RwTx, logPrefix string, blockFrom, blockTo uint64 ...@@ -210,6 +212,10 @@ func deleteTxLookupRange(tx kv.RwTx, logPrefix string, blockFrom, blockTo uint64
blockHash := common.BytesToHash(v) blockHash := common.BytesToHash(v)
body := rawdb.ReadCanonicalBodyWithTransactions(tx, blockHash, blocknum) body := rawdb.ReadCanonicalBodyWithTransactions(tx, blockHash, blocknum)
if body == nil { if body == nil {
if cfg.snapshots != nil && cfg.snapshots.Cfg().Enabled && blocknum <= cfg.snapshots.BlocksAvailable() {
log.Warn("TxLookup pruning, empty block body", "height", blocknum)
return nil
}
return fmt.Errorf("empty block body %d, hash %x", blocknum, v) return fmt.Errorf("empty block body %d, hash %x", blocknum, v)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment