Skip to content

Commit

Permalink
TxLookup fix 2 (#3994) (#3996)
Browse files Browse the repository at this point in the history
* save

* save

* tolerate some fails

* tolerate some fails

Co-authored-by: Alexey Sharp <[email protected]>

Co-authored-by: Alex Sharov <[email protected]>
Co-authored-by: Alexey Sharp <[email protected]>
  • Loading branch information
3 people authored Apr 27, 2022
1 parent b7f591b commit f3065a1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions eth/stagedsync/stage_txlookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/ethdb/prune"
"github.com/ledgerwatch/erigon/turbo/snapshotsync"
"github.com/ledgerwatch/log/v3"
)

type TxLookupCfg struct {
Expand Down Expand Up @@ -68,10 +69,11 @@ func SpawnTxLookup(s *StageState, tx kv.RwTx, toBlock uint64, cfg TxLookupCfg, c
return err
}
}
} else if cfg.snapshots != nil && cfg.snapshots.Cfg().Enabled {
}
if cfg.snapshots != nil && cfg.snapshots.Cfg().Enabled {
if cfg.snapshots.BlocksAvailable() > startBlock {
// 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
return err
}
Expand Down Expand Up @@ -210,6 +212,10 @@ func deleteTxLookupRange(tx kv.RwTx, logPrefix string, blockFrom, blockTo uint64
blockHash := common.BytesToHash(v)
body := rawdb.ReadCanonicalBodyWithTransactions(tx, blockHash, blocknum)
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)
}

Expand Down

0 comments on commit f3065a1

Please sign in to comment.