Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Merge range (ledgerwatch#4749)
Browse files Browse the repository at this point in the history
* added merge range into segments

* got rid of missing snapshot errors

* reusing RequestSnapshotDownload

* sleep out of download

* ops

* warning if we are missing snapshots
  • Loading branch information
enriavil1 committed Jul 19, 2022
1 parent d3b424c commit e768227
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 63 deletions.
7 changes: 5 additions & 2 deletions eth/stagedsync/stage_headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,10 @@ func WaitForDownloader(ctx context.Context, cfg HeadersCfg, tx kv.RwTx) error {
}
}

if len(missingSnapshots) > 0 {
log.Warn("[Snapshots] downloading missing snapshots")
}

// send all hashes to the Downloader service
preverified := snapshothashes.KnownConfig(cfg.chainConfig.ChainName).Preverified
i := 0
Expand All @@ -1361,7 +1365,6 @@ func WaitForDownloader(ctx context.Context, cfg HeadersCfg, tx kv.RwTx) error {
for _, r := range missingSnapshots {
downloadRequest = append(downloadRequest, snapshotsync.NewDownloadRequest(&r, "", ""))
}
req := snapshotsync.BuildProtoRequest(downloadRequest)

log.Info("[Snapshots] Fetching torrent files metadata")
for {
Expand All @@ -1370,7 +1373,7 @@ func WaitForDownloader(ctx context.Context, cfg HeadersCfg, tx kv.RwTx) error {
return ctx.Err()
default:
}
if _, err := cfg.snapshotDownloader.Download(ctx, req); err != nil {
if err := snapshotsync.RequestSnapshotDownload(ctx, downloadRequest, cfg.snapshotDownloader); err != nil {
log.Error("[Snapshots] call downloader", "err", err)
time.Sleep(10 * time.Second)
continue
Expand Down
6 changes: 3 additions & 3 deletions turbo/snapshotsync/block_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func (back *BlockReaderWithSnapshots) headerFromSnapshot(blockHeight uint64, sn
func (back *BlockReaderWithSnapshots) headerFromSnapshotByHash(hash common.Hash, sn *HeaderSegment, buf []byte) (*types.Header, error) {
defer func() {
if rec := recover(); rec != nil {
panic(fmt.Errorf("%+v, snapshot: %d-%d, trace: %s", rec, sn.From, sn.To, dbg.Stack()))
panic(fmt.Errorf("%+v, snapshot: %d-%d, trace: %s", rec, sn.ranges.from, sn.ranges.to, dbg.Stack()))
}
}() // avoid crash because Erigon's core does many things

Expand Down Expand Up @@ -564,7 +564,7 @@ func (back *BlockReaderWithSnapshots) bodyFromSnapshot(blockHeight uint64, sn *B
func (back *BlockReaderWithSnapshots) bodyForStorageFromSnapshot(blockHeight uint64, sn *BodySegment, buf []byte) (*types.BodyForStorage, []byte, error) {
defer func() {
if rec := recover(); rec != nil {
panic(fmt.Errorf("%+v, snapshot: %d-%d, trace: %s", rec, sn.From, sn.To, dbg.Stack()))
panic(fmt.Errorf("%+v, snapshot: %d-%d, trace: %s", rec, sn.ranges.from, sn.ranges.to, dbg.Stack()))
}
}() // avoid crash because Erigon's core does many things

Expand Down Expand Up @@ -597,7 +597,7 @@ func (back *BlockReaderWithSnapshots) bodyForStorageFromSnapshot(blockHeight uin
func (back *BlockReaderWithSnapshots) txsFromSnapshot(baseTxnID uint64, txsAmount uint32, txsSeg *TxnSegment, buf []byte) (txs []types.Transaction, senders []common.Address, err error) {
defer func() {
if rec := recover(); rec != nil {
panic(fmt.Errorf("%+v, snapshot: %d-%d, trace: %s", rec, txsSeg.From, txsSeg.To, dbg.Stack()))
panic(fmt.Errorf("%+v, snapshot: %d-%d, trace: %s", rec, txsSeg.ranges.from, txsSeg.ranges.to, dbg.Stack()))
}
}() // avoid crash because Erigon's core does many things

Expand Down
Loading

0 comments on commit e768227

Please sign in to comment.